import { Palette, VerticalBox , StandardButton, Button, HorizontalBox, ComboBox, Switch, Slider} from "std-widgets.slint"; export component RogItem inherits Rectangle { border-color: Palette.border; border-width: 1px; border-radius: 2px; min-height: 44px; max-height: 44px; } export component SystemSlider inherits RogItem { in property title; in property text; in-out property value; in property minimum; in property maximum; callback released(float); in property help_text; in property enabled: true; in property has_reset: false; callback cb_do_reset(); HorizontalLayout { HorizontalLayout { width: 40%; alignment: LayoutAlignment.stretch; padding-left: 10px; HorizontalLayout { spacing: 6px; Text { font-size: 14px; vertical-alignment: TextVerticalAlignment.center; color: Palette.control-foreground; text: root.text; } Text { font-size: 14px; horizontal-alignment: TextHorizontalAlignment.right; vertical-alignment: TextVerticalAlignment.center; color: Palette.control-foreground; text: "\{Math.round(root.value)}"; } } } HorizontalBox { padding-right: 10px; slider := Slider { enabled: root.enabled; maximum: root.maximum; minimum: root.minimum; value <=> root.value; released(value) => { root.released(value) } } } help_popup := PopupWindow { x: help.x - self.width + help.width - 10px; y: help.y - self.height + help.height - 10px; Rectangle { drop-shadow-blur: 10px; drop-shadow-color: black; border-radius: 10px; border-color: Palette.accent-background; background: Palette.background; Dialog { title: root.title; VerticalBox { Text { max-width: 420px; font-size: 18px; wrap: TextWrap.word-wrap; horizontal-alignment: TextHorizontalAlignment.center; text: root.title; } Rectangle { height: 1px; border-color: black; border-width: 1px; } Text { max-width: 420px; font-size: 16px; wrap: TextWrap.word-wrap; text: root.help_text; } } StandardButton { kind: ok; } } } } help := HorizontalBox { if (help_text != ""): StandardButton { kind: StandardButtonKind.help; clicked => { help_popup.show(); } } } reset_popup := PopupWindow { x: reset.x - self.width + reset.width; y: reset.y - self.height + reset.height; Rectangle { drop-shadow-blur: 10px; drop-shadow-color: black; border-radius: 10px; border-color: Palette.accent-background; background: Palette.background; Dialog { Text { max-width: 420px; font-size: 16px; wrap: TextWrap.word-wrap; text: @tr("confirm_reset" => "Are you sure you want to reset this?"); } StandardButton { kind: ok; clicked => { root.cb_do_reset(); } } StandardButton { kind: cancel; } } } } reset := HorizontalBox { if (has_reset): StandardButton { kind: StandardButtonKind.reset; enabled: root.enabled; clicked => { reset_popup.show(); } } } } } export component SystemToggle inherits RogItem { in property text; in-out property checked; callback toggled(bool); HorizontalLayout { spacing: 6px; HorizontalLayout { alignment: LayoutAlignment.start; padding-left: 10px; Text { font-size: 14px; vertical-alignment: TextVerticalAlignment.center; color: Palette.control-foreground; text: root.text; } } HorizontalLayout { alignment: LayoutAlignment.end; padding-right: 20px; Switch { checked <=> root.checked; toggled => { root.toggled(root.checked) } } } } } export component SystemToggleInt inherits RogItem { in property text; // in-out property checked; in-out property checked_int; callback toggled(int); HorizontalLayout { spacing: 6px; HorizontalLayout { alignment: LayoutAlignment.start; padding-left: 10px; Text { font-size: 14px; vertical-alignment: TextVerticalAlignment.center; color: Palette.control-foreground; text: root.text; } } HorizontalLayout { alignment: LayoutAlignment.end; padding-right: 20px; Switch { checked: root.checked_int != 0; toggled => { root.checked_int = self.checked ? 1 : 0; root.toggled(root.checked_int); } } } } } export component SystemToggleVert inherits RogItem { in property text; in-out property checked; callback toggled(bool); min-height: 86px; VerticalLayout { alignment: LayoutAlignment.space-around; padding-top: 8px; Text { font-size: 14px; vertical-alignment: TextVerticalAlignment.bottom; horizontal-alignment: TextHorizontalAlignment.center; color: Palette.control-foreground; text: root.text; } HorizontalLayout { alignment: LayoutAlignment.center; padding-bottom: 10px; Switch { checked <=> root.checked; toggled => { root.toggled(root.checked) } } } } } export component SystemDropdown inherits RogItem { in property text; in-out property current_index; in-out property current_value; in-out property <[string]> model; callback selected(int); HorizontalLayout { HorizontalLayout { alignment: LayoutAlignment.start; padding-left: 10px; Text { font-size: 14px; vertical-alignment: TextVerticalAlignment.center; color: Palette.control-foreground; text: root.text; } } HorizontalLayout { alignment: LayoutAlignment.end; padding-right: 20px; padding-top: 7px; padding-bottom: 7px; ComboBox { model <=> root.model; current-index <=> root.current_index; current-value <=> root.current_value; selected => { root.selected(root.current_index) } } } } } export component PopupNotification { in property heading; in property content; _p := PopupWindow { x: root.x; y: root.y; width: root.width; height: root.height; // TODO: add properties to display Rectangle { border-width: 2px; border-color: Palette.accent-background; background: Palette.background; VerticalLayout { Dialog { VerticalLayout { alignment: start; Text { text: heading; color: Palette.control-foreground; font-size: 32px; font-weight: 900; } Text { text: content; color: Palette.control-foreground; font-size: 18px; } } StandardButton { kind: ok; } StandardButton { kind: cancel; } Button { text: "More Info"; dialog-button-role: action; } } } } } public function show() { _p.show(); } }