Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions widgetLibrary/widget_slider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ local function createHorizontalSlider( slider, options )
-- We need to assign these properties to the object
view._left = viewLeft
view._right = viewRight
view._isEnabled = opt.isEnabled
view._fill = viewFill
view._middle = viewMiddle
view._handle = viewHandle
Expand All @@ -138,7 +139,12 @@ local function createHorizontalSlider( slider, options )
self.value = value
return self._view:_setValue( value )
end


-- Function to set a button as active
function slider:setEnabled( isEnabled )
self._view._isEnabled = isEnabled
end

----------------------------------------------------------
-- PRIVATE METHODS
----------------------------------------------------------
Expand Down Expand Up @@ -320,12 +326,14 @@ local function createVerticalSlider( slider, options )
-- We need to assign these properties to the object
view._top = viewTop
view._bottom = viewBottom
view._isEnabled = opt.isEnabled
view._fill = viewFill
view._middle = viewMiddle
view._handle = viewHandle
view._currentPercent = opt.defaultValue
view._width = opt.width
view._height = opt.height
view._isEnabled = opt.isEnabled
view._listener = opt.listener

-------------------------------------------------------
Expand All @@ -346,7 +354,12 @@ local function createVerticalSlider( slider, options )
self.value = value
return self._view:_setValue( value )
end


-- Function to set a button as active
function slider:setEnabled( isEnabled )
self._view._isEnabled = isEnabled
end

----------------------------------------------------------
-- PRIVATE METHODS
----------------------------------------------------------
Expand All @@ -357,6 +370,11 @@ local function createVerticalSlider( slider, options )
local _slider = event.target.parent
-- Set the target to the handle
event.target = self._handle

-- If the button isn't active, just return
if not view._isEnabled then
return
end

if "began" == phase then
-- The content bounds of our handle
Expand Down Expand Up @@ -485,10 +503,19 @@ function M.new( options, theme )
opt.width = customOptions.width or themeOptions.width or 200 -- from the sheet file
opt.height = customOptions.height or themeOptions.height or 10 -- from the sheet file
opt.id = customOptions.id

opt.isEnabled = customOptions.isEnabled

-- If the user didn't pass in a isEnabled flag, set it to true
if nil == opt.isEnabled then
opt.isEnabled = true
end

opt.baseDir = customOptions.baseDir or system.ResourceDirectory
opt.defaultValue = customOptions.value or 50
opt.orientation = customOptions.orientation or "horizontal"
opt.listener = customOptions.listener


-- Frames & Images
opt.sheet = customOptions.sheet
Expand Down
22 changes: 20 additions & 2 deletions widgetLibrary/widget_stepper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ local function initWithSprite( stepper, options )
local themeData = require( opt.themeData )
imageSheet = graphics.newImageSheet( opt.themeSheetFile, themeData:getSheet() )
end

-- Create the view
view = display.newSprite( stepper, imageSheet, sheetOptions )
view:setSequence( "default" )
Expand All @@ -122,6 +122,8 @@ local function initWithSprite( stepper, options )
-------------------------------------------------------

-- Assign to the view

view._isEnabled = opt.isEnabled
view._timerIncrementSpeed = opt.timerIncrementSpeed or 1000
view._changeIncrementSpeedAtTime = view._timerIncrementSpeed
view._increments = 0
Expand Down Expand Up @@ -164,6 +166,11 @@ local function initWithSprite( stepper, options )
function stepper:setValue( newValue )
return self._view:_setValue( newValue )
end

-- Function to set a button as active
function stepper:setEnabled( isEnabled )
self._view._isEnabled = isEnabled
end

----------------------------------------------------------
-- PRIVATE METHODS
Expand All @@ -174,6 +181,11 @@ local function initWithSprite( stepper, options )
local phase = event.phase
local _stepper = self.parent
event.target = _stepper

-- If the button isn't active, just return
if not view._isEnabled then
return
end

-- The content bounds of our increment/decrement segments
local decrementBounds = self._decrementOverlay.contentBounds
Expand Down Expand Up @@ -421,7 +433,13 @@ function M.new( options, theme )
opt.onHold = customOptions.onHold
opt.timerIncrementSpeed = customOptions.timerIncrementSpeed or 1000
opt.changeSpeedAtIncrement = customOptions.changeSpeedAtIncrement or 5

opt.isEnabled = customOptions.isEnabled

-- If the user didn't pass in a isEnabled flag, set it to true
if nil == opt.isEnabled then
opt.isEnabled = true
end

-- Frames & Images
opt.sheet = customOptions.sheet
opt.themeSheetFile = themeOptions.sheet
Expand Down