InstPressureGauge

InstPressureGauge

InstPressureGauge is an instrumentation widget in the “Instrumentation” section, built from the Instrument archetype (kind “PressureGauge”). An instrumentation gauge or meter: a needle, dial, bar, or digital readout showing one live value in a range, with programmable level, limits, and alarms.

Category: Instrumentation   Family: Inst   Section: Instrumentation   Archetype: Instrument   Kind: PressureGauge   Default size: 200×90

InstPressureGauge running under Xvfb
InstPressureGauge running in an 800×600 window under Xvfb.

Properties

PropertyTypeDefaultRust setter
backgroundColor—set_style_name
foregroundColor—set_style_name
tooltip-textStr——
visibleBooltrueset_visible
enabledBooltrueset_enabled

“—” in the setter column means the Rust widget code has no setter for that property: it is set in the designer (Inspector) and carried in the saved design, not changed from Rust code.

Instrument archetype settings (Rust)

Settings on the shared Instrument struct in crates/xframe-widgets/src/archetypes.rs. One struct serves every kind of the archetype, so only the settings matching this kind apply to it (a calendar uses set_date, a notebook uses the tab settings, a grid uses the grid settings). “—” as a default means the data gives no Inspector default for that setting.

PropertyTypeDefaultRust setter
white-colorColor—set_white_color
face-colorColor—set_face_color
ink-colorColor—set_ink_color
red-colorColor—set_red_color
amber-colorColor—set_amber_color
green-colorColor—set_green_color
blue-colorColor—set_blue_color
dark-colorColor—set_dark_color
lead-colorColor—set_lead_color
bezel-colorColor—set_bezel_color
ring-colorColor—set_ring_color
outline-colorColor—set_outline_color
panel-colorColor—set_panel_color
tick-colorColor—set_tick_color
needle-colorColor—set_needle_color
pale-colorColor—set_pale_color
fill-colorColor—set_fill_color
grid-colorColor—set_grid_color
hover-colorColor—set_hover_color
beacon-colorColor—set_beacon_color
steel-colorColor—set_steel_color
surface-colorColor—set_surface_color
seg-bg-colorColor—set_seg_bg_color
seg-bezel-colorColor—set_seg_bezel_color
seg-label-colorColor—set_seg_label_color
seg7-lit-colorColor—set_seg7_lit_color
seg7-dim-colorColor—set_seg7_dim_color
seg14-lit-colorColor—set_seg14_lit_color
seg14-dim-colorColor—set_seg14_dim_color
seg16-lit-colorColor—set_seg16_lit_color
seg16-dim-colorColor—set_seg16_dim_color
segment-on-colorColor—set_segment_on_color
segment-off-colorColor—set_segment_off_color
led-colorColor—set_led_color
lamp-colorColor—set_lamp_color
stack-red-colorColor—set_stack_red_color
stack-amber-colorColor—set_stack_amber_color
stack-green-colorColor—set_stack_green_color
red-channel-colorColor—set_red_channel_color
green-channel-colorColor—set_green_channel_color
blue-channel-colorColor—set_blue_channel_color
onBool—set_on
stack-red-onBool—set_stack_red_on
stack-amber-onBool—set_stack_amber_on
stack-green-onBool—set_stack_green_on
red-onBool—set_red_on
green-onBool—set_green_on
blue-onBool—set_blue_on
needle-line-widthInt—set_needle_line_width
marker-line-widthInt—set_marker_line_width
unitStr—set_unit
display-textStr—set_display_text

Working example

Minimal complete Rust program — this is the file examples/InstPressureGauge.rs in lightgui_rust. Run it with:

cargo run -p xframe-demo --example InstPressureGauge
//! InstPressureGauge — minimal complete XFrame example.
//!
//! Run it from the workspace root:
//!     cargo run -p xframe-demo --example InstPressureGauge
//! It opens an 800x600 window showing one InstPressureGauge widget (press Esc
//! or `q`, or close the window, to quit). The widget is the real
//! `xframe-widgets` implementation for this registry kind, created by
//! `xframe_widgets::create("InstPressureGauge")` inside `xframe_demo::run_widget`
//! — the same code path the `xframe-demo` binary uses.

use std::process::ExitCode;

fn main() -> ExitCode {
    match xframe_demo::run_widget("InstPressureGauge", false, None, None) {
        Ok(code) => ExitCode::from(code as u8),
        Err(e) => {
            eprintln!("InstPressureGauge example: {}", e);
            ExitCode::from(1)
        }
    }
}

Event handling

Every XFrame widget dispatches the same four input events through the Widget trait: button press, button release, pointer motion, and key press. The generated event loop routes a release to the widget that got the press (even if the pointer moved off it), motion to the pressed widget while dragging and otherwise to the topmost widget under the pointer, and keys only to the focused widget. A press that starts and ends inside an enabled widget fires its click handler (on_click); Return or Space fires it when the widget is focused.

This kind has no named signal of its own in the event tables: it uses the generic press / release / motion / key dispatch above, and its click handler where the archetype provides one.

Gauges: adjusting the level

A gauge shows one live value. Set its range first with set_range(min, max), then move the needle/bar/readout with set_value(level) — the widget redraws at the new level. set_step() controls the keyboard/step increment. Read the current level back with value(), and the limits with min() / max(). Drive it from a timer or data feed: set the value, then redraw.

Styling: colours, border radius, line width, line colour

Styling is per-style, not per-widget: a Style carries fill_color, outline_color, line_color, text_color, radius (border radius), line_width, and font_name. Register a style with add_style_ex (argument order: fill, outline, text, line, radius, line width, font) and apply it with set_style_name("name") on any widget — the same widget can be square or rounded, thin- or thick-lined, just by switching style. The demo's default style uses radius 6 and line width 1; dark is the dark variant.


All Rust widgets · lightgui_rust on GitHub