Make aura settings apply instantly

This commit is contained in:
Luke D. Jones
2024-03-11 23:27:07 +13:00
parent 9725062fb9
commit 672acb234f
8 changed files with 94 additions and 53 deletions

View File

@@ -214,29 +214,29 @@ pub struct MultiColourSpeed {
#[derive(Options)] #[derive(Options)]
pub enum SetAuraBuiltin { pub enum SetAuraBuiltin {
#[options(help = "set a single static colour")] #[options(help = "set a single static colour")]
Static(SingleColour), Static(SingleColour), // 0
#[options(help = "pulse between one or two colours")] #[options(help = "pulse between one or two colours")]
Breathe(TwoColourSpeed), Breathe(TwoColourSpeed), // 1
#[options(help = "strobe through all colours")] #[options(help = "strobe through all colours")]
Strobe(SingleSpeed), Strobe(SingleSpeed), // 2
#[options(help = "rainbow cycling in one of four directions")] #[options(help = "rainbow cycling in one of four directions")]
Rainbow(SingleSpeedDirection), Rainbow(SingleSpeedDirection), // 3
#[options(help = "rain pattern mimicking raindrops")] #[options(help = "rain pattern mimicking raindrops")]
Stars(TwoColourSpeed), Stars(TwoColourSpeed), // 4
#[options(help = "rain pattern of three preset colours")] #[options(help = "rain pattern of three preset colours")]
Rain(SingleSpeed), Rain(SingleSpeed), // 5
#[options(help = "pressed keys are highlighted to fade")] #[options(help = "pressed keys are highlighted to fade")]
Highlight(SingleColourSpeed), Highlight(SingleColourSpeed), // 6
#[options(help = "pressed keys generate horizontal laser")] #[options(help = "pressed keys generate horizontal laser")]
Laser(SingleColourSpeed), Laser(SingleColourSpeed), // 7
#[options(help = "pressed keys ripple outwards like a splash")] #[options(help = "pressed keys ripple outwards like a splash")]
Ripple(SingleColourSpeed), Ripple(SingleColourSpeed), // 8
#[options(help = "set a rapid pulse")] #[options(help = "set a rapid pulse")]
Pulse(SingleColour), Pulse(SingleColour), // 10
#[options(help = "set a vertical line zooming from left")] #[options(help = "set a vertical line zooming from left")]
Comet(SingleColour), Comet(SingleColour), // 11
#[options(help = "set a wide vertical line zooming from left")] #[options(help = "set a wide vertical line zooming from left")]
Flash(SingleColour), Flash(SingleColour), // 12
} }
impl Default for SetAuraBuiltin { impl Default for SetAuraBuiltin {

View File

@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-03-11 09:25+0000\n" "POT-Creation-Date: 2024-03-11 09:26+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"

View File

@@ -23,20 +23,17 @@ export component MainWindow inherits Window {
show_toast(text) => { show_toast(text) => {
toast = text != ""; toast = text != "";
toast_text = text; toast_text = text;
} }
callback exit-app(); callback exit-app();
callback show-notification(bool); callback show-notification(bool);
show-notification(yes) => { show-notification(yes) => {
show-notif = yes; show-notif = yes;
fade-cover = yes; fade-cover = yes;
} }
callback external_colour_change(); callback external_colour_change();
external_colour_change() => { external_colour_change() => {
aura.external_colour_change(); aura.external_colour_change();
aura.external_colour_change(); aura.external_colour_change();
} }
min-height: AppSize.height; min-height: AppSize.height;
min-width: AppSize.width; min-width: AppSize.width;
@@ -46,20 +43,30 @@ export component MainWindow inherits Window {
VerticalLayout { VerticalLayout {
side-bar := SideBar { side-bar := SideBar {
title: @tr("ROG"); title: @tr("ROG");
model: [@tr("Menu1" => "System Control"), @tr("Menu2" => "Keyboard Aura"), @tr("Menu3" => "AniMe Matrix"), @tr("Menu4" => "Fan Curves"), @tr("Menu5" => "App Settings"), @tr("Menu6" => "About"), ]; model: [
@tr("Menu1" => "System Control"),
@tr("Menu2" => "Keyboard Aura"),
@tr("Menu3" => "AniMe Matrix"),
@tr("Menu4" => "Fan Curves"),
@tr("Menu5" => "App Settings"),
@tr("Menu6" => "About"),
];
available: root.sidebar_items_avilable; available: root.sidebar_items_avilable;
} }
Rectangle { Rectangle {
height: qb.height; max-height: 40px;
width: side-bar.width; width: side-bar.width;
background: Palette.control-background; background: Palette.control-background;
qb := Button { Text {
max-height: 20px; vertical-alignment: center;
text: "Quit"; horizontal-alignment: center;
text: @tr("Quit");
}
TouchArea {
clicked => { clicked => {
root.exit-app(); root.exit-app();
} }
} }
} }
@@ -109,10 +116,8 @@ export component MainWindow inherits Window {
// toolbar-dropdown.close(); // toolbar-dropdown.close();
if (show-notif) { if (show-notif) {
show-notif = false; show-notif = false;
} }
fade-cover = false; fade-cover = false;
} }
} }
} }
@@ -128,7 +133,6 @@ export component MainWindow inherits Window {
width: 100%; width: 100%;
clicked => { clicked => {
toast = false; toast = false;
} }
} }
@@ -155,7 +159,6 @@ export component MainWindow inherits Window {
clicked => { clicked => {
show-notif = false; show-notif = false;
exit-app(); exit-app();
} }
} }

View File

@@ -14,6 +14,7 @@ export component PageAbout inherits VerticalLayout {
alignment: LayoutAlignment.center; alignment: LayoutAlignment.center;
VerticalBox { VerticalBox {
alignment: LayoutAlignment.center; alignment: LayoutAlignment.center;
Text { Text {
vertical-alignment: TextVerticalAlignment.center; vertical-alignment: TextVerticalAlignment.center;
horizontal-alignment: TextHorizontalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center;
@@ -26,7 +27,15 @@ export component PageAbout inherits VerticalLayout {
} }
Text { Text {
text: "- [x] Add a cpu/gpu temp/fan speed info bar"; text: "- [x] Add a fullscreen mode";
}
Text {
text: "- [x] Disable aura items depending if mode supports or not";
}
Text {
text: "- [ ] Add a cpu/gpu temp/fan speed info bar";
} }
Text { Text {

View File

@@ -37,9 +37,10 @@ export component PageAura inherits Rectangle {
width: parent.width * 1px / 2px; width: parent.width * 1px / 2px;
text: @tr("Aura mode"); text: @tr("Aura mode");
current_index <=> AuraPageData.current_available_mode; current_index <=> AuraPageData.current_available_mode;
current_value: AuraPageData.available_mode_names[self.current-index]; current_value: AuraPageData.available_mode_names[self.current-index];
model <=> AuraPageData.available_mode_names; model <=> AuraPageData.available_mode_names;
selected => { selected => {
AuraPageData.led_mode_data.mode = AuraPageData.led_mode;
AuraPageData.led_mode_data.mode = AuraPageData.current_available_mode; AuraPageData.led_mode_data.mode = AuraPageData.current_available_mode;
self.current_value = AuraPageData.available_mode_names[self.current-index]; self.current_value = AuraPageData.available_mode_names[self.current-index];
AuraPageData.set_led_mode(AuraPageData.current_available_mode); AuraPageData.set_led_mode(AuraPageData.current_available_mode);
@@ -59,14 +60,19 @@ export component PageAura inherits Rectangle {
HorizontalBox { HorizontalBox {
c1 := ColourSlider { c1 := ColourSlider {
enabled: AuraPageData.led_mode == 0 || AuraPageData.led_mode == 1 || AuraPageData.led_mode == 4 || AuraPageData.led_mode == 6 || AuraPageData.led_mode == 7 || AuraPageData.led_mode == 8 || AuraPageData.led_mode == 10 || AuraPageData.led_mode == 11 || AuraPageData.led_mode == 12;
final_colour <=> AuraPageData.color1; final_colour <=> AuraPageData.color1;
colourbox <=> AuraPageData.colorbox1; colourbox <=> AuraPageData.colorbox1;
set_hex_from_colour(c1) => { set_hex_from_colour(c1) => {
return AuraPageData.set_hex_from_colour(c1); return AuraPageData.set_hex_from_colour(c1);
} }
hex_to_colour(s) => { hex_to_colour(s) => {
return AuraPageData.set_hex_to_colour(s); return AuraPageData.set_hex_to_colour(s);
} }
released => {
AuraPageData.led_mode_data.colour1 = AuraPageData.color1;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data);
}
} }
} }
} }
@@ -80,14 +86,19 @@ export component PageAura inherits Rectangle {
HorizontalBox { HorizontalBox {
c2 := ColourSlider { c2 := ColourSlider {
enabled: AuraPageData.led_mode == 1 || AuraPageData.led_mode == 4;
final_colour <=> AuraPageData.color2; final_colour <=> AuraPageData.color2;
colourbox <=> AuraPageData.colorbox2; colourbox <=> AuraPageData.colorbox2;
set_hex_from_colour(c1) => { set_hex_from_colour(c1) => {
return AuraPageData.set_hex_from_colour(c1); return AuraPageData.set_hex_from_colour(c1);
} }
hex_to_colour(s) => { hex_to_colour(s) => {
return AuraPageData.set_hex_to_colour(s); return AuraPageData.set_hex_to_colour(s);
} }
released => {
AuraPageData.led_mode_data.colour2 = AuraPageData.color2;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data);
}
} }
} }
} }
@@ -106,11 +117,14 @@ export component PageAura inherits Rectangle {
} }
ComboBox { ComboBox {
// enabled: AuraPageData.led_mode == ;
enabled: false;
current_index <=> AuraPageData.zone; current_index <=> AuraPageData.zone;
current_value: AuraPageData.zone_names[self.current-index]; current_value: AuraPageData.zone_names[self.current-index];
model <=> AuraPageData.zone_names; model <=> AuraPageData.zone_names;
selected => { selected => {
AuraPageData.led_mode_data.zone = self.current-index; AuraPageData.led_mode_data.zone = self.current-index;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -126,11 +140,13 @@ export component PageAura inherits Rectangle {
} }
ComboBox { ComboBox {
enabled: AuraPageData.led_mode == 3;
current_index <=> AuraPageData.direction; current_index <=> AuraPageData.direction;
current_value: AuraPageData.direction_names[self.current-index]; current_value: AuraPageData.direction_names[self.current-index];
model <=> AuraPageData.direction_names; model <=> AuraPageData.direction_names;
selected => { selected => {
AuraPageData.led_mode_data.direction = self.current-index; AuraPageData.led_mode_data.direction = self.current-index;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -146,11 +162,13 @@ export component PageAura inherits Rectangle {
} }
ComboBox { ComboBox {
enabled: AuraPageData.led_mode == 1 || AuraPageData.led_mode == 2 || AuraPageData.led_mode == 3 || AuraPageData.led_mode == 4 || AuraPageData.led_mode == 5 || AuraPageData.led_mode == 6 || AuraPageData.led_mode == 7 || AuraPageData.led_mode == 8;
current_index <=> AuraPageData.speed; current_index <=> AuraPageData.speed;
current_value: AuraPageData.speed_names[self.current-index]; current_value: AuraPageData.speed_names[self.current-index];
model <=> AuraPageData.speed_names; model <=> AuraPageData.speed_names;
selected => { selected => {
AuraPageData.led_mode_data.speed = self.current-index; AuraPageData.led_mode_data.speed = self.current-index;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -165,16 +183,6 @@ export component PageAura inherits Rectangle {
root.show_aura_power = true; root.show_aura_power = true;
} }
} }
Button {
text: @tr("Apply Aura");
clicked => {
AuraPageData.led_mode_data.mode = AuraPageData.led_mode;
AuraPageData.led_mode_data.colour1 = AuraPageData.color1;
AuraPageData.led_mode_data.colour2 = AuraPageData.color2;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data);
}
}
} }
} }

View File

@@ -22,6 +22,7 @@ export component AuraPowerGroup inherits Rectangle {
color: Palette.alternate-foreground; color: Palette.alternate-foreground;
horizontal-alignment: TextHorizontalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center;
text <=> root.group-title; text <=> root.group-title;
} }
row := HorizontalBox { row := HorizontalBox {

View File

@@ -1,6 +1,7 @@
import { Palette, Slider, HorizontalBox, Button, LineEdit } from "std-widgets.slint"; import { Palette, Slider, HorizontalBox, Button, LineEdit } from "std-widgets.slint";
export component ColourSlider inherits VerticalLayout { export component ColourSlider inherits VerticalLayout {
in-out property <bool> enabled;
spacing: 10px; spacing: 10px;
property <string> hex: "#FF0000"; property <string> hex: "#FF0000";
property <color> base_colour: Colors.red; property <color> base_colour: Colors.red;
@@ -9,6 +10,7 @@ export component ColourSlider inherits VerticalLayout {
callback hex_to_colour(string) -> color; callback hex_to_colour(string) -> color;
// required // required
callback set_hex_from_colour(color) -> string; callback set_hex_from_colour(color) -> string;
callback released();
in-out property <float> c1value<=> c1.value; in-out property <float> c1value<=> c1.value;
in-out property <float> c2value<=> c2.value; in-out property <float> c2value<=> c2.value;
property <[color]> base_colours: [ property <[color]> base_colours: [
@@ -65,11 +67,14 @@ export component ColourSlider inherits VerticalLayout {
]; ];
function blend_lightness(c1: color, f: float) -> color { function blend_lightness(c1: color, f: float) -> color {
rgb(c1.red * f, c1.green * f, c1.blue * f) rgb(c1.red * f, c1.green * f, c1.blue * f)
}function set_base_colour() { }//
function set_base_colour() {
root.base_colour = base_colours[c1.value].interpolate(base_colours[c1.value + 1], c1.value - Math.floor(c1.value)); root.base_colour = base_colours[c1.value].interpolate(base_colours[c1.value + 1], c1.value - Math.floor(c1.value));
root.final_colour = blend_lightness(base_colour, ((base_shade.length - c2.value) / base_shade.length)); root.final_colour = blend_lightness(base_colour, ((base_shade.length - c2.value) / base_shade.length));
root.colourbox = root.final_colour; root.colourbox = root.final_colour;
}callback external_colour_change(); }//
callback external_colour_change();
external_colour_change => { external_colour_change => {
if (root.final_colour.hue() < 0) { if (root.final_colour.hue() < 0) {
c1.value = (root.base_colours.length - 1) * ((root.final_colour.hue() + 360) / 360); c1.value = (root.base_colours.length - 1) * ((root.final_colour.hue() + 360) / 360);
@@ -85,9 +90,10 @@ export component ColourSlider inherits VerticalLayout {
border-radius: 7px; border-radius: 7px;
border-color: Palette.border; border-color: Palette.border;
// 13 colours // 13 colours
background: @linear-gradient(90deg, base_colours[0], base_colours[1], base_colours[2], base_colours[3], base_colours[4], base_colours[5], base_colours[6], base_colours[7], base_colours[8], base_colours[9], base_colours[10], base_colours[11], base_colours[12], base_colours[13], base_colours[14], base_colours[15], base_colours[16], base_colours[17], base_colours[18], base_colours[19], base_colours[20], base_colours[21], base_colours[22], base_colours[23], base_colours[24], base_colours[25], base_colours[26], base_colours[27], base_colours[28], base_colours[29], base_colours[30], base_colours[31], base_colours[32], base_colours[33], base_colours[34], base_colours[35]); background: !root.enabled ? Palette.alternate-background : @linear-gradient(90deg, base_colours[0], base_colours[1], base_colours[2], base_colours[3], base_colours[4], base_colours[5], base_colours[6], base_colours[7], base_colours[8], base_colours[9], base_colours[10], base_colours[11], base_colours[12], base_colours[13], base_colours[14], base_colours[15], base_colours[16], base_colours[17], base_colours[18], base_colours[19], base_colours[20], base_colours[21], base_colours[22], base_colours[23], base_colours[24], base_colours[25], base_colours[26], base_colours[27], base_colours[28], base_colours[29], base_colours[30], base_colours[31], base_colours[32], base_colours[33], base_colours[34], base_colours[35]);
clip: true; clip: true;
c1 := Slider { c1 := Slider {
enabled <=> root.enabled;
width: parent.width; width: parent.width;
height: parent.height; height: parent.height;
minimum: 0; minimum: 0;
@@ -97,6 +103,9 @@ export component ColourSlider inherits VerticalLayout {
set_base_colour(); set_base_colour();
hex = set_hex_from_colour(final_colour); hex = set_hex_from_colour(final_colour);
} }
released => {
root.released();
}
} }
} }
@@ -106,9 +115,10 @@ export component ColourSlider inherits VerticalLayout {
border-radius: 7px; border-radius: 7px;
border-color: Palette.border; border-color: Palette.border;
// 11 colours // 11 colours
background: @linear-gradient(90deg, base_shade[0], base_shade[1], base_shade[2], base_shade[3], base_shade[4], base_shade[5], base_shade[6], base_shade[7], base_shade[8], base_shade[9], base_shade[10]); background: !root.enabled ? Palette.alternate-background : @linear-gradient(90deg, base_shade[0], base_shade[1], base_shade[2], base_shade[3], base_shade[4], base_shade[5], base_shade[6], base_shade[7], base_shade[8], base_shade[9], base_shade[10]);
clip: true; clip: true;
c2 := Slider { c2 := Slider {
enabled <=> root.enabled;
width: parent.width; width: parent.width;
height: parent.height; height: parent.height;
minimum: 0; minimum: 0;
@@ -117,11 +127,15 @@ export component ColourSlider inherits VerticalLayout {
set_base_colour(); set_base_colour();
hex = set_hex_from_colour(final_colour); hex = set_hex_from_colour(final_colour);
} }
released => {
root.released();
}
} }
} }
HorizontalLayout { HorizontalLayout {
LineEdit { LineEdit {
enabled <=> root.enabled;
// width: 50%; // width: 50%;
text <=> root.hex; text <=> root.hex;
edited => { edited => {
@@ -136,6 +150,8 @@ export component ColourSlider inherits VerticalLayout {
border-radius: 7px; border-radius: 7px;
border-color: Palette.border; border-color: Palette.border;
background <=> root.colourbox; background <=> root.colourbox;
} }
} }
} }

View File

@@ -24,6 +24,7 @@ export component SystemSlider inherits RogItem {
vertical-alignment: TextVerticalAlignment.center; vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground; color: Palette.control-foreground;
text <=> root.text; text <=> root.text;
} }
Text { Text {
@@ -62,6 +63,7 @@ export component SystemToggle inherits RogItem {
vertical-alignment: TextVerticalAlignment.center; vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground; color: Palette.control-foreground;
text <=> root.text; text <=> root.text;
} }
} }
@@ -92,6 +94,7 @@ export component SystemToggleVert inherits RogItem {
horizontal-alignment: TextHorizontalAlignment.center; horizontal-alignment: TextHorizontalAlignment.center;
color: Palette.control-foreground; color: Palette.control-foreground;
text <=> root.text; text <=> root.text;
} }
HorizontalLayout { HorizontalLayout {
@@ -122,6 +125,7 @@ export component SystemDropdown inherits RogItem {
vertical-alignment: TextVerticalAlignment.center; vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground; color: Palette.control-foreground;
text <=> root.text; text <=> root.text;
} }
} }