From: Olaf Wintermann Date: Mon, 18 May 2026 20:34:09 +0000 (+0200) Subject: add UI for the new notebook dialog X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=HEAD;p=note.git add UI for the new notebook dialog --- diff --git a/application/src/newnotebook.rs b/application/src/newnotebook.rs index e65ec9e..395501b 100644 --- a/application/src/newnotebook.rs +++ b/application/src/newnotebook.rs @@ -28,10 +28,12 @@ use ui_rs::{UiModel, UiActions}; use ui_rs::ui::*; +use entity::collection::{Model as Collection}; #[derive(UiModel, UiActions, Default)] struct NewNotebookDialog { - name: UiString + name: UiString, + groups: UiList } pub fn new_notebook_dialog(parent: &UiObject) { @@ -53,8 +55,19 @@ pub fn new_notebook_dialog(parent: &UiObject) { a.margin(10); a.columnspacing(10); a.rowspacing(10); + a.def_hexpand(true); + a.def_hfill(true); + a.def_vfill(true); + a.fill(true); }, |obj| { - + obj.grid_row(|obj| { + obj.rlabel_builder().label("Group").create(); + obj.dropdown_builder::().value(&data.groups).create(); + }); + obj.grid_row(|obj| { + obj.rlabel_builder().label("Name").create(); + obj.textfield_builder().value(&data.name).create(); + }); }); }).show(); } \ No newline at end of file diff --git a/application/window.c b/application/window.c index 0f3e2b5..6aabbb5 100644 --- a/application/window.c +++ b/application/window.c @@ -397,14 +397,14 @@ void action_notebook_add(UiEvent *event, void *userdata) { obj->window = wdata; // Dialog UI - ui_grid(obj, .margin = 10, .columnspacing = 10, .rowspacing = 10, .def_vfill = TRUE, .fill = TRUE) { + ui_grid(obj, .margin = 10, .columnspacing = 10, .rowspacing = 10, .def_vfill = TRUE, .def_hexpand = TRUE, .def_hfill = TRUE, .fill = TRUE) { ui_rlabel(obj, .label = "Group"); - ui_dropdown(obj, .list = wdata->groups, .getvalue = nnd_group_value, .hfill = TRUE, .hexpand = TRUE); + ui_dropdown(obj, .list = wdata->groups, .getvalue = nnd_group_value); ui_newline(obj); ui_newline(obj); ui_rlabel(obj, .label = "Name"); - ui_textfield(obj, .value = wdata->notebook_name, .hfill = TRUE, .hexpand = TRUE); + ui_textfield(obj, .value = wdata->notebook_name, .hfill = TRUE); } // Dialog Data diff --git a/ui-rs/src/ui/container.rs b/ui-rs/src/ui/container.rs index 09941ab..a3c7d01 100644 --- a/ui-rs/src/ui/container.rs +++ b/ui-rs/src/ui/container.rs @@ -246,6 +246,34 @@ impl<'a, T> ContainerBuilder<'a, T> { self } + pub fn def_hexpand(&mut self, value: bool) -> &mut Self { + unsafe { + ui_container_args_set_def_hexpand(self.args, value as c_int); + } + self + } + + pub fn def_vexpand(&mut self, value: bool) -> &mut Self { + unsafe { + ui_container_args_set_def_vexpand(self.args, value as c_int); + } + self + } + + pub fn def_hfill(&mut self, value: bool) -> &mut Self { + unsafe { + ui_container_args_set_def_hfill(self.args, value as c_int); + } + self + } + + pub fn def_vfill(&mut self, value: bool) -> &mut Self { + unsafe { + ui_container_args_set_def_vfill(self.args, value as c_int); + } + self + } + pub fn name(&mut self, value: &str) -> &mut Self { let cstr = CString::new(value).unwrap(); unsafe { @@ -1143,6 +1171,10 @@ extern "C" { fn ui_container_args_set_margin_top(args: *mut UiContainerArgs, value: c_int); fn ui_container_args_set_margin_bottom(args: *mut UiContainerArgs, value: c_int); fn ui_container_args_set_colspan(args: *mut UiContainerArgs, value: c_int); + fn ui_container_args_set_def_hexpand(args: *mut UiContainerArgs, value: c_int); + fn ui_container_args_set_def_vexpand(args: *mut UiContainerArgs, value: c_int); + fn ui_container_args_set_def_hfill(args: *mut UiContainerArgs, value: c_int); + fn ui_container_args_set_def_vfill(args: *mut UiContainerArgs, value: c_int); fn ui_container_args_set_rowspan(args: *mut UiContainerArgs, value: c_int); fn ui_container_args_set_name(args: *mut UiContainerArgs, name: *const c_char); fn ui_container_args_set_style_class(args: *mut UiContainerArgs, classname: *const c_char); diff --git a/ui-rs/src/ui/text.rs b/ui-rs/src/ui/text.rs index 8f31900..1cd3ef3 100644 --- a/ui-rs/src/ui/text.rs +++ b/ui-rs/src/ui/text.rs @@ -516,10 +516,11 @@ impl<'a, T> TextFieldBuilder<'a, T> { self } - pub fn value(&mut self, value: &toolkit::UiString) { + pub fn value(&mut self, value: &toolkit::UiString) -> &mut Self { unsafe { ui_textfield_args_set_value(self.args, value.ptr); } + self } pub fn onactivate(&mut self, f: F) -> &mut Self