2020-08-16 14:44:03 +00:00
|
|
|
sub init()
|
2020-08-08 20:43:37 +00:00
|
|
|
|
2020-08-16 14:44:03 +00:00
|
|
|
m.buttons = m.top.findNode("buttons")
|
2020-08-17 15:48:23 +00:00
|
|
|
m.buttons.buttons = [tr("TAB_VIEW"), tr("TAB_SORT"), tr("TAB_FILTER")]
|
2020-10-24 13:56:33 +00:00
|
|
|
m.buttons.selectedIndex = 1
|
2020-08-08 20:43:37 +00:00
|
|
|
m.buttons.setFocus(true)
|
|
|
|
|
2020-08-15 10:26:43 +00:00
|
|
|
m.selectedSortIndex = 0
|
2020-08-08 20:43:37 +00:00
|
|
|
m.selectedItem = 1
|
|
|
|
|
|
|
|
m.menus = []
|
|
|
|
m.menus.push(m.top.findNode("viewMenu"))
|
|
|
|
m.menus.push(m.top.findNode("sortMenu"))
|
|
|
|
m.menus.push(m.top.findNode("filterMenu"))
|
|
|
|
|
2020-08-16 14:44:03 +00:00
|
|
|
m.viewNames = []
|
|
|
|
m.sortNames = []
|
2020-10-24 22:50:07 +00:00
|
|
|
m.filterNames = []
|
2020-08-15 10:26:43 +00:00
|
|
|
|
2020-08-16 16:17:41 +00:00
|
|
|
' Animation
|
|
|
|
m.fadeAnim = m.top.findNode("fadeAnim")
|
|
|
|
m.fadeOutAnimOpacity = m.top.findNode("outOpacity")
|
|
|
|
m.fadeInAnimOpacity = m.top.findNode("inOpacity")
|
|
|
|
|
2020-08-08 20:43:37 +00:00
|
|
|
m.buttons.observeField("focusedIndex", "buttonFocusChanged")
|
|
|
|
|
|
|
|
end sub
|
|
|
|
|
|
|
|
|
2020-08-16 14:44:03 +00:00
|
|
|
sub optionsSet()
|
2020-08-08 20:43:37 +00:00
|
|
|
|
2020-08-16 14:44:03 +00:00
|
|
|
' Views Tab
|
2021-06-26 13:52:16 +00:00
|
|
|
if m.top.options.views <> invalid
|
2020-08-16 14:44:03 +00:00
|
|
|
viewContent = CreateObject("roSGNode", "ContentNode")
|
|
|
|
index = 0
|
|
|
|
selectedViewIndex = 0
|
2020-08-08 20:43:37 +00:00
|
|
|
|
2020-08-16 14:44:03 +00:00
|
|
|
for each view in m.top.options.views
|
|
|
|
entry = viewContent.CreateChild("ContentNode")
|
|
|
|
entry.title = view.Title
|
|
|
|
m.viewNames.push(view.Name)
|
2021-06-26 13:52:16 +00:00
|
|
|
if (view.selected <> invalid and view.selected = true) or viewContent.Name = m.top.view
|
2020-08-16 14:44:03 +00:00
|
|
|
selectedViewIndex = index
|
|
|
|
end if
|
|
|
|
index = index + 1
|
|
|
|
end for
|
|
|
|
m.menus[0].content = viewContent
|
|
|
|
m.menus[0].checkedItem = selectedViewIndex
|
|
|
|
end if
|
2020-08-08 20:43:37 +00:00
|
|
|
|
2020-08-16 14:44:03 +00:00
|
|
|
' Sort Tab
|
2021-06-26 13:52:16 +00:00
|
|
|
if m.top.options.sort <> invalid
|
2020-08-16 14:44:03 +00:00
|
|
|
sortContent = CreateObject("roSGNode", "ContentNode")
|
|
|
|
index = 0
|
|
|
|
m.selectedSortIndex = 0
|
|
|
|
|
|
|
|
for each sortItem in m.top.options.sort
|
|
|
|
entry = sortContent.CreateChild("ContentNode")
|
|
|
|
entry.title = sortItem.Title
|
|
|
|
m.sortNames.push(sortItem.Name)
|
2021-06-26 13:52:16 +00:00
|
|
|
if sortItem.Selected <> invalid and sortItem.Selected = true
|
2020-08-16 14:44:03 +00:00
|
|
|
m.selectedSortIndex = index
|
2021-06-26 13:52:16 +00:00
|
|
|
if sortItem.Ascending <> invalid and sortItem.Ascending = false
|
2020-08-16 14:44:03 +00:00
|
|
|
m.top.sortAscending = 0
|
|
|
|
else
|
|
|
|
m.top.sortAscending = 1
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
index = index + 1
|
|
|
|
end for
|
|
|
|
m.menus[1].content = sortContent
|
|
|
|
m.menus[1].checkedItem = m.selectedSortIndex
|
|
|
|
|
2021-06-26 13:52:16 +00:00
|
|
|
if m.top.sortAscending = 1
|
2020-08-16 14:44:03 +00:00
|
|
|
m.menus[1].focusedCheckedIconUri = m.global.constants.icons.ascending_black
|
|
|
|
m.menus[1].checkedIconUri = m.global.constants.icons.ascending_white
|
|
|
|
else
|
|
|
|
m.menus[1].focusedCheckedIconUri = m.global.constants.icons.descending_black
|
|
|
|
m.menus[1].checkedIconUri = m.global.constants.icons.descending_white
|
|
|
|
end if
|
|
|
|
end if
|
2020-08-08 20:43:37 +00:00
|
|
|
|
2020-10-24 22:50:07 +00:00
|
|
|
' Filter Tab
|
2021-06-26 13:52:16 +00:00
|
|
|
if m.top.options.filter <> invalid
|
2020-10-24 22:50:07 +00:00
|
|
|
filterContent = CreateObject("roSGNode", "ContentNode")
|
|
|
|
index = 0
|
|
|
|
m.selectedFilterIndex = 0
|
|
|
|
|
|
|
|
for each filterItem in m.top.options.filter
|
|
|
|
entry = filterContent.CreateChild("ContentNode")
|
|
|
|
entry.title = filterItem.Title
|
|
|
|
m.filterNames.push(filterItem.Name)
|
2021-06-26 13:52:16 +00:00
|
|
|
if filterItem.selected <> invalid and filterItem.selected = true
|
2020-10-24 22:50:07 +00:00
|
|
|
m.selectedFilterIndex = index
|
|
|
|
end if
|
|
|
|
index = index + 1
|
|
|
|
end for
|
|
|
|
m.menus[2].content = filterContent
|
|
|
|
m.menus[2].checkedItem = m.selectedFilterIndex
|
|
|
|
else
|
|
|
|
filterContent = CreateObject("roSGNode", "ContentNode")
|
|
|
|
entry = filterContent.CreateChild("ContentNode")
|
|
|
|
entry.title = "All"
|
|
|
|
m.filterNames.push("All")
|
|
|
|
m.menus[2].content = filterContent
|
|
|
|
m.menus[2].checkedItem = 0
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
2020-08-16 14:44:03 +00:00
|
|
|
end sub
|
2020-08-08 20:43:37 +00:00
|
|
|
|
2020-08-16 16:17:41 +00:00
|
|
|
' Switch menu shown when button focus changes
|
2020-08-16 14:44:03 +00:00
|
|
|
sub buttonFocusChanged()
|
|
|
|
if m.buttons.focusedIndex = m.selectedItem then return
|
2020-08-16 16:17:41 +00:00
|
|
|
m.fadeOutAnimOpacity.fieldToInterp = m.menus[m.selectedItem].id + ".opacity"
|
|
|
|
m.fadeInAnimOpacity.fieldToInterp = m.menus[m.buttons.focusedIndex].id + ".opacity"
|
|
|
|
m.fadeAnim.control = "start"
|
2020-08-08 20:43:37 +00:00
|
|
|
m.selectedItem = m.buttons.focusedIndex
|
|
|
|
end sub
|
|
|
|
|
|
|
|
|
|
|
|
function onKeyEvent(key as string, press as boolean) as boolean
|
|
|
|
|
2021-06-26 13:52:16 +00:00
|
|
|
if key = "down" or (key = "OK" and m.top.findNode("buttons").hasFocus())
|
2020-08-08 20:43:37 +00:00
|
|
|
m.top.findNode("buttons").setFocus(false)
|
2020-08-15 10:26:43 +00:00
|
|
|
m.menus[m.selectedItem].setFocus(true)
|
2020-08-16 14:44:03 +00:00
|
|
|
m.menus[m.selectedItem].drawFocusFeedback = true
|
2020-08-16 16:17:41 +00:00
|
|
|
|
|
|
|
'If user presses down from button menu, focus first item. If OK, focus checked item
|
2021-06-26 13:52:16 +00:00
|
|
|
if key = "down"
|
2020-08-16 16:17:41 +00:00
|
|
|
m.menus[m.selectedItem].jumpToItem = 0
|
|
|
|
else
|
|
|
|
m.menus[m.selectedItem].jumpToItem = m.menus[m.selectedItem].itemSelected
|
|
|
|
end if
|
|
|
|
|
2020-08-08 20:43:37 +00:00
|
|
|
return true
|
2020-08-16 14:44:03 +00:00
|
|
|
else if key = "OK"
|
2021-06-26 13:52:16 +00:00
|
|
|
if m.menus[m.selectedItem].isInFocusChain()
|
2020-11-23 17:13:57 +00:00
|
|
|
' Handle View Screen
|
2021-06-26 13:52:16 +00:00
|
|
|
if m.selectedItem = 0
|
2020-11-23 17:13:57 +00:00
|
|
|
m.selectedViewIndex = m.menus[0].itemSelected
|
|
|
|
m.top.view = m.viewNames[m.selectedViewIndex]
|
|
|
|
end if
|
|
|
|
|
2020-10-24 22:50:07 +00:00
|
|
|
' Handle Sort screen
|
2021-06-26 13:52:16 +00:00
|
|
|
if m.selectedItem = 1
|
|
|
|
if m.menus[1].itemSelected <> m.selectedSortIndex
|
2020-08-16 14:44:03 +00:00
|
|
|
m.menus[1].focusedCheckedIconUri = m.global.constants.icons.ascending_black
|
|
|
|
m.menus[1].checkedIconUri = m.global.constants.icons.ascending_white
|
|
|
|
|
|
|
|
m.selectedSortIndex = m.menus[1].itemSelected
|
|
|
|
m.top.sortAscending = true
|
|
|
|
m.top.sortField = m.sortNames[m.selectedSortIndex]
|
2020-08-15 10:26:43 +00:00
|
|
|
else
|
2020-08-16 14:44:03 +00:00
|
|
|
|
2021-06-26 13:52:16 +00:00
|
|
|
if m.top.sortAscending = true
|
2020-08-16 14:44:03 +00:00
|
|
|
m.top.sortAscending = false
|
|
|
|
m.menus[1].focusedCheckedIconUri = m.global.constants.icons.descending_black
|
|
|
|
m.menus[1].checkedIconUri = m.global.constants.icons.descending_white
|
|
|
|
else
|
|
|
|
m.top.sortAscending = true
|
|
|
|
m.menus[1].focusedCheckedIconUri = m.global.constants.icons.ascending_black
|
|
|
|
m.menus[1].checkedIconUri = m.global.constants.icons.ascending_white
|
|
|
|
end if
|
2020-08-15 10:26:43 +00:00
|
|
|
end if
|
|
|
|
end if
|
2020-10-24 22:50:07 +00:00
|
|
|
' Handle Filter screen
|
2021-06-26 13:52:16 +00:00
|
|
|
if m.selectedItem = 2
|
2020-10-24 22:50:07 +00:00
|
|
|
m.selectedFilterIndex = m.menus[2].itemSelected
|
|
|
|
m.top.filter = m.filterNames[m.selectedFilterIndex]
|
|
|
|
end if
|
2020-08-15 10:26:43 +00:00
|
|
|
end if
|
2020-08-08 20:43:37 +00:00
|
|
|
return true
|
2020-08-16 14:44:03 +00:00
|
|
|
else if key = "back" or key = "up"
|
2021-06-26 13:52:16 +00:00
|
|
|
if m.menus[m.selectedItem].isInFocusChain()
|
2020-08-08 20:43:37 +00:00
|
|
|
m.buttons.setFocus(true)
|
2020-08-16 14:44:03 +00:00
|
|
|
m.menus[m.selectedItem].drawFocusFeedback = false
|
2020-08-08 20:43:37 +00:00
|
|
|
return true
|
|
|
|
end if
|
2020-08-16 14:44:03 +00:00
|
|
|
else if key = "options"
|
|
|
|
m.menus[m.selectedItem].drawFocusFeedback = false
|
2020-08-08 20:43:37 +00:00
|
|
|
return false
|
|
|
|
end if
|
|
|
|
|
2020-08-16 14:44:03 +00:00
|
|
|
return false
|
|
|
|
|
2020-08-08 20:43:37 +00:00
|
|
|
end function
|