Skip to content

Commit

Permalink
Sync to 2018.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Shchvova committed Jul 6, 2018
1 parent c266598 commit 9c1aed5
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 31 deletions.
15 changes: 9 additions & 6 deletions widgetLibrary/widget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ function display.newGroup()
local function removeWidgets( group )
if group.numChildren then
for i = group.numChildren, 1, -1 do
if group[i]._isWidget then
group[i]:removeSelf()

elseif not group[i]._isWidget and group[i].numChildren then
-- Nested group (that is not a widget)
removeWidgets( group[i] )
local toRemove = group[i]
if toRemove then
if toRemove._isWidget then
toRemove:removeSelf()

elseif not toRemove._isWidget and toRemove.numChildren then
-- Nested group (that is not a widget)
removeWidgets( toRemove )
end
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions widgetLibrary/widget_momentumScrolling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ function lib.createScrollBar( view, options )

-- Setup the scrollBar's width/height
--local parentGroup = view.parent.parent
local scrollBarWidth = options.width or 5
local viewHeight = view._height -- The height of the windows visible area
local viewContentHeight = view._scrollHeight -- The height of the total content height
local minimumScrollBarHeight = 24 -- The minimum height the scrollbar can be
Expand Down Expand Up @@ -819,7 +818,7 @@ function lib.createScrollBar( view, options )
-- Insert the scrollBar into the fixed group and position it
view._fixedGroup:insert( lib.scrollBar )

view._fixedGroup.x = view._width * 0.5 - scrollBarWidth * 0.5
view._fixedGroup.x = view._width * 0.5 - opt.width * 0.5
--local viewFixedGroupY = view.parent.y - view._top - view._height * 0.5

-- this has to be positioned at the yCoord - half the height, no matter what.
Expand Down
6 changes: 6 additions & 0 deletions widgetLibrary/widget_pickerWheel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,12 @@ local function createPickerWheel( pickerWheel, options )

-- EnterFrame listener for our pickerWheel
function view:enterFrame( event )

if not self.parent then
Runtime:removeEventListener( "enterFrame", self )
return true
end

local _pickerWheel = self.parent
-- Update the y position
-- this has to be calculated in content coordinates to abstract the widget being in a group
Expand Down
23 changes: 6 additions & 17 deletions widgetLibrary/widget_scrollview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -582,23 +582,6 @@ local function createScrollView( scrollView, options )
if "began" == phase then
self._timeHeld = event.time
end

-- Android fix for objects inserted into scrollView's
if self._isPlatformAndroid then
-- Distance moved
local dy = mAbs( event.y - event.yStart )
local dx = mAbs( event.x - event.xStart )
local moveThresh = 20

-- If the finger has moved less than the desired range, set the phase back to began (Android only fix, iOS doesn't exhibit this touch behavior..)
if dy < moveThresh then
if dx < moveThresh then
if phase ~= "ended" and phase ~= "cancelled" then
event.phase = "began"
end
end
end
end

-- Handle momentum scrolling (and the view isn't locked)
if not self._isLocked then
Expand Down Expand Up @@ -639,6 +622,12 @@ local function createScrollView( scrollView, options )

-- EnterFrame listener for our scrollView
function view:enterFrame( event )

if not self.parent then
Runtime:removeEventListener( "enterFrame", self )
return true
end

local _scrollView = self.parent

-- Handle momentum @ runtime
Expand Down
20 changes: 14 additions & 6 deletions widgetLibrary/widget_tabbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ local function initWithImageFiles( tabBar, options )
viewSelected.x = viewButtons[view._defaultTab].x - ( viewSelected.contentWidth * 0.5 ) - tabBar.x

-- Throw error if tabBar width is too small to hold all passed in tab items
if ( view._totalTabWidth + 4 ) > opt.width then
error( "ERROR: " .. M._widgetName .. ": width passed is too small to fit the tab items inside, you need a width of at least " .. ( view._totalTabWidth + 4 ) .. " to fit your tab items inside", 3 )
if view._totalTabWidth > opt.width then
error( "ERROR: " .. M._widgetName .. ": width passed is too small to fit the tab items inside, you need a width of at least " .. view._totalTabWidth .. " to fit your tab items inside", 3 )
end

-------------------------------------------------------
Expand Down Expand Up @@ -438,14 +438,22 @@ local function initWithImageSheet( tabBar, options )
viewButtons[i] = display.newImageRect( tabBar, imageSheet, 7, 15, 15 )
--error( "ERROR: " .. M._widgetName .. ": tab button default file expected, got nil" )
else
viewButtons[i] = display.newImageRect( tabBar, opt.tabButtons[i].defaultFile, opt.tabButtons[i].width, opt.tabButtons[i].height )
if opt.tabButtons[i].width ~= nil and opt.tabButtons[i].height ~= nil then
viewButtons[i] = display.newImageRect( tabBar, opt.tabButtons[i].defaultFile, opt.tabButtons[i].width, opt.tabButtons[i].height )
else
viewButtons[i] = display.newImage( tabBar, opt.tabButtons[i].defaultFile )
end
end

if not opt.tabButtons[i].overFile then
viewButtons[i].over = display.newImageRect( tabBar, imageSheet, 10, 15, 15 )
--error( "ERROR: " .. M._widgetName .. ": tab button default file expected, got nil" )
else
viewButtons[i].over = display.newImageRect( tabBar, opt.tabButtons[i].overFile, opt.tabButtons[i].width, opt.tabButtons[i].height )
if opt.tabButtons[i].width ~= nil and opt.tabButtons[i].height ~= nil then
viewButtons[i].over = display.newImageRect( tabBar, opt.tabButtons[i].overFile, opt.tabButtons[i].width, opt.tabButtons[i].height )
else
viewButtons[i].over = display.newImage( tabBar, opt.tabButtons[i].overFile )
end
end
viewButtons[i].over.isVisible = false
end
Expand Down Expand Up @@ -557,8 +565,8 @@ local function initWithImageSheet( tabBar, options )
--viewSelected.y = tabBar.y - viewSelected.contentHeight * 0.5

-- Throw error if tabBar width is too small to hold all passed in tab items
if ( view._totalTabWidth + 4 ) > view.width then
error( "ERROR: " .. M._widgetName .. ": width passed is too small to fit the tab items inside, you need a width of at least " .. ( view._totalTabWidth + 4 ) .. " to fit your tab items inside", 3 )
if view._totalTabWidth > view.width then
error( "ERROR: " .. M._widgetName .. ": width passed is too small to fit the tab items inside, you need a width of at least " .. view._totalTabWidth .. " to fit your tab items inside", 3 )
end

-------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions widgetLibrary/widget_tableview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,12 @@ local function createTableView( tableView, options )

-- EnterFrame listener for our tableView
function view:enterFrame( event )

if not self.parent then
Runtime:removeEventListener( "enterFrame", self )
return true
end

local _tableView = self.parent

-- If we have finished rendering all rows
Expand Down Expand Up @@ -1199,6 +1205,11 @@ local function createTableView( tableView, options )

-- Function to insert a row into a tableView
function view:_insertRow( options, reRender )
if not self.parent then
print("WARNING: trying to insert a row into a non-existant tableView")
return false
end

-- Create the row
self._rows[table.maxn(self._rows) + 1] = {}

Expand Down

0 comments on commit 9c1aed5

Please sign in to comment.