mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Use backup hidraw brightness write if read-back value fails
This commit is contained in:
@@ -22,45 +22,35 @@ export component PageAppSettings inherits VerticalLayout {
|
||||
mainview := VerticalLayout {
|
||||
padding: 10px;
|
||||
spacing: 10px;
|
||||
HorizontalLayout {
|
||||
spacing: 10px;
|
||||
max-height: 32px;
|
||||
SystemToggle {
|
||||
text: @tr("Run in background after closing");
|
||||
checked <=> AppSettingsPageData.run_in_background;
|
||||
toggled => {
|
||||
AppSettingsPageData.set_run_in_background(AppSettingsPageData.run_in_background)
|
||||
}
|
||||
}
|
||||
|
||||
SystemToggle {
|
||||
width: parent.width * 1px / 2px;
|
||||
text: @tr("Start app in background (UI closed)");
|
||||
checked <=> AppSettingsPageData.startup_in_background;
|
||||
toggled => {
|
||||
AppSettingsPageData.set_startup_in_background(AppSettingsPageData.startup_in_background)
|
||||
}
|
||||
SystemToggle {
|
||||
text: @tr("Run in background after closing");
|
||||
checked <=> AppSettingsPageData.run_in_background;
|
||||
toggled => {
|
||||
AppSettingsPageData.set_run_in_background(AppSettingsPageData.run_in_background)
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
max-height: 32px;
|
||||
spacing: 10px;
|
||||
SystemToggle {
|
||||
text: @tr("Enable system tray icon");
|
||||
checked <=> AppSettingsPageData.enable_tray_icon;
|
||||
toggled => {
|
||||
AppSettingsPageData.set_enable_tray_icon(AppSettingsPageData.enable_tray_icon)
|
||||
}
|
||||
SystemToggle {
|
||||
text: @tr("Start app in background (UI closed)");
|
||||
checked <=> AppSettingsPageData.startup_in_background;
|
||||
toggled => {
|
||||
AppSettingsPageData.set_startup_in_background(AppSettingsPageData.startup_in_background)
|
||||
}
|
||||
}
|
||||
|
||||
SystemToggle {
|
||||
width: parent.width * 1px / 2px;
|
||||
text: @tr("Enable dGPU notifications");
|
||||
checked <=> AppSettingsPageData.enable_dgpu_notifications;
|
||||
toggled => {
|
||||
AppSettingsPageData.set_enable_dgpu_notifications(AppSettingsPageData.enable_dgpu_notifications)
|
||||
}
|
||||
SystemToggle {
|
||||
text: @tr("Enable system tray icon");
|
||||
checked <=> AppSettingsPageData.enable_tray_icon;
|
||||
toggled => {
|
||||
AppSettingsPageData.set_enable_tray_icon(AppSettingsPageData.enable_tray_icon)
|
||||
}
|
||||
}
|
||||
|
||||
SystemToggle {
|
||||
text: @tr("Enable dGPU notifications");
|
||||
checked <=> AppSettingsPageData.enable_dgpu_notifications;
|
||||
toggled => {
|
||||
AppSettingsPageData.set_enable_dgpu_notifications(AppSettingsPageData.enable_dgpu_notifications)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,183 +17,189 @@ export component PageAura inherits Rectangle {
|
||||
c2.final_colour = AuraPageData.led_mode_data.colour2;
|
||||
c2.external_colour_change();
|
||||
}
|
||||
VerticalLayout {
|
||||
padding: 10px;
|
||||
spacing: 10px;
|
||||
alignment: LayoutAlignment.start;
|
||||
HorizontalLayout {
|
||||
ScrollView {
|
||||
VerticalLayout {
|
||||
padding: 10px;
|
||||
spacing: 10px;
|
||||
SystemDropdown {
|
||||
text: @tr("Brightness");
|
||||
current_index <=> AuraPageData.brightness;
|
||||
current_value: AuraPageData.brightness_names[self.current-index];
|
||||
model <=> AuraPageData.brightness_names;
|
||||
selected => {
|
||||
AuraPageData.set_brightness(AuraPageData.brightness)
|
||||
}
|
||||
}
|
||||
|
||||
SystemDropdown {
|
||||
width: parent.width * 1px / 2px;
|
||||
text: @tr("Aura mode");
|
||||
current_index <=> AuraPageData.current_available_mode;
|
||||
current_value: AuraPageData.available_mode_names[self.current-index];
|
||||
model <=> AuraPageData.available_mode_names;
|
||||
selected => {
|
||||
AuraPageData.led_mode_data.mode = AuraPageData.led_mode;
|
||||
AuraPageData.led_mode_data.mode = AuraPageData.current_available_mode;
|
||||
self.current_value = AuraPageData.available_mode_names[self.current-index];
|
||||
AuraPageData.set_led_mode(AuraPageData.current_available_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RogItem {
|
||||
alignment: LayoutAlignment.start;
|
||||
HorizontalLayout {
|
||||
spacing: 10px;
|
||||
VerticalBox {
|
||||
Text {
|
||||
text: @tr("Colour 1");
|
||||
vertical-alignment: TextVerticalAlignment.center;
|
||||
horizontal-alignment: TextHorizontalAlignment.center;
|
||||
}
|
||||
|
||||
HorizontalBox {
|
||||
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;
|
||||
colourbox <=> AuraPageData.colorbox1;
|
||||
set_hex_from_colour(c1) => {
|
||||
return AuraPageData.set_hex_from_colour(c1);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
SystemDropdown {
|
||||
text: @tr("Brightness");
|
||||
current_index <=> AuraPageData.brightness;
|
||||
current_value: AuraPageData.brightness_names[self.current-index];
|
||||
model <=> AuraPageData.brightness_names;
|
||||
selected => {
|
||||
AuraPageData.set_brightness(AuraPageData.brightness)
|
||||
}
|
||||
}
|
||||
|
||||
VerticalBox {
|
||||
Text {
|
||||
text: @tr("Colour 2");
|
||||
vertical-alignment: TextVerticalAlignment.center;
|
||||
horizontal-alignment: TextHorizontalAlignment.center;
|
||||
SystemDropdown {
|
||||
width: root.width * 1px / 2px;
|
||||
text: @tr("Aura mode");
|
||||
current_index <=> AuraPageData.current_available_mode;
|
||||
current_value: AuraPageData.available_mode_names[self.current-index];
|
||||
model <=> AuraPageData.available_mode_names;
|
||||
selected => {
|
||||
AuraPageData.led_mode_data.mode = AuraPageData.led_mode;
|
||||
AuraPageData.led_mode_data.mode = AuraPageData.current_available_mode;
|
||||
self.current_value = AuraPageData.available_mode_names[self.current-index];
|
||||
AuraPageData.set_led_mode(AuraPageData.current_available_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RogItem {
|
||||
min-height: 220px;
|
||||
max-height: 400px;
|
||||
HorizontalLayout {
|
||||
spacing: 10px;
|
||||
VerticalBox {
|
||||
Text {
|
||||
text: @tr("Colour 1");
|
||||
vertical-alignment: TextVerticalAlignment.center;
|
||||
horizontal-alignment: TextHorizontalAlignment.center;
|
||||
}
|
||||
|
||||
HorizontalBox {
|
||||
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;
|
||||
colourbox <=> AuraPageData.colorbox1;
|
||||
set_hex_from_colour(c1) => {
|
||||
return AuraPageData.set_hex_from_colour(c1);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalBox {
|
||||
c2 := ColourSlider {
|
||||
enabled: AuraPageData.led_mode == 1 || AuraPageData.led_mode == 4;
|
||||
final_colour <=> AuraPageData.color2;
|
||||
colourbox <=> AuraPageData.colorbox2;
|
||||
set_hex_from_colour(c1) => {
|
||||
return AuraPageData.set_hex_from_colour(c1);
|
||||
}
|
||||
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);
|
||||
VerticalBox {
|
||||
Text {
|
||||
text: @tr("Colour 2");
|
||||
vertical-alignment: TextVerticalAlignment.center;
|
||||
horizontal-alignment: TextHorizontalAlignment.center;
|
||||
}
|
||||
|
||||
HorizontalBox {
|
||||
c2 := ColourSlider {
|
||||
enabled: AuraPageData.led_mode == 1 || AuraPageData.led_mode == 4;
|
||||
final_colour <=> AuraPageData.color2;
|
||||
colourbox <=> AuraPageData.colorbox2;
|
||||
set_hex_from_colour(c1) => {
|
||||
return AuraPageData.set_hex_from_colour(c1);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 10px;
|
||||
RogItem {
|
||||
padding: 0px;
|
||||
VerticalBox {
|
||||
Text {
|
||||
text: @tr("Zone");
|
||||
vertical-alignment: TextVerticalAlignment.center;
|
||||
horizontal-alignment: TextHorizontalAlignment.center;
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 10px;
|
||||
min-height: 80px;
|
||||
max-height: 90px;
|
||||
RogItem {
|
||||
padding: 0px;
|
||||
VerticalBox {
|
||||
Text {
|
||||
text: @tr("Zone");
|
||||
vertical-alignment: TextVerticalAlignment.center;
|
||||
horizontal-alignment: TextHorizontalAlignment.center;
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
// enabled: AuraPageData.led_mode == ;
|
||||
ComboBox {
|
||||
// enabled: AuraPageData.led_mode == ;
|
||||
enabled: false;
|
||||
current_index <=> AuraPageData.zone;
|
||||
current_value: AuraPageData.zone_names[self.current-index];
|
||||
model <=> AuraPageData.zone_names;
|
||||
selected => {
|
||||
AuraPageData.led_mode_data.zone = self.current-index;
|
||||
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data);
|
||||
current_index <=> AuraPageData.zone;
|
||||
current_value: AuraPageData.zone_names[self.current-index];
|
||||
model <=> AuraPageData.zone_names;
|
||||
selected => {
|
||||
AuraPageData.led_mode_data.zone = self.current-index;
|
||||
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RogItem {
|
||||
padding: 0px;
|
||||
VerticalBox {
|
||||
Text {
|
||||
text: @tr("Direction");
|
||||
vertical-alignment: TextVerticalAlignment.center;
|
||||
horizontal-alignment: TextHorizontalAlignment.center;
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
enabled: AuraPageData.led_mode == 3;
|
||||
current_index <=> AuraPageData.direction;
|
||||
current_value: AuraPageData.direction_names[self.current-index];
|
||||
model <=> AuraPageData.direction_names;
|
||||
selected => {
|
||||
AuraPageData.led_mode_data.direction = self.current-index;
|
||||
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RogItem {
|
||||
padding: 0px;
|
||||
VerticalBox {
|
||||
Text {
|
||||
text: @tr("Speed");
|
||||
vertical-alignment: TextVerticalAlignment.center;
|
||||
horizontal-alignment: TextHorizontalAlignment.center;
|
||||
}
|
||||
|
||||
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_value: AuraPageData.speed_names[self.current-index];
|
||||
model <=> AuraPageData.speed_names;
|
||||
selected => {
|
||||
AuraPageData.led_mode_data.speed = self.current-index;
|
||||
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RogItem {
|
||||
padding: 0px;
|
||||
VerticalBox {
|
||||
Text {
|
||||
text: @tr("Direction");
|
||||
vertical-alignment: TextVerticalAlignment.center;
|
||||
horizontal-alignment: TextHorizontalAlignment.center;
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
enabled: AuraPageData.led_mode == 3;
|
||||
current_index <=> AuraPageData.direction;
|
||||
current_value: AuraPageData.direction_names[self.current-index];
|
||||
model <=> AuraPageData.direction_names;
|
||||
selected => {
|
||||
AuraPageData.led_mode_data.direction = self.current-index;
|
||||
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RogItem {
|
||||
padding: 0px;
|
||||
VerticalBox {
|
||||
Text {
|
||||
text: @tr("Speed");
|
||||
vertical-alignment: TextVerticalAlignment.center;
|
||||
horizontal-alignment: TextHorizontalAlignment.center;
|
||||
}
|
||||
|
||||
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_value: AuraPageData.speed_names[self.current-index];
|
||||
model <=> AuraPageData.speed_names;
|
||||
selected => {
|
||||
AuraPageData.led_mode_data.speed = self.current-index;
|
||||
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data);
|
||||
}
|
||||
HorizontalLayout {
|
||||
Button {
|
||||
text: @tr("Power Settings");
|
||||
clicked => {
|
||||
root.show_fade_cover = true;
|
||||
root.show_aura_power = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalBox {
|
||||
Button {
|
||||
text: @tr("Power Settings");
|
||||
clicked => {
|
||||
root.show_fade_cover = true;
|
||||
root.show_aura_power = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if root.show_fade_cover: Rectangle {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: Palette.background;
|
||||
opacity: 0.8;
|
||||
TouchArea {
|
||||
height: 100%;
|
||||
if root.show_fade_cover: Rectangle {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: Palette.background;
|
||||
opacity: 0.8;
|
||||
TouchArea {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +212,7 @@ export component PageAura inherits Rectangle {
|
||||
padding: 30px;
|
||||
padding-top: 10px;
|
||||
spacing: 10px;
|
||||
alignment: LayoutAlignment.start;
|
||||
|
||||
for state[idx] in AuraPageData.led_power.states: zone := AuraPowerGroup {
|
||||
group-title: AuraPageData.power_zone_names[state.zone_name_idx];
|
||||
|
||||
@@ -19,7 +19,6 @@ component FanTab inherits Rectangle {
|
||||
HorizontalLayout {
|
||||
if root.tab_enabled: Graph {
|
||||
nodes <=> root.nodes;
|
||||
|
||||
}
|
||||
if !root.tab_enabled: Rectangle {
|
||||
Text {
|
||||
|
||||
@@ -81,7 +81,7 @@ export component ColourSlider inherits VerticalLayout {
|
||||
hsv(base_colour.to-hsv().hue, 1, 0),
|
||||
];
|
||||
|
||||
function set_base_colour(){
|
||||
function set_base_colour() {
|
||||
root.base_colour = hsv(c1.value / base_colours.length * 360, 1, 1);
|
||||
root.final_colour = hsv(base_colour.to-hsv().hue, ((base_saturation.length - c2.value) / base_saturation.length), ((base_value.length - c3.value) / base_value.length));
|
||||
root.colourbox = root.final_colour;
|
||||
|
||||
@@ -197,7 +197,7 @@ export component PopupNotification {
|
||||
}
|
||||
}
|
||||
|
||||
public function show(){
|
||||
public function show() {
|
||||
_p.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,16 +26,20 @@ export component Graph inherits Rectangle {
|
||||
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 n in 11: Path {
|
||||
viewbox-width: self.width / 1px;
|
||||
@@ -43,21 +47,23 @@ export component Graph inherits Rectangle {
|
||||
stroke: Palette.alternate-foreground.darker(200%);
|
||||
stroke-width: 1px;
|
||||
MoveTo {
|
||||
x: scale_x_to_graph(n*10px) / 1px;
|
||||
y: 0; // scale_y_to_graph(n*1px) / 1px;
|
||||
x: scale_x_to_graph(n * 10px) / 1px;
|
||||
y: 0;
|
||||
// scale_y_to_graph(n*1px) / 1px;
|
||||
}
|
||||
|
||||
LineTo {
|
||||
x: scale_x_to_graph(n*10px) / 1px;
|
||||
y: graph.height / 1px; //scale_y_to_graph(n*1px) / 1px;
|
||||
x: scale_x_to_graph(n * 10px) / 1px;
|
||||
y: graph.height / 1px;
|
||||
//scale_y_to_graph(n*1px) / 1px;
|
||||
}
|
||||
}
|
||||
|
||||
for n in 11: Text {
|
||||
color: Palette.accent-background;
|
||||
font-size <=> root.axis_font_size;
|
||||
text: "\{n*10}c";
|
||||
x: scale_x_to_graph(n*10px) - self.width / 3;
|
||||
text: "\{n * 10}c";
|
||||
x: scale_x_to_graph(n * 10px) - self.width / 3;
|
||||
y: graph.height + 2px;
|
||||
}
|
||||
|
||||
@@ -67,22 +73,24 @@ export component Graph inherits Rectangle {
|
||||
stroke: Palette.alternate-foreground.darker(200%);
|
||||
stroke-width: 1px;
|
||||
MoveTo {
|
||||
x: 0; //scale_x_to_graph(n*10px) / 1px;
|
||||
y: scale_y_to_graph(n*25.5px) / 1px;
|
||||
x: 0;
|
||||
//scale_x_to_graph(n*10px) / 1px;
|
||||
y: scale_y_to_graph(n * 25.5px) / 1px;
|
||||
}
|
||||
|
||||
LineTo {
|
||||
x: graph.width / 1px; //scale_x_to_graph(n*10px) / 1px;
|
||||
y: scale_y_to_graph(n*25.5px) / 1px;
|
||||
x: graph.width / 1px;
|
||||
//scale_x_to_graph(n*10px) / 1px;
|
||||
y: scale_y_to_graph(n * 25.5px) / 1px;
|
||||
}
|
||||
}
|
||||
|
||||
for n in 11: Text {
|
||||
color: Palette.accent-background;
|
||||
font-size <=> root.axis_font_size;
|
||||
text: "\{n*10}%";
|
||||
text: "\{n * 10}%";
|
||||
x: - self.width;
|
||||
y: graph.height - scale_y_to_graph(n*25.5px) - self.height / 2;
|
||||
y: graph.height - scale_y_to_graph(n * 25.5px) - self.height / 2;
|
||||
}
|
||||
|
||||
for l[idx] in nodes: path := Rectangle {
|
||||
@@ -115,7 +123,8 @@ export component Graph inherits Rectangle {
|
||||
tip.background: Palette.accent-background;
|
||||
tip.opacity: 1.0;
|
||||
}
|
||||
]//
|
||||
]
|
||||
//
|
||||
point := Rectangle {
|
||||
background: Palette.control-foreground;
|
||||
x: scale_x_to_graph(n.x) - self.width / 2;
|
||||
@@ -133,7 +142,6 @@ export component Graph inherits Rectangle {
|
||||
} 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;
|
||||
}
|
||||
|
||||
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;
|
||||
} else if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) < nodes[idx - 1].y {
|
||||
@@ -145,7 +153,6 @@ export component Graph inherits Rectangle {
|
||||
} 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;
|
||||
}
|
||||
|
||||
if n.y - scale_y_to_node(self.mouse-y - self.pressed-y) < 0.0 {
|
||||
n.y = 1px;
|
||||
} else if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) > nodes[idx + 1].y {
|
||||
@@ -157,14 +164,14 @@ export component Graph inherits Rectangle {
|
||||
} 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;
|
||||
}
|
||||
|
||||
if n.y - scale_y_to_node(self.mouse-y - self.pressed-y) > scale_y_to_node(graph.height) {
|
||||
n.y = scale_y_to_node(graph.height - 1px);
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
}//
|
||||
}
|
||||
//
|
||||
moved => {
|
||||
if (self.pressed) {
|
||||
n.x += scale_x_to_node(self.mouse-x - self.pressed-x);
|
||||
@@ -190,27 +197,32 @@ export component Graph inherits Rectangle {
|
||||
height: label.preferred-height;
|
||||
function x_pos() -> length {
|
||||
scale_x_to_graph(n.x) - label.preferred-width - 8px
|
||||
}//
|
||||
}
|
||||
//
|
||||
function final_x_pos() -> length {
|
||||
if x_pos() > 0 {
|
||||
x_pos()
|
||||
} else {
|
||||
x_pos() + label.preferred-width
|
||||
}
|
||||
}//
|
||||
}
|
||||
//
|
||||
function y_pos() -> length {
|
||||
graph.height - scale_y_to_graph(n.y) - self.height - 4px
|
||||
}//
|
||||
}
|
||||
//
|
||||
function final_y_pos() -> length {
|
||||
if y_pos() > 0 {
|
||||
y_pos()
|
||||
} else {
|
||||
y_pos() + label.preferred-height
|
||||
}
|
||||
}//
|
||||
}
|
||||
//
|
||||
function fan_pct() -> int {
|
||||
Math.floor(n.y / 1px) / 255 * 100
|
||||
}//
|
||||
}
|
||||
//
|
||||
label := Text {
|
||||
color: Palette.accent-foreground;
|
||||
font-size: 16px;
|
||||
|
||||
Reference in New Issue
Block a user