]> git.sesse.net Git - nageru-docs/blobdiff - theme.rst
Document new 1.9.0 menu features.
[nageru-docs] / theme.rst
index 39424bdb8dfd1fabb0acd8a810d2a8fc5eb2d99f..7667a6087ddbadb88a5ce4c686e9baa787c2f5db 100644 (file)
--- a/theme.rst
+++ b/theme.rst
@@ -248,18 +248,17 @@ preview).
 The number of channels is determined by calling this function
 once at the start of the program::
 
-  function num_channels()
+  Nageru.set_num_channels(2)
 
-It should simply return the number of channels (0 is allowed,
-but doesn't make a lot of sense). Live and preview comes in addition to this.
+0 is allowed, but doesn't make a lot of sense. Live and preview comes in
+addition to this.
 
-Each channel will have a label on it; Nageru asks the theme
-by calling this function::
+Each channel will have a label on it; you set it by calling::
 
-  function channel_name(channel)
+  Nageru.set_channel_name(2, "Side-by-side")
 
-Here, channel is 2, 3, 4, etc.—0 is always called “Live” and
-1 is always called “Preview”.
+Here, channel is 2, 3, 4, etc.—by default, 0 is called “Live” and
+1 is called “Preview”, and you probably don't need to change this.
 
 Each channel has its own scene, starting from number 2 for the first one
 (since 0 is live and 1 is preview). The simplest form is simply a direct copy
@@ -267,24 +266,18 @@ of an input, and most themes will include one such channel for each input.
 (Below, we will see that there are more types of channels, however.)
 Since the mapping between the channel UI element and inputs is so typical,
 Nageru allows the theme to simply declare that a channel corresponds to
-a given signal, by asking it::
-
-  function channel_signal(channel)
-    if channel == 2 then
-      return 0
-    elseif channel == 3 then
-      return 1
-    else
-      return -1
-    end
-  end
+a given signal::
+
+  Nageru.set_channel_signal(2, 0)
+  Nageru.set_channel_signal(3, 1)
 
 Here, channels 2 and 3 (the two first ones) correspond directly to inputs
 0 and 1, respectively. The others don't, and return -1. The effect on the
 UI is that the user can right-click on the channel and configure the input
 that way; in fact, this is currently the only way to configure them.
 
-Furthermore, channels can have a color::
+Furthermore, channels can have a color, which is governed by Nageru calling
+a function your theme::
 
   function channel_color(channel)
  
@@ -294,10 +287,10 @@ the currently playing input as red, or the preview as green.
 
 And finally, there are two entry points related to white balance::
 
-  function supports_set_wb(channel)
+  Nageru.set_supports_wb(2, true)
   function set_wb(channel, red, green, blue)
 
-If the first function returns true (called once, at the start of the program),
+If the first function is called with a true value (at the start of the theme),
 the channel will get a “Set WB” button next to it, which will activate a color
 picker. When the user picks a color (ostensibly with a gray point), the second
 function will be called (with the RGB values in linear light—not sRGB!),
@@ -382,7 +375,28 @@ labels and function references::
 When the user chooses a menu entry, the given Lua function will
 automatically be called. There are no arguments nor return values.
 
-There currently is no support for checkboxes, submenus, input boxes
+Menus can contain submenus, by giving an array instead of a function::
+
+  ThemeMenu.set(
+    { "Overlay", {
+       { "Version A", select_overlay_a },
+       { "Version B", select_overlay_b }
+    },
+    { "&Reload overlay", reload_html }
+  )
+
+They can also be checkable, or have checkboxes, by adding a third
+array element containing flags for that::
+
+  ThemeMenu.set(
+    { "Enable overlay",  enable_overlay,  Nageru.CHECKED },    -- Currently checked.
+    { "Enable crashing", make_unstable,   Nageru.CHECKABLE }   -- Can be checked, but isn't currently.
+  )
+
+When such an option is selected, you probably want to rebuild the menu to
+reflect the new state.
+
+There currently is no support for input boxes, sliders,
 or the likes. However, do note that since the theme is written in unrestricted
 Lua, so you can use e.g. `lua-http <https://github.com/daurnimator/lua-http>`_
 to listen for external connections and accept more complicated inputs