diff --git a/Cargo.toml b/Cargo.toml index 5165811..42ffc76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,5 +22,8 @@ panic = "abort" strip = true [dependencies] -makepad-widgets = { version = "0.6.0" } +# makepad-widgets = { path = "../../../../sample/makepad/widgets", version = "0.6.0" } # makepad-widgets = { git = "https://github.com/makepad/makepad/", branch = "rik" } + +# makepad-widgets = { path = "../../../samples/makepad/widgets", version = "0.6.0" } +makepad-widgets = { path = "../makepad/widgets", version = "0.6.0" } diff --git a/README.md b/README.md index 1e15390..33b42e1 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ This template should help get you started developing with Makepad Rust UI. # Desktop in Debug Mode cargo run +MAKEPAD=lines cargo +nightly run simplestacknavigation # Desktop in Release Mode cargo run --release @@ -34,5 +35,5 @@ cargo makepad apple ios install-toolchain cargo makepad android --abi=all install-toolchain git add . -git commit -m "welcome screen centered" +git commit -m "refoctor to latest rik branch" git push -u origin main \ No newline at end of file diff --git a/makepad_state.ron b/makepad_state.ron new file mode 100644 index 0000000..bb81ad2 --- /dev/null +++ b/makepad_state.ron @@ -0,0 +1,115 @@ +( + dock_items:[ + Tab( + id:file_tree, + name:"Explore", + closable:false, + kind:StudioFileTree, + ), + Tabs( + id:file_tree_tabs, + tabs:[ + file_tree, + search, + run_list, + ], + selected:0, + closable:false, + ), + Tab( + id:log_list, + name:"Log", + closable:false, + kind:LogList, + ), + Splitter( + id:split2, + axis:Horizontal, + align:Weighted(0.5), + a:edit_tabs, + b:run_tabs, + ), + Tabs( + id:log_tabs, + tabs:[ + log_list, + profiler, + ], + selected:0, + closable:false, + ), + Tab( + id:file1, + name:"app.rs", + closable:true, + kind:StudioEditor, + ), + Splitter( + id:root, + axis:Horizontal, + align:FromA(230), + a:file_tree_tabs, + b:split1, + ), + Tab( + id:run_first, + name:"View", + closable:false, + kind:RunFirst, + ), + Tabs( + id:edit_tabs, + tabs:[ + edit_first, + 17924207437592000735, + ], + selected:1, + closable:false, + ), + Tab( + id:search, + name:"Search", + closable:false, + kind:Search, + ), + Tab( + id:edit_first, + name:"Edit", + closable:false, + kind:EditFirst, + ), + Tab( + id:profiler, + name:"Profiler", + closable:false, + kind:Profiler, + ), + Splitter( + id:split1, + axis:Vertical, + align:FromB(200), + a:split2, + b:log_tabs, + ), + Tab( + id:17924207437592000735, + name:"makepad_state.ron", + closable:true, + kind:StudioEditor, + ), + Tabs( + id:run_tabs, + tabs:[ + run_first, + ], + selected:0, + closable:false, + ), + Tab( + id:run_list, + name:"Run", + closable:false, + kind:RunList, + ), + ], +) \ No newline at end of file diff --git a/src/app.rs b/src/app.rs index 623752e..c4cf052 100644 --- a/src/app.rs +++ b/src/app.rs @@ -9,10 +9,8 @@ live_design!{ import crate::welcome::welcome_screen::WelcomeScreen import crate::counter::counter_screen::CounterScreen - import crate::shared::clickable_view::ClickableView import crate::shared::stack_navigation::*; - import crate::shared::styles::*; import crate::shared::helpers::*; @@ -37,11 +35,10 @@ live_design!{ } App = {{App}} { - ui: { window: { position: vec2(0, 0), - // inner_size: vec2(360, 800) + inner_size: vec2(360, 800) dpi_override: 2 }, pass: {clear_color: #2A} @@ -82,14 +79,11 @@ app_main!(App); #[derive(Live)] pub struct App { #[live] ui: WidgetRef, - #[rust] counter: usize, #[rust] navigation_destinations: HashMap, } - -impl LiveHook for App { - fn before_live_design(cx: &mut Cx) { +impl LiveRegister for App { + fn live_register(cx: &mut Cx) { crate::makepad_widgets::live_design(cx); - // welcome crate::welcome::welcome_screen::live_design(cx); // counter @@ -106,30 +100,15 @@ impl LiveHook for App { crate::shared::stack_navigation::live_design(cx); crate::shared::clickable_view::live_design(cx); } +} +impl LiveHook for App { fn after_new_from_doc(&mut self, _cx: &mut Cx) { - self.init_navigation_destinations(); + self.init_navigation_destinations(); } } -impl App{ - fn init_navigation_destinations(&mut self) { - self.navigation_destinations = HashMap::new(); - self.navigation_destinations.insert(StackViewAction::ShowCounterScreen, live_id!(my_counter_stack_view)); - } - - async fn _do_network_request(_cx:CxRef, _ui:WidgetRef, _url:&str)->String{ - "".to_string() - } - -} - -impl AppMain for App{ - fn handle_event(&mut self, cx: &mut Cx, event: &Event) { - if let Event::Draw(event) = event { - return self.ui.draw_widget_all(&mut Cx2d::new(cx, event)); - } - let actions = self.ui.handle_widget_event(cx, event); - +impl MatchEvent for App{ + fn handle_actions(&mut self, cx:&mut Cx, actions:&Actions){ self.ui.radio_button_set(ids!( mobile_modes.tab1, )) @@ -148,4 +127,28 @@ impl AppMain for App{ &self.navigation_destinations ); } -} \ No newline at end of file +} + +impl App{ + fn init_navigation_destinations(&mut self) { + self.navigation_destinations = HashMap::new(); + self.navigation_destinations.insert(StackViewAction::ShowCounterScreen, live_id!(my_counter_stack_view)); + } + + async fn _do_network_request(_cx:CxRef, _ui:WidgetRef, _url:&str)->String{ + "".to_string() + } + // fn handle_event(&mut self, cx: &mut Cx, event: &Event) { + // if let Event::Draw(event) = event { + // return self.ui.draw_widget_all(&mut Cx2d::new(cx, event)); + // } + // let actions = self.ui.handle_widget_event(cx, event); + // } +} + +impl AppMain for App { + fn handle_event(&mut self, cx: &mut Cx, event: &Event) { + self.match_event(cx, event); + self.ui.handle_event(cx, event, &mut Scope::empty()); + } +} diff --git a/src/counter/counter_screen.rs b/src/counter/counter_screen.rs index e0bd5fb..78473e3 100644 --- a/src/counter/counter_screen.rs +++ b/src/counter/counter_screen.rs @@ -1,5 +1,3 @@ -use crate::shared::clickable_view::*; -use crate::shared::stack_view_action::StackViewAction; use makepad_widgets::widget::WidgetCache; use makepad_widgets::*; @@ -15,84 +13,81 @@ live_design! { import crate::shared::search_bar::SearchBar; import crate::shared::custom_button::CustomButton; - IMG_DEFAULT_AVATAR = dep("crate://self/resources/img/default_avatar.png") - IMG_FAVORITES = dep("crate://self/resources/img/favorites.png") - IMG_MY_POSTS = dep("crate://self/resources/img/my-posts.png") - IMG_STICKER_GALLERY = dep("crate://self/resources/img/sticker-gallery.png") - IMG_SETTINGS = dep("crate://self/resources/img/settings.png") - IMG_QR = dep("crate://self/resources/img/qr_icon.png") - Counter = {{Counter}} { - view: { - width: Fill, height: Fit - spacing: 10. + width: Fill, height: Fill + flow: Down, + spacing: 10. + draw_bg: { + color: #000 + } + // draw_bg: { + // fn pixel(self) -> vec4 { + // return mix(#3, #1, self.pos.y); + // } + // } + CounterInfo = { + width: Fill, height: Fill + flow: Right, + spacing: 10., + align: { + x: 0.5, + y: 0.5 + }, + show_bg: true draw_bg: { - color: #000 + color: #fff } - CounterInfo = { - width: Fill, height: Fill - flow: Right, - spacing: 10., - align: { - x: 0.5, - y: 0.5 - }, - show_bg: true - draw_bg: { - color: #fff - } - { - width: Fit - height: Fill - show_bg: false + { + width: Fit + height: Fill + show_bg: false + align: {x: 0.5, y: 0.5} + container = { + width: 360 + height: 400 align: {x: 0.5, y: 0.5} - container = { - width: 360 - height: 400 - align: {x: 0.5, y: 0.5} - spacing: 2.0 - draw_bg: { - color: #ddd, - radius: (CARD_CORNER_RADIUS) - } - { - width: Fit, height: Fill - flow: Down, - align: {x: 0.5, y: 0.5}, - padding: {top: 5., left: 10., right: 10.}, spacing: 20. + spacing: 2.0 + draw_bg: { + color: #ddd, + radius: (CARD_CORNER_RADIUS) + } + { + width: Fit, height: Fill + flow: Down, + align: {x: 0.5, y: 0.5}, + padding: {top: 5., left: 10., right: 10.}, spacing: 20. - avatar = { - source: (LOGO_MAKEPAD), - width: 300., height: 80. + avatar = { + source: (LOGO_MAKEPAD), + width: 300., height: 80. + } + button1 = { + button = { + text: "Hello world" } - button1 = { - button = { - text: "Hello world" + } + message_input = { + show_bg: false + input = { + width: Fill, height: Fit, margin: 0 + empty_message: "Click to count" + draw_bg: { + color: #fff + border_width: 0.5, + border_color: #b4b4b4, } } - message_input = { - show_bg: false - input = { - width: Fill, height: Fit, margin: 0 - empty_message: "Click to count" - draw_bg: { - color: #fff - border_width: 0.5, - border_color: #b4b4b4, - } - } - } - label1 =