In a toolbar or menu button, you can use the @color modifier to set the text and background colors of the button dynamically using the evaluator.
As a very basic example, @color:=text="#000000"; back="#ff0000"; would set the text color to black and the background color to red.
To specify separate colors for light and dark modes, you could use something like this:
@color:=SysInfo("DarkMode") ? { text="#ff0000"; back="#ffff00"; } : { text="#0000ff"; back="#00ffff"; }
A number of variables are available to the evaluator in this context. Note that some are only applicable to toolbars in the standalone image viewer, and some only apply to Lister toolbars.
Variable | Type | Description |
---|---|---|
dest |
path |
The current destination path. |
dest_shell |
bool |
True if the destination is a shell (virtual) folder hosted by Explorer, otherwise false. |
expanded |
uint |
Returns the number of expanded directories. |
fullscreen |
bool |
Viewer only. True if the viewer is fullscreen, otherwise false. |
key_repeat |
bool |
True if the function was launched from a repeated key press (i.e. the key was held down). |
lister_title |
string |
Returns the current title string of the Lister. |
preparse_dummy |
bool |
True if the evaluator is being called with a dummy filename as part of pre-parsing. Opus will do this for evaluator expressions inside a @perfile block. You should generally respond normally (Opus is querying to find out which values the evaluator expression requires), but you may want to filter out some behaviour (e.g. logging) for pre-parsing. |
selbytes |
uint64 |
Returns the number of selected bytes (files + directories that have had their sizes calculated). |
seldirs |
uint |
Returns the number of selected directories. |
selfiles |
uint |
Returns the number of selected files. |
selimage |
bool |
Viewer only. True if an area of the image has been selected, false otherwise. |
selitems |
uint |
Returns the total number of selected items. |
selpath |
string |
Provides the full pathname of the currently selected file. In a Lister this means the selected file with input focus (e.g. the file you right-click on). In the viewer this means the currently viewed image. Note that main toolbars in the Lister are not necessarily refreshed when the file selection changes, and so a button on the main toolbar using this may not always show the correct information. |
source |
path |
The current source path. |
source_shell |
bool |
True if the source is a shell (virtual) folder hosted by Explorer, otherwise false. |
totalbytes |
uint64 |
Returns the total number of bytes (files + directories that have had their sizes calculated). |
totaldirs |
uint |
Returns the total number of directories. |
totalfiles |
uint |
Returns the total number of files. |
totalitems |
uint |
Returns the total number of items. |
viewmode |
str |
Returns the current view mode in the file display. Values are largeicons, smallicons, list, details, power, thumbnails and tiles. |
As well as the above variables, you can also use evaluator functions like IsChecked and IsEnabled to query other information about the state of the Lister.
The SysInfo function can also be useful for testing global properties, like whether Opus is in dark or light mode.
The evaluator clause should set the value of the text and back variables. You can specify either a hex color string ("#RRGGBB") or decimal color string ("RRR,GGG,BBB"). You can also return "default" to get the button's defaults, or "none" to get the toolbar's defaults.