Progress Day 11/12 (the weekend)
Made some nice improvements to GTL over the weekend.
Firstly, the boolean flag expression stuff I mentioned above has been retro fitted into GTL so themes can now do more complex control state tests (eg: Focused && !Disabled
)
class UglyButton
{
Background:
{
Checked && Focused: Color.Red,
Focused && !Disabled: Color.Blue,
else: Color.Orange,
}
}
Also, I’ve added support for template classes which are a way to more concisely express the settings for multiple similar elements.
To explain, consider the image on the play button:
class PlayButton : Button
{
Image:
{
Pressed: Image("PlayButton_pressed.png", Center),
Disabled: Image("PlayButton.png", Center).WithAlpha(0.5),
else: Image("PlayButton.png"),
}
}
Previously that would have to be repeated for every button: the pause button, the stop button, the record button, the metronome button etc. Given the number of images like this in Cantabile, that would get tedious and messy to maintain.
With templates, you can define a base class that synthesizes the bulk of that content from parameters:
class ToolbarButton<basename> : Button
{
Image:
{
Pressed: Image(basename + "_pressed.png", Center),
Disabled: Image(basename + ".png", Center).WithAlpha(0.5),
else: Image(basename + ".png"),
}
}
Then each button definition becomes a simple one liner:
class PlayButton : ToolbarButton<"PlayButton"> {}
class StopButton : ToolbarButton<"StopButton"> {}
class PauseButton : ToolbarButton<"PauseButton"> {}
// etc..
I’m sure there’ll be more tweaks to GTL going forward but for now, all its major features are done.