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};
obj.ctx.set_state(AppStates::NoteEnableNew as i32);
obj.sidebar_builder().create(|obj|{
- obj.sourcelist(|b|{
- b.fill(true);
- b.value(&data.notebooks);
- b.getvalue(|elm,_row,item|{
+ sourcelist!(obj,
+ fill = true, value = &data.notebooks,
+ getvalue = |elm,_row,item|{
item.label = Some(elm.data.name.clone());
- });
- b.onactivate(|e|{
+ },
+ onactivate = |e|{
if let EventType::SubList(sl) = &e.event_type {
if let Some(nb) = sl.get_mut_from(&mut e.data.notebooks) {
let nav = NavigationItem { collection_id: nb.data.collection_id, ..Default::default() };
e.data.navigation.push(nav);
}
}
- });
- });
+ }
+ );
});
obj.left_panel_builder().create(|obj|{
model.add_column("Name", ColumnType::String, -1);
model.add_column("Last Modified", ColumnType::String, 0);
- obj.tableview_builder::<NoteItem>()
- .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");
+ });
});
});
+ });
});
});