From a282ace713a0dd8dbe4aebd5503b0db29f5a4a64 Mon Sep 17 00:00:00 2001 From: 1hitsong <3330318+1hitsong@users.noreply.github.com> Date: Fri, 27 Dec 2024 09:16:48 -0500 Subject: [PATCH] Change Movie Detail buttons to scrolling list --- components/Buttons/ButtonData.bs | 2 + components/Buttons/ButtonData.xml | 21 +++++++ components/MovieDetailButton.bs | 88 ++++++++++++++++++++++++++++++ components/MovieDetailButton.xml | 28 ++++++++++ components/movies/MovieDetails.bs | 74 ++++++++----------------- components/movies/MovieDetails.xml | 27 ++++++--- source/static/whatsNew/1.1.4.json | 8 +-- 7 files changed, 185 insertions(+), 63 deletions(-) create mode 100644 components/Buttons/ButtonData.bs create mode 100644 components/Buttons/ButtonData.xml create mode 100644 components/MovieDetailButton.bs create mode 100644 components/MovieDetailButton.xml diff --git a/components/Buttons/ButtonData.bs b/components/Buttons/ButtonData.bs new file mode 100644 index 000000000..e317bb6b2 --- /dev/null +++ b/components/Buttons/ButtonData.bs @@ -0,0 +1,2 @@ +sub init() +end sub diff --git a/components/Buttons/ButtonData.xml b/components/Buttons/ButtonData.xml new file mode 100644 index 000000000..84f093d8c --- /dev/null +++ b/components/Buttons/ButtonData.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/MovieDetailButton.bs b/components/MovieDetailButton.bs new file mode 100644 index 000000000..509577aa4 --- /dev/null +++ b/components/MovieDetailButton.bs @@ -0,0 +1,88 @@ +import "pkg:/source/enums/ColorPalette.bs" + +sub init() + m.buttonBackground = m.top.findNode("buttonBackground") + m.buttonIcon = m.top.findNode("buttonIcon") + m.buttonText = m.top.findNode("buttonText") +end sub + +sub itemContentChanged() + itemData = m.top.itemContent + + m.buttonText.color = ColorPalette.WHITE + m.buttonText.font.size = itemData.fontSize + m.buttonBackground.blendColor = ColorPalette.TRANSPARENT + m.buttonIcon.uri = itemData.icon + m.buttonIcon.blendcolor = itemData.iconBlendColor + m.buttonText.text = itemData.text + m.buttonBackground.height = itemData.height + m.buttonBackground.width = itemData.width + + m.focusTextColor = ColorPalette.WHITE + m.textColor = ColorPalette.WHITE + m.focusBackground = ColorPalette.HIGHLIGHT + m.focusIcon = itemData.focusIcon + m.icon = itemData.icon + m.background = ColorPalette.TRANSPARENT + m.height = itemData.height + m.width = itemData.width + m.padding = itemData.padding + m.iconSide = itemData.iconSide + + setIconSize() + + m.top.focus = itemData.focus + onFocusChanged() +end sub + + +sub onFocusChanged() + if m.top.focus + m.buttonText.color = m.focusTextColor + m.buttonIcon.uri = m.focusIcon <> "" ? m.focusIcon : m.icon + else + m.buttonText.color = m.textColor + m.buttonIcon.uri = m.icon + end if +end sub + +sub setIconSize() + height = m.buttonBackground.height + width = m.buttonBackground.width + if height > 0 and width > 0 + ' TODO: Use smallest number between them + m.buttonIcon.height = m.height + + if m.padding > 0 + m.buttonIcon.height = m.buttonIcon.height - m.padding + end if + + m.buttonIcon.width = m.buttonIcon.height + + ' Set Icon translation + if LCase(m.iconSide) = "right" + m.buttonIcon.translation = [m.buttonBackground.width - m.padding - m.buttonIcon.width, ((height - m.buttonIcon.height) / 2)] + m.buttonText.translation = [m.padding, ((height - m.buttonText.font.size) / 2)] + else + m.buttonIcon.translation = [m.padding, ((height - m.buttonIcon.height) / 2)] + m.buttonText.translation = [m.padding + m.buttonIcon.width + 20, ((height - m.buttonText.font.size) / 2)] + end if + + ' Set text max width + m.buttonText.maxWidth = m.width - m.padding - m.buttonIcon.width - 40 + end if +end sub + +function onKeyEvent(key as string, press as boolean) as boolean + if not press then return false + + if key = "right" and m.top.focus + m.top.escape = "right" + end if + + if key = "left" and m.top.focus + m.top.escape = "left" + end if + + return false +end function diff --git a/components/MovieDetailButton.xml b/components/MovieDetailButton.xml new file mode 100644 index 000000000..2255cffa5 --- /dev/null +++ b/components/MovieDetailButton.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/movies/MovieDetails.bs b/components/movies/MovieDetails.bs index 11d39a9ac..574798c93 100644 --- a/components/movies/MovieDetails.bs +++ b/components/movies/MovieDetails.bs @@ -28,6 +28,8 @@ sub init() m.infoGroup = m.top.findNode("infoGroup") m.buttonGrp = m.top.findNode("buttons") + m.buttonGrp.observeField("itemFocused", "onButtonItemFocused") + m.buttonGrp.observeField("itemUnfocused", "onButtonItemUnfocused") m.buttonGrp.setFocus(true) m.top.lastFocus = m.buttonGrp @@ -39,7 +41,7 @@ sub init() if not m.global.session.user.policy.EnableSubtitleManagement editSubtitleButton = m.top.findNode("editSubtitlesButton") if isValid(editSubtitleButton) - m.buttonGrp.removeChild(editSubtitleButton) + m.buttonGrp.content.removeChild(editSubtitleButton) end if end if @@ -54,20 +56,8 @@ sub onMovieExtrasHasItems() end sub sub setButtonColors() - buttonList = ["play-button", "options-button", "watched-button", "favorite-button", "editSubtitlesButton", "trailer-button", "part-button"] - - for each button in buttonList - buttonNode = m.top.findNode(button) - buttonNode.background = ColorPalette.TRANSPARENT - buttonNode.textColor = ColorPalette.WHITE - buttonNode.focusBackground = ColorPalette.HIGHLIGHT - buttonNode.focusTextColor = ColorPalette.WHITE - end for - - firstButton = m.top.findNode(buttonList[0]) - firstButton.setFocus(true) - - firstButton.focus = true + m.buttonGrp.focusBitmapUri = "pkg:/images/white.9.png" + m.buttonGrp.focusBitmapBlendColor = ColorPalette.HIGHLIGHT end sub ' OnScreenShown: Callback function when view is presented on screen @@ -103,7 +93,7 @@ end sub sub trailerAvailableChanged() if not m.top.trailerAvailable - m.buttonGrp.removeChild(m.top.findNode("trailer-button")) + m.buttonGrp.content.removeChild(m.top.findNode("trailer-button")) return end if end sub @@ -112,13 +102,13 @@ sub additionalPartsChanged() partButton = m.top.findNode("part-button") if not isValidAndNotEmpty(m.top.additionalParts) if isValid(partButton) - m.buttonGrp.removeChild(partButton) + m.buttonGrp.content.removeChild(partButton) end if end if if m.top.additionalParts.parts.TotalRecordCount = 0 if isValid(partButton) - m.buttonGrp.removeChild(partButton) + m.buttonGrp.content.removeChild(partButton) end if return end if @@ -680,6 +670,15 @@ sub onButtonGroupEscape() end if end sub +sub onButtonItemFocused() + button = m.buttonGrp.content.getChild(m.buttonGrp.itemFocused) + button.focus = true +end sub +sub onButtonItemUnfocused() + button = m.buttonGrp.content.getChild(m.buttonGrp.itemUnfocused) + button.focus = false +end sub + function onKeyEvent(key as string, press as boolean) as boolean if key = KeyCode.UP and m.extrasGrid.isInFocusChain() @@ -689,7 +688,9 @@ function onKeyEvent(key as string, press as boolean) as boolean m.top.findNode("extrasFader").reverse = true m.top.findNode("pplAnime").control = AnimationControl.START m.buttonGrp.setFocus(true) - m.buttonGrp.getChild(m.buttonGrp.getChildCount() - 1).focus = true + + m.buttonGrp.content.getChild(m.buttonGrp.content.getChildCount() - 1).focus = true + group = m.global.sceneManager.callFunc("getActiveScene") group.lastFocus = m.buttonGrp return true @@ -703,7 +704,7 @@ function onKeyEvent(key as string, press as boolean) as boolean if key = KeyCode.OK and m.buttonGrp.hasFocus() m.loadStatus = ViewLoadStatus.RELOAD - buttonList = m.buttonGrp.getChildren(-1, 0) + buttonList = m.buttonGrp.content.getChildren(-1, 0) i = 0 for each button in buttonList @@ -724,18 +725,12 @@ function onKeyEvent(key as string, press as boolean) as boolean end if if key = KeyCode.DOWN and m.buttonGrp.hasFocus() - buttonList = m.buttonGrp.getChildren(-1, 0) + buttonList = m.buttonGrp.content.getChildren(-1, 0) i = 0 for each button in buttonList if button.focus - if i + 1 < m.buttonGrp.getChildCount() - button.focus = false - nextButton = m.buttonGrp.getChild(i + 1) - if isValid(nextButton) - nextButton.focus = true - end if - else + if i + 1 >= m.buttonGrp.content.getChildCount() if not m.movieExtras.visible then return false button.focus = false @@ -755,27 +750,6 @@ function onKeyEvent(key as string, press as boolean) as boolean return true end if - if key = KeyCode.UP and m.buttonGrp.hasFocus() - buttonList = m.buttonGrp.getChildren(-1, 0) - - i = 0 - for each button in buttonList - if button.focus - if i - 1 >= 0 - button.focus = false - nextButton = m.buttonGrp.getChild(i - 1) - if isValid(nextButton) - nextButton.focus = true - end if - end if - exit for - end if - i++ - end for - - return true - end if - if key = KeyCode.BACK if m.options.visible = true m.options.visible = false @@ -790,7 +764,7 @@ function onKeyEvent(key as string, press as boolean) as boolean m.top.findNode("extrasFader").reverse = true m.top.findNode("pplAnime").control = AnimationControl.START m.buttonGrp.setFocus(true) - m.buttonGrp.getChild(m.buttonGrp.getChildCount() - 1).focus = true + m.buttonGrp.content.getChild(m.buttonGrp.content.getChildCount() - 1).focus = true group = m.global.sceneManager.callFunc("getActiveScene") group.lastFocus = m.buttonGrp return true diff --git a/components/movies/MovieDetails.xml b/components/movies/MovieDetails.xml index 7294ab8a9..4df964dd4 100644 --- a/components/movies/MovieDetails.xml +++ b/components/movies/MovieDetails.xml @@ -40,15 +40,24 @@ - - - - - - - - - + + + + + + + + + + + diff --git a/source/static/whatsNew/1.1.4.json b/source/static/whatsNew/1.1.4.json index 91bd717b6..ed3d6d04c 100644 --- a/source/static/whatsNew/1.1.4.json +++ b/source/static/whatsNew/1.1.4.json @@ -3,6 +3,10 @@ "description": "Pressing back on home screen focuses 1st item in row, or exits channel if already there", "author": "jimdogx" }, + { + "description": "Create My List - a personal queue", + "author": "1hitsong" + }, { "description": "Fix issue that could prevent changing audio & subtitle tracks", "author": "jimdogx" @@ -15,10 +19,6 @@ "description": "Fix possible crash when refreshing movie detail data", "author": "1hitsong" }, - { - "description": "Create My List - a personal queue", - "author": "1hitsong" - }, { "description": "Fix default sort after changing view of boxset items", "author": "1hitsong"