-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor long press * Lint fix * Queue UI, refactor PlayQueue to use ContentNode * Add queue notification hint * Play at index * Play queue with highlight * Priority * Comment --------- Co-authored-by: github-action linter <[email protected]>
- Loading branch information
Showing
24 changed files
with
523 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,91 @@ | ||
const LONG_PRESS_KEY = "OK_LONG_PRESS" | ||
const OK_LONG_PRESS_KEY = "OK_LONG_PRESS" | ||
const OPTIONS_LONG_PRESS_KEY = "OPTIONS_LONG_PRESS" | ||
|
||
function InitializeLongPress(keys as object, duration = 1.0 as float) | ||
longPressKeyMap = { | ||
"OK": OK_LONG_PRESS_KEY, | ||
"options": OPTIONS_LONG_PRESS_KEY | ||
} | ||
m._longPressKeyMap = {} | ||
for each key in keys | ||
m._longPressKeyMap[key] = longPressKeyMap[key] | ||
end for | ||
|
||
#if DEBUG | ||
' This is for testing long press using the VSCode extension. | ||
' Using the keyboard: | ||
' - press K to simulate an "OK" long press on the remote. | ||
' - press O to simulate an "options" long press on the remote. | ||
simulatedLongPressKeyMap = { | ||
"OK": "Lit_k", | ||
"options": "Lit_o" | ||
} | ||
|
||
m._simulatedLongPressKeyMap = {} | ||
for each key in keys | ||
m._simulatedLongPressKeyMap[simulatedLongPressKeyMap[key]] = key | ||
end for | ||
#end if | ||
|
||
function InitializeLongPressTimer(duration = 1.0 as float) | ||
m._longPressTimer = CreateObject("roSGNode", "Timer") | ||
m._longPressTimer.duration = duration | ||
m._longPressFired = false | ||
m._pressState = {} | ||
|
||
m._longPressTimer.ObserveField("fire", FuncName(LongPressTimerFired)) | ||
end function | ||
|
||
function LongPressHandler(key as string, press as boolean) as boolean | ||
#if DEBUG | ||
if key = "Lit_l" | ||
LogInfo("Simulating long press using key:", key, "press:", press) | ||
if m._simulatedLongPressKeyMap.DoesExist(key) | ||
subtype = m.top.subtype() | ||
simulatedKey = m._simulatedLongPressKeyMap[key] | ||
LogInfo(`[${subtype}] Simulating`, simulatedKey, "long press using key:", key, "press:", press) | ||
longPressKey = m._longPressKeyMap[simulatedKey] | ||
m._longPressFired = true | ||
return OnkeyEvent(LONG_PRESS_KEY, press) | ||
return OnkeyEvent(longPressKey, press) | ||
end if | ||
#end if | ||
if key = "OK" and press | ||
|
||
isLongPressKey = m._longPressKeyMap.DoesExist(key) | ||
if not isLongPressKey | ||
return false | ||
end if | ||
|
||
if press | ||
m._longPressTimer.control = "stop" | ||
m._longPressTimer.control = "start" | ||
m._longPressFired = false | ||
m._okPressed = true | ||
m._longPressKey = key | ||
m._pressState[key] = true | ||
return true | ||
end if | ||
|
||
if key = "OK" and not press | ||
if not press | ||
m._longPressTimer.control = "stop" | ||
if m._longPressFired = true | ||
m._longPressFired = false | ||
m._okPressed = false | ||
m._pressState[key] = false | ||
return true | ||
end if | ||
' This case is for handling a dialog: The dialog will be dismissed with the OK down event, | ||
' and we would trigger the action with the OK up event. The action should only happen if | ||
' we detected both down and up events. | ||
wasOkPressed = m._okPressed | ||
m._okPressed = false | ||
if wasOkPressed <> true | ||
wasPressed = m._pressState[key] | ||
m._pressState[key] = false | ||
if wasPressed <> true | ||
return true | ||
end if | ||
end if | ||
|
||
return false | ||
end function | ||
|
||
function LongPressTimerFired() | ||
function LongPressTimerFired() as void | ||
m._longPressFired = true | ||
OnkeyEvent(LONG_PRESS_KEY, true) | ||
if StringUtils.IsNullOrEmpty(m._longPressKey) or not m._longPressKeyMap.DoesExist(m._longPressKey) | ||
return | ||
end if | ||
|
||
OnkeyEvent(m._longPressKeyMap[m._longPressKey], true) | ||
end function |
5 changes: 5 additions & 0 deletions
5
playlet-lib/src/components/NodeByRef/ContentNodeReference.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<component name="ContentNodeReference" extends="ContentNode"> | ||
<interface> | ||
<field id="refNode" type="node" /> | ||
</interface> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
' NodeByRef: these functions provides the ability to "wrap" a node in | ||
' another node, so it can be passed by reference. This is useful for | ||
' when a node is required to be a child of multiple nodes at once, | ||
' which is not possible. | ||
' Instead, the node is wrapped, passed around, and unwrapped when needed. | ||
import "pkg:/source/utils/StringUtils.bs" | ||
|
||
namespace NodeByRef | ||
|
||
function Wrap(node as object) as object | ||
if node = invalid | ||
return invalid | ||
end if | ||
|
||
if node.refNode <> invalid | ||
return node | ||
end if | ||
|
||
ref = CreateObject("roSGNode", "ContentNodeReference") | ||
ref.refNode = node | ||
if not StringUtils.IsNullOrEmpty(node.id) | ||
ref.id = node.id + "-ref" | ||
end if | ||
return ref | ||
end function | ||
|
||
function Unwrap(node as object) as object | ||
if node = invalid | ||
return invalid | ||
end if | ||
|
||
loopGuard = 0 | ||
while node.refNode <> invalid and loopGuard < 10 | ||
node = node.refNode | ||
loopGuard += 1 | ||
end while | ||
|
||
return node | ||
end function | ||
|
||
end namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.