Phase 3: live-apply new Inspector props on the canvas (xframe_core_apply_prop)

This commit is contained in:
cnmcdee committed 2026-11-30 11:57:53 +00:00
1 parent 5a5420637a
commit af5af872bd
1 file changed
+297 -3
+297 -3
View File
@@ -762,6 +762,13 @@ bool xframe_core_apply_prop(XFrameCanvasCore* c, int id,
if (cls == "GtkScale") refresh_scale_marks(p);
return ok;
}
if (cls == "GtkProgressBar") {
double v = 0;
if (parse_double_strict(value, v))
return name == "minimum" ? p->wdg->set_min(v)
: p->wdg->set_max(v);
return true;
}
return true;
}
if (name == "step-increment") {
@@ -832,8 +839,17 @@ bool xframe_core_apply_prop(XFrameCanvasCore* c, int id,
return p->wdg->set_cursor_visible(value == "true");
if (name == "selection-mode")
return p->wdg->set_multi_select(value == "3");
if (name == "orientation")
return p->wdg->set_orientation_vertical(value != "0");
if (name == "orientation") {
// GtkPaned takes an int orientation (its own setter); the rest
// take the vertical flag.
int v = 0;
if (parse_int_strict(value, v)) {
const std::string& cls = lg::kWidgetNames[p->type];
if (cls == "GtkPaned") return p->wdg->set_orientation(v);
return p->wdg->set_orientation_vertical(v != 0);
}
return true;
}
if (name == "draw-value")
return p->wdg->set_draw_value(value == "true");
if (name == "editable") return p->wdg->set_editable(value == "true");
@@ -972,7 +988,22 @@ bool xframe_core_apply_prop(XFrameCanvasCore* c, int id,
return p->wdg->set_row_height(v);
return true;
}
if (name == "columns") return true; // model-only: single-column list
if (name == "columns") {
// StringGrid / Spreadsheet resize the grid; ListView has no
// columns API, so its columns prop stays model-only.
const std::string& cls = lg::kWidgetNames[p->type];
if (cls == "TStringGrid" || cls == "XSpreadsheet") {
int r = prop_int(p, "rows", 5);
int cc = prop_int(p, "columns", 4);
return p->wdg->set_size(cc, r);
}
return true;
}
if (name == "rows") {
int r = prop_int(p, "rows", 5);
int cc = prop_int(p, "columns", 4);
return p->wdg->set_size(cc, r);
}
if (name == "integral-height") {
// Snap the widget height to a whole number of rows.
int ih = prop_int(p, "item-height", 0);
@@ -1021,6 +1052,269 @@ bool xframe_core_apply_prop(XFrameCanvasCore* c, int id,
if (name == "want-returns")
return p->wdg->set_want_returns(value == "true");
if (name == "checked-items") return p->wdg->set_checked_items(value);
// --- Phase 3 per-widget custom properties (proposal §2.11–§2.22) ---
if (name == "label-xalign") {
double v = 0;
if (parse_double_strict(value, v)) return p->wdg->set_xalign(v);
return true;
}
if (name == "inset") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_inset(v);
return true;
}
if (name == "top-inset") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_top_inset(v);
return true;
}
if (name == "stretch") return p->wdg->set_stretch(value == "true");
if (name == "proportional")
return p->wdg->set_proportional(value == "true");
if (name == "center") return p->wdg->set_center(value == "true");
if (name == "pixel-size") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_pixel_size(v);
return true;
}
if (name == "file") return p->wdg->set_filename(value);
if (name == "position") {
// Splitter takes an int position; ProgressBar a double.
const std::string& cls = lg::kWidgetNames[p->type];
if (cls == "GtkPaned") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_position(v);
return true;
}
double v = 0;
if (parse_double_strict(value, v)) return p->wdg->set_position(v);
return true;
}
if (name == "show-text") return p->wdg->set_show_text(value == "true");
if (name == "pulsing") return p->wdg->set_pulsing(value == "true");
if (name == "inverted") return p->wdg->set_inverted(value == "true");
if (name == "step") {
double v = 0;
if (parse_double_strict(value, v)) return p->wdg->set_step(v);
return true;
}
if (name == "bar-color") {
Srgb col;
if (parse_hex_color(value, col))
return p->wdg->set_bar_color_rgb(col.r, col.g, col.b);
return true;
}
if (name == "trough-color") {
Srgb col;
if (parse_hex_color(value, col))
return p->wdg->set_trough_color_rgb(col.r, col.g, col.b);
return true;
}
if (name == "show-week-numbers")
return p->wdg->set_show_week_numbers(value == "true");
if (name == "date") {
int y = 0, m = 0, d = 0;
if (std::sscanf(value.c_str(), "%d-%d-%d", &y, &m, &d) == 3)
return p->wdg->set_date(y, m, d);
return true;
}
if (name == "grid-color") {
Srgb col;
if (parse_hex_color(value, col))
return p->wdg->set_grid_color_rgb(col.r, col.g, col.b);
return true;
}
if (name == "selected-fill-color") {
Srgb col;
if (parse_hex_color(value, col))
return p->wdg->set_selected_fill_color_rgb(col.r, col.g, col.b);
return true;
}
if (name == "selected-text-color") {
Srgb col;
if (parse_hex_color(value, col))
return p->wdg->set_selected_text_color_rgb(col.r, col.g, col.b);
return true;
}
if (name == "today-color") {
Srgb col;
if (parse_hex_color(value, col))
return p->wdg->set_today_color_rgb(col.r, col.g, col.b);
return true;
}
if (name == "dim-text-color") {
Srgb col;
if (parse_hex_color(value, col))
return p->wdg->set_dim_text_color_rgb(col.r, col.g, col.b);
return true;
}
if (name == "weekends-color") {
Srgb col;
if (parse_hex_color(value, col))
return p->wdg->set_weekends_color_rgb(col.r, col.g, col.b);
return true;
}
if (name == "disabled-color") {
Srgb col;
if (parse_hex_color(value, col))
return p->wdg->set_disabled_color_rgb(col.r, col.g, col.b);
return true;
}
if (name == "default-color") {
Srgb col;
if (parse_hex_color(value, col))
return p->wdg->set_default_color_rgb(col.r, col.g, col.b);
return true;
}
if (name == "none-color") {
Srgb col;
if (parse_hex_color(value, col))
return p->wdg->set_none_color_rgb(col.r, col.g, col.b);
return true;
}
if (name == "view-style") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_view_style(v);
return true;
}
if (name == "grid-lines")
return p->wdg->set_grid_lines(value == "true");
if (name == "row-select")
return p->wdg->set_row_select(value == "true");
if (name == "multi-select")
return p->wdg->set_multi_select(value == "true");
if (name == "sort-type") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_sort_type(v);
return true;
}
if (name == "header-height") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_header_height(v);
return true;
}
if (name == "headers-visible")
return p->wdg->set_headers_visible(value == "true");
if (name == "indent") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_indent(v);
return true;
}
if (name == "show-buttons")
return p->wdg->set_show_buttons(value == "true");
if (name == "show-lines")
return p->wdg->set_show_lines(value == "true");
if (name == "show-root")
return p->wdg->set_show_root(value == "true");
if (name == "tab-height") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_tab_height(v);
return true;
}
if (name == "tab-position") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_tab_position(v);
return true;
}
if (name == "tab-width") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_tab_width(v);
return true;
}
if (name == "pages") return p->wdg->set_items(value);
if (name == "page") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_current_page(v);
return true;
}
if (name == "group-index") {
// Stored on the widget; the group behaviour itself is
// model-only (no cross-widget coordination yet).
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_group_index(v);
return true;
}
if (name == "allow-all-up")
return p->wdg->set_allow_all_up(value == "true");
if (name == "flat") return p->wdg->set_flat(value == "true");
if (name == "min-size") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_min_size(v);
return true;
}
if (name == "resize-style") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_resize_style(v);
return true;
}
if (name == "auto-snap")
return p->wdg->set_auto_snap(value == "true");
if (name == "panels") return p->wdg->set_items(value);
if (name == "size-grip")
return p->wdg->set_size_grip(value == "true");
if (name == "show-captions")
return p->wdg->set_show_captions(value == "true");
if (name == "button-width") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_button_width(v);
return true;
}
if (name == "button-height") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_button_height(v);
return true;
}
if (name == "menus") return p->wdg->set_items(value);
if (name == "shape") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_shape(v);
return true;
}
if (name == "fill-color") {
Srgb col;
if (parse_hex_color(value, col)) return p->wdg->set_fill_color(col);
return true;
}
if (name == "pen-color") {
Srgb col;
if (parse_hex_color(value, col)) return p->wdg->set_pen_color(col);
return true;
}
if (name == "pen-width") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_pen_width(v);
return true;
}
if (name == "fixed-cols") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_frozen_cols(v);
return true;
}
if (name == "fixed-rows") {
int v = 0;
if (parse_int_strict(value, v)) return p->wdg->set_frozen_rows(v);
return true;
}
if (name == "default-col-width") {
int v = 0;
if (parse_int_strict(value, v))
return p->wdg->set_default_col_width(v);
return true;
}
if (name == "default-row-height") {
int v = 0;
if (parse_int_strict(value, v) && v > 0)
return p->wdg->set_row_height(v);
return true;
}
if (name == "grid-line-width") {
int v = 0;
if (parse_int_strict(value, v))
return p->wdg->set_grid_line_width(v);
return true;
}
if (name == "editor-enabled")
return p->wdg->set_editable(value == "true");
// Model-only (stored + emitted by the generator; no live setter):
// anchor-top/left/right/bottom, align, tab-order, tab-stop,
// cursor, tag, margin-*, show-hint, hint/tooltip-text.