mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Check in the fan curve work
This commit is contained in:
@@ -3,8 +3,7 @@ import { AppSize } from "globals.slint";
|
|||||||
import { PageSystem, AvailableSystemProperties, SystemPageData } from "pages/system.slint";
|
import { PageSystem, AvailableSystemProperties, SystemPageData } from "pages/system.slint";
|
||||||
import { SideBar } from "widgets/sidebar.slint";
|
import { SideBar } from "widgets/sidebar.slint";
|
||||||
import { PageAbout } from "pages/about.slint";
|
import { PageAbout } from "pages/about.slint";
|
||||||
import { PageFans, Node } from "pages/fans.slint";
|
import { PageFans } from "pages/fans.slint";
|
||||||
export { Node }
|
|
||||||
import { PageAnime, AnimePageData } from "pages/anime.slint";
|
import { PageAnime, AnimePageData } from "pages/anime.slint";
|
||||||
import { PageAura } from "pages/aura.slint";
|
import { PageAura } from "pages/aura.slint";
|
||||||
import { AuraPageData, AuraDevType, AuraDevTuf, AuraDevRog1, PowerZones, KbAuraPowerState, AuraPowerDev, AuraEffect } from "types/aura_types.slint";
|
import { AuraPageData, AuraDevType, AuraDevTuf, AuraDevRog1, PowerZones, KbAuraPowerState, AuraPowerDev, AuraEffect } from "types/aura_types.slint";
|
||||||
@@ -36,7 +35,6 @@ export component MainWindow inherits Window {
|
|||||||
aura.external_colour_change();
|
aura.external_colour_change();
|
||||||
aura.external_colour_change();
|
aura.external_colour_change();
|
||||||
}
|
}
|
||||||
pure callback verify_fan_curves([Node], length, length) -> [Node];
|
|
||||||
min-height: AppSize.height;
|
min-height: AppSize.height;
|
||||||
min-width: AppSize.width;
|
min-width: AppSize.width;
|
||||||
background: Colors.black;
|
background: Colors.black;
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ export component PageAura inherits Rectangle {
|
|||||||
SystemDropdown {
|
SystemDropdown {
|
||||||
text: @tr("Brightness");
|
text: @tr("Brightness");
|
||||||
current_index <=> AuraPageData.brightness;
|
current_index <=> AuraPageData.brightness;
|
||||||
current_value: AuraPageData.brightness_names[self.current-index];
|
current_value: AuraPageData.brightness_names[self.current-index];
|
||||||
model <=> AuraPageData.brightness_names;
|
model <=> AuraPageData.brightness_names;
|
||||||
selected => {
|
selected => {
|
||||||
AuraPageData.set_brightness(AuraPageData.brightness)
|
AuraPageData.set_brightness(AuraPageData.brightness)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +1,154 @@
|
|||||||
import { Palette } from "std-widgets.slint";
|
import { Palette, TabWidget, Button, CheckBox } from "std-widgets.slint";
|
||||||
import { Graph } from "../widgets/graph.slint";
|
import { Graph, Node } from "../widgets/graph.slint";
|
||||||
|
import { SystemToggle } from "../widgets/common.slint";
|
||||||
|
import { Profile, FanType, FanPageData } from "../types/fan_types.slint";
|
||||||
|
|
||||||
export struct Node { x: length, y: length}
|
component FanTab inherits Rectangle {
|
||||||
|
in-out property <bool> enabled: false;
|
||||||
|
in-out property <bool> tab_enabled: false;
|
||||||
|
in property <Profile> profile;
|
||||||
|
in property <FanType> fan_type;
|
||||||
|
callback apply();
|
||||||
|
callback cancel();
|
||||||
|
callback default();
|
||||||
|
callback toggled();
|
||||||
|
in property <string> title;
|
||||||
|
in-out property <[Node]> nodes;
|
||||||
|
|
||||||
export component PageFans inherits VerticalLayout {
|
if !root.tab_enabled: VerticalLayout {
|
||||||
in-out property <[Node]> nodes: [
|
alignment: center;
|
||||||
{
|
HorizontalLayout {
|
||||||
x: 10px,
|
alignment: center;
|
||||||
y: 10px,
|
Text {
|
||||||
},
|
font-size: 24px;
|
||||||
{
|
text: "WIP: Not enabled yet";
|
||||||
x: 40px,
|
}
|
||||||
y: 30px,
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
x: 70px,
|
|
||||||
y: 50px,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: 100px,
|
|
||||||
y: 70px,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: 130px,
|
|
||||||
y: 90px,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: 160px,
|
|
||||||
y: 110px,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: 190px,
|
|
||||||
y: 130px,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: 220px,
|
|
||||||
y: 150px,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
Text {
|
|
||||||
text: "WORK IN PROGRESS";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HorizontalLayout {
|
VerticalLayout {
|
||||||
Graph {
|
HorizontalLayout {
|
||||||
// width: root.preferred-width;
|
Graph {
|
||||||
// height: root.preferred-height;
|
nodes <=> root.nodes;
|
||||||
nodes <=> root.nodes;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HorizontalLayout {
|
||||||
|
alignment: LayoutAlignment.end;
|
||||||
|
CheckBox {
|
||||||
|
text: @tr("Enabled");
|
||||||
|
checked <=> root.enabled;
|
||||||
|
enabled <=> root.tab_enabled;
|
||||||
|
toggled => {
|
||||||
|
root.toggled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: @tr("Apply");
|
||||||
|
enabled <=> root.tab_enabled;
|
||||||
|
clicked => {
|
||||||
|
root.apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: @tr("Cancel");
|
||||||
|
enabled <=> root.tab_enabled;
|
||||||
|
clicked => {
|
||||||
|
root.cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: @tr("Factory Default");
|
||||||
|
enabled <=> root.tab_enabled;
|
||||||
|
clicked => {
|
||||||
|
root.default();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export component PageFans inherits VerticalLayout {
|
||||||
|
TabWidget {
|
||||||
|
Tab {
|
||||||
|
title: @tr("Balanced");
|
||||||
|
TabWidget {
|
||||||
|
Tab {
|
||||||
|
title: @tr("CPU");
|
||||||
|
FanTab {
|
||||||
|
nodes <=> FanPageData.balanced_cpu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tab {
|
||||||
|
title: @tr("Mid");
|
||||||
|
FanTab {
|
||||||
|
nodes <=> FanPageData.balanced_mid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tab {
|
||||||
|
title: @tr("GPU");
|
||||||
|
FanTab {
|
||||||
|
nodes <=> FanPageData.balanced_gpu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tab {
|
||||||
|
title: @tr("Performance");
|
||||||
|
TabWidget {
|
||||||
|
Tab {
|
||||||
|
title: @tr("CPU");
|
||||||
|
FanTab {
|
||||||
|
nodes <=> FanPageData.performance_cpu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tab {
|
||||||
|
title: @tr("Mid");
|
||||||
|
FanTab {
|
||||||
|
nodes <=> FanPageData.performance_mid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tab {
|
||||||
|
title: @tr("GPU");
|
||||||
|
FanTab {
|
||||||
|
nodes <=> FanPageData.performance_gpu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tab {
|
||||||
|
title: @tr("Quiet");
|
||||||
|
TabWidget {
|
||||||
|
Tab {
|
||||||
|
title: @tr("CPU");
|
||||||
|
FanTab {
|
||||||
|
nodes <=> FanPageData.quiet_cpu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tab {
|
||||||
|
title: @tr("Mid");
|
||||||
|
FanTab {
|
||||||
|
nodes <=> FanPageData.quiet_mid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Tab {
|
||||||
|
title: @tr("GPU");
|
||||||
|
FanTab {
|
||||||
|
nodes <=> FanPageData.quiet_gpu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
minimum: 20;
|
minimum: 20;
|
||||||
maximum: 100;
|
maximum: 100;
|
||||||
value <=> SystemPageData.charge_control_end_threshold;
|
value <=> SystemPageData.charge_control_end_threshold;
|
||||||
released => {
|
released => {
|
||||||
SystemPageData.set_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold))
|
SystemPageData.set_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
current_index <=> SystemPageData.throttle_thermal_policy;
|
current_index <=> SystemPageData.throttle_thermal_policy;
|
||||||
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_thermal_policy];
|
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_thermal_policy];
|
||||||
model <=> SystemPageData.throttle_policy_choices;
|
model <=> SystemPageData.throttle_policy_choices;
|
||||||
selected => {
|
selected => {
|
||||||
SystemPageData.set_throttle_thermal_policy(SystemPageData.throttle_thermal_policy)
|
SystemPageData.set_throttle_thermal_policy(SystemPageData.throttle_thermal_policy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
if SystemPageData.available.panel-od: SystemToggle {
|
if SystemPageData.available.panel-od: SystemToggle {
|
||||||
text: @tr("Panel Overdrive");
|
text: @tr("Panel Overdrive");
|
||||||
checked <=> SystemPageData.panel_od;
|
checked <=> SystemPageData.panel_od;
|
||||||
toggled => {
|
toggled => {
|
||||||
SystemPageData.set_panel_od(SystemPageData.panel_od)
|
SystemPageData.set_panel_od(SystemPageData.panel_od)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
if SystemPageData.available.mini-led-mode: SystemToggle {
|
if SystemPageData.available.mini-led-mode: SystemToggle {
|
||||||
text: @tr("MiniLED Mode");
|
text: @tr("MiniLED Mode");
|
||||||
checked <=> SystemPageData.mini_led_mode;
|
checked <=> SystemPageData.mini_led_mode;
|
||||||
toggled => {
|
toggled => {
|
||||||
SystemPageData.set_mini_led_mode(SystemPageData.mini_led_mode)
|
SystemPageData.set_mini_led_mode(SystemPageData.mini_led_mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
if SystemPageData.available.boot-sound: SystemToggle {
|
if SystemPageData.available.boot-sound: SystemToggle {
|
||||||
text: @tr("POST boot sound");
|
text: @tr("POST boot sound");
|
||||||
checked <=> SystemPageData.boot_sound;
|
checked <=> SystemPageData.boot_sound;
|
||||||
toggled => {
|
toggled => {
|
||||||
SystemPageData.set_boot_sound(SystemPageData.boot_sound)
|
SystemPageData.set_boot_sound(SystemPageData.boot_sound)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,7 +185,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
minimum: 5;
|
minimum: 5;
|
||||||
maximum: 250;
|
maximum: 250;
|
||||||
value <=> SystemPageData.ppt_pl1_spl;
|
value <=> SystemPageData.ppt_pl1_spl;
|
||||||
released => {
|
released => {
|
||||||
SystemPageData.set_ppt_pl1_spl(Math.round(SystemPageData.ppt_pl1_spl))
|
SystemPageData.set_ppt_pl1_spl(Math.round(SystemPageData.ppt_pl1_spl))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
minimum: 5;
|
minimum: 5;
|
||||||
maximum: 250;
|
maximum: 250;
|
||||||
value <=> SystemPageData.ppt_pl2_sppt;
|
value <=> SystemPageData.ppt_pl2_sppt;
|
||||||
released => {
|
released => {
|
||||||
SystemPageData.set_ppt_pl2_sppt(Math.round(SystemPageData.ppt_pl2_sppt))
|
SystemPageData.set_ppt_pl2_sppt(Math.round(SystemPageData.ppt_pl2_sppt))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
minimum: 5;
|
minimum: 5;
|
||||||
maximum: 250;
|
maximum: 250;
|
||||||
value <=> SystemPageData.ppt_fppt;
|
value <=> SystemPageData.ppt_fppt;
|
||||||
released => {
|
released => {
|
||||||
SystemPageData.set_ppt_fppt(Math.round(SystemPageData.ppt_fppt))
|
SystemPageData.set_ppt_fppt(Math.round(SystemPageData.ppt_fppt))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,7 +215,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
minimum: 5;
|
minimum: 5;
|
||||||
maximum: 130;
|
maximum: 130;
|
||||||
value <=> SystemPageData.ppt_apu_sppt;
|
value <=> SystemPageData.ppt_apu_sppt;
|
||||||
released => {
|
released => {
|
||||||
SystemPageData.set_ppt_apu_sppt(Math.round(SystemPageData.ppt_apu_sppt))
|
SystemPageData.set_ppt_apu_sppt(Math.round(SystemPageData.ppt_apu_sppt))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,7 +225,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
maximum: 130;
|
maximum: 130;
|
||||||
minimum: 5;
|
minimum: 5;
|
||||||
value <=> SystemPageData.ppt_platform_sppt;
|
value <=> SystemPageData.ppt_platform_sppt;
|
||||||
released => {
|
released => {
|
||||||
SystemPageData.set_ppt_platform_sppt(Math.round(SystemPageData.ppt_platform_sppt))
|
SystemPageData.set_ppt_platform_sppt(Math.round(SystemPageData.ppt_platform_sppt))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,7 +235,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
minimum: 5;
|
minimum: 5;
|
||||||
maximum: 25;
|
maximum: 25;
|
||||||
value <=> SystemPageData.nv_dynamic_boost;
|
value <=> SystemPageData.nv_dynamic_boost;
|
||||||
released => {
|
released => {
|
||||||
SystemPageData.set_nv_dynamic_boost(Math.round(SystemPageData.nv_dynamic_boost))
|
SystemPageData.set_nv_dynamic_boost(Math.round(SystemPageData.nv_dynamic_boost))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,7 +245,7 @@ export component PageSystem inherits Rectangle {
|
|||||||
minimum: 75;
|
minimum: 75;
|
||||||
maximum: 87;
|
maximum: 87;
|
||||||
value <=> SystemPageData.nv_temp_target;
|
value <=> SystemPageData.nv_temp_target;
|
||||||
released => {
|
released => {
|
||||||
SystemPageData.set_nv_temp_target(Math.round(SystemPageData.nv_temp_target))
|
SystemPageData.set_nv_temp_target(Math.round(SystemPageData.nv_temp_target))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ 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 {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ export component ColourSlider inherits VerticalLayout {
|
|||||||
spacing: 10px;
|
spacing: 10px;
|
||||||
in-out property <bool> enabled;
|
in-out property <bool> enabled;
|
||||||
property <string> hex: "#FF0000";
|
property <string> hex: "#FF0000";
|
||||||
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_colour: Colors.red;
|
property <color> base_colour: Colors.red;
|
||||||
in-out property <color> final_colour: Colors.red;
|
in-out property <color> final_colour: Colors.red;
|
||||||
in-out property <brush> colourbox: final_colour;
|
in-out property <brush> colourbox: final_colour;
|
||||||
@@ -151,7 +151,6 @@ 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;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ 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 {
|
||||||
@@ -63,7 +62,6 @@ 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;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +92,6 @@ 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 {
|
||||||
@@ -102,7 +99,7 @@ export component SystemToggleVert inherits RogItem {
|
|||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
Switch {
|
Switch {
|
||||||
checked <=> root.checked;
|
checked <=> root.checked;
|
||||||
toggled => {
|
toggled => {
|
||||||
root.toggled(root.checked)
|
root.toggled(root.checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,7 +122,6 @@ 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;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,98 +3,111 @@ import { Palette } from "std-widgets.slint";
|
|||||||
export struct Node { x: length, y: length}
|
export struct Node { x: length, y: length}
|
||||||
|
|
||||||
export component Graph inherits Rectangle {
|
export component Graph inherits Rectangle {
|
||||||
preferred-height: 100%;
|
|
||||||
preferred-width: 100%;
|
|
||||||
pure callback verify_positions([Node], length, length) -> [Node];
|
|
||||||
in-out property <[Node]> nodes;
|
in-out property <[Node]> nodes;
|
||||||
|
in property <Node> node_min: { x: 0px, y: 0px };
|
||||||
|
in property <Node> node_max: { x: 100px, y: 100px };
|
||||||
|
property <length> graph_padding: 20px;
|
||||||
|
graph := Rectangle {
|
||||||
|
width: root.width - root.graph_padding * 2;
|
||||||
|
height: root.height - root.graph_padding * 2;
|
||||||
|
x: root.graph_padding;
|
||||||
|
y: root.graph_padding;
|
||||||
|
function scale_x_to_graph(x: length) -> length {
|
||||||
|
((x - node_min.x) / (node_max.x - node_min.x)) * graph.width
|
||||||
|
}function scale_y_to_graph(y: length) -> length {
|
||||||
|
((y - node_min.y) / (node_max.y - node_min.y)) * graph.height
|
||||||
|
}function scale_x_to_node(x: length) -> length {
|
||||||
|
(x / graph.width) * (node_max.x - node_min.x)
|
||||||
|
}function scale_y_to_node(y: length) -> length {
|
||||||
|
(y / graph.height) * (node_max.y - node_min.y)
|
||||||
|
}for l[idx] in nodes: path := Rectangle {
|
||||||
|
if idx + 1 != nodes.length: Path {
|
||||||
|
viewbox-width: self.width / 1px;
|
||||||
|
viewbox-height: self.height / 1px;
|
||||||
|
stroke: Palette.control-foreground;
|
||||||
|
stroke-width: 2px;
|
||||||
|
MoveTo {
|
||||||
|
x: scale_x_to_graph(nodes[idx].x) / 1px;
|
||||||
|
y: graph.height / 1px - scale_y_to_graph(nodes[idx].y) / 1px;
|
||||||
|
}
|
||||||
|
|
||||||
for l[idx] in nodes: path := Rectangle {
|
LineTo {
|
||||||
if idx + 1 != nodes.length: Path {
|
x: scale_x_to_graph(nodes[idx + 1].x) / 1px;
|
||||||
viewbox-width: self.width / 1px;
|
y: graph.height / 1px - scale_y_to_graph(nodes[idx + 1].y) / 1px;
|
||||||
viewbox-height: self.height / 1px;
|
}
|
||||||
stroke: Palette.control-foreground;
|
|
||||||
stroke-width: 2px;
|
|
||||||
MoveTo {
|
|
||||||
x: nodes[idx].x / 1px;
|
|
||||||
y: root.height / 1px - nodes[idx].y / 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
LineTo {
|
|
||||||
x: nodes[idx + 1].x / 1px;
|
|
||||||
y: root.height / 1px - nodes[idx + 1].y / 1px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for n[idx] in nodes: Rectangle {
|
for n[idx] in nodes: Rectangle {
|
||||||
states [
|
states [
|
||||||
pressed when touch.pressed: {
|
pressed when touch.pressed: {
|
||||||
state.background: Palette.selection-background;
|
state.background: Palette.selection-background;
|
||||||
}
|
}
|
||||||
hover when touch.has-hover: {
|
hover when touch.has-hover: {
|
||||||
state.background: Palette.accent-background;
|
state.background: Palette.accent-background;
|
||||||
}
|
}
|
||||||
]state := Rectangle {
|
]state := Rectangle {
|
||||||
background: Palette.control-foreground;
|
background: Palette.control-foreground;
|
||||||
x: n.x - self.width / 2;
|
x: scale_x_to_graph(n.x) - self.width / 2;
|
||||||
y: root.height - n.y - self.height / 2;
|
y: graph.height - scale_y_to_graph(n.y) - self.height / 2;
|
||||||
width: 18px;
|
width: 18px;
|
||||||
height: self.width;
|
height: self.width;
|
||||||
border-radius: self.width / 2;
|
border-radius: self.width / 2;
|
||||||
property <length> pad: self.border-radius / 2;
|
property <length> pad: 1px;
|
||||||
|
|
||||||
touch := TouchArea {
|
touch := TouchArea {
|
||||||
function check() {
|
function check() {
|
||||||
if idx + 1 < nodes.length && idx > 0 {
|
if idx + 1 < nodes.length && idx > 0 {
|
||||||
if n.x + self.mouse-x - self.pressed-x > nodes[idx + 1].x {
|
if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) > nodes[idx + 1].x {
|
||||||
n.x = nodes[idx + 1].x - pad;
|
n.x = nodes[idx + 1].x - pad;
|
||||||
} else if n.x + self.mouse-x - self.pressed-x < nodes[idx - 1].x {
|
} else if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) < nodes[idx - 1].x {
|
||||||
n.x = nodes[idx - 1].x + pad;
|
n.x = nodes[idx - 1].x + pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if n.y + self.height - self.mouse-y - self.pressed-y > nodes[idx + 1].y {
|
if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) > nodes[idx + 1].y {
|
||||||
n.y = nodes[idx + 1].y - pad;
|
n.y = nodes[idx + 1].y - pad;
|
||||||
} else if n.y + self.height - self.mouse-y - self.pressed-y < nodes[idx - 1].y {
|
} else if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) < nodes[idx - 1].y {
|
||||||
n.y = nodes[idx - 1].y + pad;
|
n.y = nodes[idx - 1].y + pad;
|
||||||
}
|
}
|
||||||
} else if idx == 0 {
|
} else if idx == 0 {
|
||||||
if n.x + self.mouse-x - self.pressed-x < 0.0 {
|
if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) < 0.0 {
|
||||||
n.x = 1px;
|
n.x = 1px;
|
||||||
} else if n.x + self.mouse-x - self.pressed-x > nodes[idx + 1].x {
|
} else if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) > nodes[idx + 1].x {
|
||||||
n.x = nodes[idx + 1].x - pad;
|
n.x = nodes[idx + 1].x - pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if n.y - self.mouse-y - self.pressed-y < 0.0 {
|
if n.y - scale_y_to_node(self.mouse-y - self.pressed-y) < 0.0 {
|
||||||
n.y = 1px;
|
n.y = 1px;
|
||||||
} else if n.y + self.height - self.mouse-y - self.pressed-y > nodes[idx + 1].y {
|
} else if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) > nodes[idx + 1].y {
|
||||||
n.y = nodes[idx + 1].y - pad;
|
n.y = nodes[idx + 1].y - pad;
|
||||||
}
|
}
|
||||||
} else if idx == nodes.length - 1 {
|
} else if idx == nodes.length - 1 {
|
||||||
if n.x + self.mouse-x - self.pressed-x > root.width {
|
if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) > scale_x_to_node(graph.width) {
|
||||||
n.x = root.width - 1px;
|
n.x = scale_x_to_node(graph.width - 1px);
|
||||||
} else if n.x + self.mouse-x - self.pressed-x < nodes[idx - 1].x {
|
} else if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) < nodes[idx - 1].x {
|
||||||
n.x = nodes[idx - 1].x + pad;
|
n.x = nodes[idx - 1].x + pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if n.y - self.mouse-y - self.pressed-y > root.height {
|
if n.y - scale_y_to_node(self.mouse-y - self.pressed-y) > scale_y_to_node(graph.height) {
|
||||||
n.y = root.height - 1px;
|
n.y = scale_y_to_node(graph.height - 1px);
|
||||||
} else if n.y + self.height - self.mouse-y - self.pressed-y < nodes[idx - 1].y {
|
} else if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) < nodes[idx - 1].y {
|
||||||
n.y = nodes[idx - 1].y + pad;
|
n.y = nodes[idx - 1].y + pad;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}moved => {
|
||||||
|
if (self.pressed) {
|
||||||
|
n.x += scale_x_to_node(self.mouse-x - self.pressed-x);
|
||||||
|
n.y -= scale_y_to_node(self.mouse-y - self.pressed-y);
|
||||||
|
self.check();
|
||||||
|
// nodes[idx] = n;
|
||||||
}
|
}
|
||||||
}moved => {
|
}
|
||||||
if (self.pressed) {
|
|
||||||
n.x += self.mouse-x - self.pressed-x;
|
clicked => {
|
||||||
n.y -= self.mouse-y - self.pressed-y;
|
|
||||||
self.check();
|
self.check();
|
||||||
// nodes[idx] = n;
|
|
||||||
}
|
}
|
||||||
|
mouse-cursor: move;
|
||||||
}
|
}
|
||||||
|
|
||||||
clicked => {
|
|
||||||
self.check();
|
|
||||||
}
|
|
||||||
mouse-cursor: move;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ component SideBarItem inherits Rectangle {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
in property <bool> selected;
|
in property <bool> selected;
|
||||||
in property <bool> has-focus;
|
in property <bool> has-focus;
|
||||||
in-out property <string> text<=> label.text;
|
in-out property <string> text <=> label.text;
|
||||||
callback clicked<=>touch.clicked;
|
callback clicked <=> touch.clicked;
|
||||||
min-height: self.visible ? l.preferred-height + 10px : 0px;
|
min-height: self.visible ? l.preferred-height + 10px : 0px;
|
||||||
// min-width: self.visible ? l.preferred-width + 10px : 0px;
|
// min-width: self.visible ? l.preferred-width + 10px : 0px;
|
||||||
states [
|
states [
|
||||||
@@ -54,7 +54,7 @@ component SideBarItem inherits Rectangle {
|
|||||||
export component SideBar inherits Rectangle {
|
export component SideBar inherits Rectangle {
|
||||||
in property <[string]> model: [];
|
in property <[string]> model: [];
|
||||||
in property <[bool]> available: [];
|
in property <[bool]> available: [];
|
||||||
in property <string> title<=> label.text;
|
in property <string> title <=> label.text;
|
||||||
out property <int> current-item: 0;
|
out property <int> current-item: 0;
|
||||||
out property <int> current-focused: fs.has-focus ? fs.focused-tab : -1;
|
out property <int> current-focused: fs.has-focus ? fs.focused-tab : -1;
|
||||||
// The currently focused tab
|
// The currently focused tab
|
||||||
|
|||||||
Reference in New Issue
Block a user