Files
asusctl/rog-control-center/ui/widgets/common.slint
2024-05-24 18:49:23 +12:00

204 lines
5.8 KiB
Plaintext

import { Palette, VerticalBox , StandardButton, Button, HorizontalBox, ComboBox, Switch, Slider} from "std-widgets.slint";
export component RogItem inherits Rectangle {
background: Palette.control-background;
border-color: Palette.border;
border-width: 3px;
border-radius: 10px;
min-height: 48px;
max-height: 56px;
}
export component SystemSlider inherits RogItem {
in property <string> text;
in-out property <float> value;
in-out property <float> minimum;
in-out property <float> maximum;
callback released(int);
HorizontalLayout {
HorizontalLayout {
width: 50%;
alignment: LayoutAlignment.space-between;
padding-left: 10px;
Text {
font-size: 16px;
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text <=> root.text;
}
Text {
font-size: 16px;
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text: "\{Math.round(root.value)}";
}
}
HorizontalBox {
// alignment: LayoutAlignment.end;
padding-right: 20px;
Slider {
maximum: root.maximum;
minimum: root.minimum;
value <=> root.value;
released => {
root.released(Math.round(root.value))
}
}
}
}
}
export component SystemToggle inherits RogItem {
in property <string> text;
in-out property <bool> checked;
callback toggled(bool);
HorizontalLayout {
spacing: 6px;
HorizontalLayout {
alignment: LayoutAlignment.start;
padding-left: 10px;
Text {
font-size: 16px;
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 SystemToggleVert inherits RogItem {
in property <string> text;
in-out property <bool> checked;
callback toggled(bool);
min-height: 86px;
VerticalLayout {
alignment: LayoutAlignment.space-around;
padding-top: 8px;
Text {
font-size: 16px;
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 <string> text;
in-out property <int> current_index;
in-out property <string> current_value;
in-out property <[string]> model;
callback selected(int);
HorizontalLayout {
HorizontalLayout {
alignment: LayoutAlignment.start;
padding-left: 10px;
Text {
font-size: 16px;
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 <string> heading;
in property <string> 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;
// TODO: drop shadows slow
// drop-shadow-offset-x: 7px;
// drop-shadow-offset-y: 7px;
// drop-shadow-color: black;
// drop-shadow-blur: 30px;
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();
}
}