Inst*: proportions fix (audit Dec 2026) — worst offenders

Seg14/16 + LedDigits fill widget (label band removed, ghost
segments dimmed, diagonals thinned); DigitalReadout digits scale
to display; Nameplate engraving fit to plate width; NeedleVu
red-zone numerals + VU clear of scale; dial numerals 7-8% of
diameter with titles inside below top numerals; KeySwitch NO KEY
light-on-dark; HorizontalTank capsule ends inside widget.
Shared scaled-font helpers in InstData.h (cap-height convention).
This commit is contained in:
Muse committed 2026-12-05 21:31:56 +00:00
1 parent e474894bae
commit 560d0aac2f
31 files changed
+425 -289

No files matched your search

@@ -96,6 +96,13 @@ public:
int cx = (x1_ + x2_) / 2;
int cy = (y1_ + y2_) / 2;
int r = std::min(width(), height()) / 2 - 10;
// Audit G1/G3: numerals 7-8% of dial diameter (bold), title inside
// the dial below the top numerals, value below the hub.
int numCap = std::max(14, r / 7);
SStyle stNum = st; stNum.font_ = xframe::inst_cap_font(display_, numCap);
int numAsc = stNum.font_ ? stNum.font_->ascent : 13;
SStyle stTitle = st; stTitle.font_ = xframe::inst_cap_font_prop(display_, 17);
SStyle stVal = st; stVal.font_ = xframe::inst_cap_font(display_, 18);
XSetForeground(display_, gc_, face);
XFillArc(display_, window_, gc_, cx - r, cy - r, 2 * r, 2 * r, 0, 360 * 64);
XSetForeground(display_, gc_, ink);
@@ -112,10 +119,10 @@ public:
XDrawLine(display_, window_, gc_, tx1, ty1, tx2, ty2);
if (i % 2 == 0) {
std::string lab = fmt(min_ + f * (max_ - min_));
int tw = xf::text_width(st, lab);
int lx = cx + (int)((r - 26) * std::cos(ang)) - tw / 2;
int ly = cy - (int)((r - 26) * std::sin(ang)) + 4;
xf::draw_text_at(display_, window_, gc_, st, lx, ly, lab);
int tw = xf::text_width(stNum, lab);
int lx = cx + (int)((r - numCap - 14) * std::cos(ang)) - tw / 2;
int ly = cy - (int)((r - numCap - 14) * std::sin(ang)) + numAsc / 2;
xf::draw_text_at(display_, window_, gc_, stNum, lx, ly, lab);
}
}
double nang = (225.0 - 270.0 * fraction()) * pi / 180.0;
@@ -128,10 +135,11 @@ public:
XSetForeground(display_, gc_, ink);
XFillArc(display_, window_, gc_, cx - 5, cy - 5, 10, 10, 0, 360 * 64);
std::string val = fmt(value_) + "";
int vw = xf::text_width(st, val);
xf::draw_text_at(display_, window_, gc_, st, cx - vw / 2, cy + r - 16, val);
int tw2 = xf::text_width(st, text_);
xf::draw_text_at(display_, window_, gc_, st, cx - tw2 / 2, y1_ + 16, text_);
int vw = xf::text_width(stVal, val);
xf::draw_text_at(display_, window_, gc_, stVal, cx - vw / 2, cy + r - 18, val);
// Title inside the dial, below the top numerals (audit G3).
int tw2 = xf::text_width(stTitle, text_);
xf::draw_text_at(display_, window_, gc_, stTitle, cx - tw2 / 2, cy - (int)(r * 0.43), text_); // audit G3: below the top numerals, clear of them
XSetForeground(display_, gc_, st.lineColor_);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width(), height());
+70
View File
@@ -8,6 +8,9 @@
#pragma once
#include <cstdint>
#include <cstdio>
#include <map>
#include <string>
#include <X11/Xlib.h>
@@ -94,4 +97,71 @@ inline XFontStruct* inst_bold_font(Display* display) {
return cached;
}
// Scaled bold fonts — Inst* proportions fix (Dec 2026 audit, G1).
// Audit sizes are CAP heights (glyph height); a core font's pixel size
// is ~cap / 0.72 (probed on hot_dallas: misc-fixed bold 48 px renders
// ~34 px cap-height digits; helvetica bold the same). The X server only
// ships bitmap fixed fonts at 13/14/15/18 px, but the scalable XLFD
// entries ("-...--<px>-0-75-75-...") render cleanly at any size
// (verified 14..48 px, mono + helvetica). Cached per cap height;
// falls back to inst_bold_font() when a size cannot load.
inline int inst_px_for_cap(int cap) {
if (cap <= 0) return 18;
return (cap * 100 + 71) / 72;
}
// Bold monospace font with cap height ~cap px (numerals, values).
inline XFontStruct* inst_cap_font(Display* display, int cap) {
if (!display) return nullptr;
static std::map<int, XFontStruct*> cache;
auto it = cache.find(cap);
if (it != cache.end()) return it->second;
int px = inst_px_for_cap(cap);
char name[160];
XFontStruct* f = nullptr;
std::snprintf(name, sizeof name, "-misc-fixed-bold-r-normal--%d-0-75-75-c-0-iso8859-1", px);
f = XLoadQueryFont(display, name);
if (!f) {
std::snprintf(name, sizeof name, "-adobe-helvetica-bold-r-normal--%d-0-75-75-p-0-iso8859-1", px);
f = XLoadQueryFont(display, name);
}
if (!f) f = inst_bold_font(display);
cache[cap] = f;
return f;
}
// Bold proportional font with cap height ~cap px (titles, word labels).
inline XFontStruct* inst_cap_font_prop(Display* display, int cap) {
if (!display) return nullptr;
static std::map<int, XFontStruct*> cache;
auto it = cache.find(cap);
if (it != cache.end()) return it->second;
int px = inst_px_for_cap(cap);
char name[160];
XFontStruct* f = nullptr;
std::snprintf(name, sizeof name, "-adobe-helvetica-bold-r-normal--%d-0-75-75-p-0-iso8859-1", px);
f = XLoadQueryFont(display, name);
if (!f) {
std::snprintf(name, sizeof name, "-urw-nimbus sans l-bold-r-normal--%d-0-0-0-p-0-iso8859-1", px);
f = XLoadQueryFont(display, name);
}
if (!f) f = inst_bold_font(display);
cache[cap] = f;
return f;
}
// Largest proportional-bold cap height (<= max_cap) whose rendering of
// `text` fits in target_w px; 8 px floor. Used by InstNameplate so the
// engraving fills ~40-50% of the plate width.
inline XFontStruct* inst_prop_font_fit(Display* display, const std::string& text,
int target_w, int max_cap) {
if (!display || text.empty() || target_w <= 0) return inst_cap_font_prop(display, 16);
for (int cap = max_cap; cap >= 8; --cap) {
XFontStruct* f = inst_cap_font_prop(display, cap);
if (!f) continue;
if (XTextWidth(f, text.c_str(), (int)text.size()) <= target_w) return f;
}
return inst_cap_font_prop(display, 8);
}
} // namespace xframe
@@ -35,7 +35,7 @@ private:
// Getter/setter pass (Group D): draw colours/state exposed as properties.
// Defaults preserve the original rendering.
Srgb segment_on_color_ = {255, 176, 0};
Srgb segment_off_color_ = {50, 45, 20};
Srgb segment_off_color_ = {56, 48, 20}; // audit: unlit segments slightly more visible, uniform dim
Srgb white_color_ = {255, 255, 255};
Srgb ink_color_ = {40, 40, 40};
Srgb amber_color_ = {255, 176, 0};
@@ -77,7 +77,7 @@ public:
static const bool seg[10][7] = {{1,1,1,1,1,1,0},{0,1,1,0,0,0,0},{1,1,0,1,1,0,1},{1,1,1,1,0,0,1},{0,1,1,0,0,1,1},{1,0,1,1,0,1,1},{1,0,1,1,1,1,1},{1,1,1,0,0,0,0},{1,1,1,1,1,1,1},{1,1,1,1,0,1,1}};
unsigned long on = styles_->get_color_rgb(segment_on_color_.r, segment_on_color_.g, segment_on_color_.b);
unsigned long off = styles_->get_color_rgb(segment_off_color_.r, segment_off_color_.g, segment_off_color_.b);
int t = 8; // was 6 (x1.33)
int t = std::max(6, h / 10); // segment thickness scales with digit height
draw_segment(x + t, y, w - 2 * t, t, seg[d][0], on, off);
draw_segment(x + w - t, y + t, t, h / 2 - 2 * t, seg[d][1], on, off);
draw_segment(x + w - t, y + h / 2 + t, t, h / 2 - 2 * t, seg[d][2], on, off);
@@ -107,31 +107,38 @@ public:
void draw() {
if (!visible_) return;
SStyle st = style();
// Audit G4: title 16 px; digits scale with the display.
SStyle stTitle = st; stTitle.font_ = xframe::inst_cap_font_prop(display_, 16);
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 amber = styles_->get_color_rgb(amber_color_.r, amber_color_.g, amber_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 tw0 = xf::text_width(st, text_);
xf::draw_text_at(display_, window_, gc_, st, x1_ + (width() - tw0) / 2, y1_ + 18, text_);
int dx = x1_ + 12, dy = y1_ + 30, dw = width() - 24, dh = height() - 42;
int tw0 = xf::text_width(stTitle, text_);
xf::draw_text_at(display_, window_, gc_, stTitle, x1_ + (width() - tw0) / 2, y1_ + 24, text_);
int dx = x1_ + 12, dy = y1_ + 34, dw = width() - 24, dh = height() - 46;
XSetForeground(display_, gc_, dark);
XFillRectangle(display_, window_, gc_, dx, dy, dw, dh);
XSetForeground(display_, gc_, ink);
XDrawRectangle(display_, window_, gc_, dx, dy, dw, dh);
std::string s = fmt(value_, 1);
int digw = 45, digh = 85, gap = 11; // glyphs x1.33 (was 34x64, gap 8)
// Audit G4: digits were fixed 45x85 in a 696x438 window (19% of
// its height); now ~42% of the display height, centred.
int digh = (int)(dh * 0.42);
int digw = (int)(digh * 0.55);
int gap = 20;
int dps = std::max(8, digh / 12);
int totalw = 0;
for (char c : s) totalw += (c == '.') ? 16 : (c == '-' ? 27 : digw + gap);
for (char c : s) totalw += (c == '.') ? (dps + 6) : (c == '-' ? 27 : digw + gap);
totalw -= gap;
int tx = dx + (dw - totalw) / 2;
int ty = dy + (dh - digh) / 2;
for (char c : s) {
if (c == '.') {
XSetForeground(display_, gc_, amber);
XFillRectangle(display_, window_, gc_, tx, ty + digh - 11, 11, 11);
tx += 16;
XFillRectangle(display_, window_, gc_, tx, ty + digh - dps, dps, dps);
tx += dps + 6;
} else if (c == '-') {
XSetForeground(display_, gc_, amber);
XFillRectangle(display_, window_, gc_, tx, ty + digh / 2 - 4, 21, 8);
@@ -46,7 +46,7 @@ public:
int x, int y, int width, int height, double level = xframe::inst_demo_level(43)) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstHorizontalTankLevel"; text_ = "InstHorizontalTankLevel";
name_ = "InstHorizontalTankLevel"; text_ = "";
level_ = xframe::inst_clamp_level(level);
}
~InstHorizontalTankLevel() {}
@@ -105,6 +105,10 @@ public:
void draw() {
if (!visible_) return;
SStyle st = style();
// Audit: scale 16 px, word labels 14 px bold.
SStyle stNum = st; stNum.font_ = xframe::inst_cap_font(display_, 16);
int numAsc = stNum.font_ ? stNum.font_->ascent : 13;
SStyle stLab = st; stLab.font_ = xframe::inst_cap_font_prop(display_, 14);
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);
@@ -114,12 +118,17 @@ public:
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_ + 40;
int ty = y1_ + 90;
int tw = width() - 180;
// Audit: capsule ends are true half-discs INSIDE the widget;
// the old left cap drew an arc centred off-window (tx-th/2 < x1_)
// and the pale fill never covered the caps.
int th = 150;
int tx = x1_ + th / 2 + 12;
int ty = y1_ + 90;
int tw = width() - th - 24;
XSetForeground(display_, gc_, pale);
XFillRectangle(display_, window_, gc_, tx, ty, tw, th);
XFillArc(display_, window_, gc_, tx - th / 2, ty, th, th, 90 * 64, 180 * 64);
XFillArc(display_, window_, gc_, tx + tw - th / 2, ty, th, th, 270 * 64, 180 * 64);
int fw = (int)(tw * level_ / 100.0);
if (fw > 0) {
XSetForeground(display_, gc_, fillc);
@@ -135,21 +144,24 @@ public:
XSetForeground(display_, gc_, grid);
XDrawLine(display_, window_, gc_, gx, ty + th + 4, gx, ty + th + 14);
std::string lab = std::to_string(v);
int lw = xf::text_width(st, lab);
xf::draw_text_at(display_, window_, gc_, st, gx - lw / 2, ty + th + 28, lab);
int lw = xf::text_width(stNum, lab);
xf::draw_text_at(display_, window_, gc_, stNum, gx - lw / 2, ty + th + 32, lab);
}
auto mark = [&](double pct, unsigned long c, const char* lab) {
int gx = tx + (int)(tw * pct / 100.0);
XSetForeground(display_, gc_, c);
XDrawLine(display_, window_, gc_, gx, ty, gx, ty + th);
xf::draw_text_at(display_, window_, gc_, st, gx + 4, ty - 8, lab);
xf::draw_text_at(display_, window_, gc_, stLab, gx + 4, ty - 10, lab);
};
mark(bands_.hi_hi, red, "HI-HI");
mark(bands_.hi, amber, "HI");
mark(bands_.lo, amber, "LO");
mark(bands_.lo_lo, red, "LO-LO");
std::string pct = fmt(level_) + "%";
xf::draw_text_at(display_, window_, gc_, st, tx + tw + 12, ty + th / 2 + 4, pct);
// % centred below the scale, clear of the right cap curve (G7).
SStyle stVal = st; stVal.font_ = xframe::inst_cap_font(display_, 18);
int pvw = xf::text_width(stVal, pct);
xf::draw_text_at(display_, window_, gc_, stVal, x1_ + (width() - pvw) / 2, ty + th + 58, pct);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 8, y1_ + 16, text_);
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());
@@ -98,6 +98,13 @@ public:
void draw() {
if (!visible_) return;
SStyle st = style();
// Audit: position numerals 16 px (was ~10 px), "NO KEY" light
// grey on the dark centre (G6), state + title 16 px bold.
SStyle stNum = st; stNum.font_ = xframe::inst_cap_font(display_, 16);
int numAsc = stNum.font_ ? stNum.font_->ascent : 13;
SStyle stLab = st; stLab.font_ = xframe::inst_cap_font_prop(display_, 16);
SStyle stNoKey = st; stNoKey.font_ = xframe::inst_cap_font_prop(display_, 14);
stNoKey.text_color_ = styles_->get_color_rgb(225, 225, 225);
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);
@@ -117,7 +124,8 @@ public:
double a = -2.094 + i * (4.188 / (positions_ > 1 ? (positions_ - 1) : 1));
int tx = cx + (int)((r + 30) * std::cos(a));
int ty = cy + (int)((r + 30) * std::sin(a)) + 5;
xf::draw_text_at(display_, window_, gc_, st, tx - 4, ty, std::to_string(i));
int tw = xf::text_width(stNum, std::to_string(i));
xf::draw_text_at(display_, window_, gc_, stNum, tx - tw / 2, ty + numAsc / 2 - 5, std::to_string(i));
}
double pa = -2.094 + position_ * (4.188 / (positions_ > 1 ? (positions_ - 1) : 1));
int px = cx + (int)((r - 20) * std::cos(pa));
@@ -134,11 +142,11 @@ public:
XSetForeground(display_, gc_, dark);
XDrawArc(display_, window_, gc_, px - 12, py - 12, 24, 24, 0, 360 * 64);
} else {
xf::draw_text_centered(display_, window_, gc_, st, cx - 60, cy - 10, cx + 60, cy + 10, "NO KEY");
xf::draw_text_centered(display_, window_, gc_, stNoKey, cx - 60, cy - 10, cx + 60, cy + 10, "NO KEY");
}
std::string pos = key_in_ ? ("KEY IN POS " + std::to_string(position_)) : "KEY OUT";
xf::draw_text_centered(display_, window_, gc_, st, cx - 110, cy + r + 40, cx + 110, cy + r + 64, pos);
xf::draw_text_centered(display_, window_, gc_, st, x1_, y2_ - 28, x2_, y2_ - 6, text_);
xf::draw_text_centered(display_, window_, gc_, stLab, cx - 110, cy + r + 44, cx + 110, cy + r + 68, pos);
xf::draw_text_centered(display_, window_, gc_, stLab, x1_, y2_ - 28, x2_, y2_ - 6, text_);
XSetForeground(display_, gc_, st.lineColor_);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width(), height());
if (focused_) {
@@ -55,7 +55,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 60, 35};
Srgb dim_color_ = {52, 14, 11};
Srgb dim_color_ = {24, 15, 13}; // audit G5: unlit segments barely visible, never a ghost "8"
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 1;
@@ -69,7 +69,7 @@ public:
// Short label: at the 18 px bold font the full name (14 chars,
// 126 px) does not fit this 90 px display, and clipping it
// mid-word reads badly, so the label shows "LedDigits".
text_ = "LedDigits";
text_ = "";
value_ = xframe::inst_demo_value(0.0, max_value(), 42);
}
~InstLedDigits1() {}
@@ -158,22 +158,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
// Name label clipped to the widget bounds: at the 18 px bold
// instrumentation font the full name is wider than the narrowest
// displays, and without the clip it would overwrite neighbours.
XRectangle label_clip = { (short)x1_, (short)y1_, (unsigned short)width(), (unsigned short)height() };
XSetClipRectangles(display_, gc_, 0, 0, &label_clip, 1, Unsorted);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
XSetClipMask(display_, gc_, None);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
int dp_w = (decimal_places_ > 0) ? 8 : 0;
@@ -55,7 +55,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 60, 35};
Srgb dim_color_ = {52, 14, 11};
Srgb dim_color_ = {24, 15, 13}; // audit G5: unlit segments barely visible, never a ghost "8"
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 2;
@@ -65,7 +65,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstLedDigits2"; text_ = "InstLedDigits2";
name_ = "InstLedDigits2"; text_ = "";
value_ = xframe::inst_demo_value(0.0, max_value(), 42);
}
~InstLedDigits2() {}
@@ -154,16 +154,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
int dp_w = (decimal_places_ > 0) ? 8 : 0;
@@ -55,7 +55,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 60, 35};
Srgb dim_color_ = {52, 14, 11};
Srgb dim_color_ = {24, 15, 13}; // audit G5: unlit segments barely visible, never a ghost "8"
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 3;
@@ -65,7 +65,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstLedDigits3"; text_ = "InstLedDigits3";
name_ = "InstLedDigits3"; text_ = "";
value_ = xframe::inst_demo_value(0.0, max_value(), 42);
}
~InstLedDigits3() {}
@@ -154,16 +154,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
int dp_w = (decimal_places_ > 0) ? 8 : 0;
@@ -55,7 +55,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 60, 35};
Srgb dim_color_ = {52, 14, 11};
Srgb dim_color_ = {24, 15, 13}; // audit G5: unlit segments barely visible, never a ghost "8"
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 4;
@@ -65,7 +65,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstLedDigits4"; text_ = "InstLedDigits4";
name_ = "InstLedDigits4"; text_ = "";
value_ = xframe::inst_demo_value(0.0, max_value(), 42);
}
~InstLedDigits4() {}
@@ -154,16 +154,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
int dp_w = (decimal_places_ > 0) ? 8 : 0;
@@ -55,7 +55,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 60, 35};
Srgb dim_color_ = {52, 14, 11};
Srgb dim_color_ = {24, 15, 13}; // audit G5: unlit segments barely visible, never a ghost "8"
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 5;
@@ -65,7 +65,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstLedDigits5"; text_ = "InstLedDigits5";
name_ = "InstLedDigits5"; text_ = "";
value_ = xframe::inst_demo_value(0.0, max_value(), 42);
}
~InstLedDigits5() {}
@@ -154,16 +154,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
int dp_w = (decimal_places_ > 0) ? 8 : 0;
@@ -55,7 +55,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 60, 35};
Srgb dim_color_ = {52, 14, 11};
Srgb dim_color_ = {24, 15, 13}; // audit G5: unlit segments barely visible, never a ghost "8"
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 6;
@@ -65,7 +65,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstLedDigits6"; text_ = "InstLedDigits6";
name_ = "InstLedDigits6"; text_ = "";
value_ = xframe::inst_demo_value(0.0, max_value(), 42);
}
~InstLedDigits6() {}
@@ -154,16 +154,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
int dp_w = (decimal_places_ > 0) ? 8 : 0;
@@ -104,11 +104,19 @@ public:
XDrawRectangle(display_, window_, gc_, x1_ + 14, y1_ + 14, width() - 28, height() - 28);
XSetForeground(display_, gc_, grey);
XDrawRectangle(display_, window_, gc_, x1_ + 18, y1_ + 18, width() - 36, height() - 36);
int tw = xf::text_width(st, text_);
// Audit: the engraving must fill 40-50% of the plate width
// (it was ~2% at the default 18 px font), so fit the font to the
// plate width (width ratio wins over the audit's "~30-40 px tall"
// parenthetical — ~68 px cap for "PUMP 1").
XFontStruct* plate_font = xframe::inst_prop_font_fit(display_, text_, (int)((width() - 20) * 0.45), 72);
int plateAsc = plate_font ? plate_font->ascent : 13;
SStyle stPlate = st; stPlate.font_ = plate_font;
int tw = xf::text_width(stPlate, text_);
int tx = x1_ + (width() - tw) / 2;
int ty = y1_ + height() / 2 + 5;
xf::draw_text_at(display_, window_, gc_, st, tx + 1, ty + 1, text_);
int ty = y1_ + height() / 2 + plateAsc / 2;
xf::draw_text_at(display_, window_, gc_, stPlate, tx + 1, ty + 1, text_);
XSetForeground(display_, gc_, styles_->get_color_rgb(engraved_color_.r, engraved_color_.g, engraved_color_.b));
if (plate_font) XSetFont(display_, gc_, plate_font->fid);
XDrawString(display_, window_, gc_, tx, ty, text_.c_str(), (int)text_.size());
draw_screw(x1_ + 24, y1_ + height() / 2);
draw_screw(x2_ - 24, y1_ + height() / 2);
@@ -46,7 +46,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstNeedleEdgewise"; text_ = "InstNeedleEdgewise";
name_ = "InstNeedleEdgewise"; text_ = "";
value_ = xframe::inst_demo_value(min_, max_, 42);
}
~InstNeedleEdgewise() {}
@@ -108,7 +108,7 @@ public:
// Needle angle in degrees from vertical, negative = left: -50 .. +50.
double needle_angle_deg() const { return -50.0 + 100.0 * fraction(); }
int pivot_x() const { return x1_ + width() / 2; }
int pivot_y() const { return y2_ - 16; }
int pivot_y() const { return scale_y() + 36; } // audit: pivot attached to the scale
int scale_y() const { return y1_ + (int)(height() * 0.45); }
int scale_half() const { return std::max(10, width() / 2 - 24); }
int needle_len() const { return pivot_y() - scale_y() + 6; }
@@ -146,6 +146,10 @@ public:
XSetForeground(display_, gc_, panel);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
int px = pivot_x(), py = pivot_y(), sy = scale_y(), half = scale_half();
// Audit: numerals 18-20 px bold (3% of scale length).
SStyle stNum = st; stNum.font_ = xframe::inst_cap_font(display_, 18);
int numAsc = stNum.font_ ? stNum.font_->ascent : 13;
SStyle stCap = st; stCap.font_ = xframe::inst_cap_font_prop(display_, 16);
XSetForeground(display_, gc_, face);
XFillRectangle(display_, window_, gc_, x1_ + 8, y1_ + 8, width() - 16, sy - y1_ + 22);
XSetForeground(display_, gc_, bezel);
@@ -164,8 +168,8 @@ public:
XDrawLine(display_, window_, gc_, tx, sy, tx, sy - th);
if (major) {
std::string lab = std::to_string((int)std::llround(min_ + f * (max_ - min_)));
int tw = xf::text_width(st, lab);
xf::draw_text_at(display_, window_, gc_, st, tx - tw / 2, sy - th - 12, lab);
int tw = xf::text_width(stNum, lab);
xf::draw_text_at(display_, window_, gc_, stNum, tx - tw / 2, sy - th - 6, lab);
}
}
// Needle sweeps left-right from the pivot below the scale.
@@ -175,8 +179,8 @@ public:
XSetForeground(display_, gc_, bezel);
XFillArc(display_, window_, gc_, px - 7, py - 7, 14, 14, 0, 360 * 64);
XSetForeground(display_, gc_, tick_col);
int tw = xf::text_width(st, text_);
xf::draw_text_at(display_, window_, gc_, st, px - tw / 2, py + 24, text_);
int tw = xf::text_width(stCap, text_);
xf::draw_text_at(display_, window_, gc_, stCap, px - tw / 2, py + 24, text_);
if (focused_) {
XSetForeground(display_, gc_, st.lineColor_);
XDrawRectangle(display_, window_, gc_, x1_ + 1, y1_ + 1, width() - 3, height() - 3);
@@ -47,7 +47,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstNeedleKnifeEdge"; text_ = "InstNeedleKnifeEdge";
name_ = "InstNeedleKnifeEdge"; text_ = "";
value_ = xframe::inst_demo_value(min_, max_, 42);
}
~InstNeedleKnifeEdge() {}
@@ -140,6 +140,11 @@ public:
XSetForeground(display_, gc_, panel);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
int cx = centre_x(), cy = centre_y(), R = dial_radius();
// Audit G1: numerals 7-8% of dial diameter, bold.
int numCap = std::max(14, R / 7);
SStyle stNum = st; stNum.font_ = xframe::inst_cap_font(display_, numCap);
int numAsc = stNum.font_ ? stNum.font_->ascent : 13;
SStyle stCap = st; stCap.font_ = xframe::inst_cap_font_prop(display_, 16);
XSetForeground(display_, gc_, bezel);
XFillArc(display_, window_, gc_, cx - R - 3, cy - R - 3, 2 * R + 6, 2 * R + 6, 0, 360 * 64);
XSetForeground(display_, gc_, face);
@@ -182,10 +187,10 @@ public:
cx + (int)(R * sx), cy + (int)(R * sy));
if (major) {
std::string lab = std::to_string((int)std::llround(min_ + f * (max_ - min_)));
int tw = xf::text_width(st, lab);
int lx = cx + (int)((R - 26) * sx) - tw / 2;
int ly = cy + (int)((R - 26) * sy) + 4;
xf::draw_text_at(display_, window_, gc_, st, lx, ly, lab);
int tw = xf::text_width(stNum, lab);
int lx = cx + (int)((R - numCap - 12) * sx) - tw / 2;
int ly = cy + (int)((R - numCap - 12) * sy) + numAsc / 2;
xf::draw_text_at(display_, window_, gc_, stNum, lx, ly, lab);
}
}
// Knife-edge needle: hair-thin pointer with a pointed tip and a tail.
@@ -204,8 +209,12 @@ public:
XSetForeground(display_, gc_, bezel);
XFillArc(display_, window_, gc_, cx - 6, cy - 6, 12, 12, 0, 360 * 64);
XSetForeground(display_, gc_, tick_col);
int tw = xf::text_width(st, text_);
xf::draw_text_at(display_, window_, gc_, st, cx - tw / 2, cy + R - 26, text_);
// Units caption inside the dial bottom; the class-name default is
// now empty (audit G2), so nothing is drawn unless text is set.
if (!text_.empty()) {
int tw = xf::text_width(stCap, text_);
xf::draw_text_at(display_, window_, gc_, stCap, cx - tw / 2, cy + R - 30, text_);
}
if (focused_) {
XSetForeground(display_, gc_, st.lineColor_);
XDrawRectangle(display_, window_, gc_, x1_ + 1, y1_ + 1, width() - 3, height() - 3);
@@ -46,7 +46,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstNeedleTapered"; text_ = "InstNeedleTapered";
name_ = "InstNeedleTapered"; text_ = "";
value_ = xframe::inst_demo_value(min_, max_, 42);
}
~InstNeedleTapered() {}
@@ -136,6 +136,11 @@ public:
XSetForeground(display_, gc_, panel);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
int cx = centre_x(), cy = centre_y(), R = dial_radius();
// Audit G1: numerals 7-8% of dial diameter, bold.
int numCap = std::max(14, R / 7);
SStyle stNum = st; stNum.font_ = xframe::inst_cap_font(display_, numCap);
int numAsc = stNum.font_ ? stNum.font_->ascent : 13;
SStyle stCap = st; stCap.font_ = xframe::inst_cap_font_prop(display_, 16);
XSetForeground(display_, gc_, bezel);
XFillArc(display_, window_, gc_, cx - R - 4, cy - R - 4, 2 * R + 8, 2 * R + 8, 0, 360 * 64);
XSetForeground(display_, gc_, face);
@@ -163,10 +168,10 @@ public:
cx + (int)(R * sx), cy + (int)(R * sy));
if (major) {
std::string lab = std::to_string((int)std::llround(min_ + f * (max_ - min_)));
int tw = xf::text_width(st, lab);
int lx = cx + (int)((R - 26) * sx) - tw / 2;
int ly = cy + (int)((R - 26) * sy) + 4;
xf::draw_text_at(display_, window_, gc_, st, lx, ly, lab);
int tw = xf::text_width(stNum, lab);
int lx = cx + (int)((R - numCap - 12) * sx) - tw / 2;
int ly = cy + (int)((R - numCap - 12) * sy) + numAsc / 2;
xf::draw_text_at(display_, window_, gc_, stNum, lx, ly, lab);
}
}
// Tapered needle: wide at the hub, narrow at the tip.
@@ -183,8 +188,12 @@ public:
XSetForeground(display_, gc_, bezel);
XFillArc(display_, window_, gc_, cx - 8, cy - 8, 16, 16, 0, 360 * 64);
XSetForeground(display_, gc_, tick_col);
int tw = xf::text_width(st, text_);
xf::draw_text_at(display_, window_, gc_, st, cx - tw / 2, cy + R - 26, text_);
// Units caption inside the dial bottom; the class-name default is
// now empty (audit G2), so nothing is drawn unless text is set.
if (!text_.empty()) {
int tw = xf::text_width(stCap, text_);
xf::draw_text_at(display_, window_, gc_, stCap, cx - tw / 2, cy + R - 30, text_);
}
if (focused_) {
XSetForeground(display_, gc_, st.lineColor_);
XDrawRectangle(display_, window_, gc_, x1_ + 1, y1_ + 1, width() - 3, height() - 3);
+16 -9
View File
@@ -46,7 +46,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstNeedleVu"; text_ = "InstNeedleVu";
name_ = "InstNeedleVu"; text_ = "";
value_ = xframe::inst_demo_value(min_, max_, 42);
}
~InstNeedleVu() {}
@@ -150,6 +150,12 @@ public:
XSetForeground(display_, gc_, panel);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
int px = pivot_x(), py = pivot_y(), R = arc_radius();
// Audit: numerals 16-18 px bold (4% of width), red in the red zone;
// "VU" below the arc centre, clear of the numerals.
SStyle stNum = st; stNum.font_ = xframe::inst_cap_font(display_, 17);
int numAsc = stNum.font_ ? stNum.font_->ascent : 13;
SStyle stNumRed = stNum; stNumRed.text_color_ = red;
SStyle stVu = st; stVu.font_ = xframe::inst_cap_font_prop(display_, 20);
XSetForeground(display_, gc_, face);
XFillRectangle(display_, window_, gc_, x1_ + 6, y1_ + 6, width() - 12, height() - 12);
XSetForeground(display_, gc_, bezel);
@@ -185,10 +191,11 @@ public:
XSetForeground(display_, gc_, (kDb[i] >= 0) ? red : tick_col);
XDrawLine(display_, window_, gc_, tx0, ty0, tx1, ty1);
std::string lab = (kDb[i] > 0) ? ("+" + std::to_string((int)kDb[i])) : std::to_string((int)kDb[i]);
int tw = xf::text_width(st, lab);
int lx = px + (int)((R - 26) * sx) - tw / 2;
int ly = py + (int)((R - 26) * sy) + 4;
xf::draw_text_at(display_, window_, gc_, st, lx, ly, lab);
SStyle& stLab = (kDb[i] >= 0) ? stNumRed : stNum;
int tw = xf::text_width(stLab, lab);
int lx = px + (int)((R - 38) * sx) - tw / 2;
int ly = py + (int)((R - 38) * sy) + numAsc / 2;
xf::draw_text_at(display_, window_, gc_, stLab, lx, ly, lab);
}
// VU needle: thin black pointer with a short tail.
double a = needle_angle_deg() * kPi / 180.0;
@@ -206,10 +213,10 @@ public:
XSetForeground(display_, gc_, bezel);
XFillArc(display_, window_, gc_, px - 7, py - 7, 14, 14, 0, 360 * 64);
XSetForeground(display_, gc_, tick_col);
int tw = xf::text_width(st, "VU");
xf::draw_text_at(display_, window_, gc_, st, px - tw / 2, py - R + 34, "VU");
int tw2 = xf::text_width(st, text_);
xf::draw_text_at(display_, window_, gc_, st, px - tw2 / 2, py - R + 50, text_);
// "VU" below the arc centre, clear of the scale numerals (audit
// G3); the class-name caption is gone (audit G2).
int tw = xf::text_width(stVu, "VU");
xf::draw_text_at(display_, window_, gc_, stVu, px - tw / 2, py - R + 96, "VU");
if (focused_) {
XSetForeground(display_, gc_, st.lineColor_);
XDrawRectangle(display_, window_, gc_, x1_ + 1, y1_ + 1, width() - 3, height() - 3);
@@ -96,6 +96,13 @@ public:
int cx = (x1_ + x2_) / 2;
int cy = (y1_ + y2_) / 2;
int r = std::min(width(), height()) / 2 - 10;
// Audit G1/G3: numerals 7-8% of dial diameter (bold), title inside
// the dial below the top numerals, value below the hub.
int numCap = std::max(14, r / 7);
SStyle stNum = st; stNum.font_ = xframe::inst_cap_font(display_, numCap);
int numAsc = stNum.font_ ? stNum.font_->ascent : 13;
SStyle stTitle = st; stTitle.font_ = xframe::inst_cap_font_prop(display_, 17);
SStyle stVal = st; stVal.font_ = xframe::inst_cap_font(display_, 18);
XSetForeground(display_, gc_, face);
XFillArc(display_, window_, gc_, cx - r, cy - r, 2 * r, 2 * r, 0, 360 * 64);
XSetForeground(display_, gc_, ink);
@@ -112,10 +119,10 @@ public:
XDrawLine(display_, window_, gc_, tx1, ty1, tx2, ty2);
if (i % 2 == 0) {
std::string lab = fmt(min_ + f * (max_ - min_));
int tw = xf::text_width(st, lab);
int lx = cx + (int)((r - 26) * std::cos(ang)) - tw / 2;
int ly = cy - (int)((r - 26) * std::sin(ang)) + 4;
xf::draw_text_at(display_, window_, gc_, st, lx, ly, lab);
int tw = xf::text_width(stNum, lab);
int lx = cx + (int)((r - numCap - 14) * std::cos(ang)) - tw / 2;
int ly = cy - (int)((r - numCap - 14) * std::sin(ang)) + numAsc / 2;
xf::draw_text_at(display_, window_, gc_, stNum, lx, ly, lab);
}
}
double nang = (225.0 - 270.0 * fraction()) * pi / 180.0;
@@ -128,10 +135,11 @@ public:
XSetForeground(display_, gc_, ink);
XFillArc(display_, window_, gc_, cx - 5, cy - 5, 10, 10, 0, 360 * 64);
std::string val = fmt(value_) + " psi";
int vw = xf::text_width(st, val);
xf::draw_text_at(display_, window_, gc_, st, cx - vw / 2, cy + r - 16, val);
int tw2 = xf::text_width(st, text_);
xf::draw_text_at(display_, window_, gc_, st, cx - tw2 / 2, y1_ + 16, text_);
int vw = xf::text_width(stVal, val);
xf::draw_text_at(display_, window_, gc_, stVal, cx - vw / 2, cy + r - 18, val);
// Title inside the dial, below the top numerals (audit G3).
int tw2 = xf::text_width(stTitle, text_);
xf::draw_text_at(display_, window_, gc_, stTitle, cx - tw2 / 2, cy - (int)(r * 0.43), text_); // audit G3: below the top numerals, clear of them
XSetForeground(display_, gc_, st.lineColor_);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width(), height());
@@ -162,10 +162,10 @@ private:
else if (seg == "g2") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx, midy - t / 2, hw, t); }
else if (seg == "i") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, y + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "l") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, midy + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, t, col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, t, col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, t, col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, t, col);
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
}
void draw_digit(int x, int y, int w, int h, int t, char ch,
unsigned long lit, unsigned long dim) {
@@ -179,7 +179,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 176, 0};
Srgb dim_color_ = {60, 42, 8};
Srgb dim_color_ = {26, 20, 10}; // audit G5: unlit segments very dim, never brown blocks
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 1;
@@ -191,7 +191,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstSeg14Display1"; text_ = "InstSeg14Display1";
name_ = "InstSeg14Display1"; text_ = "";
}
~InstSeg14Display1() {}
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
@@ -276,22 +276,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
// Name label clipped to the widget bounds: at the 18 px bold
// instrumentation font the full name is wider than the narrowest
// displays, and without the clip it would overwrite neighbours.
XRectangle label_clip = { (short)x1_, (short)y1_, (unsigned short)width(), (unsigned short)height() };
XSetClipRectangles(display_, gc_, 0, 0, &label_clip, 1, Unsorted);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
XSetClipMask(display_, gc_, None);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
bool has_dp = value_.find('.') != std::string::npos;
@@ -162,10 +162,10 @@ private:
else if (seg == "g2") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx, midy - t / 2, hw, t); }
else if (seg == "i") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, y + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "l") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, midy + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, t, col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, t, col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, t, col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, t, col);
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
}
void draw_digit(int x, int y, int w, int h, int t, char ch,
unsigned long lit, unsigned long dim) {
@@ -179,7 +179,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 176, 0};
Srgb dim_color_ = {60, 42, 8};
Srgb dim_color_ = {26, 20, 10}; // audit G5: unlit segments very dim, never brown blocks
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 2;
@@ -191,7 +191,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstSeg14Display2"; text_ = "InstSeg14Display2";
name_ = "InstSeg14Display2"; text_ = "";
}
~InstSeg14Display2() {}
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
@@ -276,22 +276,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
// Name label clipped to the widget bounds: at the 18 px bold
// instrumentation font the full name is wider than the narrowest
// displays, and without the clip it would overwrite neighbours.
XRectangle label_clip = { (short)x1_, (short)y1_, (unsigned short)width(), (unsigned short)height() };
XSetClipRectangles(display_, gc_, 0, 0, &label_clip, 1, Unsorted);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
XSetClipMask(display_, gc_, None);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
bool has_dp = value_.find('.') != std::string::npos;
@@ -162,10 +162,10 @@ private:
else if (seg == "g2") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx, midy - t / 2, hw, t); }
else if (seg == "i") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, y + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "l") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, midy + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, t, col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, t, col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, t, col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, t, col);
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
}
void draw_digit(int x, int y, int w, int h, int t, char ch,
unsigned long lit, unsigned long dim) {
@@ -179,7 +179,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 176, 0};
Srgb dim_color_ = {60, 42, 8};
Srgb dim_color_ = {26, 20, 10}; // audit G5: unlit segments very dim, never brown blocks
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 3;
@@ -191,7 +191,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstSeg14Display3"; text_ = "InstSeg14Display3";
name_ = "InstSeg14Display3"; text_ = "";
}
~InstSeg14Display3() {}
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
@@ -276,16 +276,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
bool has_dp = value_.find('.') != std::string::npos;
@@ -162,10 +162,10 @@ private:
else if (seg == "g2") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx, midy - t / 2, hw, t); }
else if (seg == "i") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, y + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "l") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, midy + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, t, col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, t, col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, t, col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, t, col);
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
}
void draw_digit(int x, int y, int w, int h, int t, char ch,
unsigned long lit, unsigned long dim) {
@@ -179,7 +179,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 176, 0};
Srgb dim_color_ = {60, 42, 8};
Srgb dim_color_ = {26, 20, 10}; // audit G5: unlit segments very dim, never brown blocks
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 4;
@@ -191,7 +191,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstSeg14Display4"; text_ = "InstSeg14Display4";
name_ = "InstSeg14Display4"; text_ = "";
}
~InstSeg14Display4() {}
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
@@ -276,16 +276,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
bool has_dp = value_.find('.') != std::string::npos;
@@ -162,10 +162,10 @@ private:
else if (seg == "g2") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx, midy - t / 2, hw, t); }
else if (seg == "i") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, y + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "l") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, midy + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, t, col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, t, col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, t, col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, t, col);
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
}
void draw_digit(int x, int y, int w, int h, int t, char ch,
unsigned long lit, unsigned long dim) {
@@ -179,7 +179,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 176, 0};
Srgb dim_color_ = {60, 42, 8};
Srgb dim_color_ = {26, 20, 10}; // audit G5: unlit segments very dim, never brown blocks
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 5;
@@ -191,7 +191,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstSeg14Display5"; text_ = "InstSeg14Display5";
name_ = "InstSeg14Display5"; text_ = "";
}
~InstSeg14Display5() {}
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
@@ -276,16 +276,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
bool has_dp = value_.find('.') != std::string::npos;
@@ -162,10 +162,10 @@ private:
else if (seg == "g2") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx, midy - t / 2, hw, t); }
else if (seg == "i") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, y + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "l") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, midy + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, t, col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, t, col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, t, col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, t, col);
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
}
void draw_digit(int x, int y, int w, int h, int t, char ch,
unsigned long lit, unsigned long dim) {
@@ -179,7 +179,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 176, 0};
Srgb dim_color_ = {60, 42, 8};
Srgb dim_color_ = {26, 20, 10}; // audit G5: unlit segments very dim, never brown blocks
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 6;
@@ -191,7 +191,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstSeg14Display6"; text_ = "InstSeg14Display6";
name_ = "InstSeg14Display6"; text_ = "";
}
~InstSeg14Display6() {}
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
@@ -276,16 +276,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
bool has_dp = value_.find('.') != std::string::npos;
@@ -162,10 +162,10 @@ private:
else if (seg == "g2") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx, midy - t / 2, hw, t); }
else if (seg == "i") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, y + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "l") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, midy + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, t, col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, t, col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, t, col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, t, col);
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
}
void draw_digit(int x, int y, int w, int h, int t, char ch,
unsigned long lit, unsigned long dim) {
@@ -179,7 +179,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 176, 0};
Srgb dim_color_ = {60, 42, 8};
Srgb dim_color_ = {26, 20, 10}; // audit G5: unlit segments very dim, never brown blocks
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 1;
@@ -191,7 +191,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstSeg16Display1"; text_ = "InstSeg16Display1";
name_ = "InstSeg16Display1"; text_ = "";
}
~InstSeg16Display1() {}
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
@@ -276,22 +276,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
// Name label clipped to the widget bounds: at the 18 px bold
// instrumentation font the full name is wider than the narrowest
// displays, and without the clip it would overwrite neighbours.
XRectangle label_clip = { (short)x1_, (short)y1_, (unsigned short)width(), (unsigned short)height() };
XSetClipRectangles(display_, gc_, 0, 0, &label_clip, 1, Unsorted);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
XSetClipMask(display_, gc_, None);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
bool has_dp = value_.find('.') != std::string::npos;
@@ -162,10 +162,10 @@ private:
else if (seg == "g2") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx, midy - t / 2, hw, t); }
else if (seg == "i") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, y + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "l") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, midy + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, t, col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, t, col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, t, col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, t, col);
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
}
void draw_digit(int x, int y, int w, int h, int t, char ch,
unsigned long lit, unsigned long dim) {
@@ -179,7 +179,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 176, 0};
Srgb dim_color_ = {60, 42, 8};
Srgb dim_color_ = {26, 20, 10}; // audit G5: unlit segments very dim, never brown blocks
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 2;
@@ -191,7 +191,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstSeg16Display2"; text_ = "InstSeg16Display2";
name_ = "InstSeg16Display2"; text_ = "";
}
~InstSeg16Display2() {}
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
@@ -276,22 +276,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
// Name label clipped to the widget bounds: at the 18 px bold
// instrumentation font the full name is wider than the narrowest
// displays, and without the clip it would overwrite neighbours.
XRectangle label_clip = { (short)x1_, (short)y1_, (unsigned short)width(), (unsigned short)height() };
XSetClipRectangles(display_, gc_, 0, 0, &label_clip, 1, Unsorted);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
XSetClipMask(display_, gc_, None);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
bool has_dp = value_.find('.') != std::string::npos;
@@ -162,10 +162,10 @@ private:
else if (seg == "g2") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx, midy - t / 2, hw, t); }
else if (seg == "i") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, y + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "l") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, midy + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, t, col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, t, col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, t, col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, t, col);
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
}
void draw_digit(int x, int y, int w, int h, int t, char ch,
unsigned long lit, unsigned long dim) {
@@ -179,7 +179,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 176, 0};
Srgb dim_color_ = {60, 42, 8};
Srgb dim_color_ = {26, 20, 10}; // audit G5: unlit segments very dim, never brown blocks
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 3;
@@ -191,7 +191,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstSeg16Display3"; text_ = "InstSeg16Display3";
name_ = "InstSeg16Display3"; text_ = "";
}
~InstSeg16Display3() {}
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
@@ -276,16 +276,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
bool has_dp = value_.find('.') != std::string::npos;
@@ -162,10 +162,10 @@ private:
else if (seg == "g2") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx, midy - t / 2, hw, t); }
else if (seg == "i") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, y + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "l") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, midy + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, t, col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, t, col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, t, col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, t, col);
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
}
void draw_digit(int x, int y, int w, int h, int t, char ch,
unsigned long lit, unsigned long dim) {
@@ -179,7 +179,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 176, 0};
Srgb dim_color_ = {60, 42, 8};
Srgb dim_color_ = {26, 20, 10}; // audit G5: unlit segments very dim, never brown blocks
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 4;
@@ -191,7 +191,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstSeg16Display4"; text_ = "InstSeg16Display4";
name_ = "InstSeg16Display4"; text_ = "";
}
~InstSeg16Display4() {}
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
@@ -276,16 +276,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
bool has_dp = value_.find('.') != std::string::npos;
@@ -162,10 +162,10 @@ private:
else if (seg == "g2") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx, midy - t / 2, hw, t); }
else if (seg == "i") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, y + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "l") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, midy + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, t, col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, t, col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, t, col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, t, col);
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
}
void draw_digit(int x, int y, int w, int h, int t, char ch,
unsigned long lit, unsigned long dim) {
@@ -179,7 +179,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 176, 0};
Srgb dim_color_ = {60, 42, 8};
Srgb dim_color_ = {26, 20, 10}; // audit G5: unlit segments very dim, never brown blocks
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 5;
@@ -191,7 +191,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstSeg16Display5"; text_ = "InstSeg16Display5";
name_ = "InstSeg16Display5"; text_ = "";
}
~InstSeg16Display5() {}
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
@@ -276,16 +276,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
bool has_dp = value_.find('.') != std::string::npos;
@@ -162,10 +162,10 @@ private:
else if (seg == "g2") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx, midy - t / 2, hw, t); }
else if (seg == "i") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, y + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "l") { XSetForeground(display_, gc_, col); XFillRectangle(display_, window_, gc_, midx - t / 2, midy + t, t, std::max(1, h / 2 - 2 * t)); }
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, t, col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, t, col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, t, col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, t, col);
else if (seg == "h") draw_diag(x + t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "j") draw_diag(x + w - t, y + t, midx, midy - t, std::max(2, t * 2 / 3), col);
else if (seg == "k") draw_diag(x + t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
else if (seg == "m") draw_diag(x + w - t, y + h - t, midx, midy + t, std::max(2, t * 2 / 3), col);
}
void draw_digit(int x, int y, int w, int h, int t, char ch,
unsigned long lit, unsigned long dim) {
@@ -179,7 +179,7 @@ private:
Srgb bg_color_ = {12, 12, 14};
Srgb bezel_color_ = {58, 58, 62};
Srgb lit_color_ = {255, 176, 0};
Srgb dim_color_ = {60, 42, 8};
Srgb dim_color_ = {26, 20, 10}; // audit G5: unlit segments very dim, never brown blocks
Srgb label_color_ = {170, 170, 170};
public:
static constexpr int kDigits = 6;
@@ -191,7 +191,7 @@ public:
int x, int y, int width, int height) {
display_ = display; screen_ = screen; window_ = window; gc_ = gc; styles_ = styles;
x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height;
name_ = "InstSeg16Display6"; text_ = "InstSeg16Display6";
name_ = "InstSeg16Display6"; text_ = "";
}
~InstSeg16Display6() {}
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
@@ -276,16 +276,16 @@ public:
unsigned long bezel = styles_->get_color_rgb(bezel_color_.r, bezel_color_.g, bezel_color_.b);
unsigned long lit = styles_->get_color_rgb(lit_color_.r, lit_color_.g, lit_color_.b);
unsigned long dim = styles_->get_color_rgb(dim_color_.r, dim_color_.g, dim_color_.b);
unsigned long label_col = styles_->get_color_rgb(label_color_.r, label_color_.g, label_color_.b);
XSetForeground(display_, gc_, bg);
XFillRectangle(display_, window_, gc_, x1_, y1_, width(), height());
XSetForeground(display_, gc_, bezel);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width() - 1, height() - 1);
XDrawRectangle(display_, window_, gc_, x1_ + 2, y1_ + 2, width() - 5, height() - 5);
XSetForeground(display_, gc_, label_col);
xf::draw_text_at(display_, window_, gc_, st, x1_ + 6, y1_ + 12, text_);
int label_h = 16;
int ax = x1_ + 6, ay = y1_ + label_h + 4, aw = width() - 12, ah = height() - label_h - 10;
// No name label (audit G2: the class-name default is gone); the
// digits fill the widget, centred (audit G4: 70-80% of height).
int ax = x1_ + 6, aw = width() - 12;
int ah = (int)(height() * 0.78);
int ay = y1_ + (height() - ah) / 2;
if (aw >= 10 && ah >= 10) {
int gap = 4;
bool has_dp = value_.find('.') != std::string::npos;
@@ -96,6 +96,13 @@ public:
int cx = (x1_ + x2_) / 2;
int cy = (y1_ + y2_) / 2;
int r = std::min(width(), height()) / 2 - 10;
// Audit G1/G3: numerals 7-8% of dial diameter (bold), title inside
// the dial below the top numerals, value below the hub.
int numCap = std::max(14, r / 7);
SStyle stNum = st; stNum.font_ = xframe::inst_cap_font(display_, numCap);
int numAsc = stNum.font_ ? stNum.font_->ascent : 13;
SStyle stTitle = st; stTitle.font_ = xframe::inst_cap_font_prop(display_, 17);
SStyle stVal = st; stVal.font_ = xframe::inst_cap_font(display_, 18);
XSetForeground(display_, gc_, face);
XFillArc(display_, window_, gc_, cx - r, cy - r, 2 * r, 2 * r, 0, 360 * 64);
XSetForeground(display_, gc_, ink);
@@ -112,10 +119,10 @@ public:
XDrawLine(display_, window_, gc_, tx1, ty1, tx2, ty2);
if (i % 2 == 0) {
std::string lab = fmt(min_ + f * (max_ - min_));
int tw = xf::text_width(st, lab);
int lx = cx + (int)((r - 26) * std::cos(ang)) - tw / 2;
int ly = cy - (int)((r - 26) * std::sin(ang)) + 4;
xf::draw_text_at(display_, window_, gc_, st, lx, ly, lab);
int tw = xf::text_width(stNum, lab);
int lx = cx + (int)((r - numCap - 14) * std::cos(ang)) - tw / 2;
int ly = cy - (int)((r - numCap - 14) * std::sin(ang)) + numAsc / 2;
xf::draw_text_at(display_, window_, gc_, stNum, lx, ly, lab);
}
}
double nang = (225.0 - 270.0 * fraction()) * pi / 180.0;
@@ -128,10 +135,11 @@ public:
XSetForeground(display_, gc_, ink);
XFillArc(display_, window_, gc_, cx - 5, cy - 5, 10, 10, 0, 360 * 64);
std::string val = fmt(value_) + " C";
int vw = xf::text_width(st, val);
xf::draw_text_at(display_, window_, gc_, st, cx - vw / 2, cy + r - 16, val);
int tw2 = xf::text_width(st, text_);
xf::draw_text_at(display_, window_, gc_, st, cx - tw2 / 2, y1_ + 16, text_);
int vw = xf::text_width(stVal, val);
xf::draw_text_at(display_, window_, gc_, stVal, cx - vw / 2, cy + r - 18, val);
// Title inside the dial, below the top numerals (audit G3).
int tw2 = xf::text_width(stTitle, text_);
xf::draw_text_at(display_, window_, gc_, stTitle, cx - tw2 / 2, cy - (int)(r * 0.43), text_); // audit G3: below the top numerals, clear of them
XSetForeground(display_, gc_, st.lineColor_);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width(), height());
+16 -8
View File
@@ -96,6 +96,13 @@ public:
int cx = (x1_ + x2_) / 2;
int cy = (y1_ + y2_) / 2;
int r = std::min(width(), height()) / 2 - 10;
// Audit G1/G3: numerals 7-8% of dial diameter (bold), title inside
// the dial below the top numerals, value below the hub.
int numCap = std::max(14, r / 7);
SStyle stNum = st; stNum.font_ = xframe::inst_cap_font(display_, numCap);
int numAsc = stNum.font_ ? stNum.font_->ascent : 13;
SStyle stTitle = st; stTitle.font_ = xframe::inst_cap_font_prop(display_, 17);
SStyle stVal = st; stVal.font_ = xframe::inst_cap_font(display_, 18);
XSetForeground(display_, gc_, face);
XFillArc(display_, window_, gc_, cx - r, cy - r, 2 * r, 2 * r, 0, 360 * 64);
XSetForeground(display_, gc_, ink);
@@ -112,10 +119,10 @@ public:
XDrawLine(display_, window_, gc_, tx1, ty1, tx2, ty2);
if (i % 2 == 0) {
std::string lab = fmt(min_ + f * (max_ - min_));
int tw = xf::text_width(st, lab);
int lx = cx + (int)((r - 26) * std::cos(ang)) - tw / 2;
int ly = cy - (int)((r - 26) * std::sin(ang)) + 4;
xf::draw_text_at(display_, window_, gc_, st, lx, ly, lab);
int tw = xf::text_width(stNum, lab);
int lx = cx + (int)((r - numCap - 14) * std::cos(ang)) - tw / 2;
int ly = cy - (int)((r - numCap - 14) * std::sin(ang)) + numAsc / 2;
xf::draw_text_at(display_, window_, gc_, stNum, lx, ly, lab);
}
}
double nang = (225.0 - 270.0 * fraction()) * pi / 180.0;
@@ -128,10 +135,11 @@ public:
XSetForeground(display_, gc_, ink);
XFillArc(display_, window_, gc_, cx - 5, cy - 5, 10, 10, 0, 360 * 64);
std::string val = fmt(value_) + " VU";
int vw = xf::text_width(st, val);
xf::draw_text_at(display_, window_, gc_, st, cx - vw / 2, cy + r - 16, val);
int tw2 = xf::text_width(st, text_);
xf::draw_text_at(display_, window_, gc_, st, cx - tw2 / 2, y1_ + 16, text_);
int vw = xf::text_width(stVal, val);
xf::draw_text_at(display_, window_, gc_, stVal, cx - vw / 2, cy + r - 18, val);
// Title inside the dial, below the top numerals (audit G3).
int tw2 = xf::text_width(stTitle, text_);
xf::draw_text_at(display_, window_, gc_, stTitle, cx - tw2 / 2, cy - (int)(r * 0.43), text_); // audit G3: below the top numerals, clear of them
XSetForeground(display_, gc_, st.lineColor_);
XDrawRectangle(display_, window_, gc_, x1_, y1_, width(), height());