Phase 4: generator emits Stock/Instrumentation props (lightgui-gen)
Mirrors the C generator: a generic Phase 4 loop driven by PHASE4_CAPS
(caps_rs mode of tools/gen_phase4_props.py) emits one setter call per
Inspector-table prop the widget actually has, with the arg form from
the table kind (set_value(double) for gauges, set_value("...") for Seg
displays). Pairs are emitted together (minimum/maximum -> set_range,
y-min/y-max -> set_y_range, set_anchors3 when all six anchor
components are present, else one set_anchor per complete anchor). The
StockChart branch keeps only the NOTE for data-file/indicators/
drawings/compare-files/scale-mode; its up/down colours now come from
the generic loop. The common background prop falls back to
set_bg_color for Stock/Inst classes that have it (PHASE4_BG_COLOR,
bg_rs mode).
This commit is contained in:
1 parent
45b36e89ef
commit
a98d24d495
2 files changed
+343
-9
No files matched your search
@@ -22,7 +22,7 @@ use lightgui_core::canonicalize::trim_c;
|
||||
use lightgui_core::cnum::{atof_c, atoi_c, fmt_g};
|
||||
use lightgui_core::events::{find_event, EventKind};
|
||||
use lightgui_core::model::{Project, Widget};
|
||||
use lightgui_core::{class_kind, looks_like_class};
|
||||
use lightgui_core::{class_kind, find_prop, looks_like_class, PropKind};
|
||||
use std::path::Path;
|
||||
|
||||
pub struct GenResult {
|
||||
@@ -848,6 +848,187 @@ fn emit_scale_marks(o: &mut String, w: &Widget, var: &str, mn: f64, mx: f64) {
|
||||
o.push_str(&format!(" {var}.w.set_marks({{{}}});\n", lit.join(", ")));
|
||||
}
|
||||
|
||||
// ---- Phase 4 (proposal 2.22 / 4.12): Stock + Instrumentation ----
|
||||
// Phase 4 capability table (generated by tools/gen_phase4_props.py).
|
||||
// (prop, setter) rows the generator may emit for a class; the arg
|
||||
// form comes from the Inspector table's kind for that prop.
|
||||
static PHASE4_CAPS: &[(&str, &[(&str, &str)])] = &[
|
||||
("InstAnalogGauge", &[("face-color", "set_face_color"), ("ink-color", "set_ink_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("maximum", "set_range"), ("minimum", "set_range"), ("needle-line-width", "set_needle_line_width"), ("value", "set_value")]),
|
||||
("InstBarMeter", &[("amber-color", "set_amber_color"), ("face-color", "set_face_color"), ("green-color", "set_green_color"), ("ink-color", "set_ink_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("horizontal", "set_horizontal"), ("marker-line-width", "set_marker_line_width"), ("maximum", "set_range"), ("minimum", "set_range"), ("value", "set_value")]),
|
||||
("InstBeacon", &[("beacon-color", "set_beacon_color"), ("dark-color", "set_dark_color"), ("hover-color", "set_hover_color"), ("white-color", "set_white_color"), ("brightness", "set_brightness"), ("flash-rate", "set_flash_rate"), ("on", "set_on"), ("phase", "set_phase")]),
|
||||
("InstBezel", &[("ink-color", "set_ink_color"), ("panel-color", "set_panel_color"), ("screw-color", "set_screw_color"), ("screw-ring-color", "set_screw_ring_color"), ("white-color", "set_white_color")]),
|
||||
("InstCircuitBreaker", &[("amber-color", "set_amber_color"), ("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("green-color", "set_green_color"), ("panel-color", "set_panel_color"), ("plate-color", "set_plate_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("lever-line-width", "set_lever_line_width")]),
|
||||
("InstControlPanel", &[("amber-color", "set_amber_color"), ("face-color", "set_face_color"), ("ink-color", "set_ink_color"), ("panel-color", "set_panel_color"), ("screw-color", "set_screw_color"), ("screw-ring-color", "set_screw_ring_color"), ("white-color", "set_white_color"), ("grid-cols", "set_grid_cols"), ("grid-rows", "set_grid_rows")]),
|
||||
("InstDigitalReadout", &[("amber-color", "set_amber_color"), ("dark-color", "set_dark_color"), ("ink-color", "set_ink_color"), ("segment-off-color", "set_segment_off_color"), ("segment-on-color", "set_segment_on_color"), ("white-color", "set_white_color"), ("maximum", "set_range"), ("minimum", "set_range"), ("value", "set_value")]),
|
||||
("InstEmergencyStop", &[("amber-color", "set_amber_color"), ("dark-color", "set_dark_color"), ("red-color", "set_red_color"), ("redlit-color", "set_redlit_color"), ("surround-color", "set_surround_color"), ("white-color", "set_white_color"), ("on", "set_on")]),
|
||||
("InstFlowMeter", &[("face-color", "set_face_color"), ("ink-color", "set_ink_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("maximum", "set_range"), ("minimum", "set_range"), ("value", "set_value")]),
|
||||
("InstHorizontalTankLevel", &[("amber-color", "set_amber_color"), ("fill-color", "set_fill_color"), ("grid-color", "set_grid_color"), ("hover-color", "set_hover_color"), ("ink-color", "set_ink_color"), ("pale-color", "set_pale_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("alarm-hi", "set_alarm_hi"), ("alarm-hi-hi", "set_alarm_hi_hi"), ("alarm-lo", "set_alarm_lo"), ("alarm-lo-lo", "set_alarm_lo_lo"), ("level", "set_level")]),
|
||||
("InstKeySwitch", &[("amber-color", "set_amber_color"), ("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("panel-color", "set_panel_color"), ("plate-color", "set_plate_color"), ("white-color", "set_white_color"), ("key-in", "set_key_in"), ("pointer-line-width", "set_pointer_line_width"), ("positions", "set_positions")]),
|
||||
("InstLampTestButton", &[("bezel-color", "set_bezel_color"), ("face-color", "set_face_color"), ("face-down-color", "set_face_down_color"), ("hover-color", "set_hover_color"), ("white-color", "set_white_color")]),
|
||||
("InstLedBlue", &[("dark-color", "set_dark_color"), ("hover-color", "set_hover_color"), ("lead-color", "set_lead_color"), ("lens-color", "set_lens_color"), ("white-color", "set_white_color"), ("brightness", "set_brightness"), ("on", "set_on")]),
|
||||
("InstLedDigits1", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("decimal-places", "set_decimal_places"), ("value", "set_value")]),
|
||||
("InstLedDigits2", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("decimal-places", "set_decimal_places"), ("value", "set_value")]),
|
||||
("InstLedDigits3", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("decimal-places", "set_decimal_places"), ("value", "set_value")]),
|
||||
("InstLedDigits4", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("decimal-places", "set_decimal_places"), ("value", "set_value")]),
|
||||
("InstLedDigits5", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("decimal-places", "set_decimal_places"), ("value", "set_value")]),
|
||||
("InstLedDigits6", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("decimal-places", "set_decimal_places"), ("value", "set_value")]),
|
||||
("InstLedGreen", &[("dark-color", "set_dark_color"), ("hover-color", "set_hover_color"), ("lead-color", "set_lead_color"), ("lens-color", "set_lens_color"), ("white-color", "set_white_color"), ("brightness", "set_brightness"), ("on", "set_on")]),
|
||||
("InstLedRed", &[("dark-color", "set_dark_color"), ("hover-color", "set_hover_color"), ("lead-color", "set_lead_color"), ("lens-color", "set_lens_color"), ("white-color", "set_white_color"), ("brightness", "set_brightness"), ("on", "set_on")]),
|
||||
("InstLevelColumnGauge", &[("amber-color", "set_amber_color"), ("fill-color", "set_fill_color"), ("grid-color", "set_grid_color"), ("hover-color", "set_hover_color"), ("ink-color", "set_ink_color"), ("pale-color", "set_pale_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("alarm-hi", "set_alarm_hi"), ("alarm-hi-hi", "set_alarm_hi_hi"), ("alarm-lo", "set_alarm_lo"), ("alarm-lo-lo", "set_alarm_lo_lo"), ("level", "set_level")]),
|
||||
("InstLevelTransmitter", &[("amber-color", "set_amber_color"), ("fill-color", "set_fill_color"), ("grid-color", "set_grid_color"), ("hover-color", "set_hover_color"), ("ink-color", "set_ink_color"), ("pale-color", "set_pale_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("alarm-hi", "set_alarm_hi"), ("alarm-hi-hi", "set_alarm_hi_hi"), ("alarm-lo", "set_alarm_lo"), ("alarm-lo-lo", "set_alarm_lo_lo"), ("level", "set_level")]),
|
||||
("InstManometer", &[("blue-color", "set_blue_color"), ("face-color", "set_face_color"), ("ink-color", "set_ink_color"), ("white-color", "set_white_color"), ("maximum", "set_range"), ("minimum", "set_range"), ("value", "set_value")]),
|
||||
("InstNameplate", &[("amber-color", "set_amber_color"), ("dark-color", "set_dark_color"), ("engraved-color", "set_engraved_color"), ("grey-color", "set_grey_color"), ("screw-color", "set_screw_color"), ("screw-ring-color", "set_screw_ring_color"), ("white-color", "set_white_color")]),
|
||||
("InstNeedleEdgewise", &[("bezel-color", "set_bezel_color"), ("face-color", "set_face_color"), ("needle-color", "set_needle_color"), ("panel-color", "set_panel_color"), ("red-color", "set_red_color"), ("tick-color", "set_tick_color"), ("maximum", "set_range"), ("minimum", "set_range"), ("value", "set_value")]),
|
||||
("InstNeedleKnifeEdge", &[("bezel-color", "set_bezel_color"), ("face-color", "set_face_color"), ("mirror-color", "set_mirror_color"), ("needle-color", "set_needle_color"), ("panel-color", "set_panel_color"), ("red-color", "set_red_color"), ("tick-color", "set_tick_color"), ("maximum", "set_range"), ("minimum", "set_range"), ("value", "set_value")]),
|
||||
("InstNeedleTapered", &[("bezel-color", "set_bezel_color"), ("face-color", "set_face_color"), ("needle-color", "set_needle_color"), ("panel-color", "set_panel_color"), ("red-color", "set_red_color"), ("tick-color", "set_tick_color"), ("maximum", "set_range"), ("minimum", "set_range"), ("value", "set_value")]),
|
||||
("InstNeedleVu", &[("bezel-color", "set_bezel_color"), ("face-color", "set_face_color"), ("needle-color", "set_needle_color"), ("panel-color", "set_panel_color"), ("red-color", "set_red_color"), ("tick-color", "set_tick_color"), ("maximum", "set_range"), ("minimum", "set_range"), ("value", "set_value")]),
|
||||
("InstOpenChannelLevel", &[("amber-color", "set_amber_color"), ("fill-color", "set_fill_color"), ("grid-color", "set_grid_color"), ("hover-color", "set_hover_color"), ("ink-color", "set_ink_color"), ("pale-color", "set_pale_color"), ("red-color", "set_red_color"), ("surface-color", "set_surface_color"), ("white-color", "set_white_color"), ("alarm-hi", "set_alarm_hi"), ("alarm-hi-hi", "set_alarm_hi_hi"), ("alarm-lo", "set_alarm_lo"), ("alarm-lo-lo", "set_alarm_lo_lo"), ("level", "set_level")]),
|
||||
("InstPanelLampAmber", &[("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("hover-color", "set_hover_color"), ("lens-color", "set_lens_color"), ("ring-color", "set_ring_color"), ("white-color", "set_white_color"), ("brightness", "set_brightness"), ("on", "set_on")]),
|
||||
("InstPanelLampBlue", &[("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("hover-color", "set_hover_color"), ("lens-color", "set_lens_color"), ("ring-color", "set_ring_color"), ("white-color", "set_white_color"), ("brightness", "set_brightness"), ("on", "set_on")]),
|
||||
("InstPanelLampGreen", &[("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("hover-color", "set_hover_color"), ("lens-color", "set_lens_color"), ("ring-color", "set_ring_color"), ("white-color", "set_white_color"), ("brightness", "set_brightness"), ("on", "set_on")]),
|
||||
("InstPanelLampRed", &[("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("hover-color", "set_hover_color"), ("lens-color", "set_lens_color"), ("ring-color", "set_ring_color"), ("white-color", "set_white_color"), ("brightness", "set_brightness"), ("on", "set_on")]),
|
||||
("InstPanelLampWhite", &[("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("hover-color", "set_hover_color"), ("lens-color", "set_lens_color"), ("ring-color", "set_ring_color"), ("white-color", "set_white_color"), ("brightness", "set_brightness"), ("on", "set_on")]),
|
||||
("InstPanelPlate", &[("amber-color", "set_amber_color"), ("ink-color", "set_ink_color"), ("panel-color", "set_panel_color"), ("screw-color", "set_screw_color"), ("screw-ring-color", "set_screw_ring_color"), ("white-color", "set_white_color")]),
|
||||
("InstPressureGauge", &[("face-color", "set_face_color"), ("ink-color", "set_ink_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("maximum", "set_range"), ("minimum", "set_range"), ("needle-line-width", "set_needle_line_width"), ("value", "set_value")]),
|
||||
("InstPushButton", &[("amber-color", "set_amber_color"), ("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("green-color", "set_green_color"), ("greenlit-color", "set_greenlit_color"), ("red-color", "set_red_color"), ("redlit-color", "set_redlit_color"), ("white-color", "set_white_color"), ("on", "set_on")]),
|
||||
("InstPushButtonLatching", &[("amber-color", "set_amber_color"), ("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("green-color", "set_green_color"), ("greenlit-color", "set_greenlit_color"), ("redlit-color", "set_redlit_color"), ("white-color", "set_white_color"), ("on", "set_on")]),
|
||||
("InstRgbStatusLed", &[("blue-channel-color", "set_blue_channel_color"), ("dark-color", "set_dark_color"), ("green-channel-color", "set_green_channel_color"), ("hover-color", "set_hover_color"), ("red-channel-color", "set_red_channel_color"), ("swatch-outline-color", "set_swatch_outline_color"), ("white-color", "set_white_color"), ("all-on", "set_all"), ("blue-on", "set_blue"), ("brightness", "set_brightness"), ("green-on", "set_green"), ("red-on", "set_red")]),
|
||||
("InstRockerSwitch", &[("amber-color", "set_amber_color"), ("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("dimred-color", "set_dimred_color"), ("green-color", "set_green_color"), ("panel-color", "set_panel_color"), ("rocker-color", "set_rocker_color"), ("white-color", "set_white_color"), ("on", "set_on")]),
|
||||
("InstRockerSwitchDouble", &[("amber-color", "set_amber_color"), ("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("green-color", "set_green_color"), ("red-color", "set_red_color"), ("rocker-color", "set_rocker_color"), ("white-color", "set_white_color"), ("position", "set_position")]),
|
||||
("InstRockerSwitchIlluminated", &[("amber-color", "set_amber_color"), ("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("dimred-color", "set_dimred_color"), ("green-color", "set_green_color"), ("greenlit-color", "set_greenlit_color"), ("red-color", "set_red_color"), ("rocker-color", "set_rocker_color"), ("white-color", "set_white_color"), ("on", "set_on")]),
|
||||
("InstRotarySelector", &[("amber-color", "set_amber_color"), ("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("panel-color", "set_panel_color"), ("plate-color", "set_plate_color"), ("white-color", "set_white_color"), ("pointer-line-width", "set_pointer_line_width"), ("position", "set_position"), ("positions", "set_positions")]),
|
||||
("InstSeg14Display1", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("value", "set_value")]),
|
||||
("InstSeg14Display2", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("value", "set_value")]),
|
||||
("InstSeg14Display3", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("value", "set_value")]),
|
||||
("InstSeg14Display4", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("value", "set_value")]),
|
||||
("InstSeg14Display5", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("value", "set_value")]),
|
||||
("InstSeg14Display6", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("value", "set_value")]),
|
||||
("InstSeg16Display1", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("value", "set_value")]),
|
||||
("InstSeg16Display2", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("value", "set_value")]),
|
||||
("InstSeg16Display3", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("value", "set_value")]),
|
||||
("InstSeg16Display4", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("value", "set_value")]),
|
||||
("InstSeg16Display5", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("value", "set_value")]),
|
||||
("InstSeg16Display6", &[("bezel-color", "set_bezel_color"), ("dim-color", "set_dim_color"), ("label-color", "set_label_color"), ("lit-color", "set_lit_color"), ("value", "set_value")]),
|
||||
("InstSightGlassLevel", &[("amber-color", "set_amber_color"), ("fill-color", "set_fill_color"), ("grid-color", "set_grid_color"), ("hover-color", "set_hover_color"), ("ink-color", "set_ink_color"), ("pale-color", "set_pale_color"), ("red-color", "set_red_color"), ("steel-color", "set_steel_color"), ("white-color", "set_white_color"), ("alarm-hi", "set_alarm_hi"), ("alarm-hi-hi", "set_alarm_hi_hi"), ("alarm-lo", "set_alarm_lo"), ("alarm-lo-lo", "set_alarm_lo_lo"), ("level", "set_level")]),
|
||||
("InstSlideSwitch", &[("amber-color", "set_amber_color"), ("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("green-color", "set_green_color"), ("panel-color", "set_panel_color"), ("rocker-color", "set_rocker_color"), ("white-color", "set_white_color"), ("on", "set_on")]),
|
||||
("InstSphericalTankLevel", &[("amber-color", "set_amber_color"), ("fill-color", "set_fill_color"), ("grid-color", "set_grid_color"), ("hover-color", "set_hover_color"), ("ink-color", "set_ink_color"), ("pale-color", "set_pale_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("alarm-hi", "set_alarm_hi"), ("alarm-hi-hi", "set_alarm_hi_hi"), ("alarm-lo", "set_alarm_lo"), ("alarm-lo-lo", "set_alarm_lo_lo"), ("level", "set_level")]),
|
||||
("InstStackLight", &[("amber-color", "set_amber_color"), ("dark-color", "set_dark_color"), ("green-color", "set_green_color"), ("hover-color", "set_hover_color"), ("red-color", "set_red_color"), ("tier-outline-color", "set_tier_outline_color"), ("white-color", "set_white_color"), ("all-on", "set_all"), ("amber-brightness", "set_amber_brightness"), ("amber-on", "set_amber"), ("green-brightness", "set_green_brightness"), ("green-on", "set_green"), ("red-brightness", "set_red_brightness"), ("red-on", "set_red")]),
|
||||
("InstTankLevelAlarms", &[("amber-color", "set_amber_color"), ("fill-color", "set_fill_color"), ("grid-color", "set_grid_color"), ("hover-color", "set_hover_color"), ("ink-color", "set_ink_color"), ("pale-color", "set_pale_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("alarm-hi", "set_alarm_hi"), ("alarm-hi-hi", "set_alarm_hi_hi"), ("alarm-lo", "set_alarm_lo"), ("alarm-lo-lo", "set_alarm_lo_lo"), ("level", "set_level")]),
|
||||
("InstTemperatureGauge", &[("face-color", "set_face_color"), ("ink-color", "set_ink_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("maximum", "set_range"), ("minimum", "set_range"), ("needle-line-width", "set_needle_line_width"), ("value", "set_value")]),
|
||||
("InstToggleSwitch", &[("amber-color", "set_amber_color"), ("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("greenlit-color", "set_greenlit_color"), ("panel-color", "set_panel_color"), ("plate-color", "set_plate_color"), ("redlit-color", "set_redlit_color"), ("white-color", "set_white_color"), ("lever-line-width", "set_lever_line_width"), ("on", "set_on")]),
|
||||
("InstToggleSwitchIlluminated", &[("amber-color", "set_amber_color"), ("bezel-color", "set_bezel_color"), ("dark-color", "set_dark_color"), ("dimred-color", "set_dimred_color"), ("greenlit-color", "set_greenlit_color"), ("panel-color", "set_panel_color"), ("plate-color", "set_plate_color"), ("white-color", "set_white_color"), ("lever-line-width", "set_lever_line_width"), ("on", "set_on")]),
|
||||
("InstVerticalTankLevel", &[("amber-color", "set_amber_color"), ("fill-color", "set_fill_color"), ("grid-color", "set_grid_color"), ("hover-color", "set_hover_color"), ("ink-color", "set_ink_color"), ("pale-color", "set_pale_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("alarm-hi", "set_alarm_hi"), ("alarm-hi-hi", "set_alarm_hi_hi"), ("alarm-lo", "set_alarm_lo"), ("alarm-lo-lo", "set_alarm_lo_lo"), ("level", "set_level")]),
|
||||
("InstVuMeter", &[("face-color", "set_face_color"), ("ink-color", "set_ink_color"), ("red-color", "set_red_color"), ("white-color", "set_white_color"), ("maximum", "set_range"), ("minimum", "set_range"), ("needle-line-width", "set_needle_line_width"), ("value", "set_value")]),
|
||||
("StockAccumulationDistribution", &[("line-color", "set_line_color"), ("symbol", "set_symbol"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockAreaChart", &[("axis-color", "set_axis_color"), ("down-color", "set_down_color"), ("fill-color", "set_fill_color"), ("grid-color", "set_grid_color"), ("line-color", "set_line_color"), ("up-color", "set_up_color"), ("auto-y", "set_auto_y"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("line-width", "set_line_width"), ("view-count", "set_view_count"), ("view-first", "set_view_first"), ("y-max", "set_y_range"), ("y-min", "set_y_range")]),
|
||||
("StockArrow", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("grid-color", "set_grid_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("line-width", "set_line_width")]),
|
||||
("StockBaselineChart", &[("axis-color", "set_axis_color"), ("baseline-color", "set_baseline_color"), ("down-color", "set_down_color"), ("down-fill-color", "set_down_fill_color"), ("grid-color", "set_grid_color"), ("line-color", "set_line_color"), ("up-color", "set_up_color"), ("up-fill-color", "set_up_fill_color"), ("auto-y", "set_auto_y"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("baseline", "set_baseline"), ("line-width", "set_line_width"), ("view-count", "set_view_count"), ("view-first", "set_view_first"), ("y-max", "set_y_range"), ("y-min", "set_y_range")]),
|
||||
("StockBrush", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("grid-color", "set_grid_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("line-width", "set_line_width")]),
|
||||
("StockCandlestickChart", &[("axis-color", "set_axis_color"), ("down-color", "set_down_color"), ("grid-color", "set_grid_color"), ("up-color", "set_up_color"), ("auto-y", "set_auto_y"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("view-count", "set_view_count"), ("view-first", "set_view_first"), ("y-max", "set_y_range"), ("y-min", "set_y_range")]),
|
||||
("StockCorrelationView", &[("axis-color", "set_axis_color"), ("corr-color", "set_corr_color"), ("grid-color", "set_grid_color"), ("scatter-color", "set_scatter_color"), ("zero-line-color", "set_zero_line_color"), ("view-count", "set_view_count"), ("view-first", "set_view_first"), ("window", "set_window")]),
|
||||
("StockEllipse", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("fill-color", "set_fill_color"), ("grid-color", "set_grid_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("line-width", "set_line_width")]),
|
||||
("StockFibExtension", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("grid-color", "set_grid_color"), ("level-color", "set_level_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w")]),
|
||||
("StockFibRetracement", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("grid-color", "set_grid_color"), ("level-color", "set_level_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w")]),
|
||||
("StockHeikinAshi", &[("axis-color", "set_axis_color"), ("down-color", "set_down_color"), ("grid-color", "set_grid_color"), ("up-color", "set_up_color"), ("auto-y", "set_auto_y"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("view-count", "set_view_count"), ("view-first", "set_view_first"), ("y-max", "set_y_range"), ("y-min", "set_y_range")]),
|
||||
("StockHollowCandles", &[("axis-color", "set_axis_color"), ("down-color", "set_down_color"), ("grid-color", "set_grid_color"), ("up-color", "set_up_color"), ("auto-y", "set_auto_y"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("view-count", "set_view_count"), ("view-first", "set_view_first"), ("y-max", "set_y_range"), ("y-min", "set_y_range")]),
|
||||
("StockHorizontalLine", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("grid-color", "set_grid_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("line-width", "set_line_width")]),
|
||||
("StockIndexedComparison", &[("base-line-color", "set_base_line_color"), ("base-value", "set_base_value"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockLineChart", &[("axis-color", "set_axis_color"), ("down-color", "set_down_color"), ("grid-color", "set_grid_color"), ("line-color", "set_line_color"), ("up-color", "set_up_color"), ("auto-y", "set_auto_y"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("line-width", "set_line_width"), ("view-count", "set_view_count"), ("view-first", "set_view_first"), ("y-max", "set_y_range"), ("y-min", "set_y_range")]),
|
||||
("StockMeasureTool", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("grid-color", "set_grid_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("line-width", "set_line_width")]),
|
||||
("StockMoneyFlowChart", &[("down-color", "set_down_color"), ("up-color", "set_up_color"), ("zero-line-color", "set_zero_line_color"), ("symbol", "set_symbol"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockMultiSymbolChart", &[("axis-color", "set_axis_color"), ("grid-color", "set_grid_color"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockOBVChart", &[("line-color", "set_line_color"), ("symbol", "set_symbol"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockOHLCBarChart", &[("axis-color", "set_axis_color"), ("down-color", "set_down_color"), ("grid-color", "set_grid_color"), ("up-color", "set_up_color"), ("auto-y", "set_auto_y"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("view-count", "set_view_count"), ("view-first", "set_view_first"), ("y-max", "set_y_range"), ("y-min", "set_y_range")]),
|
||||
("StockOverlayChart", &[("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockParallelChannel", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("grid-color", "set_grid_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("line-width", "set_line_width")]),
|
||||
("StockPitchfork", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("grid-color", "set_grid_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("line-width", "set_line_width")]),
|
||||
("StockPriceLabel", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("grid-color", "set_grid_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w")]),
|
||||
("StockRatioChart", &[("line-color", "set_line_color"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockRectangle", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("fill-color", "set_fill_color"), ("grid-color", "set_grid_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("line-width", "set_line_width")]),
|
||||
("StockRelativePerformance", &[("zero-line-color", "set_zero_line_color"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockRenko", &[("axis-color", "set_axis_color"), ("down-color", "set_down_color"), ("grid-color", "set_grid_color"), ("up-color", "set_up_color"), ("auto-y", "set_auto_y"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("brick-size", "set_brick_size"), ("view-count", "set_view_count"), ("view-first", "set_view_first"), ("y-max", "set_y_range"), ("y-min", "set_y_range")]),
|
||||
("StockSectorComparison", &[("labels", "set_labels_text"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockSpreadChart", &[("line-color", "set_line_color"), ("zero-line-color", "set_zero_line_color"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockTextAnnotation", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("fill-color", "set_fill_color"), ("grid-color", "set_grid_color"), ("text-color", "set_text_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("annotation-text", "set_annotation_text"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w")]),
|
||||
("StockTrendline", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("grid-color", "set_grid_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("line-width", "set_line_width")]),
|
||||
("StockVWAP", &[("line-color", "set_line_color"), ("vwap-color", "set_vwap_color"), ("symbol", "set_symbol"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockVerticalLine", &[("axis-color", "set_axis_color"), ("candle-down-color", "set_candle_down_color"), ("candle-up-color", "set_candle_up_color"), ("color", "set_color"), ("grid-color", "set_grid_color"), ("anchor-1-bar", "set_anchors"), ("anchor-1-price", "set_anchors"), ("anchor-2-bar", "set_anchors"), ("anchor-2-price", "set_anchors"), ("anchor-3-bar", "set_anchors"), ("anchor-3-price", "set_anchors"), ("axis-height", "set_axis_h"), ("axis-width", "set_axis_w"), ("line-width", "set_line_width")]),
|
||||
("StockVolumeBars", &[("down-color", "set_down_color"), ("grid-color", "set_grid_color"), ("line-color", "set_line_color"), ("up-color", "set_up_color"), ("symbol", "set_symbol"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockVolumeCandles", &[("down-color", "set_down_color"), ("up-color", "set_up_color"), ("symbol", "set_symbol"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
("StockVolumeProfile", &[("line-color", "set_line_color"), ("poc-color", "set_poc_color"), ("bins", "set_bins"), ("symbol", "set_symbol"), ("view-count", "set_view_count"), ("view-first", "set_view_first")]),
|
||||
];
|
||||
|
||||
// Phase 4: classes with set_bg_color(Srgb) (generated by
|
||||
// tools/gen_phase4_props.py). The common "background"
|
||||
// prop is emitted through set_bg_color for these.
|
||||
static PHASE4_BG_COLOR: &[&str] = &[
|
||||
"InstLedDigits1",
|
||||
"InstLedDigits2",
|
||||
"InstLedDigits3",
|
||||
"InstLedDigits4",
|
||||
"InstLedDigits5",
|
||||
"InstLedDigits6",
|
||||
"InstSeg14Display1",
|
||||
"InstSeg14Display2",
|
||||
"InstSeg14Display3",
|
||||
"InstSeg14Display4",
|
||||
"InstSeg14Display5",
|
||||
"InstSeg14Display6",
|
||||
"InstSeg16Display1",
|
||||
"InstSeg16Display2",
|
||||
"InstSeg16Display3",
|
||||
"InstSeg16Display4",
|
||||
"InstSeg16Display5",
|
||||
"InstSeg16Display6",
|
||||
"StockAccumulationDistribution",
|
||||
"StockAreaChart",
|
||||
"StockArrow",
|
||||
"StockBaselineChart",
|
||||
"StockBrush",
|
||||
"StockCandlestickChart",
|
||||
"StockCorrelationView",
|
||||
"StockEllipse",
|
||||
"StockFibExtension",
|
||||
"StockFibRetracement",
|
||||
"StockHeikinAshi",
|
||||
"StockHollowCandles",
|
||||
"StockHorizontalLine",
|
||||
"StockIndexedComparison",
|
||||
"StockLineChart",
|
||||
"StockMeasureTool",
|
||||
"StockMoneyFlowChart",
|
||||
"StockMultiSymbolChart",
|
||||
"StockOBVChart",
|
||||
"StockOHLCBarChart",
|
||||
"StockOverlayChart",
|
||||
"StockParallelChannel",
|
||||
"StockPitchfork",
|
||||
"StockPriceLabel",
|
||||
"StockRatioChart",
|
||||
"StockRectangle",
|
||||
"StockRelativePerformance",
|
||||
"StockRenko",
|
||||
"StockSectorComparison",
|
||||
"StockSpreadChart",
|
||||
"StockTextAnnotation",
|
||||
"StockTrendline",
|
||||
"StockVWAP",
|
||||
"StockVerticalLine",
|
||||
"StockVolumeBars",
|
||||
"StockVolumeCandles",
|
||||
"StockVolumeProfile",
|
||||
];
|
||||
|
||||
/// Resolve the XFrame class name for a Phase 4 lookup: the StockChart
|
||||
/// palette key maps to its class; direct class names pass through.
|
||||
fn phase4_class(kind: &str) -> &str {
|
||||
if kind == "StockChart" {
|
||||
"StockCandlestickChart"
|
||||
} else {
|
||||
kind
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind: &str) {
|
||||
let t = kind;
|
||||
let has = |n: &str| w.props.get(n).is_some_and(|v| !v.is_empty());
|
||||
@@ -2168,14 +2349,7 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
// GTK chart's CSV/indicator/drawing engine has no counterpart in
|
||||
// the XFrame widget API, so the design data is recorded here for
|
||||
// hand-wiring instead of silently dropped.
|
||||
let up = prop_rgb_args(w, "up-color");
|
||||
let down = prop_rgb_args(w, "down-color");
|
||||
if !up.is_empty() {
|
||||
emit_color_call(o, var, "set_up_color", true, &up);
|
||||
}
|
||||
if !down.is_empty() {
|
||||
emit_color_call(o, var, "set_down_color", true, &down);
|
||||
}
|
||||
// up/down colours are emitted by the generic Phase 4 loop below.
|
||||
if has("data-file")
|
||||
|| has("indicators")
|
||||
|| has("drawings")
|
||||
@@ -2244,6 +2418,132 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
));
|
||||
}
|
||||
|
||||
// Phase 4: Stock/Instrumentation generic emission. One call per
|
||||
// Inspector-table prop the widget actually has, gated by the
|
||||
// capability table (so a prop is never emitted for a class whose
|
||||
// widget lacks the setter) and by the table kind (so "value" emits
|
||||
// set_value(double) for gauges and set_value("...") for Seg displays).
|
||||
{
|
||||
let cls = phase4_class(t);
|
||||
if let Some(caps) = PHASE4_CAPS
|
||||
.iter()
|
||||
.find(|(c, _)| *c == cls)
|
||||
.map(|(_, r)| *r)
|
||||
{
|
||||
// Pairs first: one setter takes two values, so both props
|
||||
// are emitted together from the model.
|
||||
if w.props.contains_key("minimum") || w.props.contains_key("maximum") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_range({}, {});\n",
|
||||
fmt_double(&prop_or(w, "minimum", "0")),
|
||||
fmt_double(&prop_or(w, "maximum", "100"))
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("y-min") || w.props.contains_key("y-max") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_y_range({}, {});\n",
|
||||
fmt_double(&prop_or(w, "y-min", "0")),
|
||||
fmt_double(&prop_or(w, "y-max", "1"))
|
||||
));
|
||||
}
|
||||
// Anchors: all six components -> set_anchors3; otherwise
|
||||
// one set_anchor(i, bar, price) per anchor whose two
|
||||
// components are both present (never silently reset a
|
||||
// sibling anchor).
|
||||
let all6 = [
|
||||
"anchor-1-bar",
|
||||
"anchor-1-price",
|
||||
"anchor-2-bar",
|
||||
"anchor-2-price",
|
||||
"anchor-3-bar",
|
||||
"anchor-3-price",
|
||||
]
|
||||
.iter()
|
||||
.all(|k| w.props.contains_key(*k));
|
||||
if all6 {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_anchors3({}, {}, {}, {}, {}, {});\n",
|
||||
prop_int(w, "anchor-1-bar", 0),
|
||||
fmt_double(&prop_or(w, "anchor-1-price", "100")),
|
||||
prop_int(w, "anchor-2-bar", 10),
|
||||
fmt_double(&prop_or(w, "anchor-2-price", "100")),
|
||||
prop_int(w, "anchor-3-bar", 20),
|
||||
fmt_double(&prop_or(w, "anchor-3-price", "100"))
|
||||
));
|
||||
} else {
|
||||
for i in 1..=3 {
|
||||
let bar_key = format!("anchor-{i}-bar");
|
||||
let price_key = format!("anchor-{i}-price");
|
||||
if !w.props.contains_key(&bar_key) || !w.props.contains_key(&price_key) {
|
||||
continue;
|
||||
}
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_anchor({}, {}, {});\n",
|
||||
i - 1,
|
||||
prop_int(w, &bar_key, (i - 1) * 10),
|
||||
fmt_double(&prop_or(w, &price_key, "100"))
|
||||
));
|
||||
}
|
||||
}
|
||||
for (prop, setter) in caps {
|
||||
if *prop == "text" {
|
||||
continue; // shared path above
|
||||
}
|
||||
if *prop == "minimum"
|
||||
|| *prop == "maximum"
|
||||
|| *prop == "y-min"
|
||||
|| *prop == "y-max"
|
||||
|| prop.starts_with("anchor-")
|
||||
{
|
||||
continue; // pairs, emitted above
|
||||
}
|
||||
if !w.props.contains_key(*prop) {
|
||||
continue;
|
||||
}
|
||||
let Some(d) = find_prop(cls, *prop) else {
|
||||
continue;
|
||||
};
|
||||
match d.kind {
|
||||
PropKind::Color => {
|
||||
let rgb = prop_rgb_args(w, *prop);
|
||||
if !rgb.is_empty() {
|
||||
emit_color_call(o, var, setter, true, &rgb);
|
||||
}
|
||||
}
|
||||
PropKind::Double => {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.{setter}({});\n",
|
||||
fmt_double(&prop_or(w, *prop, d.def))
|
||||
));
|
||||
}
|
||||
PropKind::Int => {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.{setter}({});\n",
|
||||
prop_int(w, *prop, d.def.parse::<i32>().unwrap_or(0))
|
||||
));
|
||||
}
|
||||
PropKind::Str => {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.{setter}(\"{}\");\n",
|
||||
esc_c(&prop_or(w, *prop, d.def))
|
||||
));
|
||||
}
|
||||
// Bool (no Enum props in the Phase 4 tables).
|
||||
_ => {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.{setter}({});\n",
|
||||
if prop_bool(w, *prop, d.def == "true") {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Common background / foreground: direct setter where the class has
|
||||
// one, otherwise the per-widget style clone (emitted above).
|
||||
if !m.fill.is_empty() {
|
||||
@@ -2251,6 +2551,13 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
if !rgb.is_empty() {
|
||||
emit_color_call(o, var, m.fill, m.fill_srgb, &rgb);
|
||||
}
|
||||
} else {
|
||||
// Phase 4: the map has no fill setter for Stock/Inst classes;
|
||||
// those with set_bg_color take the background through it.
|
||||
let rgb = prop_rgb_args(w, "background");
|
||||
if !rgb.is_empty() && PHASE4_BG_COLOR.contains(&phase4_class(t)) {
|
||||
emit_color_call(o, var, "set_bg_color", true, &rgb);
|
||||
}
|
||||
}
|
||||
if !m.text.is_empty() {
|
||||
let rgb = prop_rgb_args(w, "foreground");
|
||||
|
||||
@@ -401,6 +401,33 @@ def main():
|
||||
out.append(' {"%s", {%s}},' % (w, ", ".join(rows)))
|
||||
print("\n".join(out))
|
||||
return
|
||||
if mode == "caps_rs":
|
||||
# Same capability table as "caps", in Rust syntax for
|
||||
# crates/lightgui-gen/src/gen.rs (PHASE4_CAPS).
|
||||
out = []
|
||||
out.append("// Phase 4 capability table (generated by tools/gen_phase4_props.py).")
|
||||
out.append("// (prop, setter) rows the generator may emit for a class; the arg")
|
||||
out.append("// form comes from the Inspector table's kind for that prop.")
|
||||
for w in sorted(all_props):
|
||||
rows = []
|
||||
for (prop, kind, lo, hi, default, setter) in all_props[w]:
|
||||
if prop == "text":
|
||||
continue # text is emitted by the shared path, not here
|
||||
rows.append('("%s", "%s")' % (prop, setter))
|
||||
out.append(' ("%s", &[%s]),' % (w, ", ".join(rows)))
|
||||
print("\n".join(out))
|
||||
return
|
||||
if mode == "bg_rs":
|
||||
# Same bg list as "bg", in Rust syntax (PHASE4_BG_COLOR).
|
||||
out = []
|
||||
out.append("// Phase 4: classes with set_bg_color(Srgb) (generated by")
|
||||
out.append("// tools/gen_phase4_props.py). The common \"background\"")
|
||||
out.append("// prop is emitted through set_bg_color for these.")
|
||||
for w in sorted(widgets):
|
||||
if "set_bg_color" in widgets[w]["setters"]:
|
||||
out.append(' "%s",' % w)
|
||||
print("\n".join(out))
|
||||
return
|
||||
if mode == "registry":
|
||||
# Named dispatch for the C++ live-apply path (widgets/common/registry.h):
|
||||
# 8 IWidget virtuals + one SFINAE trait per distinct Phase-4 setter +
|
||||
|
||||
Reference in new issue
Block a user