Closed mattblovell closed 3 years ago
I decide to make the TOML value a 2-element string array. Per a follow-up posting to Idea #14, the elements in the array are interpreted as follows:
STRING_CB
table).When using display_if
, the second string must equal the return value for the element to be displayed.
When using display_ifnot
, the second string must not equal the return value for the element to be display.
This functionality is being rolled out for all fields
array entries, as well as the top-level thumb
and prog
layout elements.
Some mostly non-sensical examples for setup.toml:
[A_LAYOUT.A_DEFAULT.thumb] # Artwork
posx = 3
posy = 4
size = 405
# If artwork is smaller than the above size, should it be centered
# where the fullsize artwork would have been placed?
center_sm = 1
display_ifnot = [ "test_track", "02" ]
[A_LAYOUT.A_DEFAULT.prog] # Progress Bar
posx = 420 # upper-left corner x position
posy = 8 # upper-left corner y position
height = 12 # pixel height
short_len = 196 # length when elapsed time matches 00:00 (min, seconds)
long_len = 300 # length when elapsed time matches 00:00:00 (hrs, mins, seconds)
color_fg = "color_7S"
color_bg = "color_gray"
display_ifnot = [ "test_track", "02" ]
[[A_LAYOUT.A_DEFAULT.fields]]
name = "greeting"
posx = 5
posy = 0
format_str = "Hello, Track 2!"
display_if = [ "test_track", "02" ]
font = "font_bold"
fill = "white"
where the kodi_panel_demo.py script was augmented to contain:
def example_callback(info, screen_mode, layout_name):
return info['MusicPlayer.TrackNumber']
kodi_panel_display.STRING_CB['test_track'] = example_callback
works fine: eg in my setup: https://github.com/nico1080/kodi_panel/commit/60503a5faaba103dca5a401d68c5a4e7afe488b3
See the 21 Jan update to Idea #14.
TOML doesn't support the exact syntax shown in that post, but the general idea is certainly possible -- have a function to invoke and use the string returned by that function as a condition for rendering that
fields
entry.