Phase 3: Widget trait setters + archetype fields/overrides for Inspector props (ProgressBar, SpinEdit, Calendar, Image, Notebook, ToggleButton, ListView, TreeView, Splitter, StatusBar, ToolBar, ColorBox, Shape, StringGrid, Spreadsheet)

This commit is contained in:
cnmcdee committed 2026-11-30 11:58:47 +00:00
1 parent ae56d21e34
commit c5bcdf618d
3 files changed
+920 -1

No files matched your search

+817
View File
@@ -75,6 +75,11 @@ pub struct ButtonWidget {
pub disabled_text_color: Srgb,
/// Latched/on state (C++ `InstEmergencyStop` / `InstPushButton` `set_on`).
pub on: bool,
/// Colour picker style (0 = Standard, 1 = Extended, 2 = System, 3 = Custom).
pub style_val: i32,
/// Colour picker default / "none" colours (C++ `GtkColorButton`).
pub default_color: Srgb,
pub none_color: Srgb,
/// Default button (draws an extra outer ring, C++ `default_`).
pub default_button: bool,
/// Cancel button (Esc closes the dialog; no visual effect).
@@ -101,6 +106,9 @@ impl ButtonWidget {
on_click_cb: None,
disabled_text_color: Srgb::new(140, 140, 140),
on: false,
style_val: 0,
default_color: Srgb::new(255, 255, 255),
none_color: Srgb::new(0, 0, 0),
direction: 1,
default_button: false,
cancel: false,
@@ -160,6 +168,24 @@ impl ButtonWidget {
pub fn set_layout(&mut self, v: i32) {
self.layout = v;
}
pub fn get_style(&self) -> i32 {
self.style_val
}
pub fn set_style(&mut self, v: i32) {
self.style_val = v;
}
pub fn get_default_color(&self) -> Srgb {
self.default_color
}
pub fn set_default_color(&mut self, c: Srgb) {
self.default_color = c;
}
pub fn get_none_color(&self) -> Srgb {
self.none_color
}
pub fn set_none_color(&mut self, c: Srgb) {
self.none_color = c;
}
/// MenuButton direction (0=Up 1=Down 2=Left 3=Right 4=None).
pub fn get_direction(&self) -> i32 {
self.direction
@@ -191,6 +217,15 @@ archetype_impl!(ButtonWidget, Archetype::Button,
fn set_layout(&mut self, v: i32) {
self.layout = v;
}
fn set_style(&mut self, v: i32) {
self.set_style(v);
}
fn set_default_color_rgb(&mut self, r: u8, g: u8, b: u8) {
self.set_default_color(Srgb::new(r as i32, g as i32, b as i32));
}
fn set_none_color_rgb(&mut self, r: u8, g: u8, b: u8) {
self.set_none_color(Srgb::new(r as i32, g as i32, b as i32));
}
fn draw(&self, target: &mut dyn DrawTarget, styles: &mut StyleManager) {
if !self.state.visible {
return;
@@ -261,6 +296,12 @@ pub struct ToggleWidget {
pub group_id: i32,
/// Disabled text colour (was hardcoded (140,140,140) in `draw_button_body`).
pub disabled_text_color: Srgb,
/// ToggleButton group index (stored; no cross-widget group yet).
pub group_index: i32,
/// ToggleButton: allow all buttons up.
pub allow_all_up: bool,
/// ToggleButton: flat (no polished frame unless active/pressed).
pub flat: bool,
}
impl ToggleWidget {
@@ -278,6 +319,9 @@ impl ToggleWidget {
value_unchecked: String::new(),
group_id: 0,
disabled_text_color: Srgb::new(140, 140, 140),
group_index: 0,
allow_all_up: false,
flat: false,
}
}
@@ -330,6 +374,24 @@ impl ToggleWidget {
pub fn set_group_id(&mut self, v: i32) {
self.group_id = v;
}
pub fn get_group_index(&self) -> i32 {
self.group_index
}
pub fn set_group_index(&mut self, v: i32) {
self.group_index = v;
}
pub fn get_allow_all_up(&self) -> bool {
self.allow_all_up
}
pub fn set_allow_all_up(&mut self, v: bool) {
self.allow_all_up = v;
}
pub fn get_flat(&self) -> bool {
self.flat
}
pub fn set_flat(&mut self, v: bool) {
self.flat = v;
}
}
archetype_impl!(ToggleWidget, Archetype::Toggle,
@@ -357,6 +419,15 @@ archetype_impl!(ToggleWidget, Archetype::Toggle,
fn set_group_id(&mut self, v: i32) {
self.group_id = v;
}
fn set_group_index(&mut self, v: i32) {
self.set_group_index(v);
}
fn set_allow_all_up(&mut self, v: bool) {
self.set_allow_all_up(v);
}
fn set_flat(&mut self, v: bool) {
self.set_flat(v);
}
fn draw(&self, target: &mut dyn DrawTarget, styles: &mut StyleManager) {
if !self.state.visible {
return;
@@ -740,6 +811,9 @@ archetype_impl!(EntryWidget, Archetype::Entry,
fn set_cursor_visible(&mut self, v: bool) {
self.cursor_visible = v;
}
fn set_editable(&mut self, v: bool) {
self.set_editable(v);
}
fn draw(&self, target: &mut dyn DrawTarget, styles: &mut StyleManager) {
if !self.state.visible {
return;
@@ -872,6 +946,15 @@ pub struct RangeWidget {
/// Scrollbar page increment (C++ `GtkScrollbar::page_increment_`,
/// default 10): the PgUp/PgDn step.
pub page_increment: f64,
/// ProgressBar text / pulse / direction (C++ `GtkProgressBar`).
pub show_text: bool,
pub pulsing: bool,
pub inverted: bool,
/// ProgressBar bar / trough colours.
pub bar_color: Srgb,
pub trough_color: Srgb,
/// SpinButton typing enabled (C++ `GtkSpinButton::editable_`).
pub editable: bool,
}
impl RangeWidget {
@@ -887,6 +970,12 @@ impl RangeWidget {
dragging: false,
page_size: 25.0,
page_increment: 10.0,
show_text: false,
pulsing: false,
inverted: false,
bar_color: Srgb::new(52, 101, 164),
trough_color: Srgb::new(225, 225, 225),
editable: true,
page_step: 10.0,
marks: Vec::new(),
show_sel_range: false,
@@ -958,6 +1047,69 @@ impl RangeWidget {
pub fn set_page_increment(&mut self, v: f64) {
self.page_increment = v;
}
pub fn get_show_text(&self) -> bool {
self.show_text
}
pub fn set_show_text(&mut self, v: bool) {
self.show_text = v;
}
pub fn get_pulsing(&self) -> bool {
self.pulsing
}
pub fn set_pulsing(&mut self, v: bool) {
self.pulsing = v;
}
pub fn get_inverted(&self) -> bool {
self.inverted
}
pub fn set_inverted(&mut self, v: bool) {
self.inverted = v;
}
pub fn get_bar_color(&self) -> Srgb {
self.bar_color
}
pub fn set_bar_color(&mut self, c: Srgb) {
self.bar_color = c;
}
pub fn get_trough_color(&self) -> Srgb {
self.trough_color
}
pub fn set_trough_color(&mut self, c: Srgb) {
self.trough_color = c;
}
pub fn get_editable(&self) -> bool {
self.editable
}
pub fn set_editable(&mut self, v: bool) {
self.editable = v;
}
pub fn get_position(&self) -> f64 {
self.state.value
}
pub fn set_position(&mut self, v: f64) {
self.state.value = self.state.clamp_value(v);
}
pub fn get_min(&self) -> f64 {
self.state.min
}
pub fn set_min(&mut self, v: f64) {
self.state.min = v;
self.state.value = self.state.clamp_value(self.state.value);
}
pub fn get_max(&self) -> f64 {
self.state.max
}
pub fn set_max(&mut self, v: f64) {
self.state.max = v;
self.state.value = self.state.clamp_value(self.state.value);
}
pub fn get_fraction(&self) -> f64 {
self.frac()
}
pub fn set_fraction(&mut self, f: f64) {
let (mn, mx) = (self.state.min, self.state.max);
self.state.value = self.state.clamp_value(mn + f.clamp(0.0, 1.0) * (mx - mn));
}
fn frac(&self) -> f64 {
let (mn, mx) = (self.state.min, self.state.max);
@@ -1012,6 +1164,39 @@ archetype_impl!(RangeWidget, Archetype::Range,
fn set_sel_end(&mut self, v: f64) {
self.sel_end = v;
}
fn set_show_text(&mut self, v: bool) {
self.set_show_text(v);
}
fn set_pulsing(&mut self, v: bool) {
self.set_pulsing(v);
}
fn set_inverted(&mut self, v: bool) {
self.set_inverted(v);
}
fn set_position(&mut self, v: f64) {
self.set_position(v);
}
fn set_min(&mut self, v: f64) {
self.set_min(v);
}
fn set_max(&mut self, v: f64) {
self.set_max(v);
}
fn set_fraction(&mut self, v: f64) {
self.set_fraction(v);
}
fn set_digits(&mut self, d: i32) {
self.set_digits(d);
}
fn set_editable(&mut self, v: bool) {
self.set_editable(v);
}
fn set_bar_color_rgb(&mut self, r: u8, g: u8, b: u8) {
self.set_bar_color(Srgb::new(r as i32, g as i32, b as i32));
}
fn set_trough_color_rgb(&mut self, r: u8, g: u8, b: u8) {
self.set_trough_color(Srgb::new(r as i32, g as i32, b as i32));
}
fn draw(&self, target: &mut dyn DrawTarget, styles: &mut StyleManager) {
if !self.state.visible {
return;
@@ -1167,6 +1352,27 @@ pub struct ListSelWidget {
pub open: bool,
/// Selected-row fill (was hardcoded 0xc6dcf5 in `draw`).
pub selected_fill: Srgb,
/// ListView view style (0 = report, 1 = icon, 2 = small icon, 3 = list).
pub view_style: i32,
/// ListView/TreeView grid lines.
pub grid_lines: bool,
/// ListView/TreeView full-row select (false = first column only).
pub row_select: bool,
/// ListView/TreeView sort (0 = none, 1 = ascending, 2 = descending).
pub sort_type: i32,
/// TreeView header height / visibility.
pub header_height: i32,
pub headers_visible: bool,
/// TreeView indent (pixels per level) and guides.
pub indent: i32,
pub show_buttons: bool,
pub show_lines: bool,
pub show_root: bool,
/// ToolBar captions / flat / fixed button size (0 = auto).
pub show_captions: bool,
pub flat: bool,
pub button_width: i32,
pub button_height: i32,
}
impl ListSelWidget {
@@ -1183,6 +1389,20 @@ impl ListSelWidget {
row_h: 20,
open: false,
selected_fill: Srgb::new(198, 220, 245),
view_style: 0,
grid_lines: false,
row_select: true,
sort_type: 0,
header_height: 22,
headers_visible: true,
indent: 16,
show_buttons: true,
show_lines: true,
show_root: true,
show_captions: true,
flat: false,
button_width: 0,
button_height: 0,
checked: Vec::new(),
sorted: false,
style_val: 0,
@@ -1211,6 +1431,97 @@ impl ListSelWidget {
pub fn set_row_height(&mut self, h: i32) {
self.row_h = h.max(1);
}
pub fn get_view_style(&self) -> i32 {
self.view_style
}
pub fn set_view_style(&mut self, v: i32) {
self.view_style = v;
}
pub fn get_grid_lines(&self) -> bool {
self.grid_lines
}
pub fn set_grid_lines(&mut self, v: bool) {
self.grid_lines = v;
}
pub fn get_row_select(&self) -> bool {
self.row_select
}
pub fn set_row_select(&mut self, v: bool) {
self.row_select = v;
}
pub fn get_sort_type(&self) -> i32 {
self.sort_type
}
pub fn set_sort_type(&mut self, v: i32) {
self.sort_type = v;
if v == 1 {
self.sort_items();
} else if v == 2 {
self.sort_items();
self.items.reverse();
self.checked.reverse();
}
}
pub fn get_header_height(&self) -> i32 {
self.header_height
}
pub fn set_header_height(&mut self, v: i32) {
self.header_height = v.max(1);
}
pub fn get_headers_visible(&self) -> bool {
self.headers_visible
}
pub fn set_headers_visible(&mut self, v: bool) {
self.headers_visible = v;
}
pub fn get_indent(&self) -> i32 {
self.indent
}
pub fn set_indent(&mut self, v: i32) {
self.indent = v.max(0);
}
pub fn get_show_buttons(&self) -> bool {
self.show_buttons
}
pub fn set_show_buttons(&mut self, v: bool) {
self.show_buttons = v;
}
pub fn get_show_lines(&self) -> bool {
self.show_lines
}
pub fn set_show_lines(&mut self, v: bool) {
self.show_lines = v;
}
pub fn get_show_root(&self) -> bool {
self.show_root
}
pub fn set_show_root(&mut self, v: bool) {
self.show_root = v;
}
pub fn get_show_captions(&self) -> bool {
self.show_captions
}
pub fn set_show_captions(&mut self, v: bool) {
self.show_captions = v;
}
pub fn get_flat(&self) -> bool {
self.flat
}
pub fn set_flat(&mut self, v: bool) {
self.flat = v;
}
pub fn get_button_width(&self) -> i32 {
self.button_width
}
pub fn set_button_width(&mut self, v: i32) {
self.button_width = v.max(0);
}
pub fn get_button_height(&self) -> i32 {
self.button_height
}
pub fn set_button_height(&mut self, v: i32) {
self.button_height = v.max(0);
}
pub fn get_multi_select(&self) -> bool {
self.multi
}
@@ -1319,6 +1630,48 @@ archetype_impl!(ListSelWidget, Archetype::ListSel,
fn set_char_case(&mut self, v: i32) {
self.char_case = v;
}
fn set_view_style(&mut self, v: i32) {
self.set_view_style(v);
}
fn set_grid_lines(&mut self, v: bool) {
self.set_grid_lines(v);
}
fn set_row_select(&mut self, v: bool) {
self.set_row_select(v);
}
fn set_sort_type(&mut self, v: i32) {
self.set_sort_type(v);
}
fn set_header_height(&mut self, v: i32) {
self.set_header_height(v);
}
fn set_headers_visible(&mut self, v: bool) {
self.set_headers_visible(v);
}
fn set_indent(&mut self, v: i32) {
self.set_indent(v);
}
fn set_show_buttons(&mut self, v: bool) {
self.set_show_buttons(v);
}
fn set_show_lines(&mut self, v: bool) {
self.set_show_lines(v);
}
fn set_show_root(&mut self, v: bool) {
self.set_show_root(v);
}
fn set_show_captions(&mut self, v: bool) {
self.set_show_captions(v);
}
fn set_flat(&mut self, v: bool) {
self.set_flat(v);
}
fn set_button_width(&mut self, v: i32) {
self.set_button_width(v);
}
fn set_button_height(&mut self, v: i32) {
self.set_button_height(v);
}
fn items(&self) -> &[String] {
&self.items
}
@@ -1467,6 +1820,52 @@ pub struct ContainerWidget {
pub on_click_cb: Option<Box<dyn FnMut()>>,
pub children: Vec<Box<dyn Widget>>,
pub active_page: usize,
/// Frame label x-align (0.0..=1.0; C++ `GtkFrame::set_label_xalign`).
pub label_xalign: f64,
/// Frame inner padding (C++ `GtkFrame::inset_` / `top_inset_`).
pub inset: i32,
pub top_inset: i32,
/// Calendar: show ISO week numbers in the gutter.
pub show_week_numbers: bool,
/// Calendar selected date (year, month, day).
pub date: (i32, i32, i32),
/// Calendar colours (C++ `GtkCalendar` defaults).
pub grid_color: Srgb,
pub selected_fill_color: Srgb,
pub selected_text_color: Srgb,
pub today_color: Srgb,
pub dim_text_color: Srgb,
pub weekends_color: Srgb,
pub disabled_color: Srgb,
/// Notebook tab geometry (tab_width 0 = auto).
pub tab_height: i32,
pub tab_position: i32,
pub tab_width: i32,
/// Splitter position / minimum size / resize style / auto-snap.
pub position: i32,
pub min_size: i32,
pub resize_style: i32,
pub auto_snap: bool,
/// Splitter orientation (0 = horizontal, 1 = vertical).
pub orientation: i32,
/// StatusBar size grip.
pub size_grip: bool,
/// Notebook pages / StatusBar panels / MenuBar menus (model).
pub items: Vec<String>,
/// StringGrid header visibility (headers always drawn in Rust).
pub headers_visible: bool,
/// StringGrid frozen columns / rows.
pub frozen_cols: i32,
pub frozen_rows: i32,
/// StringGrid default column width / row height / grid line width.
pub default_col_width: i32,
pub default_row_height: i32,
pub grid_line_width: i32,
/// StringGrid grid size (columns, rows).
pub grid_cols: i32,
pub grid_rows: i32,
/// TreeView header height.
pub header_height: i32,
}
impl ContainerWidget {
@@ -1478,6 +1877,37 @@ impl ContainerWidget {
on_click_cb: None,
children: Vec::new(),
active_page: 0,
label_xalign: 0.0,
inset: 8,
top_inset: 14,
show_week_numbers: false,
date: (0, 0, 0),
grid_color: Srgb::new(205, 205, 205),
selected_fill_color: Srgb::new(52, 101, 164),
selected_text_color: Srgb::new(255, 255, 255),
today_color: Srgb::new(200, 50, 50),
dim_text_color: Srgb::new(110, 110, 110),
weekends_color: Srgb::new(170, 60, 60),
disabled_color: Srgb::new(150, 150, 150),
tab_height: 26,
tab_position: 0,
tab_width: 0,
position: 100,
min_size: 0,
resize_style: 0,
auto_snap: false,
orientation: 0,
size_grip: true,
items: Vec::new(),
headers_visible: true,
frozen_cols: 0,
frozen_rows: 0,
default_col_width: 84,
default_row_height: 20,
grid_line_width: 1,
grid_cols: 4,
grid_rows: 5,
header_height: 22,
}
}
pub fn new_widget(name: &str, kind: &str, x: i32, y: i32, w: i32, h: i32) -> ContainerWidget {
@@ -1490,6 +1920,187 @@ impl ContainerWidget {
pub fn set_active_page(&mut self, page: usize) {
self.active_page = page;
}
pub fn get_label_xalign(&self) -> f64 {
self.label_xalign
}
pub fn set_label_xalign(&mut self, v: f64) {
self.label_xalign = v.clamp(0.0, 1.0);
}
pub fn get_inset(&self) -> i32 {
self.inset
}
pub fn set_inset(&mut self, v: i32) {
self.inset = v;
}
pub fn get_top_inset(&self) -> i32 {
self.top_inset
}
pub fn set_top_inset(&mut self, v: i32) {
self.top_inset = v;
}
pub fn get_show_week_numbers(&self) -> bool {
self.show_week_numbers
}
pub fn set_show_week_numbers(&mut self, v: bool) {
self.show_week_numbers = v;
}
pub fn get_date(&self) -> (i32, i32, i32) {
self.date
}
pub fn set_date(&mut self, y: i32, m: i32, d: i32) {
self.date = (y, m, d);
}
pub fn get_grid_color(&self) -> Srgb {
self.grid_color
}
pub fn set_grid_color(&mut self, c: Srgb) {
self.grid_color = c;
}
pub fn get_selected_fill_color(&self) -> Srgb {
self.selected_fill_color
}
pub fn set_selected_fill_color(&mut self, c: Srgb) {
self.selected_fill_color = c;
}
pub fn get_selected_text_color(&self) -> Srgb {
self.selected_text_color
}
pub fn set_selected_text_color(&mut self, c: Srgb) {
self.selected_text_color = c;
}
pub fn get_today_color(&self) -> Srgb {
self.today_color
}
pub fn set_today_color(&mut self, c: Srgb) {
self.today_color = c;
}
pub fn get_dim_text_color(&self) -> Srgb {
self.dim_text_color
}
pub fn set_dim_text_color(&mut self, c: Srgb) {
self.dim_text_color = c;
}
pub fn get_weekends_color(&self) -> Srgb {
self.weekends_color
}
pub fn set_weekends_color(&mut self, c: Srgb) {
self.weekends_color = c;
}
pub fn get_disabled_color(&self) -> Srgb {
self.disabled_color
}
pub fn set_disabled_color(&mut self, c: Srgb) {
self.disabled_color = c;
}
pub fn get_tab_height(&self) -> i32 {
self.tab_height
}
pub fn set_tab_height(&mut self, v: i32) {
self.tab_height = v.max(1);
}
pub fn get_tab_position(&self) -> i32 {
self.tab_position
}
pub fn set_tab_position(&mut self, v: i32) {
self.tab_position = v;
}
pub fn get_tab_width(&self) -> i32 {
self.tab_width
}
pub fn set_tab_width(&mut self, v: i32) {
self.tab_width = v.max(0);
}
pub fn get_position(&self) -> i32 {
self.position
}
pub fn set_position(&mut self, v: i32) {
self.position = v;
}
pub fn get_min_size(&self) -> i32 {
self.min_size
}
pub fn set_min_size(&mut self, v: i32) {
self.min_size = v.max(0);
}
pub fn get_resize_style(&self) -> i32 {
self.resize_style
}
pub fn set_resize_style(&mut self, v: i32) {
self.resize_style = v;
}
pub fn get_auto_snap(&self) -> bool {
self.auto_snap
}
pub fn set_auto_snap(&mut self, v: bool) {
self.auto_snap = v;
}
pub fn get_orientation(&self) -> i32 {
self.orientation
}
pub fn set_orientation(&mut self, v: i32) {
self.orientation = v;
}
pub fn get_size_grip(&self) -> bool {
self.size_grip
}
pub fn set_size_grip(&mut self, v: bool) {
self.size_grip = v;
}
pub fn get_items(&self) -> &[String] {
&self.items
}
pub fn set_items(&mut self, items: &[String]) {
self.items = items.to_vec();
}
pub fn get_headers_visible(&self) -> bool {
self.headers_visible
}
pub fn set_headers_visible(&mut self, v: bool) {
self.headers_visible = v;
}
pub fn get_frozen_cols(&self) -> i32 {
self.frozen_cols
}
pub fn set_frozen_cols(&mut self, v: i32) {
self.frozen_cols = v.max(0);
}
pub fn get_frozen_rows(&self) -> i32 {
self.frozen_rows
}
pub fn set_frozen_rows(&mut self, v: i32) {
self.frozen_rows = v.max(0);
}
pub fn get_default_col_width(&self) -> i32 {
self.default_col_width
}
pub fn set_default_col_width(&mut self, v: i32) {
self.default_col_width = v.max(1);
}
pub fn get_default_row_height(&self) -> i32 {
self.default_row_height
}
pub fn set_default_row_height(&mut self, v: i32) {
self.default_row_height = v.max(1);
}
pub fn get_grid_line_width(&self) -> i32 {
self.grid_line_width
}
pub fn set_grid_line_width(&mut self, v: i32) {
self.grid_line_width = v.max(1);
}
pub fn get_grid_size(&self) -> (i32, i32) {
(self.grid_cols, self.grid_rows)
}
pub fn set_grid_size(&mut self, cols: i32, rows: i32) {
self.grid_cols = cols.max(1);
self.grid_rows = rows.max(1);
}
pub fn get_header_height(&self) -> i32 {
self.header_height
}
pub fn set_header_height(&mut self, v: i32) {
self.header_height = v.max(1);
}
}
archetype_impl!(ContainerWidget, Archetype::Container,
@@ -1499,6 +2110,99 @@ archetype_impl!(ContainerWidget, Archetype::Container,
fn active_page(&self) -> usize {
self.active_page
}
fn set_xalign(&mut self, v: f64) {
self.set_label_xalign(v);
}
fn set_inset(&mut self, v: i32) {
self.set_inset(v);
}
fn set_top_inset(&mut self, v: i32) {
self.set_top_inset(v);
}
fn set_show_week_numbers(&mut self, v: bool) {
self.set_show_week_numbers(v);
}
fn set_date(&mut self, y: i32, m: i32, d: i32) {
self.set_date(y, m, d);
}
fn set_grid_color_rgb(&mut self, r: u8, g: u8, b: u8) {
self.set_grid_color(Srgb::new(r as i32, g as i32, b as i32));
}
fn set_selected_fill_color_rgb(&mut self, r: u8, g: u8, b: u8) {
self.set_selected_fill_color(Srgb::new(r as i32, g as i32, b as i32));
}
fn set_selected_text_color_rgb(&mut self, r: u8, g: u8, b: u8) {
self.set_selected_text_color(Srgb::new(r as i32, g as i32, b as i32));
}
fn set_today_color_rgb(&mut self, r: u8, g: u8, b: u8) {
self.set_today_color(Srgb::new(r as i32, g as i32, b as i32));
}
fn set_dim_text_color_rgb(&mut self, r: u8, g: u8, b: u8) {
self.set_dim_text_color(Srgb::new(r as i32, g as i32, b as i32));
}
fn set_weekends_color_rgb(&mut self, r: u8, g: u8, b: u8) {
self.set_weekends_color(Srgb::new(r as i32, g as i32, b as i32));
}
fn set_disabled_color_rgb(&mut self, r: u8, g: u8, b: u8) {
self.set_disabled_color(Srgb::new(r as i32, g as i32, b as i32));
}
fn set_tab_height(&mut self, v: i32) {
self.set_tab_height(v);
}
fn set_tab_position(&mut self, v: i32) {
self.set_tab_position(v);
}
fn set_tab_width(&mut self, v: i32) {
self.set_tab_width(v);
}
fn set_current_page(&mut self, v: i32) {
self.set_active_page(v.max(0) as usize);
}
fn set_position_int(&mut self, v: i32) {
self.set_position(v);
}
fn set_orientation(&mut self, v: i32) {
self.set_orientation(v);
}
fn set_min_size(&mut self, v: i32) {
self.set_min_size(v);
}
fn set_resize_style(&mut self, v: i32) {
self.set_resize_style(v);
}
fn set_auto_snap(&mut self, v: bool) {
self.set_auto_snap(v);
}
fn set_size_grip(&mut self, v: bool) {
self.set_size_grip(v);
}
fn set_items(&mut self, items: &[String]) {
self.set_items(items);
}
fn set_grid_size(&mut self, cols: i32, rows: i32) {
self.set_grid_size(cols, rows);
}
fn set_frozen_cols(&mut self, v: i32) {
self.set_frozen_cols(v);
}
fn set_frozen_rows(&mut self, v: i32) {
self.set_frozen_rows(v);
}
fn set_default_col_width(&mut self, v: i32) {
self.set_default_col_width(v);
}
fn set_row_height(&mut self, v: i32) {
self.set_default_row_height(v);
}
fn set_grid_line_width(&mut self, v: i32) {
self.set_grid_line_width(v);
}
fn set_headers_visible(&mut self, v: bool) {
self.set_headers_visible(v);
}
fn set_header_height(&mut self, v: i32) {
self.set_header_height(v);
}
fn draw(&self, target: &mut dyn DrawTarget, styles: &mut StyleManager) {
if !self.state.visible {
return;
@@ -4572,6 +5276,19 @@ pub struct DisplayWidget {
pub click_count: u32,
pub on_click_cb: Option<Box<dyn FnMut()>>,
pub progress: f64,
/// Image scaling (C++ `GtkImage`).
pub stretch: bool,
pub proportional: bool,
pub center: bool,
pub transparent: bool,
/// Image pixel size (-1 = bounds) and file name.
pub pixel_size: i32,
pub filename: String,
/// Shape type (0..=9, C++ `TShapeType`) and colours.
pub shape: i32,
pub fill_color: Srgb,
pub pen_color: Srgb,
pub pen_width: i32,
}
impl DisplayWidget {
@@ -4582,6 +5299,16 @@ impl DisplayWidget {
click_count: 0,
on_click_cb: None,
progress: 0.0,
stretch: false,
proportional: true,
center: true,
transparent: false,
pixel_size: -1,
filename: String::new(),
shape: 0,
fill_color: Srgb::new(70, 130, 200),
pen_color: Srgb::new(20, 40, 80),
pen_width: 2,
}
}
pub fn new_widget(name: &str, kind: &str, x: i32, y: i32, w: i32, h: i32) -> DisplayWidget {
@@ -4595,9 +5322,99 @@ impl DisplayWidget {
pub fn set_progress(&mut self, v: f64) {
self.progress = v;
}
pub fn get_stretch(&self) -> bool {
self.stretch
}
pub fn set_stretch(&mut self, v: bool) {
self.stretch = v;
}
pub fn get_proportional(&self) -> bool {
self.proportional
}
pub fn set_proportional(&mut self, v: bool) {
self.proportional = v;
}
pub fn get_center(&self) -> bool {
self.center
}
pub fn set_center(&mut self, v: bool) {
self.center = v;
}
pub fn get_transparent(&self) -> bool {
self.transparent
}
pub fn set_transparent(&mut self, v: bool) {
self.transparent = v;
}
pub fn get_pixel_size(&self) -> i32 {
self.pixel_size
}
pub fn set_pixel_size(&mut self, v: i32) {
self.pixel_size = v;
}
pub fn get_filename(&self) -> &str {
&self.filename
}
pub fn set_filename(&mut self, v: &str) {
self.filename = v.to_string();
}
pub fn get_shape(&self) -> i32 {
self.shape
}
pub fn set_shape(&mut self, v: i32) {
self.shape = v.clamp(0, 9);
}
pub fn get_fill_color(&self) -> Srgb {
self.fill_color
}
pub fn set_fill_color(&mut self, c: Srgb) {
self.fill_color = c;
}
pub fn get_pen_color(&self) -> Srgb {
self.pen_color
}
pub fn set_pen_color(&mut self, c: Srgb) {
self.pen_color = c;
}
pub fn get_pen_width(&self) -> i32 {
self.pen_width
}
pub fn set_pen_width(&mut self, v: i32) {
self.pen_width = v.max(1);
}
}
archetype_impl!(DisplayWidget, Archetype::Display,
fn set_stretch(&mut self, v: bool) {
self.set_stretch(v);
}
fn set_proportional(&mut self, v: bool) {
self.set_proportional(v);
}
fn set_center(&mut self, v: bool) {
self.set_center(v);
}
fn set_transparent(&mut self, v: bool) {
self.set_transparent(v);
}
fn set_pixel_size(&mut self, v: i32) {
self.set_pixel_size(v);
}
fn set_filename(&mut self, v: &str) {
self.set_filename(v);
}
fn set_shape(&mut self, v: i32) {
self.set_shape(v);
}
fn set_fill_color(&mut self, c: Srgb) {
self.set_fill_color(c);
}
fn set_pen_color(&mut self, c: Srgb) {
self.set_pen_color(c);
}
fn set_pen_width(&mut self, v: i32) {
self.set_pen_width(v);
}
fn draw(&self, target: &mut dyn DrawTarget, styles: &mut StyleManager) {
if !self.state.visible {
return;
+37
View File
@@ -79,6 +79,10 @@ pub struct XSpreadsheet {
pub header_fill_color: Srgb,
pub active_fill_color: Srgb,
pub selection_fill_color: Srgb,
/// Default column width for new columns (C++ `XSpreadsheet`).
pub default_col_width: i32,
/// Grid line width in pixels.
pub grid_line_width: i32,
}
impl XSpreadsheet {
@@ -125,6 +129,8 @@ impl XSpreadsheet {
header_fill_color: Srgb::new(232, 232, 232),
active_fill_color: Srgb::new(198, 220, 245),
selection_fill_color: Srgb::new(220, 235, 250),
default_col_width: 84,
grid_line_width: 1,
};
// Demo data (C++ constructor).
ss.set_cell_text(0, 0, "Part");
@@ -225,6 +231,19 @@ impl XSpreadsheet {
pub fn set_row_height(&mut self, h: i32) {
self.row_height = h.max(1);
}
pub fn get_default_col_width(&self) -> i32 {
self.default_col_width
}
pub fn set_default_col_width(&mut self, w: i32) {
self.default_col_width = w.max(1);
self.col_widths = vec![self.default_col_width; self.cols as usize];
}
pub fn get_grid_line_width(&self) -> i32 {
self.grid_line_width
}
pub fn set_grid_line_width(&mut self, w: i32) {
self.grid_line_width = w.max(1);
}
pub fn get_frozen_rows(&self) -> i32 {
self.frozen_rows
}
@@ -885,6 +904,24 @@ impl Widget for XSpreadsheet {
fn set_bounds(&mut self, x: i32, y: i32, w: i32, h: i32) {
self.state.bounds = Rect::new(x, y, w, h);
}
fn set_grid_size(&mut self, cols: i32, rows: i32) {
self.set_size(cols, rows);
}
fn set_frozen_cols(&mut self, v: i32) {
self.set_frozen_cols(v);
}
fn set_frozen_rows(&mut self, v: i32) {
self.set_frozen_rows(v);
}
fn set_default_col_width(&mut self, v: i32) {
self.set_default_col_width(v);
}
fn set_row_height(&mut self, v: i32) {
self.set_row_height(v);
}
fn set_grid_line_width(&mut self, v: i32) {
self.set_grid_line_width(v);
}
fn draw(&self, target: &mut dyn DrawTarget, styles: &mut StyleManager) {
if !self.state.visible {
+66 -1
View File
@@ -15,7 +15,7 @@
//! rect inset 3.
use xframe_core::draw::{draw_polished, draw_text_centered};
use xframe_core::{DrawTarget, Style, StyleManager};
use xframe_core::{DrawTarget, Srgb, Style, StyleManager};
use crate::state::{Key, Rect, WidgetState};
@@ -249,6 +249,71 @@ pub trait Widget {
fn set_want_returns(&mut self, _v: bool) {}
fn set_yalign(&mut self, _v: f64) {}
fn set_checked_items(&mut self, _csv: &str) {}
// --- Phase 3 (Inspector properties §2.11-§2.22) ---
fn set_show_text(&mut self, _v: bool) {}
fn set_pulsing(&mut self, _v: bool) {}
fn set_inverted(&mut self, _v: bool) {}
fn set_position(&mut self, _v: f64) {}
fn set_position_int(&mut self, _v: i32) {}
fn set_min(&mut self, _v: f64) {}
fn set_max(&mut self, _v: f64) {}
fn set_fraction(&mut self, _v: f64) {}
fn set_digits(&mut self, _d: i32) {}
fn set_editable(&mut self, _v: bool) {}
fn set_show_week_numbers(&mut self, _v: bool) {}
fn set_stretch(&mut self, _v: bool) {}
fn set_proportional(&mut self, _v: bool) {}
fn set_center(&mut self, _v: bool) {}
fn set_tab_width(&mut self, _v: i32) {}
fn set_tab_position(&mut self, _v: i32) {}
fn set_group_index(&mut self, _v: i32) {}
fn set_allow_all_up(&mut self, _v: bool) {}
fn set_flat(&mut self, _v: bool) {}
fn set_view_style(&mut self, _v: i32) {}
fn set_grid_lines(&mut self, _v: bool) {}
fn set_row_select(&mut self, _v: bool) {}
fn set_sort_type(&mut self, _v: i32) {}
fn set_indent(&mut self, _v: i32) {}
fn set_show_buttons(&mut self, _v: bool) {}
fn set_show_lines(&mut self, _v: bool) {}
fn set_show_root(&mut self, _v: bool) {}
fn set_min_size(&mut self, _v: i32) {}
fn set_resize_style(&mut self, _v: i32) {}
fn set_auto_snap(&mut self, _v: bool) {}
fn set_size_grip(&mut self, _v: bool) {}
fn set_show_captions(&mut self, _v: bool) {}
fn set_button_width(&mut self, _v: i32) {}
fn set_button_height(&mut self, _v: i32) {}
fn set_shape(&mut self, _v: i32) {}
fn set_pen_color(&mut self, _c: Srgb) {}
fn set_pen_width(&mut self, _v: i32) {}
fn set_frozen_cols(&mut self, _v: i32) {}
fn set_frozen_rows(&mut self, _v: i32) {}
fn set_default_col_width(&mut self, _v: i32) {}
fn set_grid_line_width(&mut self, _v: i32) {}
fn set_grid_size(&mut self, _cols: i32, _rows: i32) {}
fn set_inset(&mut self, _v: i32) {}
fn set_top_inset(&mut self, _v: i32) {}
fn set_header_height(&mut self, _v: i32) {}
fn set_headers_visible(&mut self, _v: bool) {}
fn set_current_page(&mut self, _v: i32) {}
fn set_tab_height(&mut self, _v: i32) {}
fn set_pixel_size(&mut self, _v: i32) {}
fn set_filename(&mut self, _v: &str) {}
fn set_date(&mut self, _y: i32, _m: i32, _d: i32) {}
fn set_orientation(&mut self, _v: i32) {}
fn set_bar_color_rgb(&mut self, _r: u8, _g: u8, _b: u8) {}
fn set_trough_color_rgb(&mut self, _r: u8, _g: u8, _b: u8) {}
fn set_grid_color_rgb(&mut self, _r: u8, _g: u8, _b: u8) {}
fn set_selected_fill_color_rgb(&mut self, _r: u8, _g: u8, _b: u8) {}
fn set_selected_text_color_rgb(&mut self, _r: u8, _g: u8, _b: u8) {}
fn set_today_color_rgb(&mut self, _r: u8, _g: u8, _b: u8) {}
fn set_dim_text_color_rgb(&mut self, _r: u8, _g: u8, _b: u8) {}
fn set_weekends_color_rgb(&mut self, _r: u8, _g: u8, _b: u8) {}
fn set_disabled_color_rgb(&mut self, _r: u8, _g: u8, _b: u8) {}
fn set_default_color_rgb(&mut self, _r: u8, _g: u8, _b: u8) {}
fn set_none_color_rgb(&mut self, _r: u8, _g: u8, _b: u8) {}
fn set_fill_color(&mut self, _c: Srgb) {}
fn set_max_length(&mut self, _v: i32) {}
fn set_xalign(&mut self, _v: f64) {}