From: Olaf Wintermann Date: Fri, 24 Jul 2026 19:25:50 +0000 (+0200) Subject: use new widget/container macros for the note window ui X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fmain;p=note.git use new widget/container macros for the note window ui --- diff --git a/application/note/src/window.rs b/application/note/src/window.rs index fed3a66..5f518d4 100644 --- a/application/note/src/window.rs +++ b/application/note/src/window.rs @@ -28,7 +28,7 @@ use std::any::Any; use backend::backend::{BackendHandle, BroadcastMessage, NoteId}; -use ui_rs::{action, button, hbox, ui_actions, UiModel}; +use ui_rs::{action, button, grid, hbox, label, sidebar, sourcelist, tableview, tabview, textarea, textfield, ui_actions, UiModel}; use ui_rs::ui::*; use crate::{App, AppStates}; use entity::collection::{Model as Collection, Node}; @@ -195,13 +195,12 @@ pub fn create_window(app: &App, ctx: &AppContext) -> UiObject) -> UiObject) -> UiObject() - .varname("notes") - .model(&model) - .fill(true) - .getvalue(notelist_getvalue) - .onselection_action("note_selected") - .onactivate_action("note_activated") - .create(); + tableview!(obj, + varname = "notes", + model = &model, + fill = true, + getvalue = notelist_getvalue, + onselection_action = "note_selected", + onactivate_action = "note_activated"); }); obj.right_panel_builder().create(|obj|{ - obj.tabview( - |b|{ - b.fill(true); - b.tabview_type(TabViewType::Invisible); - b.varname("note_type"); - }, - |tabview| { - tabview.tab("empty", |_obj| {}); - - tabview.tab("textnote", |obj| { - obj.label(|l|{ - l.margin(4); - l.varname("note_info"); - l.visibility_states(&[AppStates::NoteShowInfo as i32]); - }); + tabview!(obj, fill = true, tabview_type = TabViewType::Invisible, varname = "note_type", |tabview|{ + tabview.tab("empty", |_obj| {}); - obj.hbox_builder() - .visibility_states(&[AppStates::NoteShowExtModInfo as i32]) - .spacing(4) - .create(|obj|{ - obj.label(|l|{ - l.label("The note has been modified by an external program"); - l.fill(true); - }); - obj.button(|b|{ - b.label("Reload"); - b.action("note_reload"); - }); - obj.button(|b|{ - b.label("Close"); - b.action("note_extmod_close"); - }); - }); + tabview.tab("textnote", |obj| { + label!(obj, margin = 4, varname = "note_info", visibility_states = &[AppStates::NoteShowInfo as i32]); - let textarea = obj.textarea(|b|{ - b.fill(true); - b.varname("note_text"); - b.onchange_action("note_text_change"); - b.ontextchanged_action("note_text_changed"); - }); - obj.ctx.add_action_untyped("textarea_focus", move|_event|{ - textarea.focus(); - }); + hbox!(obj, visibility_states = &[AppStates::NoteShowExtModInfo as i32], spacing = 4, |obj|{ + label!(obj, fill = true, label = "The note has been modified by an external program"); + button!(obj, label = "Reload", action = "note_reload"); + button!(obj, label = "Close", action = "note_extmod_close"); }); + let textarea = textarea!(obj, fill = true, varname = "note_text", onchange_action = "note_text_change", ontextchanged_action = "note_text_changed"); + obj.ctx.add_action_untyped("textarea_focus", move|_event|{ + textarea.focus(); + }); + }); - tabview.tab("file", |obj| { - obj.grid( - |g|{ - g.fill(true); - g.margin(8); - g.columnspacing(8); - g.rowspacing(8); - g.def_vfill(true); - }, - |obj|{ - obj.grid_row(|obj|{ - obj.rlabel(|l|{ - l.label("Name"); - }); - obj.textfield(|t|{ - t.hexpand(true); - t.hfill(true); - t.varname("note_nodename"); - t.onchange_action("note_nodename_change"); - }); - button!(obj, label = "Open", action = "open_extern"); - }); - - hbox!(obj, spacing = 10, |obj| { - - }); - } - ); + tabview.tab("file", |obj| { + grid!(obj, fill = true, margin = 8, columnspacing = 8, rowspacing = 8, def_vfill = true, |g|{ + g.grid_row(|obj|{ + label!(obj, label = "Name"); + textfield!(obj, hexpand = true, hfill = true, varname = "note_nodename", onchange_action = "note_nodename_change"); + button!(obj, label = "Open", action = "open_extern"); + }); }); }); + }); }); }); diff --git a/ui-rs/src/ui/container.rs b/ui-rs/src/ui/container.rs index c2025a6..5dca705 100644 --- a/ui-rs/src/ui/container.rs +++ b/ui-rs/src/ui/container.rs @@ -188,6 +188,22 @@ macro_rules! right_panel { }}; } +#[macro_export] +macro_rules! tabview { + ( + $parent:expr + $(, $name:ident = $value:expr )* + , + |$child:ident| $body:block + ) => {{ + $parent.tabview_builder() + $(.$name($value))* + .create(|$child| $body) + }}; +} + + + macro_rules! container_fn { ($fn_name:ident, $builder_fn:ident, $builder_ty:ident) => { pub fn $fn_name(&mut self, build: F, ui: U)