Skip to content

Commit

Permalink
hide overhang logo and user when viewing media
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert committed Nov 18, 2023
1 parent 76b7066 commit 6016920
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 8 deletions.
74 changes: 72 additions & 2 deletions components/JFOverhang.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import "pkg:/source/utils/config.bs"

sub init()
m.top.id = "overhang"
m.top.translation = [54, 0]

m.leftGroup = m.top.findNode("overlayLeftGroup")
m.rightGroup = m.top.findNode("overlayRightGroup")
' hide seperators till they're needed
m.leftSeperator = m.top.findNode("overlayLeftSeperator")
m.leftSeperator.visible = "false"
Expand Down Expand Up @@ -38,7 +42,7 @@ end sub

sub onVisibleChange()
if m.top.disableMoveAnimation
m.top.translation = [0, 0]
m.top.translation = [54, 0]
return
end if
if m.top.isVisible
Expand Down Expand Up @@ -84,7 +88,9 @@ end sub
sub updateUser()
setRightSeperatorVisibility()
user = m.top.findNode("overlayCurrentUser")
user.text = m.top.currentUser
if isValid(user)
user.text = m.top.currentUser
end if
end sub

sub updateTime()
Expand Down Expand Up @@ -145,3 +151,67 @@ sub updateOptions()
m.optionStar.visible = false
end if
end sub

' Ensure the Jellyfin logo is shown on the overhang.
sub showLogo()
scene = m.top.getScene()
logo = scene.findNode("overlayLogo")
leftSeperator = scene.findNode("overlayLeftSeperator")

if not isValid(leftSeperator)
seperator = createSeperator("overlayLeftSeperator")
m.leftGroup.insertChild(seperator, 0)
end if
if not isValid(logo)
posterLogo = createLogoPoster()
m.leftGroup.insertChild(posterLogo, 0)
end if
end sub

' Remove the Jellyfin logo from the overhang.
sub hideLogo()
scene = m.top.getScene()

logo = scene.findNode("overlayLogo")
leftSeperator = scene.findNode("overlayLeftSeperator")

if isValid(logo)
m.leftGroup.removeChild(logo)
end if
if isValid(leftSeperator)
m.leftGroup.removeChild(leftSeperator)
end if
end sub

' Ensure the current user is shown on the overhang.
sub showUser()
print "HELLO from showUser()"
scene = m.top.getScene()
currentUser = scene.findNode("overlayCurrentUser")
rightSeperator = scene.findNode("overlayRightSeperator")

if not isValid(rightSeperator)
seperator = createSeperator("overlayRightSeperator")
m.rightGroup.insertChild(seperator, 0)
end if
if not isValid(currentUser)
myUser = createOverhangUser()
myUser.text = m.top.currentUser
m.rightGroup.insertChild(myUser, 0)
end if
end sub

' Remove the Jellyfin logo from the overhang.
sub hideUser()
scene = m.top.getScene()

currentUser = scene.findNode("overlayCurrentUser")
rightSeperator = scene.findNode("overlayRightSeperator")

if isValid(currentUser)
m.rightGroup.removeChild(currentUser)
end if
if isValid(rightSeperator)
m.rightGroup.removeChild(rightSeperator)
end if
end sub
12 changes: 8 additions & 4 deletions components/JFOverhang.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<component name="JFOverhang" extends="Group">
<children>
<Poster id="overlayLogo" uri="pkg:/images/logo.png" translation="[70, 53]" width="270" height="72" />
<LayoutGroup id="overlayLeftGroup" layoutDirection="horiz" translation="[375, 53]" itemSpacings="30">
<LayoutGroup id="overlayLeftGroup" layoutDirection="horiz" translation="[54, 54]" itemSpacings="30">
<Poster id="overlayLogo" uri="pkg:/images/logo.png" width="210" height="66" />
<Rectangle id="overlayLeftSeperator" color="#666666" width="2" height="64" />
<ScrollingLabel id="overlayTitle" font="font:LargeSystemFont" vertAlign="center" height="64" maxWidth="1100" repeatCount="0" />
</LayoutGroup>
<LayoutGroup id="overlayRightGroup" layoutDirection="horiz" itemSpacings="30" translation="[1820, 53]" horizAlignment="right">
<LayoutGroup id="overlayRightGroup" layoutDirection="horiz" itemSpacings="30" translation="[1766, 53]" horizAlignment="right">
<Label id="overlayCurrentUser" font="font:MediumSystemFont" width="300" horizAlign="right" vertAlign="center" height="64" />
<Rectangle id="overlayRightSeperator" color="#666666" width="2" height="64" visible="false" />
<LayoutGroup id="overlayTimeGroup" layoutDirection="horiz" horizAlignment="right" itemSpacings="0">
Expand All @@ -17,7 +17,7 @@
</LayoutGroup>
</LayoutGroup>

<LayoutGroup layoutDirection="horiz" horizAlignment="right" translation="[1820, 125]" vertAlignment="custom">
<LayoutGroup layoutDirection="horiz" horizAlignment="right" translation="[1766, 125]" vertAlignment="custom">
<Label id="overlayOptionsStar" font="font:LargeSystemFont" text="*" />
<Label id="overlayOptionsText" font="font:SmallSystemFont" text="Options" translation="[0,6]" />
</LayoutGroup>
Expand All @@ -38,6 +38,10 @@
<field id="showOptions" value="true" type="boolean" onChange="updateOptions" />
<field id="isVisible" value="true" type="boolean" onChange="onVisibleChange" />
<field id="disableMoveAnimation" value="false" type="boolean" />
<function name="showLogo" />
<function name="hideLogo" />
<function name="showUser" />
<function name="hideUser" />
<function name="resetTime" />
</interface>
</component>
22 changes: 20 additions & 2 deletions components/home/Home.bs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@ sub loadLibraries()
m.top.findNode("homeRows").callFunc("loadLibraries")
end sub

' JFScreen hook that gets ran as needed.
' Used to update the focus, the state of the data, and tells the server about the device profile
' JFScreen hook.
' Used to show logo, update the focus, the state of the data, and tells the server about the device profile.
sub OnScreenShown()
scene = m.top.getScene()
overhang = scene.findNode("overhang")

' show the jellyfin logo
overhang.callFunc("showLogo")
overhang.callFunc("showUser")

if isValid(m.top.lastFocus)
m.top.lastFocus.setFocus(true)
else
Expand All @@ -46,6 +53,17 @@ sub OnScreenShown()
end if
end sub

' JFScreen hook.
' Remove the Jellyfin logo and left seperator from the overhang
sub OnScreenHidden()
scene = m.top.getScene()
overhang = scene.findNode("overhang")
if isValid(overhang)
overhang.callFunc("hideLogo")
overhang.callFunc("hideUser")
end if
end sub

' Triggered by m.postTask after completing a post.
' Empty the task data when finished.
sub postFinished()
Expand Down
Binary file modified images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/branding/beta/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/branding/release/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions source/utils/misc.bs
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,41 @@ function shuffleArray(array as object) as object
end for
return array
end function

' Create and return a Jellyfin logo poster node
function createLogoPoster()
logoPoster = createObject("roSGNode", "Poster")
logoPoster.id = "overlayLogo"
logoPoster.uri = "pkg:/images/logo.png"
logoPoster.translation = "[70, 53]"
logoPoster.width = "270"
logoPoster.height = "72"

return logoPoster
end function

' Create and return a rectangle node used as a seperator in the overhang
function createSeperator(id as string)
if not isValidAndNotEmpty(id) then return invalid

seperator = createObject("roSGNode", "Rectangle")
seperator.id = id
seperator.color = "#666666"
seperator.width = "2"
seperator.height = "64"

return seperator
end function

'
function createOverhangUser()
userLabel = createObject("roSGNode", "Label")
userLabel.id = "overlayCurrentUser"
userLabel.font = "font:MediumSystemFont"
userLabel.horizAlign = "right"
userLabel.vertAlign = "center"
userLabel.width = "300"
userLabel.height = "64"

return userLabel
end function

0 comments on commit 6016920

Please sign in to comment.