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
55 changes: 32 additions & 23 deletions widgetLibrary/widget_pickerWheel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ local labelColor = { 0.60 }
local defaultRowColor = { 1 }
local blackColor = { 0 }

local screenScaleFactor = display.contentWidth / 320; -- factor that adjust the pickerWheel to work with config.content.width > 320

if isByteColorRange then
_widget._convertColorToV1( labelColor )
_widget._convertColorToV1( defaultRowColor )
Expand Down Expand Up @@ -142,12 +144,12 @@ local function createPickerWheel( pickerWheel, options )
row.value = rowTitle.text

-- check if the text is greater than the actual column size
local availableWidth = viewOverlay.width - 28
local availableWidth = viewOverlay.width - 28 * screenScaleFactor
local columnWidth = view._columns[ row.id ].width or availableWidth / #view._columns
local textWidth = rowTitle.contentWidth
if textWidth > columnWidth - 1 then
--cap the text
local pixelsPerChar = 23 -- aproximate median value
local pixelsPerChar = 23 * screenScaleFactor -- aproximate median value
local numChars = columnWidth / pixelsPerChar
row._label = row._label:sub(1, numChars)
rowTitle.text = row._label
Expand All @@ -169,9 +171,9 @@ local function createPickerWheel( pickerWheel, options )

local rowTitleX
if isGraphicsV1 then
rowTitleX = ( rowTitle.contentWidth * 0.5 ) + 6
rowTitleX = ( rowTitle.contentWidth * 0.5 ) + 6 * screenScaleFactor
else
rowTitleX = row.x + 6
rowTitleX = row.x + 6 * screenScaleFactor
rowTitle.anchorX = 0
end
rowTitle.x = rowTitleX
Expand All @@ -180,9 +182,9 @@ local function createPickerWheel( pickerWheel, options )

local rowTitleX
if isGraphicsV1 then
rowTitleX = row.x + ( row.contentWidth * 0.5 ) - ( rowTitle.contentWidth * 0.5 ) - 6
rowTitleX = row.x + ( row.contentWidth * 0.5 ) - ( rowTitle.contentWidth * 0.5 ) - 6 * screenScaleFactor
else
rowTitleX = row.x + columnWidth - 6
rowTitleX = row.x + columnWidth - 6 * screenScaleFactor
rowTitle.anchorX = 1
end
rowTitle.x = rowTitleX
Expand All @@ -206,7 +208,7 @@ local function createPickerWheel( pickerWheel, options )
end

-- The available width for the whole pickerWheel (to fit columns)
local availableWidth = viewOverlay.width - 28
local availableWidth = viewOverlay.width - 28 * screenScaleFactor

-- local method that handles scrolling to the tapped / touched index
local function didTapValue( event )
Expand All @@ -225,6 +227,9 @@ local function createPickerWheel( pickerWheel, options )
topPadding = 90
bottomPadding = pickerWheel.contentHeight - 20 - pickerWheel.contentHeight * 0.5 -- 20 is half a row height
end

topPadding = topPadding * screenScaleFactor
bottomPadding = bottomPadding * screenScaleFactor

local initialX = 0
local initialPos = -140
Expand All @@ -233,18 +238,22 @@ local function createPickerWheel( pickerWheel, options )
--else
--initialPos = -144
end

for i = 1, #opt.columnData do
initialPos = initialPos * screenScaleFactor

for i = 1, #opt.columnData do

if i > 1 then
initialPos = viewColumns[i-1].x + ( viewColumns[i-1]._view._width * 0.5 )
end


local tableViewWidth = opt.columnData[i].width or availableWidth / #opt.columnData
tableViewWidth = tableViewWidth * screenScaleFactor

viewColumns[i] = _widget.newTableView
{
left = initialPos,
top = -110,
width = opt.columnData[i].width or availableWidth / #opt.columnData,
top = -110 * screenScaleFactor,
width = tableViewWidth,
height = opt.overlayFrameHeight - 1,
topPadding = topPadding,
bottomPadding = bottomPadding,
Expand Down Expand Up @@ -280,7 +289,7 @@ local function createPickerWheel( pickerWheel, options )
for j = 1, #opt.columnData[i].labels do
viewColumns[i]:insertRow
{
rowHeight = 40,
rowHeight = opt.rowHeight,
rowColor = {
default = opt.columnColor,
over = opt.columnColor,
Expand Down Expand Up @@ -452,19 +461,19 @@ function M.new( options, theme )
opt.baseDir = customOptions.baseDir or system.ResourceDirectory
--opt.maskFile = customOptions.maskFile or themeOptions.maskFile
opt.font = customOptions.font or themeOptions.font or native.systemFontBold
opt.fontSize = customOptions.fontSize or themeOptions.fontSize or 22
opt.fontSize = customOptions.fontSize or (themeOptions.fontSize and themeOptions.fontSize * screenScaleFactor) or 22 * screenScaleFactor
opt.fontColor = customOptions.fontColor or themeOptions.fontColor or labelColor
opt.fontColorSelected = customOptions.fontColorSelected or themeOptions.fontColorSelected or blackColor
opt.columnColor = customOptions.columnColor or themeOptions.columnColor or defaultRowColor
opt.backgroundColor = customOptions.columnColor or themeOptions.columnColor or defaultRowColor

if _widget.isSeven() then
opt.font = customOptions.font or themeOptions.font or "HelveticaNeue-Medium"
opt.fontSize = customOptions.fontSize or themeOptions.fontSize or 20
opt.fontSize = customOptions.fontSize or (themeOptions.fontSize and themeOptions.fontSize * screenScaleFactor) or 20 * screenScaleFactor
end

-- Properties
opt.rowHeight = customOptions.rowHeight or 40
opt.rowHeight = customOptions.rowHeight or 40 * screenScaleFactor
opt.columnData = customOptions.columns

-- Frames & images
Expand All @@ -473,17 +482,17 @@ function M.new( options, theme )
opt.themeData = themeOptions.data

opt.backgroundFrame = customOptions.backgroundFrame or _widget._getFrameIndex( themeOptions, themeOptions.backgroundFrame )
opt.backgroundFrameWidth = customOptions.backgroundFrameWidth or themeOptions.backgroundFrameWidth
opt.backgroundFrameHeight = customOptions.backgroundFrameHeight or themeOptions.backgroundFrameHeight
opt.backgroundFrameWidth = customOptions.backgroundFrameWidth or (themeOptions.backgroundFrameWidth and themeOptions.backgroundFrameWidth * screenScaleFactor)
opt.backgroundFrameHeight = customOptions.backgroundFrameHeight or (themeOptions.backgroundFrameHeight and themeOptions.backgroundFrameHeight * screenScaleFactor)

opt.overlayFrame = customOptions.overlayFrame or _widget._getFrameIndex( themeOptions, themeOptions.overlayFrame )
opt.overlayFrameWidth = customOptions.overlayFrameWidth or themeOptions.overlayFrameWidth
opt.overlayFrameHeight = customOptions.overlayFrameHeight or themeOptions.overlayFrameHeight
opt.overlayFrameWidth = customOptions.overlayFrameWidth or (themeOptions.overlayFrameWidth and themeOptions.overlayFrameWidth * screenScaleFactor)
opt.overlayFrameHeight = customOptions.overlayFrameHeight or (themeOptions.overlayFrameHeight and themeOptions.overlayFrameHeight * screenScaleFactor)

opt.separatorFrame = customOptions.separatorFrame or _widget._getFrameIndex( themeOptions, themeOptions.separatorFrame ) or _widget._getFrameIndex( themeOptions, themeOptions.seperatorFrame ) or nil
opt.separatorFrameWidth = customOptions.separatorFrameWidth or themeOptions.separatorFrameWidth or themeOptions.seperatorFrameWidth or nil
opt.separatorFrameHeight = customOptions.separatorFrameHeight or themeOptions.separatorFrameHeight or themeOptions.seperatorFrameHeight or nil
opt.separatorFrameWidth = customOptions.separatorFrameWidth or (themeOptions.separatorFrameWidth and themeOptions.separatorFrameWidth * screenScaleFactor) or (themeOptions.seperatorFrameWidth and themeOptions.seperatorFrameWidth * screenScaleFactor) or nil
opt.separatorFrameHeight = customOptions.separatorFrameHeight or (themeOptions.separatorFrameHeight and themeOptions.separatorFrameHeight * screenScaleFactor) or (themeOptions.seperatorFrameHeight and themeOptions.seperatorFrameHeight * screenScaleFactor) or nil
-------------------------------------------------------
-- Create the pickerWheel
-------------------------------------------------------
Expand Down
17 changes: 13 additions & 4 deletions widgetLibrary/widget_tableview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,14 @@ local function createTableView( tableView, options )
end

-- If the row is within bounds
if isWithinBounds then
local translateToPos = - currentRow.y - self.parent.y - 6
if isWithinBounds then
local translateToPos = - currentRow.y - self.parent.y - 6

if self._isUsedInPickerWheel then
local screenScaleFactor = display.contentWidth / 320; -- factor that adjust the pickerWheel to work with config.content.width > 320
translateToPos = - currentRow.y - self.parent.y - 6 * screenScaleFactor
end

if isGraphicsV1 then
translateToPos = - currentRow.y - self.parent.y
end
Expand Down Expand Up @@ -1511,8 +1517,11 @@ local function createTableView( tableView, options )

-- The calculation needs altering for pickerWheels
if self._isUsedInPickerWheel then

local screenScaleFactor = display.contentWidth / 320; -- factor that adjust the pickerWheel to work with config.content.width > 320

-- TODO: this is just because we have a single theme for all the pickers, we'll have to add a real solution here.
local jumpY = - 26 - self._rows[rowIndex].y + ( self._rows[rowIndex]._height * 0.5 )
local jumpY = - 26 * screenScaleFactor - self._rows[rowIndex].y + ( self._rows[rowIndex]._height * 0.5 )
if isGraphicsV1 then
jumpY = - self._rows[rowIndex]._height * 0.5 - self._rows[rowIndex].y + ( self._rows[rowIndex]._height * 0.5 )
end
Expand Down Expand Up @@ -1592,7 +1601,7 @@ local function createTableView( tableView, options )
end

-- we have to rerender the stuck category on the top, if it exists
if ( self._rows[ 1 ].isCategory ) then
if ( self._rows[ 1 ] and self._rows[ 1 ].isCategory ) then
self:_renderCategory( self._rows[ 1 ], true )
end

Expand Down