XVerticalBar

XVerticalBar

XVerticalBar is a Monitor widget in LightGUI's XFrame widget set. Vertical bar meter with a scale and a peak-hold marker.

XVerticalBar is the tall meter: a vertical fill with a scale beside it and a peak-hold marker that stays at the highest value seen until you reset it. Good for audio-style levels or any value where the peak matters as much as the present reading.

XVerticalBar running under Xvfb
XVerticalBar running — screenshot taken from the example below under Xvfb.

Key methods

  • set_value(v) — the current value
  • get_value() — the current value
  • set_max(m) — the value that fills the bar
  • get_max() — the current maximum
  • set_peak_hold(on) — keep a marker at the highest value seen
  • reset_peak() — drop the peak marker back to the current value

Every widget also gets the shared properties visible, enabled, bounds (x, y, width, height) and style_name, plus the background / foreground colours from the active style.

Example

The peak marker holds at the highest value until reset_peak() drops it.

XVerticalBar widget(display, screen, window, gc, &styles, 20, 20, 60, 480);
widget.set_max(100.0);
widget.set_peak_hold(true);
widget.set_value(72.0);
widget.draw();

The snippet above is the widget part only. As with every XFrame example, the full program opens a display, creates a window and a style manager, then runs the standard event loop — see the complete example in the repo.

Build it from the repo root:

g++ -std=c++17 -Iwidgets/components -Iwidgets examples/XVerticalBar.cpp -lX11 -o XVerticalBar

Run it under Xvfb or a real X server; close the window to quit.

Example in the repo

The full working example is examples/XVerticalBar.cpp in the lightgui repo (C is canonical). The same widget is ported to the Rust and Python repos under the same name — see the links below.

Get the code

These widgets ship in all three LightGUI repos:

See also

Linux Rocks Every Day
Source code: LightGUI (C) · LightGUI (Rust) · LightGUI (Python)