Home /Examples/examples/gui/NEW-custom-theme-roles.sleela

NEW-custom-theme-roles.sleela

examples/gui/NEW-custom-theme-roles.sleela · 24 line(s) · sleela

#sleela 2.5
// NEW: derive a custom palette and override selected semantic roles.
class CustomThemeRoles {
  int main() {
    SLUserInterface ui = new SLUserInterface(); ui.configure("com.mearvk.examples.CustomTheme");
    if (!ui.open()) { return 1; }
    SLTheme theme = new SLTheme(); theme.defaultTheme();
    SLColor base = new SLColor(); base.rgb(34, 42, 52);
    theme.setBaseColor(base.value());
    SLColor accent = new SLColor(); accent.rgb(55, 145, 210);
    theme.setAccent(accent.value());
    SLColor danger = new SLColor(); danger.rgb(190, 62, 70);
    theme.setDanger(danger.value());
    SLWindow win = ui.openWindow("Custom Theme Roles", 600, 360, theme.handle());
    SLWidget root = win.rootWidget();
    SLBox col = new SLBox(); col.vertical(root, 12); col.setMarginAll(18);
    SLHeading title = new SLHeading(); title.createIn(col, "Semantic theme roles", 22);
    SLButton action = new SLButton(); action.createIn(col, "Suggested action"); action.setSuggested(true);
    SLButton remove = new SLButton(); remove.createIn(col, "Destructive action"); remove.setDestructive(true);
    SLLabel note = new SLLabel(); note.createIn(col, "Widgets consume semantic roles; the app does not paint each widget individually.");
    win.show(); return ui.run();
  }
}