Getter/setter pass Group D (Instrumentation) batch 7/7: StackLight, TankLevelAlarms, TemperatureGauge, ToggleSwitch, ToggleSwitchIlluminated, VerticalTankLevel, VuMeter
Expose draw colours as Srgb members with get_<name>_color/set_<name>_color (defaults are the original literals, rendering unchanged); tier colours for StackLight draw_tier(); needle line width for TemperatureGauge/VuMeter; lever line widths for ToggleSwitch/ToggleSwitchIlluminated. Dead colour locals that draw() never used are removed. Setters mutate state only, matching every existing setter in the codebase; the host redraws after a state change. Group D (66 Instrumentation widgets) complete.
This commit is contained in:
1 parent
7e3e0986ca
commit
9813b60339
7 files changed
+225
-81
No files matched your search
@@ -31,6 +31,15 @@ private:
|
||||
xframe::InstLamp red_;
|
||||
xframe::InstLamp amber_;
|
||||
xframe::InstLamp green_;
|
||||
// Getter/setter pass (Group D): draw colours/state exposed as properties.
|
||||
// Defaults preserve the original rendering.
|
||||
Srgb white_color_ = {255, 255, 255};
|
||||
Srgb dark_color_ = {40, 40, 40};
|
||||
Srgb hover_color_ = {0, 120, 200};
|
||||
Srgb tier_outline_color_ = {60, 60, 60};
|
||||
Srgb red_color_ = {220, 30, 30};
|
||||
Srgb amber_color_ = {230, 160, 20};
|
||||
Srgb green_color_ = {30, 200, 60};
|
||||
public:
|
||||
std::function<void()> on_click;
|
||||
|
||||
@@ -81,26 +90,41 @@ public:
|
||||
unsigned long c = styles_->get_color_rgb((unsigned char)(r * f), (unsigned char)(g * f), (unsigned char)(b * f));
|
||||
XSetForeground(display_, gc_, c);
|
||||
XFillRectangle(display_, window_, gc_, x, y, w, h);
|
||||
XSetForeground(display_, gc_, styles_->get_color_rgb(60, 60, 60));
|
||||
XSetForeground(display_, gc_, styles_->get_color_rgb(tier_outline_color_.r, tier_outline_color_.g, tier_outline_color_.b));
|
||||
XDrawRectangle(display_, window_, gc_, x, y, w, h);
|
||||
SStyle st = style();
|
||||
int tw = xf::text_width(st, lab);
|
||||
xf::draw_text_at(display_, window_, gc_, st, x + (w - tw) / 2, y + h / 2 + 5, lab);
|
||||
}
|
||||
|
||||
// Exposed draw colours/state (Group D getter/setter pass).
|
||||
Srgb get_white_color() const { return white_color_; }
|
||||
void set_white_color(Srgb c) { white_color_ = c; }
|
||||
Srgb get_dark_color() const { return dark_color_; }
|
||||
void set_dark_color(Srgb c) { dark_color_ = c; }
|
||||
Srgb get_hover_color() const { return hover_color_; }
|
||||
void set_hover_color(Srgb c) { hover_color_ = c; }
|
||||
Srgb get_tier_outline_color() const { return tier_outline_color_; }
|
||||
void set_tier_outline_color(Srgb c) { tier_outline_color_ = c; }
|
||||
Srgb get_red_color() const { return red_color_; }
|
||||
void set_red_color(Srgb c) { red_color_ = c; }
|
||||
Srgb get_amber_color() const { return amber_color_; }
|
||||
void set_amber_color(Srgb c) { amber_color_ = c; }
|
||||
Srgb get_green_color() const { return green_color_; }
|
||||
void set_green_color(Srgb c) { green_color_ = c; }
|
||||
void draw() {
|
||||
if (!visible_) return;
|
||||
SStyle st = style();
|
||||
unsigned long white = styles_->get_color_rgb(255, 255, 255);
|
||||
unsigned long dark = styles_->get_color_rgb(40, 40, 40);
|
||||
unsigned long white = styles_->get_color_rgb(white_color_.r, white_color_.g, white_color_.b);
|
||||
unsigned long dark = styles_->get_color_rgb(dark_color_.r, dark_color_.g, dark_color_.b);
|
||||
XSetForeground(display_, gc_, white);
|
||||
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
|
||||
int cx = (x1_ + x2_) / 2;
|
||||
int tw2 = 70;
|
||||
int th = tier_h();
|
||||
draw_tier(cx - tw2 / 2, tier_y(0), tw2, th, red_, 220, 30, 30, "R");
|
||||
draw_tier(cx - tw2 / 2, tier_y(1), tw2, th, amber_, 230, 160, 20, "A");
|
||||
draw_tier(cx - tw2 / 2, tier_y(2), tw2, th, green_, 30, 200, 60, "G");
|
||||
draw_tier(cx - tw2 / 2, tier_y(0), tw2, th, red_, red_color_.r, red_color_.g, red_color_.b, "R");
|
||||
draw_tier(cx - tw2 / 2, tier_y(1), tw2, th, amber_, amber_color_.r, amber_color_.g, amber_color_.b, "A");
|
||||
draw_tier(cx - tw2 / 2, tier_y(2), tw2, th, green_, green_color_.r, green_color_.g, green_color_.b, "G");
|
||||
int pole_top = tier_y(2) + th + 4;
|
||||
int pole_bot = std::max(pole_top + 1, y2_ - 30);
|
||||
XSetForeground(display_, gc_, dark);
|
||||
@@ -109,7 +133,7 @@ public:
|
||||
int tw = xf::text_width(st, text_);
|
||||
xf::draw_text_at(display_, window_, gc_, st, cx - tw / 2, y2_ - 6, text_);
|
||||
if (hovered_ || focused_) {
|
||||
XSetForeground(display_, gc_, styles_->get_color_rgb(0, 120, 200));
|
||||
XSetForeground(display_, gc_, styles_->get_color_rgb(hover_color_.r, hover_color_.g, hover_color_.b));
|
||||
XDrawRectangle(display_, window_, gc_, x1_ + 1, y1_ + 1, width() - 2, height() - 2);
|
||||
}
|
||||
XSetForeground(display_, gc_, st.lineColor_);
|
||||
|
||||
@@ -31,6 +31,16 @@ private:
|
||||
xframe::InstAlarmBands bands_;
|
||||
std::function<void()> on_click_;
|
||||
|
||||
// Getter/setter pass (Group D): draw colours/state exposed as properties.
|
||||
// Defaults preserve the original rendering.
|
||||
Srgb white_color_ = {255, 255, 255};
|
||||
Srgb ink_color_ = {60, 60, 60};
|
||||
Srgb pale_color_ = {235, 242, 248};
|
||||
Srgb fill_color_ = {40, 120, 200};
|
||||
Srgb grid_color_ = {210, 210, 210};
|
||||
Srgb amber_color_ = {220, 150, 0};
|
||||
Srgb red_color_ = {200, 30, 30};
|
||||
Srgb hover_color_ = {255, 170, 0};
|
||||
public:
|
||||
InstTankLevelAlarms(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||
int x, int y, int width, int height, double level = xframe::inst_demo_level(47)) {
|
||||
@@ -71,16 +81,33 @@ public:
|
||||
double f = 1.0 - (double)(y - ty) / (double)th;
|
||||
return xframe::inst_clamp_level(f * 100.0);
|
||||
}
|
||||
// Exposed draw colours/state (Group D getter/setter pass).
|
||||
Srgb get_white_color() const { return white_color_; }
|
||||
void set_white_color(Srgb c) { white_color_ = c; }
|
||||
Srgb get_ink_color() const { return ink_color_; }
|
||||
void set_ink_color(Srgb c) { ink_color_ = c; }
|
||||
Srgb get_pale_color() const { return pale_color_; }
|
||||
void set_pale_color(Srgb c) { pale_color_ = c; }
|
||||
Srgb get_fill_color() const { return fill_color_; }
|
||||
void set_fill_color(Srgb c) { fill_color_ = c; }
|
||||
Srgb get_grid_color() const { return grid_color_; }
|
||||
void set_grid_color(Srgb c) { grid_color_ = c; }
|
||||
Srgb get_amber_color() const { return amber_color_; }
|
||||
void set_amber_color(Srgb c) { amber_color_ = c; }
|
||||
Srgb get_red_color() const { return red_color_; }
|
||||
void set_red_color(Srgb c) { red_color_ = c; }
|
||||
Srgb get_hover_color() const { return hover_color_; }
|
||||
void set_hover_color(Srgb c) { hover_color_ = c; }
|
||||
void draw() {
|
||||
if (!visible_) return;
|
||||
SStyle st = style();
|
||||
unsigned long white = styles_->get_color_rgb(255, 255, 255);
|
||||
unsigned long ink = styles_->get_color_rgb(60, 60, 60);
|
||||
unsigned long pale = styles_->get_color_rgb(235, 242, 248);
|
||||
unsigned long fillc = styles_->get_color_rgb(40, 120, 200);
|
||||
unsigned long grid = styles_->get_color_rgb(210, 210, 210);
|
||||
unsigned long amber = styles_->get_color_rgb(220, 150, 0);
|
||||
unsigned long red = styles_->get_color_rgb(200, 30, 30);
|
||||
unsigned long white = styles_->get_color_rgb(white_color_.r, white_color_.g, white_color_.b);
|
||||
unsigned long ink = styles_->get_color_rgb(ink_color_.r, ink_color_.g, ink_color_.b);
|
||||
unsigned long pale = styles_->get_color_rgb(pale_color_.r, pale_color_.g, pale_color_.b);
|
||||
unsigned long fillc = styles_->get_color_rgb(fill_color_.r, fill_color_.g, fill_color_.b);
|
||||
unsigned long grid = styles_->get_color_rgb(grid_color_.r, grid_color_.g, grid_color_.b);
|
||||
unsigned long amber = styles_->get_color_rgb(amber_color_.r, amber_color_.g, amber_color_.b);
|
||||
unsigned long red = styles_->get_color_rgb(red_color_.r, red_color_.g, red_color_.b);
|
||||
XSetForeground(display_, gc_, white);
|
||||
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
|
||||
int tx = x1_ + 60;
|
||||
@@ -119,7 +146,7 @@ public:
|
||||
int pw2 = xf::text_width(st, pct);
|
||||
xf::draw_text_at(display_, window_, gc_, st, tx + (tw - pw2) / 2, ty + th + 18, pct);
|
||||
xf::draw_text_at(display_, window_, gc_, st, x1_ + 8, y1_ + 16, text_);
|
||||
XSetForeground(display_, gc_, hovered_ ? styles_->get_color_rgb(255, 170, 0) : st.lineColor_);
|
||||
XSetForeground(display_, gc_, hovered_ ? styles_->get_color_rgb(hover_color_.r, hover_color_.g, hover_color_.b) : st.lineColor_);
|
||||
XDrawRectangle(display_, window_, gc_, x1_, y1_, width(), height());
|
||||
XFlush(display_);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,13 @@ private:
|
||||
double max_ = 200;
|
||||
double value_ = 85.0;
|
||||
|
||||
// Getter/setter pass (Group D): draw colours/state exposed as properties.
|
||||
// Defaults preserve the original rendering.
|
||||
Srgb white_color_ = {255, 255, 255};
|
||||
Srgb face_color_ = {245, 245, 240};
|
||||
Srgb ink_color_ = {40, 40, 40};
|
||||
Srgb red_color_ = {200, 30, 30};
|
||||
int needle_line_width_ = 3;
|
||||
public:
|
||||
InstTemperatureGauge(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||
int x, int y, int width, int height, double value = 85.0) {
|
||||
@@ -66,21 +73,24 @@ public:
|
||||
std::ostringstream oss; oss.precision(prec); oss << std::fixed << v;
|
||||
return oss.str();
|
||||
}
|
||||
// Exposed draw colours/state (Group D getter/setter pass).
|
||||
Srgb get_white_color() const { return white_color_; }
|
||||
void set_white_color(Srgb c) { white_color_ = c; }
|
||||
Srgb get_face_color() const { return face_color_; }
|
||||
void set_face_color(Srgb c) { face_color_ = c; }
|
||||
Srgb get_ink_color() const { return ink_color_; }
|
||||
void set_ink_color(Srgb c) { ink_color_ = c; }
|
||||
Srgb get_red_color() const { return red_color_; }
|
||||
void set_red_color(Srgb c) { red_color_ = c; }
|
||||
int get_needle_line_width() const { return needle_line_width_; }
|
||||
void set_needle_line_width(int w) { needle_line_width_ = w; }
|
||||
void draw() {
|
||||
if (!visible_) return;
|
||||
SStyle st = style();
|
||||
unsigned long white = styles_->get_color_rgb(255, 255, 255);
|
||||
unsigned long face = styles_->get_color_rgb(245, 245, 240);
|
||||
unsigned long ink = styles_->get_color_rgb(40, 40, 40);
|
||||
unsigned long grey = styles_->get_color_rgb(150, 150, 150);
|
||||
unsigned long red = styles_->get_color_rgb(200, 30, 30);
|
||||
unsigned long amber = styles_->get_color_rgb(255, 176, 0);
|
||||
unsigned long green = styles_->get_color_rgb(0, 150, 0);
|
||||
unsigned long blue = styles_->get_color_rgb(30, 120, 200);
|
||||
unsigned long dark = styles_->get_color_rgb(30, 30, 30);
|
||||
unsigned long panel = styles_->get_color_rgb(210, 210, 205);
|
||||
(void)white; (void)face; (void)ink; (void)grey; (void)red; (void)amber;
|
||||
(void)green; (void)blue; (void)dark; (void)panel;
|
||||
unsigned long white = styles_->get_color_rgb(white_color_.r, white_color_.g, white_color_.b);
|
||||
unsigned long face = styles_->get_color_rgb(face_color_.r, face_color_.g, face_color_.b);
|
||||
unsigned long ink = styles_->get_color_rgb(ink_color_.r, ink_color_.g, ink_color_.b);
|
||||
unsigned long red = styles_->get_color_rgb(red_color_.r, red_color_.g, red_color_.b);
|
||||
XSetForeground(display_, gc_, white);
|
||||
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
|
||||
int cx = (x1_ + x2_) / 2;
|
||||
@@ -111,7 +121,7 @@ public:
|
||||
double nang = (225.0 - 270.0 * fraction()) * pi / 180.0;
|
||||
int nx = cx + (int)((r - 14) * std::cos(nang));
|
||||
int ny = cy - (int)((r - 14) * std::sin(nang));
|
||||
XSetLineAttributes(display_, gc_, 3, LineSolid, CapRound, JoinMiter);
|
||||
XSetLineAttributes(display_, gc_, needle_line_width_, LineSolid, CapRound, JoinMiter);
|
||||
XSetForeground(display_, gc_, red);
|
||||
XDrawLine(display_, window_, gc_, cx, cy, nx, ny);
|
||||
XSetLineAttributes(display_, gc_, 1, LineSolid, CapButt, JoinMiter);
|
||||
|
||||
@@ -27,6 +27,17 @@ private:
|
||||
bool pressed_ = false;
|
||||
bool on_ = false;
|
||||
|
||||
// Getter/setter pass (Group D): draw colours/state exposed as properties.
|
||||
// Defaults preserve the original rendering.
|
||||
Srgb white_color_ = {255, 255, 255};
|
||||
Srgb panel_color_ = {58, 58, 62};
|
||||
Srgb bezel_color_ = {38, 38, 42};
|
||||
Srgb plate_color_ = {210, 210, 210};
|
||||
Srgb dark_color_ = {40, 40, 40};
|
||||
Srgb amber_color_ = {255, 176, 0};
|
||||
Srgb greenlit_color_ = {60, 255, 90};
|
||||
Srgb redlit_color_ = {255, 70, 60};
|
||||
int lever_line_width_ = 10;
|
||||
public:
|
||||
std::function<void()> on_click;
|
||||
InstToggleSwitch(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||
@@ -53,24 +64,36 @@ public:
|
||||
bool is_on() { return on_; }
|
||||
xframe::InstSwitchState get_state() { return on_ ? xframe::InstSwitchState::On : xframe::InstSwitchState::Off; }
|
||||
|
||||
// Exposed draw colours/state (Group D getter/setter pass).
|
||||
Srgb get_white_color() const { return white_color_; }
|
||||
void set_white_color(Srgb c) { white_color_ = c; }
|
||||
Srgb get_panel_color() const { return panel_color_; }
|
||||
void set_panel_color(Srgb c) { panel_color_ = c; }
|
||||
Srgb get_bezel_color() const { return bezel_color_; }
|
||||
void set_bezel_color(Srgb c) { bezel_color_ = c; }
|
||||
Srgb get_plate_color() const { return plate_color_; }
|
||||
void set_plate_color(Srgb c) { plate_color_ = c; }
|
||||
Srgb get_dark_color() const { return dark_color_; }
|
||||
void set_dark_color(Srgb c) { dark_color_ = c; }
|
||||
Srgb get_amber_color() const { return amber_color_; }
|
||||
void set_amber_color(Srgb c) { amber_color_ = c; }
|
||||
Srgb get_greenlit_color() const { return greenlit_color_; }
|
||||
void set_greenlit_color(Srgb c) { greenlit_color_ = c; }
|
||||
Srgb get_redlit_color() const { return redlit_color_; }
|
||||
void set_redlit_color(Srgb c) { redlit_color_ = c; }
|
||||
int get_lever_line_width() const { return lever_line_width_; }
|
||||
void set_lever_line_width(int w) { lever_line_width_ = w; }
|
||||
void draw() {
|
||||
if (!visible_) return;
|
||||
SStyle st = style();
|
||||
unsigned long white = styles_->get_color_rgb(255, 255, 255);
|
||||
unsigned long panel = styles_->get_color_rgb(58, 58, 62);
|
||||
unsigned long bezel = styles_->get_color_rgb(38, 38, 42);
|
||||
unsigned long plate = styles_->get_color_rgb(210, 210, 210);
|
||||
unsigned long rocker = styles_->get_color_rgb(190, 190, 195);
|
||||
unsigned long dark = styles_->get_color_rgb(40, 40, 40);
|
||||
unsigned long amber = styles_->get_color_rgb(255, 176, 0);
|
||||
unsigned long green = styles_->get_color_rgb(0, 180, 0);
|
||||
unsigned long greenlit = styles_->get_color_rgb(60, 255, 90);
|
||||
unsigned long red = styles_->get_color_rgb(200, 30, 30);
|
||||
unsigned long redlit = styles_->get_color_rgb(255, 70, 60);
|
||||
unsigned long dimred = styles_->get_color_rgb(120, 30, 30);
|
||||
unsigned long outline = styles_->get_color_rgb(120, 120, 120);
|
||||
(void)white; (void)panel; (void)bezel; (void)plate; (void)rocker; (void)dark;
|
||||
(void)amber; (void)green; (void)greenlit; (void)red; (void)redlit; (void)dimred; (void)outline;
|
||||
unsigned long white = styles_->get_color_rgb(white_color_.r, white_color_.g, white_color_.b);
|
||||
unsigned long panel = styles_->get_color_rgb(panel_color_.r, panel_color_.g, panel_color_.b);
|
||||
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
|
||||
unsigned long plate = styles_->get_color_rgb(plate_color_.r, plate_color_.g, plate_color_.b);
|
||||
unsigned long dark = styles_->get_color_rgb(dark_color_.r, dark_color_.g, dark_color_.b);
|
||||
unsigned long amber = styles_->get_color_rgb(amber_color_.r, amber_color_.g, amber_color_.b);
|
||||
unsigned long greenlit = styles_->get_color_rgb(greenlit_color_.r, greenlit_color_.g, greenlit_color_.b);
|
||||
unsigned long redlit = styles_->get_color_rgb(redlit_color_.r, redlit_color_.g, redlit_color_.b);
|
||||
XSetForeground(display_, gc_, white);
|
||||
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
|
||||
int cx = (x1_ + x2_) / 2;
|
||||
@@ -83,7 +106,7 @@ public:
|
||||
int ly = on_ ? cy - 78 : cy + 78;
|
||||
XSetForeground(display_, gc_, dark);
|
||||
XDrawLine(display_, window_, gc_, cx, cy, lx, ly);
|
||||
xf::set_line_width(display_, gc_, 10);
|
||||
xf::set_line_width(display_, gc_, lever_line_width_);
|
||||
XSetForeground(display_, gc_, plate);
|
||||
XDrawLine(display_, window_, gc_, cx, cy, lx, ly);
|
||||
xf::set_line_width(display_, gc_, 1);
|
||||
|
||||
@@ -27,6 +27,17 @@ private:
|
||||
bool pressed_ = false;
|
||||
bool on_ = false;
|
||||
|
||||
// Getter/setter pass (Group D): draw colours/state exposed as properties.
|
||||
// Defaults preserve the original rendering.
|
||||
Srgb white_color_ = {255, 255, 255};
|
||||
Srgb panel_color_ = {58, 58, 62};
|
||||
Srgb bezel_color_ = {38, 38, 42};
|
||||
Srgb plate_color_ = {210, 210, 210};
|
||||
Srgb dark_color_ = {40, 40, 40};
|
||||
Srgb amber_color_ = {255, 176, 0};
|
||||
Srgb greenlit_color_ = {60, 255, 90};
|
||||
Srgb dimred_color_ = {120, 30, 30};
|
||||
int lever_line_width_ = 10;
|
||||
public:
|
||||
std::function<void()> on_click;
|
||||
InstToggleSwitchIlluminated(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||
@@ -53,24 +64,36 @@ public:
|
||||
bool is_on() { return on_; }
|
||||
xframe::InstSwitchState get_state() { return on_ ? xframe::InstSwitchState::On : xframe::InstSwitchState::Off; }
|
||||
|
||||
// Exposed draw colours/state (Group D getter/setter pass).
|
||||
Srgb get_white_color() const { return white_color_; }
|
||||
void set_white_color(Srgb c) { white_color_ = c; }
|
||||
Srgb get_panel_color() const { return panel_color_; }
|
||||
void set_panel_color(Srgb c) { panel_color_ = c; }
|
||||
Srgb get_bezel_color() const { return bezel_color_; }
|
||||
void set_bezel_color(Srgb c) { bezel_color_ = c; }
|
||||
Srgb get_plate_color() const { return plate_color_; }
|
||||
void set_plate_color(Srgb c) { plate_color_ = c; }
|
||||
Srgb get_dark_color() const { return dark_color_; }
|
||||
void set_dark_color(Srgb c) { dark_color_ = c; }
|
||||
Srgb get_amber_color() const { return amber_color_; }
|
||||
void set_amber_color(Srgb c) { amber_color_ = c; }
|
||||
Srgb get_greenlit_color() const { return greenlit_color_; }
|
||||
void set_greenlit_color(Srgb c) { greenlit_color_ = c; }
|
||||
Srgb get_dimred_color() const { return dimred_color_; }
|
||||
void set_dimred_color(Srgb c) { dimred_color_ = c; }
|
||||
int get_lever_line_width() const { return lever_line_width_; }
|
||||
void set_lever_line_width(int w) { lever_line_width_ = w; }
|
||||
void draw() {
|
||||
if (!visible_) return;
|
||||
SStyle st = style();
|
||||
unsigned long white = styles_->get_color_rgb(255, 255, 255);
|
||||
unsigned long panel = styles_->get_color_rgb(58, 58, 62);
|
||||
unsigned long bezel = styles_->get_color_rgb(38, 38, 42);
|
||||
unsigned long plate = styles_->get_color_rgb(210, 210, 210);
|
||||
unsigned long rocker = styles_->get_color_rgb(190, 190, 195);
|
||||
unsigned long dark = styles_->get_color_rgb(40, 40, 40);
|
||||
unsigned long amber = styles_->get_color_rgb(255, 176, 0);
|
||||
unsigned long green = styles_->get_color_rgb(0, 180, 0);
|
||||
unsigned long greenlit = styles_->get_color_rgb(60, 255, 90);
|
||||
unsigned long red = styles_->get_color_rgb(200, 30, 30);
|
||||
unsigned long redlit = styles_->get_color_rgb(255, 70, 60);
|
||||
unsigned long dimred = styles_->get_color_rgb(120, 30, 30);
|
||||
unsigned long outline = styles_->get_color_rgb(120, 120, 120);
|
||||
(void)white; (void)panel; (void)bezel; (void)plate; (void)rocker; (void)dark;
|
||||
(void)amber; (void)green; (void)greenlit; (void)red; (void)redlit; (void)dimred; (void)outline;
|
||||
unsigned long white = styles_->get_color_rgb(white_color_.r, white_color_.g, white_color_.b);
|
||||
unsigned long panel = styles_->get_color_rgb(panel_color_.r, panel_color_.g, panel_color_.b);
|
||||
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
|
||||
unsigned long plate = styles_->get_color_rgb(plate_color_.r, plate_color_.g, plate_color_.b);
|
||||
unsigned long dark = styles_->get_color_rgb(dark_color_.r, dark_color_.g, dark_color_.b);
|
||||
unsigned long amber = styles_->get_color_rgb(amber_color_.r, amber_color_.g, amber_color_.b);
|
||||
unsigned long greenlit = styles_->get_color_rgb(greenlit_color_.r, greenlit_color_.g, greenlit_color_.b);
|
||||
unsigned long dimred = styles_->get_color_rgb(dimred_color_.r, dimred_color_.g, dimred_color_.b);
|
||||
XSetForeground(display_, gc_, white);
|
||||
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
|
||||
int cx = (x1_ + x2_) / 2;
|
||||
@@ -83,7 +106,7 @@ public:
|
||||
int ly = on_ ? cy - 78 : cy + 78;
|
||||
XSetForeground(display_, gc_, dark);
|
||||
XDrawLine(display_, window_, gc_, cx, cy, lx, ly);
|
||||
xf::set_line_width(display_, gc_, 10);
|
||||
xf::set_line_width(display_, gc_, lever_line_width_);
|
||||
XSetForeground(display_, gc_, plate);
|
||||
XDrawLine(display_, window_, gc_, cx, cy, lx, ly);
|
||||
xf::set_line_width(display_, gc_, 1);
|
||||
|
||||
@@ -31,6 +31,16 @@ private:
|
||||
xframe::InstAlarmBands bands_;
|
||||
std::function<void()> on_click_;
|
||||
|
||||
// Getter/setter pass (Group D): draw colours/state exposed as properties.
|
||||
// Defaults preserve the original rendering.
|
||||
Srgb white_color_ = {255, 255, 255};
|
||||
Srgb ink_color_ = {60, 60, 60};
|
||||
Srgb pale_color_ = {235, 242, 248};
|
||||
Srgb fill_color_ = {40, 120, 200};
|
||||
Srgb grid_color_ = {210, 210, 210};
|
||||
Srgb amber_color_ = {220, 150, 0};
|
||||
Srgb red_color_ = {200, 30, 30};
|
||||
Srgb hover_color_ = {255, 170, 0};
|
||||
public:
|
||||
InstVerticalTankLevel(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||
int x, int y, int width, int height, double level = xframe::inst_demo_level(42)) {
|
||||
@@ -71,16 +81,33 @@ public:
|
||||
double f = 1.0 - (double)(y - ty) / (double)th;
|
||||
return xframe::inst_clamp_level(f * 100.0);
|
||||
}
|
||||
// Exposed draw colours/state (Group D getter/setter pass).
|
||||
Srgb get_white_color() const { return white_color_; }
|
||||
void set_white_color(Srgb c) { white_color_ = c; }
|
||||
Srgb get_ink_color() const { return ink_color_; }
|
||||
void set_ink_color(Srgb c) { ink_color_ = c; }
|
||||
Srgb get_pale_color() const { return pale_color_; }
|
||||
void set_pale_color(Srgb c) { pale_color_ = c; }
|
||||
Srgb get_fill_color() const { return fill_color_; }
|
||||
void set_fill_color(Srgb c) { fill_color_ = c; }
|
||||
Srgb get_grid_color() const { return grid_color_; }
|
||||
void set_grid_color(Srgb c) { grid_color_ = c; }
|
||||
Srgb get_amber_color() const { return amber_color_; }
|
||||
void set_amber_color(Srgb c) { amber_color_ = c; }
|
||||
Srgb get_red_color() const { return red_color_; }
|
||||
void set_red_color(Srgb c) { red_color_ = c; }
|
||||
Srgb get_hover_color() const { return hover_color_; }
|
||||
void set_hover_color(Srgb c) { hover_color_ = c; }
|
||||
void draw() {
|
||||
if (!visible_) return;
|
||||
SStyle st = style();
|
||||
unsigned long white = styles_->get_color_rgb(255, 255, 255);
|
||||
unsigned long ink = styles_->get_color_rgb(60, 60, 60);
|
||||
unsigned long pale = styles_->get_color_rgb(235, 242, 248);
|
||||
unsigned long fillc = styles_->get_color_rgb(40, 120, 200);
|
||||
unsigned long grid = styles_->get_color_rgb(210, 210, 210);
|
||||
unsigned long amber = styles_->get_color_rgb(220, 150, 0);
|
||||
unsigned long red = styles_->get_color_rgb(200, 30, 30);
|
||||
unsigned long white = styles_->get_color_rgb(white_color_.r, white_color_.g, white_color_.b);
|
||||
unsigned long ink = styles_->get_color_rgb(ink_color_.r, ink_color_.g, ink_color_.b);
|
||||
unsigned long pale = styles_->get_color_rgb(pale_color_.r, pale_color_.g, pale_color_.b);
|
||||
unsigned long fillc = styles_->get_color_rgb(fill_color_.r, fill_color_.g, fill_color_.b);
|
||||
unsigned long grid = styles_->get_color_rgb(grid_color_.r, grid_color_.g, grid_color_.b);
|
||||
unsigned long amber = styles_->get_color_rgb(amber_color_.r, amber_color_.g, amber_color_.b);
|
||||
unsigned long red = styles_->get_color_rgb(red_color_.r, red_color_.g, red_color_.b);
|
||||
XSetForeground(display_, gc_, white);
|
||||
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
|
||||
int tx = x1_ + 60;
|
||||
@@ -117,7 +144,7 @@ public:
|
||||
int pw2 = xf::text_width(st, pct);
|
||||
xf::draw_text_at(display_, window_, gc_, st, tx + (tw - pw2) / 2, ty + th + 18, pct);
|
||||
xf::draw_text_at(display_, window_, gc_, st, x1_ + 8, y1_ + 16, text_);
|
||||
XSetForeground(display_, gc_, hovered_ ? styles_->get_color_rgb(255, 170, 0) : st.lineColor_);
|
||||
XSetForeground(display_, gc_, hovered_ ? styles_->get_color_rgb(hover_color_.r, hover_color_.g, hover_color_.b) : st.lineColor_);
|
||||
XDrawRectangle(display_, window_, gc_, x1_, y1_, width(), height());
|
||||
XFlush(display_);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,13 @@ private:
|
||||
double max_ = 3;
|
||||
double value_ = -6.0;
|
||||
|
||||
// Getter/setter pass (Group D): draw colours/state exposed as properties.
|
||||
// Defaults preserve the original rendering.
|
||||
Srgb white_color_ = {255, 255, 255};
|
||||
Srgb face_color_ = {245, 245, 240};
|
||||
Srgb ink_color_ = {40, 40, 40};
|
||||
Srgb red_color_ = {200, 30, 30};
|
||||
int needle_line_width_ = 3;
|
||||
public:
|
||||
InstVuMeter(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||
int x, int y, int width, int height, double value = -6.0) {
|
||||
@@ -66,21 +73,24 @@ public:
|
||||
std::ostringstream oss; oss.precision(prec); oss << std::fixed << v;
|
||||
return oss.str();
|
||||
}
|
||||
// Exposed draw colours/state (Group D getter/setter pass).
|
||||
Srgb get_white_color() const { return white_color_; }
|
||||
void set_white_color(Srgb c) { white_color_ = c; }
|
||||
Srgb get_face_color() const { return face_color_; }
|
||||
void set_face_color(Srgb c) { face_color_ = c; }
|
||||
Srgb get_ink_color() const { return ink_color_; }
|
||||
void set_ink_color(Srgb c) { ink_color_ = c; }
|
||||
Srgb get_red_color() const { return red_color_; }
|
||||
void set_red_color(Srgb c) { red_color_ = c; }
|
||||
int get_needle_line_width() const { return needle_line_width_; }
|
||||
void set_needle_line_width(int w) { needle_line_width_ = w; }
|
||||
void draw() {
|
||||
if (!visible_) return;
|
||||
SStyle st = style();
|
||||
unsigned long white = styles_->get_color_rgb(255, 255, 255);
|
||||
unsigned long face = styles_->get_color_rgb(245, 245, 240);
|
||||
unsigned long ink = styles_->get_color_rgb(40, 40, 40);
|
||||
unsigned long grey = styles_->get_color_rgb(150, 150, 150);
|
||||
unsigned long red = styles_->get_color_rgb(200, 30, 30);
|
||||
unsigned long amber = styles_->get_color_rgb(255, 176, 0);
|
||||
unsigned long green = styles_->get_color_rgb(0, 150, 0);
|
||||
unsigned long blue = styles_->get_color_rgb(30, 120, 200);
|
||||
unsigned long dark = styles_->get_color_rgb(30, 30, 30);
|
||||
unsigned long panel = styles_->get_color_rgb(210, 210, 205);
|
||||
(void)white; (void)face; (void)ink; (void)grey; (void)red; (void)amber;
|
||||
(void)green; (void)blue; (void)dark; (void)panel;
|
||||
unsigned long white = styles_->get_color_rgb(white_color_.r, white_color_.g, white_color_.b);
|
||||
unsigned long face = styles_->get_color_rgb(face_color_.r, face_color_.g, face_color_.b);
|
||||
unsigned long ink = styles_->get_color_rgb(ink_color_.r, ink_color_.g, ink_color_.b);
|
||||
unsigned long red = styles_->get_color_rgb(red_color_.r, red_color_.g, red_color_.b);
|
||||
XSetForeground(display_, gc_, white);
|
||||
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
|
||||
int cx = (x1_ + x2_) / 2;
|
||||
@@ -111,7 +121,7 @@ public:
|
||||
double nang = (225.0 - 270.0 * fraction()) * pi / 180.0;
|
||||
int nx = cx + (int)((r - 14) * std::cos(nang));
|
||||
int ny = cy - (int)((r - 14) * std::sin(nang));
|
||||
XSetLineAttributes(display_, gc_, 3, LineSolid, CapRound, JoinMiter);
|
||||
XSetLineAttributes(display_, gc_, needle_line_width_, LineSolid, CapRound, JoinMiter);
|
||||
XSetForeground(display_, gc_, red);
|
||||
XDrawLine(display_, window_, gc_, cx, cy, nx, ny);
|
||||
XSetLineAttributes(display_, gc_, 1, LineSolid, CapButt, JoinMiter);
|
||||
|
||||
Reference in new issue
Block a user