Animation when switching option menu
This commit is contained in:
parent
5d3dc87d62
commit
0f5c233771
|
@ -110,6 +110,9 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
|||
highlightSelected(m.selectedFocusedIndex)
|
||||
m.top.focusedIndex = m.selectedFocusedIndex
|
||||
return true
|
||||
else if key = "OK"
|
||||
m.top.selectedIndex = m.selectedFocusedIndex
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
|
|
@ -59,10 +59,12 @@ sub loadInitialItems()
|
|||
|
||||
end sub
|
||||
|
||||
' Data to display when options button selected
|
||||
sub SetUpOptions()
|
||||
|
||||
options = {}
|
||||
|
||||
'Movies
|
||||
if m.top.parentItem.collectionType = "movies" then
|
||||
options.views = [{ "Title": tr("Movies"), "Name": "movies" }]
|
||||
options.sort = [
|
||||
|
@ -76,6 +78,7 @@ sub SetUpOptions()
|
|||
{ "Title": tr("Release Date"), "Name": "PremiereDate" },
|
||||
{ "Title": tr("Run Time"), "Name": "Runtime" }
|
||||
]
|
||||
'TV Shows
|
||||
else if m.top.parentItem.collectionType = "tvshows" then
|
||||
options.views = [{ "Title": tr("Shows"), "Name": "shows" }]
|
||||
options.sort = [
|
||||
|
|
|
@ -15,6 +15,11 @@ sub init()
|
|||
m.viewNames = []
|
||||
m.sortNames = []
|
||||
|
||||
' Animation
|
||||
m.fadeAnim = m.top.findNode("fadeAnim")
|
||||
m.fadeOutAnimOpacity = m.top.findNode("outOpacity")
|
||||
m.fadeInAnimOpacity = m.top.findNode("inOpacity")
|
||||
|
||||
m.buttons.observeField("focusedIndex", "buttonFocusChanged")
|
||||
|
||||
end sub
|
||||
|
@ -75,21 +80,30 @@ sub optionsSet()
|
|||
|
||||
end sub
|
||||
|
||||
|
||||
' Switch menu shown when button focus changes
|
||||
sub buttonFocusChanged()
|
||||
if m.buttons.focusedIndex = m.selectedItem then return
|
||||
m.menus[m.selectedItem].visible = false
|
||||
m.menus[m.buttons.focusedIndex].visible = true
|
||||
m.fadeOutAnimOpacity.fieldToInterp = m.menus[m.selectedItem].id + ".opacity"
|
||||
m.fadeInAnimOpacity.fieldToInterp = m.menus[m.buttons.focusedIndex].id + ".opacity"
|
||||
m.fadeAnim.control = "start"
|
||||
m.selectedItem = m.buttons.focusedIndex
|
||||
end sub
|
||||
|
||||
|
||||
function onKeyEvent(key as string, press as boolean) as boolean
|
||||
|
||||
if key = "down" OR (key = "OK" AND m.top.findNode("buttons").hasFocus()) then
|
||||
if key = "down" or (key = "OK" and m.top.findNode("buttons").hasFocus()) then
|
||||
m.top.findNode("buttons").setFocus(false)
|
||||
m.menus[m.selectedItem].setFocus(true)
|
||||
m.menus[m.selectedItem].drawFocusFeedback = true
|
||||
|
||||
'If user presses down from button menu, focus first item. If OK, focus checked item
|
||||
if key = "down" then
|
||||
m.menus[m.selectedItem].jumpToItem = 0
|
||||
else
|
||||
m.menus[m.selectedItem].jumpToItem = m.menus[m.selectedItem].itemSelected
|
||||
end if
|
||||
|
||||
return true
|
||||
else if key = "OK"
|
||||
' Handle Sort screen
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
<LayoutGroup horizAlignment="center" translation="[860,50]" itemSpacings="[50]">
|
||||
<JFButtons id="buttons" />
|
||||
<Group>
|
||||
<RadiobuttonList id = "viewMenu" itemspacing="[0,10]" vertFocusAnimationStyle="floatingFocus" visible="false" drawFocusFeedback="false">
|
||||
<RadiobuttonList id="viewMenu" itemspacing="[0,10]" vertFocusAnimationStyle="floatingFocus" opacity="0" drawFocusFeedback="false">
|
||||
</RadiobuttonList>
|
||||
<RadiobuttonList id = "sortMenu" itemspacing="[0,10]" vertFocusAnimationStyle="floatingFocus" visible="true" numRows="8" drawFocusFeedback="false">
|
||||
<RadiobuttonList id="sortMenu" itemspacing="[0,10]" vertFocusAnimationStyle="floatingFocus" opacity="1" numRows="8" drawFocusFeedback="false">
|
||||
</RadiobuttonList>
|
||||
<LabelList id = "filterMenu" itemspacing="[0,10]" vertFocusAnimationStyle="floatingFocus" visible="false" drawFocusFeedback="false">
|
||||
<LabelList id = "filterMenu" itemspacing="[0,10]" vertFocusAnimationStyle="floatingFocus" opacity="0" drawFocusFeedback="false">
|
||||
<ContentNode id = "filterMenuContent" role = "content">
|
||||
<ContentNode title = "Coming Soon..." />
|
||||
</ContentNode>
|
||||
|
@ -19,6 +19,12 @@
|
|||
</Group>
|
||||
</LayoutGroup>
|
||||
</Group>
|
||||
|
||||
<Animation id="fadeAnim" duration="0.5" repeat="false">
|
||||
<FloatFieldInterpolator id="outOpacity" key="[0.0, 0.5, 1.0]" keyValue="[ 1, 0, 0 ]" fieldToInterp="focus.opacity" />
|
||||
<FloatFieldInterpolator id="inOpacity" key="[0.0, 0.5, 1.0]" keyValue="[ 0, 0, 1 ]" fieldToInterp="focus.opacity" />
|
||||
</Animation>
|
||||
|
||||
</children>
|
||||
<interface>
|
||||
<field id="buttons" type="nodearray" />
|
||||
|
|
Loading…
Reference in New Issue
Block a user