Fix sensors
Signed-off-by: Vasiliy Doylov <nekodevelopper@gmail.com>
This commit is contained in:
parent
de2add8d0f
commit
ad3636e69f
2 changed files with 39 additions and 4 deletions
|
@ -3,18 +3,22 @@ class TheCatTools.GUI.BoubleBar : Adw.Bin, Gtk.Orientable {
|
|||
public Gtk.Adjustment adjustment { get; set; default = new Gtk.Adjustment (0, -90, 90, 0, 0, 0); }
|
||||
public Gtk.Orientation orientation { get; set; }
|
||||
public Bubble bubble = new Bubble ();
|
||||
public Line clamps_ok = new Line ();
|
||||
public Gtk.Overlay overlay = new Gtk.Overlay ();
|
||||
|
||||
construct {
|
||||
width_request = 60;
|
||||
notify["value"].connect (queue_draw);
|
||||
add_css_class ("bubble-bar");
|
||||
notify["value"].connect (queue_draw);
|
||||
notify["orientation"].connect (orientation_changed);
|
||||
orientation_changed ();
|
||||
bubble.vexpand = true;
|
||||
bubble.hexpand = true;
|
||||
overlay.add_overlay (bubble);
|
||||
overlay.add_overlay (clamps_ok);
|
||||
set_child (overlay);
|
||||
notify["orientation"].connect (orientation_changed);
|
||||
orientation_changed ();
|
||||
bind_property ("orientation", clamps_ok, "orientation", GLib.BindingFlags.SYNC_CREATE);
|
||||
clamps_ok.bind_state_to_bubble_pos (bubble);
|
||||
}
|
||||
|
||||
public void orientation_changed () {
|
||||
|
@ -25,8 +29,31 @@ class TheCatTools.GUI.BoubleBar : Adw.Bin, Gtk.Orientable {
|
|||
}
|
||||
|
||||
public class Line : DrawingAreaOrientable {
|
||||
public Gtk.Adjustment adjustment { get; set; default = new Gtk.Adjustment (0, -90, 90, 0, 0, 0); }
|
||||
public Gtk.Adjustment clamps { get; set; default = new Gtk.Adjustment (0, -10, 10, 0, 0, 0); }
|
||||
construct {
|
||||
add_css_class ("line");
|
||||
}
|
||||
public void bind_state_to_bubble_pos (Bubble bubble) {
|
||||
bubble.notify["value-x"].connect (() => {
|
||||
if (bubble.value_x >= clamps.upper) {
|
||||
set_state_flags (Gtk.StateFlags.CHECKED, false);
|
||||
} else if (bubble.value_x <= clamps.lower) {
|
||||
set_state_flags (Gtk.StateFlags.CHECKED, false);
|
||||
} else
|
||||
set_state_flags (Gtk.StateFlags.CHECKED, true);
|
||||
});
|
||||
}
|
||||
|
||||
public override void draw_func (Gtk.DrawingArea self, Cairo.Context cr, int width, int height) {
|
||||
assert_not_reached ();
|
||||
var range = adjustment.upper - adjustment.lower;
|
||||
Utils.set_color_rgba (cr, get_color ());
|
||||
cr.move_to (0, height / range * (clamps.upper - adjustment.lower));
|
||||
cr.rel_line_to (width, 0);
|
||||
cr.stroke ();
|
||||
cr.move_to (0, height / range * (clamps.lower - adjustment.lower));
|
||||
cr.rel_line_to (width, 0);
|
||||
cr.stroke ();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,4 +2,12 @@
|
|||
color: var(--accent-bg-color);
|
||||
background-color: var(--view-bg-color);
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.bubble-bar>overlay>.line {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.bubble-bar>overlay>.line#checked {
|
||||
color: green;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue