Init with colour sliders in approx position

This commit is contained in:
Luke D. Jones
2024-03-03 12:57:45 +13:00
parent a88c33c201
commit 3da848d131
11 changed files with 198 additions and 217 deletions

View File

@@ -2,10 +2,10 @@ import { VerticalBox , StandardButton, Button, HorizontalBox, ComboBox, Switch,
import { Theme } from "globals.slint";
export component RogItem inherits Rectangle {
background: Theme.background-color;
border-color: Colors.black;
border-width: 3px;
border-radius: 10px;
background: Theme.background-color;
border-color: Colors.black;
border-width: 3px;
border-radius: 10px;
}
export component SystemSlider inherits RogItem {
@@ -122,8 +122,7 @@ export component ValueBar inherits Rectangle {
return 0.50 - (value - (min - max) / 2) / (max - min);
}
return (value - min) / (max - min);
}
function set_x(min: float, max: float, value: float, width: length) -> length {
}function set_x(min: float, max: float, value: float, width: length) -> length {
if (min < 0.0 && max > 0.0) {
if (value < max + min) {
return width / 2 - width * (percentage(min, max, value));
@@ -131,8 +130,7 @@ export component ValueBar inherits Rectangle {
return width / 2;
}
return 0;
}
Rectangle {
}Rectangle {
border-radius: 3px;
background: Theme.neutral-box;
Rectangle {

View File

@@ -15,7 +15,6 @@ export component MainWindow inherits Window {
in property <[bool]> sidebar_items_avilable: [true, true, true, true, true, true];
private property <bool> show-notif;
private property <bool> fade-cover;
private property <bool> toast: false;
private property <string> toast_text: "I show when something is waiting";
callback show_toast(string);
@@ -23,20 +22,17 @@ export component MainWindow inherits Window {
toast = text != "";
toast_text = text;
}
callback exit-app();
callback show-notification(bool);
show-notification(yes) => {
show-notif = yes;
fade-cover = yes;
}
min-height: AppSize.height;
min-width: AppSize.width;
background: Colors.black;
HorizontalLayout {
padding: 0px;
VerticalLayout {
side-bar := SideBar {
title: @tr("ROG");

View File

@@ -11,6 +11,7 @@ export component PageAbout inherits VerticalLayout {
text: "A UI for asusctl made with slint";
font-size: 22px;
}
Text {
vertical-alignment: TextVerticalAlignment.center;
horizontal-alignment: TextHorizontalAlignment.center;

View File

@@ -11,22 +11,16 @@ export global AnimePageData {
];
in-out property <int> brightness;
callback set_brightness(int);
in-out property <bool> builtins_enabled;
callback set_builtins_enabled(bool);
in-out property <bool> enable_display;
callback set_enable_display(bool);
in-out property <bool> off_when_lid_closed;
callback set_off_when_lid_closed(bool);
in-out property <bool> off_when_suspended;
callback set_off_when_suspended(bool);
in-out property <bool> off_when_unplugged;
callback set_off_when_unplugged(bool);
in-out property <[string]> boot_anim_choices: [@tr("Glitch Construction"), @tr("Static Emergence")];
in property <int> boot_anim: 0;
in-out property <[string]> awake_anim_choices: [@tr("Binary Banner Scroll"), @tr("Rog Logo Glitch")];
@@ -42,7 +36,6 @@ export component PageAnime inherits Rectangle {
property <bool> show_fade_cover: false;
property <bool> show_display_advanced: false;
property <bool> show_builtin_advanced: false;
clip: true;
// TODO: slow with border-radius
padding: 8px;
@@ -142,7 +135,6 @@ export component PageAnime inherits Rectangle {
VerticalLayout {
padding: 50px;
spacing: 10px;
GroupBox {
height: 100px;
VerticalBox {
@@ -217,7 +209,6 @@ export component PageAnime inherits Rectangle {
VerticalLayout {
padding: 50px;
spacing: 10px;
GroupBox {
height: 100px;
VerticalBox {

View File

@@ -4,13 +4,10 @@ import { SystemToggle } from "../common_widgets.slint";
export global AppSettingsPageData {
in-out property <bool> run_in_background;
callback set_run_in_background(bool);
in-out property <bool> startup_in_background;
callback set_startup_in_background(bool);
in-out property <bool> enable_tray_icon;
callback set_enable_tray_icon(bool);
in-out property <bool> enable_notifications;
callback set_enable_notifications(bool);
}

View File

@@ -28,7 +28,6 @@ export global AuraPageData {
];
in-out property <int> brightness;
callback set_brightness(int);
in-out property <[string]> mode_names: [
@tr("Basic aura mode" => "Static"),
@tr("Basic aura mode" => "Breathe"),
@@ -50,11 +49,9 @@ export global AuraPageData {
@tr("Basic aura mode" => "Strobe"),
];
in-out property <int> current_available_mode: 0;
in-out property <[int]> supported_basic_modes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12];
in-out property <int> led_mode;
callback set_led_mode(int);
in-out property <[string]> zone_names: [
@tr("Aura zone" => "None"),
@tr("Aura zone" => "Key1"),
@@ -66,7 +63,6 @@ export global AuraPageData {
@tr("Aura zone" => "Lightbar Right"),
];
in-out property <int> zone;
in-out property <[string]> direction_names: [
@tr("Aura direction" => "Right"),
@tr("Aura direction" => "Left"),
@@ -74,14 +70,12 @@ export global AuraPageData {
@tr("Aura direction" => "Down"),
];
in-out property <int> direction;
in-out property <[string]> speed_names: [
@tr("Aura speed" => "Low"),
@tr("Aura speed" => "Medium"),
@tr("Aura speed" => "High"),
];
in-out property <int> speed;
in-out property <AuraEffect> led_mode_data: {
mode: 0,
zone: 0,
@@ -93,12 +87,10 @@ export global AuraPageData {
direction: 0,
};
callback set_led_mode_data(AuraEffect);
in-out property <color> color1;
in-out property <brush> colorbox1;
in-out property <color> color2;
in-out property <brush> colorbox2;
callback update_led_mode_data(AuraEffect);
update_led_mode_data(data) => {
led_mode_data = data;
@@ -111,11 +103,12 @@ export global AuraPageData {
colorbox1 = data.colour1;
colorbox2 = data.colour2;
}
callback blend_colour(color, color, float) -> color;
callback blend_lightness(color, float) -> color;
callback set_hex_from_colour(color) -> string;
callback set_hex_to_colour(string) -> color;
pure callback set_hue(color) -> float;
pure callback set_bright(color) -> float;
}
export component PageAura inherits VerticalLayout {
@@ -159,10 +152,10 @@ export component PageAura inherits VerticalLayout {
}
HorizontalBox {
ColourSlider {
c1 := ColourSlider {
final_colour <=> AuraPageData.color1;
colourbox <=> AuraPageData.colorbox1;
set_hex_from_colour(c1) => {
colourbox <=> AuraPageData.colorbox1;
set_hex_from_colour(c1) => {
return AuraPageData.set_hex_from_colour(c1);
}
blend_colour(c1, c2, f) => {
@@ -174,6 +167,12 @@ export component PageAura inherits VerticalLayout {
hex_to_colour(s) => {
return AuraPageData.set_hex_to_colour(s);
}
set_hue(color) => {
return AuraPageData.set_hue(color);
}
set_bright(color) => {
return AuraPageData.set_bright(color);
}
init => {
self.colourbox = AuraPageData.led_mode_data.colour1;
self.final_colour = AuraPageData.led_mode_data.colour1;
@@ -190,10 +189,10 @@ export component PageAura inherits VerticalLayout {
}
HorizontalBox {
ColourSlider {
c2 := ColourSlider {
final_colour <=> AuraPageData.color2;
colourbox <=> AuraPageData.colorbox2;
set_hex_from_colour(c1) => {
colourbox <=> AuraPageData.colorbox2;
set_hex_from_colour(c1) => {
return AuraPageData.set_hex_from_colour(c1);
}
blend_colour(c1, c2, f) => {
@@ -205,6 +204,9 @@ export component PageAura inherits VerticalLayout {
hex_to_colour(s) => {
return AuraPageData.set_hex_to_colour(s);
}
set_bright(color) => {
return AuraPageData.set_bright(color);
}
init => {
self.colourbox = AuraPageData.led_mode_data.colour2;
self.final_colour = AuraPageData.led_mode_data.colour2;

View File

@@ -22,11 +22,9 @@ export struct AvailableSystemProperties {
export global SystemPageData {
in-out property <float> charge_control_end_threshold: 30;
callback set_charge_control_end_threshold(/* charge limit */ int);
in-out property <int> throttle_thermal_policy: 0;
in-out property <[string]> throttle_policy_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")];
callback set_throttle_thermal_policy(int);
in-out property <[string]> energy_performance_choices: [
@tr("Default"),
@tr("Performance"),
@@ -47,34 +45,24 @@ export global SystemPageData {
callback set_throttle_policy_on_ac(int);
in-out property <int> throttle_policy_on_battery: 0;
callback set_throttle_policy_on_battery(int);
in-out property <bool> panel_od;
callback set_panel_od(bool);
in-out property <bool> mini_led_mode;
callback set_mini_led_mode(bool);
in-out property <float> ppt_pl1_spl: 5;
callback set_ppt_pl1_spl(int);
in-out property <float> ppt_pl2_sppt: 5;
callback set_ppt_pl2_sppt(int);
in-out property <float> ppt_fppt: 5;
callback set_ppt_fppt(int);
in-out property <float> ppt_apu_sppt: 5;
callback set_ppt_apu_sppt(int);
in-out property <float> ppt_platform_sppt: 5;
callback set_ppt_platform_sppt(int);
in-out property <float> nv_dynamic_boost: 5;
callback set_nv_dynamic_boost(int);
in-out property <float> nv_temp_target: 75;
callback set_nv_temp_target(int);
in-out property <AvailableSystemProperties> available: {
charge_control_end_threshold: true,
panel_od: true,
@@ -102,7 +90,6 @@ export component PageSystem inherits Rectangle {
VerticalLayout {
padding: 10px;
spacing: 10px;
Rectangle {
background: Theme.background-color;
border-color: Colors.black;
@@ -221,6 +208,7 @@ export component PageSystem inherits Rectangle {
SystemPageData.set_ppt_apu_sppt(Math.round(SystemPageData.ppt_apu_sppt))
}
}
if SystemPageData.available.ppt-platform-sppt: SystemSlider {
text: @tr("ppt_platform_sppt" => "ppt_platform_sppt");
maximum: 130;
@@ -240,6 +228,7 @@ export component PageSystem inherits Rectangle {
SystemPageData.set_nv_dynamic_boost(Math.round(SystemPageData.nv_dynamic_boost))
}
}
if SystemPageData.available.nv-temp-target: SystemSlider {
text: @tr("nv_temp_target" => "nv_temp_target");
minimum: 75;
@@ -279,7 +268,6 @@ export component PageSystem inherits Rectangle {
padding: 50px;
padding-top: 5px;
spacing: 10px;
GroupBox {
VerticalBox {
spacing: 10px;

View File

@@ -6,14 +6,16 @@ export component ColourSlider inherits VerticalLayout {
property <color> base_colour: Colors.red;
in-out property <color> final_colour: Colors.red;
in-out property <brush> colourbox: final_colour;
callback hex_to_colour(string) -> color;
// required
callback set_hex_from_colour(color) -> string;
/// This callback is required until slint adds direct acces to color channels
callback blend_colour(color, color, float) -> color;
callback blend_lightness(color, float) -> color;
pure callback set_hue(color) -> float;
pure callback set_bright(color) -> float;
in-out property <float> c1value<=> c1.value;
in-out property <float> c2value<=> c2.value;
property <[color]> base_colours: [
Colors.rgb( 255, 0, 0),
Colors.rgb( 255, 128, 0),
@@ -42,13 +44,17 @@ export component ColourSlider inherits VerticalLayout {
base_colour.with-alpha(10%),
base_colour.with-alpha(0%)
];
function set_base_colour() {
// base_colour = base_colours[c1.value].mix(base_colours[c1.value+1], _index_rem);
root.base_colour = blend_colour(base_colours[c1.value], 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.colourbox = root.final_colour;
}
callback external_colour_change();
external_colour_change => {
c1.value = 13 * (root.set_hue(root.final_colour) / 360);
c2.value = 12 * (root.set_bright(root.final_colour) / 0.86);
root.set_base_colour();
}
Rectangle {
height: 32px;
// 13 colours
@@ -64,6 +70,9 @@ export component ColourSlider inherits VerticalLayout {
set_base_colour();
hex = set_hex_from_colour(final_colour);
}
init => {
self.value = 13 * (root.set_hue(root.final_colour) / 360);
}
}
}
@@ -82,6 +91,10 @@ export component ColourSlider inherits VerticalLayout {
set_base_colour();
hex = set_hex_from_colour(final_colour);
}
init => {
self.value = 12 * (root.set_bright(root.final_colour) / 0.86);
root.set_base_colour();
}
}
}
@@ -98,7 +111,6 @@ export component ColourSlider inherits VerticalLayout {
Rectangle {
width: self.height;
background <=> root.colourbox;
}
}
}
@@ -107,9 +119,7 @@ component ColorButton {
callback select<=>i_touch_area.clicked;
in property <brush> color<=> i_container.background;
in property <bool> selected;
height: self.width;
i_container := Rectangle {
border_width: 2px;
}
@@ -128,10 +138,8 @@ export component ColorPicker {
private property <int> selected_color_index;
in-out property <float> colors_per_row: 13.0;
private property <length> color_size: self.width / colors_per_row;
out property <color> selected_color: palette[selected_color_index];
callback selected(color);
in property <[color]> palette: [
Colors.rgb(51,0,0),
Colors.rgb(51,25,0),
@@ -259,18 +267,15 @@ export component ColorPicker {
Colors.rgb(255,204,229),
Colors.rgb(224,224,224),
];
Rectangle {
border_width: 1px;
border_color: Colors.black;
for color[index] in palette: ColorButton {
x: color_size * mod(index, colors_per_row);
y: color_size * floor(index / colors_per_row);
width: color_size;
color: color;
selected: index == selected_color_index;
select => {
selected_color_index = index;
// debug(Math.mod(selected_color_index, colors_per_row)); // X pos

View File

@@ -106,13 +106,13 @@ export component SideBar inherits Rectangle {
alignment: start;
vertical-stretch: 0;
for item[index] in root.model: SideBarItem {
visible: root.available[index];
clicked => {
root.current-item = index;
}
has-focus: index == root.current-focused;
text: item;
selected: index == root.current-item;
visible: root.available[index];
clicked => {
root.current-item = index;
}
has-focus: index == root.current-focused;
text: item;
selected: index == root.current-item;
}
}