Weekend Update
Earlier in the week I mentioned working on adding vector support to GuiKit’s theming capabilities. I’ve now completed that work and converted GuiKit’s two built-in themes to exclusively use vectors (instead of pngs at multiple resolutions).
I’m really pleased with the result because:
- The final themes packages are much smaller…
old:
vs new:
- They’re now infinitely scalable with no pixelation artefacts. Full screen radio buttons anyone? Ah the crispness.
- They’re just as performant because the vector data is rasterized on demand. eg: note the
Rasterize()
call on the first line of the GTL code to make a checkbox:
var makeCheckBox = (fillColor, borderColor, checkColor) => Rasterize()
{
Size: (13,13),
Inner: [
BorderFrame(fillColor, borderColor),
Frame()
{
Padding: 2,
Inner: Path()
{
SvgData: "M 11.091797,2.7460938 A 0.625,0.625 0 0 0 10.646484,2.921875 L 5.1484375,8.2480469 3.1035156,6.0507812 a 0.625,0.625 0 0 0 -0.8828125,-0.03125 0.625,0.625 0 0 0 -0.03125,0.8828125 l 2.4785156,2.6640626 a 0.6250625,0.6250625 0 0 0 0.8925782,0.021484 L 11.515625,3.8203125 A 0.625,0.625 0 0 0 11.53125,2.9355469 0.625,0.625 0 0 0 11.091797,2.7460938 Z",
FillColor: checkColor,
MaintainAspectRatio: true,
}
}
]
};
- They’re a little harder to setup, but much easier to maintain and re-use. eg: instead of drawing a bunch of radio button images, I can now programmatically generate them for each state:
Checked && Disabled: makeRadio(colorDisabledFill, colorDisabledBorder, colorDisabledBorder),
Disabled: makeRadio(colorDisabledFill, colorDisabledBorder, Color.Clear),
Checked && Pressed: makeRadio(colorFocus, colorFocus, Color.White),
Pressed: makeRadio(colorFocus, colorFocus, Color.Clear),
Checked && Focused: makeRadio(colorFill, colorFocus, Color.White),
Checked: makeRadio(colorFill, colorBrightBorder, Color.White),
Focused: makeRadio(colorFill, colorFocus, Color.Clear),
else: makeRadio(colorFill, colorBrightBorder, Color.Clear),
- The Light theme just imports the Dark theme and overrides the colors. Again, this reduces maintainance because most theme changes only need to be done in one place. This is the entire Light theme gtl file:
// GuiKit Standard Light Theme
// Start with Dark theme
import("GuiKit.Dark");
// Redefine colors...
var colorForm = #f5f5f5;
var colorText = #000000;
var colorScrollbar = #f5f5f5;
var colorScrollbarThumb = #C2C3C9;
var colorFocus = #0095fe;
var colorDisabledFill = #F5F5F5;
var colorDisabledBorder = #BBBBBB;
var colorDisabledText = #808080;
var colorFill = #FFFFFF;
var colorBorder = #AAAAAA;
var colorBrightBorder = #666666;
var colorButtonFill = #ECECF0;
var colorButtonBorder = #ACACAC;
var colorSubtleText = #333333;
var colorProgressBar = #00b200;
I even went to the trouble of reducing banding in linear gradients. It’s a subtle change, but stops my eyes bleeding:
I still need to convert Cantabile’s themes to a similar approach, but I’ll do that as a side project in parallel with on-going development - but will definitely aim to getting it finished before releasing this Tech Update.