-use ui_rs::{action, ui, ui_actions, UiModel};
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2026 Olaf Wintermann. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+mod window;
+
+use ui_rs::{ui};
use ui_rs::ui::*;
+use crate::window::*;
fn main() {
ui::app_init("note");
let mut app = App;
- ui::app_run::<TestData>(&mut app);
+ ui::app_run::<MainWindow>(&mut app);
}
struct App;
-#[derive(UiModel, Default)]
-struct TestData {
- i: i32,
- #[bind("list")]
- list: UiList<i32>,
- #[bind("source")]
- sublists: UiSourceList<String>
-}
-
-#[ui_actions]
-impl TestData {
- #[action]
- pub fn my_action(&mut self, _event: &ActionEvent) {
- println!("my action {}", self.i);
- self.i += 1;
- }
-}
-
-fn create_window(app: &AppContext<TestData>) {
- let testdata: TestData = Default::default();
-
- let window = app.window("note", testdata, |obj, data| {
- let list = data.list.data();
- list.push(10);
- list.push(11);
- list.push(12);
-
- let mut sl = SubList::new();
- sl.set_header("Header");
- sl.data().push(String::from("Elm 1"));
- sl.data().push(String::from("Elm 2"));
-
- data.sublists.push(sl);
-
-
- obj.button_builder().label("Hello").onclick(|e| {
- println!("Button clicked: {}", e.data.i);
- e.data.i += 1;
- }).create();
- obj.button_builder().label("Action").action("my_action").create();
- //let mut model = TableModel::new();
- //model.add_column("Name", ColumnType::String, -1);
- //obj.tableview_builder::<i32>().fill(true).varname("list").model(&model).getvalue(|elm, _row, _col| {
- // ListValue::String(elm.to_string())
- //}).create();
- obj.sourcelist_builder::<String>().fill(true).value(&data.sublists).getvalue(|elm, index, item| {
- item.label = Some(elm.to_string());
- item.badge = Some(index.to_string());
- }).create();
-
- println!("test");
- });
-
- window.show();
-}
-impl Application<TestData> for App {
- fn on_startup(&mut self, app: &AppContext<TestData>) {
- app.menu("File", |menu| {
- menu.item("Open").create();
- });
+impl Application<MainWindow> for App {
+ fn on_startup(&mut self, app: &AppContext<MainWindow>) {
+ //app.menu("File", |menu| {
+ // menu.item("Open").create();
+ //});
create_window(app);
}
--- /dev/null
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2026 Olaf Wintermann. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+use ui_rs::{action, ui_actions, UiModel};
+use ui_rs::ui::*;
+
+#[derive(UiModel, Default)]
+pub struct MainWindow {
+ #[bind]
+ notebooks: UiSourceList<String>
+}
+
+#[ui_actions]
+impl MainWindow {
+ #[action]
+ pub fn my_action(&mut self, _event: &ActionEvent) {
+
+ }
+}
+
+pub fn create_window(app: &AppContext<MainWindow>) {
+ let windowdata: MainWindow = Default::default();
+
+ let window = app.splitview_window("note", true, windowdata, |obj, data| {
+ obj.sidebar_builder().create(|obj|{
+ obj.sourcelist(|b|{
+ b.fill(true);
+ b.value(&data.notebooks);
+ });
+ });
+
+ obj.left_panel_builder().create(|obj|{
+ let mut model = TableModel::new();
+ model.add_column("Name", ColumnType::String, -1);
+ model.add_column("Last Modified", ColumnType::String, 0);
+
+ obj.tableview_builder::<String>()
+ .varname("notes")
+ .fill(true)
+ .create();
+ });
+
+ 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.textarea(|b|{
+ b.fill(true);
+ });
+ });
+ });
+ })
+ });
+
+ window.show();
+}
\ No newline at end of file