Skip to content

Commit

Permalink
update alpha - refactor, bugfix, and QOL updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert committed Nov 27, 2023
1 parent 69ab11c commit 33fe6bb
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 118 deletions.
41 changes: 20 additions & 21 deletions components/ItemGrid/Alpha.bs
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
sub init()
m.top.visible = true
m.Alphamenu = m.top.findNode("Alphamenu")
m.Alphamenu.focusable = true
m.Alphatext = m.top.findNode("alphatext")
m.focusedChild = m.top.findNode("focusedChild")
m.Alphamenu.focusedFont.size = 25
m.Alphamenu.font.size = 25
m.top.setFocus(false)

m.alphaText = m.top.findNode("alphaText")
m.alphaMenu = m.top.findNode("alphaMenu")
m.alphaMenu.setFocus(false)
m.alphaMenu.focusedFont.size = 25
m.alphaMenu.font.size = 25

' show mic icon above alpha menu if remote supports voice commands
if m.global.device.hasVoiceRemote
alphaMic = m.top.findNode("alphaMic")
alphaMic.visible = true
end if
end sub

function onKeyEvent(key as string, press as boolean) as boolean

if not press then return false
if not m.alphaMenu.isInFocusChain() then return false

if key = "OK"
child = m.Alphatext.getChild(m.Alphamenu.itemFocused)

if child.title = m.top.itemAlphaSelected
m.top.itemAlphaSelected = ""
m.Alphamenu.focusFootprintBitmapUri = ""
else
m.Alphamenu.focusFootprintBitmapUri = "pkg:/images/white.png"
m.top.itemAlphaSelected = child.title
end if
child = m.alphaText.getChild(m.alphaMenu.itemFocused)
m.top.letterSelected = child.title
return true
end if

if key = "up"
if m.Alphamenu.itemFocused = 0
m.Alphamenu.jumpToItem = m.Alphamenu.numRows - 1
if m.alphaMenu.itemFocused = 0
m.alphaMenu.jumpToItem = m.alphaMenu.numRows - 1
return true
end if
end if

if key = "down"
if m.Alphamenu.itemFocused = m.Alphamenu.numRows - 1
m.Alphamenu.jumpToItem = 0
if m.alphaMenu.itemFocused = m.alphaMenu.numRows - 1
m.alphaMenu.jumpToItem = 0
return true
end if
end if
Expand Down
14 changes: 7 additions & 7 deletions components/ItemGrid/Alpha.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<component name="Alpha" extends="Group">
<children>
<Poster id="alphaMic" height="22" width="15" uri="pkg:/images/icons/mic_icon.png" translation="[60, 150]" visible="false" />
<LabelList
translation="[50, 185]"
id="alphaMenu"
translation="[52, 186]"
vertFocusAnimationStyle="floatingFocus"
drawFocusFeedback="true"
id="Alphamenu"
font="font:SmallestSystemFont"
focusedFont="font:SmallestSystemFont"
itemSpacing="[0,2]"
itemSize="[28,28]"
numRows="27"
textHorizAlign="center"
drawFocusFeedback="true"
focusBitmapUri="pkg:/images/white.png"
focusBitmapBlendColor="#FFFFFF"
focusFootprintBlendColor="#666666"
>
<ContentNode id="alphatext" role="content">
<ContentNode id="alphaText" role="content">
<ContentNode title="#" />
<ContentNode title="A" />
<ContentNode title="B" />
Expand Down Expand Up @@ -47,8 +49,6 @@
</LabelList>
</children>
<interface>
<field id="selectedItem" type="node" alwaysNotify="true" />
<field id="focusedChild" type="node" onChange="focusChanged" />
<field id="itemAlphaSelected" type="string" />
<field id="letterSelected" type="string" alwaysNotify="true" />
</interface>
</component>
70 changes: 39 additions & 31 deletions components/ItemGrid/ItemGrid.bs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ sub init()

m.itemGrid.observeField("itemFocused", "onItemFocused")
m.itemGrid.observeField("itemSelected", "onItemSelected")
m.itemGrid.observeField("alphaSelected", "onItemalphaSelected")

'Voice filter setup
m.voiceBox = m.top.findNode("voiceBox")
Expand Down Expand Up @@ -67,19 +66,11 @@ sub init()
m.spinner = m.top.findNode("spinner")
m.spinner.visible = true

m.Alpha = m.top.findNode("AlphaMenu")
m.AlphaSelected = m.top.findNode("AlphaSelected")
m.alpha = m.top.findNode("alpha")
m.alphaSelected = m.top.findNode("alphaSelected")

'Get reset folder setting
m.resetGrid = m.global.session.user.settings["itemgrid.reset"]

m.micButton = m.top.findNode("micButton")
m.micButtonText = m.top.findNode("micButtonText")
'Hide voice search if device does not have voice remote
if m.global.device.hasVoiceRemote = false
m.micButton.visible = false
m.micButtonText.visible = false
end if
end sub

'
Expand All @@ -106,13 +97,22 @@ sub loadInitialItems()
if m.top.parentItem.collectionType = "livetv"
' Translate between app and server nomenclature
viewSetting = m.global.session.user.settings["display.livetv.landing"]
'Move mic to be visiable on TV Guide screen
if m.global.device.hasVoiceRemote = true
m.micButton.translation = "[1540, 92]"
m.micButtonText.visible = true
m.micButtonText.translation = "[1600,130]"
m.micButtonText.font.size = 22
m.micButtonText.text = tr("Search")
' Show mic icon and text on TV Guide screen
if m.global.device.hasVoiceRemote
micIcon = CreateObject("roSGNode", "Poster")
micIcon.id = "micIcon"
micIcon.uri = "pkg:/images/icons/mic_icon.png"
micIcon.translation = "[1578, 130]"

micIconText = CreateObject("roSGNode", "Label")
micIconText.id = "micIconText"
micIconText.font = "font:SmallSystemFont"
micIconText.translation = "[1600,130]"
micIconText.font.size = 22
micIconText.text = tr("Search")

m.top.appendChild(micIcon)
m.top.appendChild(micIconText)
end if
if viewSetting = "guide"
m.view = "tvGuide"
Expand Down Expand Up @@ -166,9 +166,15 @@ sub loadInitialItems()
else
m.loadItemsTask.itemId = m.top.parentItem.Id
end if

' if we already searched for this alpha text than reset filter
if m.loadItemsTask.nameStartsWith = m.top.alphaSelected
m.loadItemsTask.nameStartsWith = ""
else
m.loadItemsTask.nameStartsWith = m.alpha.letterSelected
end if
updateTitle()

m.loadItemsTask.nameStartsWith = m.top.alphaSelected
m.loadItemsTask.searchTerm = m.voiceBox.text
m.emptyText.visible = false
m.loadItemsTask.sortField = m.sortField
Expand Down Expand Up @@ -446,7 +452,6 @@ sub SetUpOptions()
m.options.options = options
end sub


'
'Handle loaded data, and add to Grid
sub ItemDataLoaded(msg)
Expand Down Expand Up @@ -483,8 +488,14 @@ sub ItemDataLoaded(msg)
m.data.appendChild(item)
end for

m.itemGrid.opacity = "1"
m.genreList.opacity = "0"
' keep focus on alpha menu when loading new data
if not m.alpha.isinFocusChain()
m.itemGrid.opacity = "1"
m.genreList.opacity = "0"

m.itemGrid.setFocus(true)
m.genreList.setFocus(false)
end if

'Update the stored counts
m.loadedItems = m.itemGrid.content.getChildCount()
Expand All @@ -496,8 +507,6 @@ sub ItemDataLoaded(msg)
m.emptyText.visible = true
end if

m.itemGrid.setFocus(true)
m.genreList.setFocus(false)
m.spinner.visible = false
end sub

Expand Down Expand Up @@ -585,16 +594,16 @@ sub onItemSelected()
m.top.selectedItem = m.itemGrid.content.getChild(m.itemGrid.itemSelected)
end sub

sub onItemalphaSelected()
sub alphaSelectedChanged()
if m.top.alphaSelected <> ""
m.loadedRows = 0
m.loadedItems = 0
m.data = CreateObject("roSGNode", "ContentNode")
m.itemGrid.content = m.data
m.loadItemsTask.searchTerm = ""
m.VoiceBox.text = ""
m.loadItemsTask.nameStartsWith = m.alpha.itemAlphaSelected
m.spinner.visible = true

loadInitialItems()
end if
end sub
Expand Down Expand Up @@ -826,14 +835,13 @@ function onKeyEvent(key as string, press as boolean) as boolean
else if key = "left" and topGrp.isinFocusChain()
m.top.alphaActive = true
topGrp.setFocus(false)
alpha = m.alpha.getChild(0).findNode("Alphamenu")
alpha = m.alpha.getChild(0).findNode("alphaMenu")
alpha.setFocus(true)
return true

else if key = "right" and m.Alpha.isinFocusChain()
else if key = "right" and m.alpha.isinFocusChain()
m.top.alphaActive = false
m.Alpha.setFocus(false)
m.Alpha.visible = true
m.alpha.setFocus(false)
topGrp.setFocus(true)
return true
else if key = "replay" and topGrp.isinFocusChain()
Expand Down Expand Up @@ -872,7 +880,7 @@ sub updateTitle()
m.top.overhangTitle = m.top.parentItem.title + tr(" (Filtered by ") + m.loadItemsTask.searchTerm + ")"
end if

if m.top.alphaSelected <> ""
if m.loadItemsTask.nameStartsWith <> ""
m.top.overhangTitle = m.top.parentItem.title + tr(" (Filtered by ") + m.loadItemsTask.nameStartsWith + ")"
end if

Expand Down
8 changes: 3 additions & 5 deletions components/ItemGrid/ItemGrid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,23 @@
drawFocusFeedback="false" />

<RowList opacity="0" id="genrelist" translation="[120, 160]" showRowLabel="true" itemComponentName="GridItemSmall" numColumns="1" numRows="3" vertFocusAnimationStyle="fixed" itemSize="[1900, 360]" rowItemSize="[ [230, 320] ]" rowItemSpacing="[ [20, 0] ]" itemSpacing="[0, 60]" />

<Label id="micButtonText" font="font:SmallSystemFont" visible="false" />
<Button id="micButton" maxWidth="20" translation="[20, 120]" iconUri="pkg:/images/icons/mic_icon.png" />

<Label translation="[0,540]" id="emptyText" font="font:LargeSystemFont" width="1910" horizAlign="center" vertAlign="center" height="64" visible="false" />
<ItemGridOptions id="options" visible="false" />
<Spinner id="spinner" translation="[900, 450]" />
<Animation id="backroundSwapAnimation" duration="1" repeat="false" easeFunction="linear">
<FloatFieldInterpolator id="fadeinLoading" key="[0.0, 1.0]" keyValue="[ 0.00, 0.25 ]" fieldToInterp="backdropTransition.opacity" />
<FloatFieldInterpolator id="fadeoutLoaded" key="[0.0, 1.0]" keyValue="[ 0.25, 0.00 ]" fieldToInterp="backdrop.opacity" />
</Animation>
<Alpha id="AlphaMenu" />
<Alpha id="alpha" />
</children>
<interface>
<field id="HomeLibraryItem" type="string" />
<field id="parentItem" type="node" onChange="loadInitialItems" />
<field id="selectedItem" type="node" alwaysNotify="true" />
<field id="quickPlayNode" type="node" alwaysNotify="true" />
<field id="imageDisplayMode" type="string" value="scaleToZoom" />
<field id="AlphaSelected" type="string" alias="AlphaMenu.itemAlphaSelected" alwaysNotify="true" onChange="onItemAlphaSelected" />
<field id="alphaSelected" type="string" alias="alpha.letterSelected" alwaysNotify="true" onChange="alphaSelectedChanged" />
<field id="alphaActive" type="boolean" value="false" />
<field id="jumpToItem" type="integer" value="" />
</interface>
Expand Down
43 changes: 20 additions & 23 deletions components/ItemGrid/MovieLibraryView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ sub setupNodes()
m.movieLogo = m.top.findNode("movieLogo")
m.swapAnimation = m.top.findNode("backroundSwapAnimation")
m.spinner = m.top.findNode("spinner")
m.Alpha = m.top.findNode("AlphaMenu")
m.AlphaSelected = m.top.findNode("AlphaSelected")
m.micButton = m.top.findNode("micButton")
m.micButtonText = m.top.findNode("micButtonText")
m.alpha = m.top.findNode("alpha")
m.alphaSelected = m.top.findNode("alphaSelected")
m.communityRatingGroup = m.top.findNode("communityRatingGroup")
m.criticRatingIcon = m.top.findNode("criticRatingIcon")
m.criticRatingGroup = m.top.findNode("criticRatingGroup")
Expand Down Expand Up @@ -53,7 +51,6 @@ sub init()

m.itemGrid.observeField("itemFocused", "onItemFocused")
m.itemGrid.observeField("itemSelected", "onItemSelected")
m.itemGrid.observeField("alphaSelected", "onItemalphaSelected")

'Voice filter setup
m.voiceBox.voiceEnabled = true
Expand Down Expand Up @@ -87,12 +84,6 @@ sub init()

'Get reset folder setting
m.resetGrid = m.global.session.user.settings["itemgrid.reset"]

'Hide voice search if device does not have voice remote
if m.global.device.hasVoiceRemote = false
m.micButton.visible = false
m.micButtonText.visible = false
end if
end sub

sub OnScreenHidden()
Expand Down Expand Up @@ -163,7 +154,12 @@ sub loadInitialItems()
m.loadItemsTask.itemId = m.top.parentItem.Id
end if

m.loadItemsTask.nameStartsWith = m.top.alphaSelected
' if we already searched for this alpha text than reset filter
if m.loadItemsTask.nameStartsWith = m.top.alphaSelected
m.loadItemsTask.nameStartsWith = ""
else
m.loadItemsTask.nameStartsWith = m.alpha.letterSelected
end if
m.loadItemsTask.searchTerm = m.voiceBox.text
m.emptyText.visible = false
m.loadItemsTask.sortField = m.sortField
Expand Down Expand Up @@ -444,11 +440,14 @@ sub ItemDataLoaded(msg)
return
end if

m.itemGrid.opacity = "1"
m.genreList.opacity = "0"
' keep focus on alpha menu when loading new data
if not m.alpha.isinFocusChain()
m.itemGrid.opacity = "1"
m.genreList.opacity = "0"

m.itemGrid.setFocus(true)
m.genreList.setFocus(false)
m.itemGrid.setFocus(true)
m.genreList.setFocus(false)
end if

if m.data.getChildCount() = 0
m.itemGrid.jumpToItem = 0
Expand Down Expand Up @@ -722,7 +721,7 @@ sub onGenreItemSelected()
m.top.selectedItem = m.genreList.content.getChild(m.genreList.rowItemSelected[0]).getChild(m.genreList.rowItemSelected[1])
end sub

sub onItemalphaSelected()
sub alphaSelectedChanged()
if m.top.alphaSelected <> ""
m.loadedRows = 0
m.loadedItems = 0
Expand All @@ -735,7 +734,6 @@ sub onItemalphaSelected()

m.loadItemsTask.searchTerm = ""
m.VoiceBox.text = ""
m.loadItemsTask.nameStartsWith = m.alpha.itemAlphaSelected
m.spinner.visible = true
loadInitialItems()
end if
Expand Down Expand Up @@ -886,21 +884,20 @@ function onKeyEvent(key as string, press as boolean) as boolean
if m.itemGrid.isinFocusChain()
m.top.alphaActive = true
m.itemGrid.setFocus(false)
alpha = m.alpha.getChild(0).findNode("Alphamenu")
alpha = m.alpha.getChild(0).findNode("alphaMenu")
alpha.setFocus(true)
return true
else if m.genreList.isinFocusChain()
m.top.alphaActive = true
m.genreList.setFocus(false)
alpha = m.alpha.getChild(0).findNode("Alphamenu")
alpha = m.alpha.getChild(0).findNode("alphaMenu")
alpha.setFocus(true)
return true
end if

else if key = "right" and m.Alpha.isinFocusChain()
else if key = "right" and m.alpha.isinFocusChain()
m.top.alphaActive = false
m.Alpha.setFocus(false)
m.Alpha.visible = true
m.alpha.setFocus(false)

m.itemGrid.setFocus(m.itemGrid.opacity = 1)
m.genreList.setFocus(m.genreList.opacity = 1)
Expand Down
Loading

0 comments on commit 33fe6bb

Please sign in to comment.