refoctor to latest rik branch
This commit is contained in:
parent
21b28f7f11
commit
d9e2a0b603
14 changed files with 494 additions and 640 deletions
|
@ -22,5 +22,8 @@ panic = "abort"
|
||||||
strip = true
|
strip = true
|
||||||
|
|
||||||
[dependencies]
|
[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 = { 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" }
|
||||||
|
|
|
@ -9,6 +9,7 @@ This template should help get you started developing with Makepad Rust UI.
|
||||||
|
|
||||||
# Desktop in Debug Mode
|
# Desktop in Debug Mode
|
||||||
cargo run
|
cargo run
|
||||||
|
MAKEPAD=lines cargo +nightly run simplestacknavigation
|
||||||
|
|
||||||
# Desktop in Release Mode
|
# Desktop in Release Mode
|
||||||
cargo run --release
|
cargo run --release
|
||||||
|
@ -34,5 +35,5 @@ cargo makepad apple ios install-toolchain
|
||||||
cargo makepad android --abi=all install-toolchain
|
cargo makepad android --abi=all install-toolchain
|
||||||
|
|
||||||
git add .
|
git add .
|
||||||
git commit -m "welcome screen centered"
|
git commit -m "refoctor to latest rik branch"
|
||||||
git push -u origin main
|
git push -u origin main
|
115
makepad_state.ron
Normal file
115
makepad_state.ron
Normal file
|
@ -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,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
59
src/app.rs
59
src/app.rs
|
@ -9,10 +9,8 @@ live_design!{
|
||||||
|
|
||||||
import crate::welcome::welcome_screen::WelcomeScreen
|
import crate::welcome::welcome_screen::WelcomeScreen
|
||||||
import crate::counter::counter_screen::CounterScreen
|
import crate::counter::counter_screen::CounterScreen
|
||||||
|
|
||||||
import crate::shared::clickable_view::ClickableView
|
import crate::shared::clickable_view::ClickableView
|
||||||
import crate::shared::stack_navigation::*;
|
import crate::shared::stack_navigation::*;
|
||||||
|
|
||||||
import crate::shared::styles::*;
|
import crate::shared::styles::*;
|
||||||
import crate::shared::helpers::*;
|
import crate::shared::helpers::*;
|
||||||
|
|
||||||
|
@ -37,11 +35,10 @@ live_design!{
|
||||||
}
|
}
|
||||||
|
|
||||||
App = {{App}} {
|
App = {{App}} {
|
||||||
|
|
||||||
ui: <Window>{
|
ui: <Window>{
|
||||||
window: {
|
window: {
|
||||||
position: vec2(0, 0),
|
position: vec2(0, 0),
|
||||||
// inner_size: vec2(360, 800)
|
inner_size: vec2(360, 800)
|
||||||
dpi_override: 2
|
dpi_override: 2
|
||||||
},
|
},
|
||||||
pass: {clear_color: #2A}
|
pass: {clear_color: #2A}
|
||||||
|
@ -82,14 +79,11 @@ app_main!(App);
|
||||||
#[derive(Live)]
|
#[derive(Live)]
|
||||||
pub struct App {
|
pub struct App {
|
||||||
#[live] ui: WidgetRef,
|
#[live] ui: WidgetRef,
|
||||||
#[rust] counter: usize,
|
|
||||||
#[rust] navigation_destinations: HashMap<StackViewAction, LiveId>,
|
#[rust] navigation_destinations: HashMap<StackViewAction, LiveId>,
|
||||||
}
|
}
|
||||||
|
impl LiveRegister for App {
|
||||||
impl LiveHook for App {
|
fn live_register(cx: &mut Cx) {
|
||||||
fn before_live_design(cx: &mut Cx) {
|
|
||||||
crate::makepad_widgets::live_design(cx);
|
crate::makepad_widgets::live_design(cx);
|
||||||
|
|
||||||
// welcome
|
// welcome
|
||||||
crate::welcome::welcome_screen::live_design(cx);
|
crate::welcome::welcome_screen::live_design(cx);
|
||||||
// counter
|
// counter
|
||||||
|
@ -106,30 +100,15 @@ impl LiveHook for App {
|
||||||
crate::shared::stack_navigation::live_design(cx);
|
crate::shared::stack_navigation::live_design(cx);
|
||||||
crate::shared::clickable_view::live_design(cx);
|
crate::shared::clickable_view::live_design(cx);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
impl LiveHook for App {
|
||||||
fn after_new_from_doc(&mut self, _cx: &mut Cx) {
|
fn after_new_from_doc(&mut self, _cx: &mut Cx) {
|
||||||
self.init_navigation_destinations();
|
self.init_navigation_destinations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App{
|
impl MatchEvent for App{
|
||||||
fn init_navigation_destinations(&mut self) {
|
fn handle_actions(&mut self, cx:&mut Cx, actions:&Actions){
|
||||||
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);
|
|
||||||
|
|
||||||
self.ui.radio_button_set(ids!(
|
self.ui.radio_button_set(ids!(
|
||||||
mobile_modes.tab1,
|
mobile_modes.tab1,
|
||||||
))
|
))
|
||||||
|
@ -149,3 +128,27 @@ impl AppMain for App{
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use crate::shared::clickable_view::*;
|
|
||||||
use crate::shared::stack_view_action::StackViewAction;
|
|
||||||
use makepad_widgets::widget::WidgetCache;
|
use makepad_widgets::widget::WidgetCache;
|
||||||
use makepad_widgets::*;
|
use makepad_widgets::*;
|
||||||
|
|
||||||
|
@ -15,20 +13,18 @@ live_design! {
|
||||||
import crate::shared::search_bar::SearchBar;
|
import crate::shared::search_bar::SearchBar;
|
||||||
import crate::shared::custom_button::CustomButton;
|
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}} {
|
Counter = {{Counter}} {
|
||||||
view: {
|
width: Fill, height: Fill
|
||||||
width: Fill, height: Fit
|
flow: Down,
|
||||||
spacing: 10.
|
spacing: 10.
|
||||||
draw_bg: {
|
draw_bg: {
|
||||||
color: #000
|
color: #000
|
||||||
}
|
}
|
||||||
|
// draw_bg: {
|
||||||
|
// fn pixel(self) -> vec4 {
|
||||||
|
// return mix(#3, #1, self.pos.y);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
CounterInfo = <View> {
|
CounterInfo = <View> {
|
||||||
width: Fill, height: Fill
|
width: Fill, height: Fill
|
||||||
flow: Right,
|
flow: Right,
|
||||||
|
@ -94,7 +90,6 @@ live_design! {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
CounterScreen = <View> {
|
CounterScreen = <View> {
|
||||||
width: Fill, height: Fill
|
width: Fill, height: Fill
|
||||||
|
@ -102,54 +97,33 @@ live_design! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Live)]
|
#[derive(Live, LiveHook, Widget)]
|
||||||
pub struct Counter {
|
pub struct Counter {
|
||||||
#[live]
|
#[deref] view: View,
|
||||||
view:View,
|
|
||||||
#[rust] counter: usize,
|
#[rust] counter: usize,
|
||||||
}
|
|
||||||
|
|
||||||
impl LiveHook for Counter {
|
|
||||||
fn before_live_design(cx: &mut Cx) {
|
|
||||||
register_widget!(cx, Counter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget for Counter {
|
impl Widget for Counter {
|
||||||
fn handle_widget_event_with(
|
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
|
||||||
&mut self,
|
let actions = cx.capture_actions(|cx| self.view.handle_event(cx, event, scope));
|
||||||
cx: &mut Cx,
|
// if self
|
||||||
event: &Event,
|
// .view
|
||||||
dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem),
|
// .clickable_view(id!(my_profile_frame))
|
||||||
) {
|
// .clicked(&actions)
|
||||||
let uid = self.widget_uid();
|
// {
|
||||||
self.handle_event_with(cx, event, &mut |cx, action: StackViewAction| {
|
// let uid = self.widget_uid();
|
||||||
dispatch_action(cx, WidgetActionItem::new(action.into(), uid));
|
// cx.widget_action(uid, &scope.path, StackViewAction::ShowMyProfile);
|
||||||
});
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
fn redraw(&mut self, cx: &mut Cx) {
|
|
||||||
self.view.redraw(cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find_widgets(&mut self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet) {
|
|
||||||
self.view.find_widgets(path, cached, results);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_walk_widget(&mut self, cx: &mut Cx2d, walk: Walk) -> WidgetDraw {
|
|
||||||
self.view.draw_walk_widget(cx, walk)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Counter {
|
|
||||||
fn handle_event_with(
|
|
||||||
&mut self,
|
|
||||||
cx: &mut Cx,
|
|
||||||
event: &Event,
|
|
||||||
_dispatch_action: &mut dyn FnMut(&mut Cx, StackViewAction),
|
|
||||||
) {
|
|
||||||
let actions = self.view.handle_widget_event(cx, event);
|
|
||||||
|
|
||||||
|
// if self.view.button(id!(welcome_frame)).clicked(&actions)
|
||||||
|
// {
|
||||||
|
// let uid = self.widget_uid();
|
||||||
|
// cx.widget_action(uid, &scope.path, StackViewAction::ShowCounterScreen);
|
||||||
|
// // dispatch_action(cx, StackViewAction::ShowCounterScreen);
|
||||||
|
// let user_prompt1 = self.view.text_input(id!(message_input.input)).text();
|
||||||
|
// log!("WELCOME BUTTON CLICKED: {}", user_prompt1);
|
||||||
|
// }
|
||||||
if self.view.button(id!(button1)).clicked(&actions)
|
if self.view.button(id!(button1)).clicked(&actions)
|
||||||
{
|
{
|
||||||
log!("BUTTON CLICKED {}", self.counter);
|
log!("BUTTON CLICKED {}", self.counter);
|
||||||
|
@ -158,4 +132,26 @@ impl Counter {
|
||||||
label.set_text_and_redraw(cx,&format!("Counter: {}", self.counter));
|
label.set_text_and_redraw(cx,&format!("Counter: {}", self.counter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {
|
||||||
|
self.view.draw_walk(cx, scope, walk)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// impl Counter {
|
||||||
|
// fn handle_event_with(
|
||||||
|
// &mut self,
|
||||||
|
// cx: &mut Cx,
|
||||||
|
// event: &Event,
|
||||||
|
// _dispatch_action: &mut dyn FnMut(&mut Cx, StackViewAction),
|
||||||
|
// ) {
|
||||||
|
// let actions = self.view.handle_widget_event(cx, event);
|
||||||
|
// if self.view.button(id!(button1)).clicked(&actions)
|
||||||
|
// {
|
||||||
|
// log!("BUTTON CLICKED {}", self.counter);
|
||||||
|
// self.counter += 1;
|
||||||
|
// let label = self.view.label(id!(label1));
|
||||||
|
// label.set_text_and_redraw(cx,&format!("Counter: {}", self.counter));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
|
@ -3,25 +3,25 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||||
<title>Makepad Template</title>
|
<title>Simple UI example</title>
|
||||||
<script type='module'>
|
<script type='module'>
|
||||||
import {WasmWebGL} from "/makepad-template/platform/src/os/web/web_gl.js"
|
import {WasmWebGL} from "/makepad/platform/src/os/web/web_gl.js"
|
||||||
|
|
||||||
const wasm = await WasmWebGL.fetch_and_instantiate_wasm(
|
const wasm = await WasmWebGL.fetch_and_instantiate_wasm(
|
||||||
"makepad-template/target/wasm32-unknown-unknown/release/login.wasm"
|
"/makepad/target/wasm32-unknown-unknown/release/simplestacknavigation.wasm"
|
||||||
);
|
);
|
||||||
|
|
||||||
class MyWasmApp {
|
class MyWasmApp {
|
||||||
constructor(wasm) {
|
constructor(wasm) {
|
||||||
let canvas = document.getElementsByClassName('full_canvas')[0];
|
let canvas = document.getElementsByClassName('full_canvas')[0];
|
||||||
this.webgl = new WasmWebGL (wasm, this, canvas);
|
this.bridge = new WasmWebGL (wasm, this, canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let app = new MyWasmApp(wasm);
|
let app = new MyWasmApp(wasm);
|
||||||
</script>
|
</script>
|
||||||
<script type='module' src='/makepad-template/platform/src/os/web/auto_reload.js'></script>
|
<script type='module' src='/makepad/platform/src/os/web/auto_reload.js'></script>
|
||||||
<link rel='stylesheet' type='text/css' href='/makepad-template/platform/src/os/web/full_canvas.css'>
|
<link rel='stylesheet' type='text/css' href='/makepad/platform/src/os/web/full_canvas.css'>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<canvas class='full_canvas'></canvas>
|
<canvas class='full_canvas'></canvas>
|
|
@ -14,83 +14,42 @@ live_design! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Live)]
|
#[derive(Live, LiveHook, Widget)]
|
||||||
pub struct ClickableView {
|
pub struct ClickableView {
|
||||||
#[deref]
|
#[deref]
|
||||||
view:View,
|
view: View,
|
||||||
}
|
}
|
||||||
|
#[derive(Clone, DefaultNone, Debug)]
|
||||||
impl LiveHook for ClickableView {
|
|
||||||
fn before_live_design(cx: &mut Cx) {
|
|
||||||
register_widget!(cx, ClickableView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, WidgetAction)]
|
|
||||||
pub enum ClickableViewAction {
|
pub enum ClickableViewAction {
|
||||||
None,
|
None,
|
||||||
Click,
|
Click,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget for ClickableView {
|
impl Widget for ClickableView {
|
||||||
fn handle_widget_event_with(
|
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
|
||||||
&mut self,
|
let uid = self.widget_uid().clone();
|
||||||
cx: &mut Cx,
|
|
||||||
event: &Event,
|
|
||||||
dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem),
|
|
||||||
) {
|
|
||||||
let uid = self.widget_uid();
|
|
||||||
self.handle_event_with(cx, event, &mut |cx, action| {
|
|
||||||
dispatch_action(cx, WidgetActionItem::new(action.into(), uid));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn redraw(&mut self, cx: &mut Cx) {
|
|
||||||
self.view.redraw(cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn walk(&mut self, cx: &mut Cx) -> Walk {
|
|
||||||
self.view.walk(cx)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find_widgets(&mut self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet) {
|
|
||||||
self.view.find_widgets(path, cached, results);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_walk_widget(&mut self, cx: &mut Cx2d, walk: Walk) -> WidgetDraw {
|
|
||||||
self.view.draw_walk_widget(cx, walk)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ClickableView {
|
|
||||||
pub fn handle_event_with(
|
|
||||||
&mut self,
|
|
||||||
cx: &mut Cx,
|
|
||||||
event: &Event,
|
|
||||||
dispatch_action: &mut dyn FnMut(&mut Cx, ClickableViewAction),
|
|
||||||
) {
|
|
||||||
match event.hits(cx, self.view.area()){
|
match event.hits(cx, self.view.area()){
|
||||||
Hit::FingerDown(_fe) => {
|
Hit::FingerDown(_fe) => {
|
||||||
cx.set_key_focus(self.view.area());
|
cx.set_key_focus(self.view.area());
|
||||||
}
|
}
|
||||||
Hit::FingerUp(fe) => if fe.was_tap() {
|
Hit::FingerUp(fe) => if fe.was_tap() {
|
||||||
dispatch_action(cx, ClickableViewAction::Click);
|
cx.widget_action(uid, &scope.path, ClickableViewAction::Click);
|
||||||
}
|
}
|
||||||
_ =>()
|
_ =>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {
|
||||||
|
self.view.draw_walk(cx, scope, walk)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, WidgetRef)]
|
|
||||||
pub struct ClickableViewRef(WidgetRef);
|
|
||||||
|
|
||||||
impl ClickableViewRef {
|
impl ClickableViewRef {
|
||||||
pub fn clicked(&self, actions: &WidgetActions) -> bool {
|
pub fn clicked(&self, actions: &Actions) -> bool {
|
||||||
if let Some(item) = actions.find_single_action(self.widget_uid()) {
|
if let ClickableViewAction::Click = actions.find_widget_action(self.widget_uid()).cast() {
|
||||||
if let ClickableViewAction::Click = item.action() {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ live_design! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Live)]
|
#[derive(Live, Widget)]
|
||||||
pub struct WechatDropDown {
|
pub struct WechatDropDown {
|
||||||
#[animator]
|
#[animator]
|
||||||
animator: Animator,
|
animator: Animator,
|
||||||
|
@ -91,7 +91,7 @@ pub struct WechatDropDown {
|
||||||
#[layout]
|
#[layout]
|
||||||
layout: Layout,
|
layout: Layout,
|
||||||
|
|
||||||
#[live]
|
#[live] #[redraw]
|
||||||
draw_bg: DrawQuad,
|
draw_bg: DrawQuad,
|
||||||
#[live]
|
#[live]
|
||||||
draw_icon: DrawIcon,
|
draw_icon: DrawIcon,
|
||||||
|
@ -124,10 +124,6 @@ pub struct WechatDropDown {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LiveHook for WechatDropDown {
|
impl LiveHook for WechatDropDown {
|
||||||
fn before_live_design(cx: &mut Cx) {
|
|
||||||
register_widget!(cx, WechatDropDown)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn after_apply(&mut self, cx: &mut Cx, from: ApplyFrom, _index: usize, _nodes: &[LiveNode]) {
|
fn after_apply(&mut self, cx: &mut Cx, from: ApplyFrom, _index: usize, _nodes: &[LiveNode]) {
|
||||||
if self.popup_menu.is_none() || !from.is_from_doc() {
|
if self.popup_menu.is_none() || !from.is_from_doc() {
|
||||||
return;
|
return;
|
||||||
|
@ -144,7 +140,7 @@ impl LiveHook for WechatDropDown {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[derive(Clone, WidgetAction, Debug)]
|
#[derive(Clone, DefaultNone, Debug)]
|
||||||
pub enum WechatDropDownAction {
|
pub enum WechatDropDownAction {
|
||||||
Select(usize, LiveValue),
|
Select(usize, LiveValue),
|
||||||
None,
|
None,
|
||||||
|
@ -180,14 +176,42 @@ impl WechatDropDown {
|
||||||
self.draw_bg.redraw(cx);
|
self.draw_bg.redraw(cx);
|
||||||
cx.sweep_unlock(self.draw_bg.area());
|
cx.sweep_unlock(self.draw_bg.area());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn handle_event_with(
|
// It is named WechatDropDown because DropDown is already a widget in makepad_widgets
|
||||||
&mut self,
|
impl Widget for WechatDropDown {
|
||||||
cx: &mut Cx,
|
fn widget_to_data(
|
||||||
event: &Event,
|
&self,
|
||||||
dispatch_action: &mut dyn FnMut(&mut Cx, WechatDropDownAction),
|
_cx: &mut Cx,
|
||||||
) {
|
actions: &Actions,
|
||||||
|
nodes: &mut LiveNodeVec,
|
||||||
|
path: &[LiveId],
|
||||||
|
) -> bool {
|
||||||
|
match actions.find_widget_action(self.widget_uid()).cast() {
|
||||||
|
WechatDropDownAction::Select(_, value) => {
|
||||||
|
nodes.write_field_value(path, value.clone());
|
||||||
|
true
|
||||||
|
}
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn data_to_widget(&mut self, cx: &mut Cx, nodes: &[LiveNode], path: &[LiveId]) {
|
||||||
|
if let Some(value) = nodes.read_field_value(path) {
|
||||||
|
if let Some(index) = self.values.iter().position(|v| v == value) {
|
||||||
|
if self.selected_item != index {
|
||||||
|
self.selected_item = index;
|
||||||
|
self.redraw(cx);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// error!("Value not in values list {:?}", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
|
||||||
self.animator_handle_event(cx, event);
|
self.animator_handle_event(cx, event);
|
||||||
|
let uid = self.widget_uid();
|
||||||
|
|
||||||
if self.is_open && self.popup_menu.is_some() {
|
if self.is_open && self.popup_menu.is_some() {
|
||||||
let global = cx.global::<PopupMenuGlobal>().clone();
|
let global = cx.global::<PopupMenuGlobal>().clone();
|
||||||
|
@ -199,16 +223,17 @@ impl WechatDropDown {
|
||||||
event,
|
event,
|
||||||
self.draw_bg.area(),
|
self.draw_bg.area(),
|
||||||
&mut |cx, action| if let PopupMenuAction::WasSelected(node_id) = action {
|
&mut |cx, action| if let PopupMenuAction::WasSelected(node_id) = action {
|
||||||
self.selected_item = node_id.0 .0 as usize;
|
self.selected_item = node_id.0.0 as usize;
|
||||||
dispatch_action(
|
cx.widget_action(
|
||||||
cx,
|
uid,
|
||||||
|
&scope.path,
|
||||||
WechatDropDownAction::Select(
|
WechatDropDownAction::Select(
|
||||||
self.selected_item,
|
self.selected_item,
|
||||||
self.values
|
self.values
|
||||||
.get(self.selected_item)
|
.get(self.selected_item)
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or(LiveValue::None),
|
.unwrap_or(LiveValue::None)
|
||||||
),
|
)
|
||||||
);
|
);
|
||||||
self.draw_bg.redraw(cx);
|
self.draw_bg.redraw(cx);
|
||||||
close = true;
|
close = true;
|
||||||
|
@ -237,12 +262,16 @@ impl WechatDropDown {
|
||||||
KeyCode::ArrowUp => {
|
KeyCode::ArrowUp => {
|
||||||
if self.selected_item > 0 {
|
if self.selected_item > 0 {
|
||||||
self.selected_item -= 1;
|
self.selected_item -= 1;
|
||||||
dispatch_action(
|
cx.widget_action(
|
||||||
cx,
|
uid,
|
||||||
|
&scope.path,
|
||||||
WechatDropDownAction::Select(
|
WechatDropDownAction::Select(
|
||||||
self.selected_item,
|
self.selected_item,
|
||||||
self.values[self.selected_item].clone(),
|
self.values
|
||||||
),
|
.get(self.selected_item)
|
||||||
|
.cloned()
|
||||||
|
.unwrap_or(LiveValue::None)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
self.set_closed(cx);
|
self.set_closed(cx);
|
||||||
self.draw_bg.redraw(cx);
|
self.draw_bg.redraw(cx);
|
||||||
|
@ -251,12 +280,16 @@ impl WechatDropDown {
|
||||||
KeyCode::ArrowDown => {
|
KeyCode::ArrowDown => {
|
||||||
if !self.values.is_empty() && self.selected_item < self.values.len() - 1 {
|
if !self.values.is_empty() && self.selected_item < self.values.len() - 1 {
|
||||||
self.selected_item += 1;
|
self.selected_item += 1;
|
||||||
dispatch_action(
|
cx.widget_action(
|
||||||
cx,
|
uid,
|
||||||
|
&scope.path,
|
||||||
WechatDropDownAction::Select(
|
WechatDropDownAction::Select(
|
||||||
self.selected_item,
|
self.selected_item,
|
||||||
self.values[self.selected_item].clone(),
|
self.values
|
||||||
),
|
.get(self.selected_item)
|
||||||
|
.cloned()
|
||||||
|
.unwrap_or(LiveValue::None)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
self.set_closed(cx);
|
self.set_closed(cx);
|
||||||
self.draw_bg.redraw(cx);
|
self.draw_bg.redraw(cx);
|
||||||
|
@ -289,7 +322,7 @@ impl WechatDropDown {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_walk(&mut self, cx: &mut Cx2d, walk: Walk) {
|
fn draw_walk(&mut self, cx: &mut Cx2d, _scope: &mut Scope, walk: Walk) -> DrawStep {
|
||||||
// cx.clear_sweep_lock(self.draw_bg.area());
|
// cx.clear_sweep_lock(self.draw_bg.area());
|
||||||
|
|
||||||
self.draw_bg.begin(cx, walk, self.layout);
|
self.draw_bg.begin(cx, walk, self.layout);
|
||||||
|
@ -314,73 +347,15 @@ impl WechatDropDown {
|
||||||
|
|
||||||
popup_menu.end(cx, self.draw_bg.area());
|
popup_menu.end(cx, self.draw_bg.area());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DrawStep::done()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is named WechatDropDown because DropDown is already a widget in makepad_widgets
|
|
||||||
impl Widget for WechatDropDown {
|
|
||||||
fn widget_to_data(
|
|
||||||
&self,
|
|
||||||
_cx: &mut Cx,
|
|
||||||
actions: &WidgetActions,
|
|
||||||
nodes: &mut LiveNodeVec,
|
|
||||||
path: &[LiveId],
|
|
||||||
) -> bool {
|
|
||||||
match actions.single_action(self.widget_uid()) {
|
|
||||||
WechatDropDownAction::Select(_, value) => {
|
|
||||||
nodes.write_field_value(path, value.clone());
|
|
||||||
true
|
|
||||||
}
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn data_to_widget(&mut self, cx: &mut Cx, nodes: &[LiveNode], path: &[LiveId]) {
|
|
||||||
if let Some(value) = nodes.read_field_value(path) {
|
|
||||||
if let Some(index) = self.values.iter().position(|v| v == value) {
|
|
||||||
if self.selected_item != index {
|
|
||||||
self.selected_item = index;
|
|
||||||
self.redraw(cx);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// error!("Value not in values list {:?}", value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn redraw(&mut self, cx: &mut Cx) {
|
|
||||||
self.draw_bg.redraw(cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_widget_event_with(
|
|
||||||
&mut self,
|
|
||||||
cx: &mut Cx,
|
|
||||||
event: &Event,
|
|
||||||
dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem),
|
|
||||||
) {
|
|
||||||
let uid = self.widget_uid();
|
|
||||||
self.handle_event_with(cx, event, &mut |cx, action| {
|
|
||||||
dispatch_action(cx, WidgetActionItem::new(action.into(), uid))
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn walk(&mut self, _cx: &mut Cx) -> Walk {
|
|
||||||
self.walk
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_walk_widget(&mut self, cx: &mut Cx2d, walk: Walk) -> WidgetDraw {
|
|
||||||
self.draw_walk(cx, walk);
|
|
||||||
WidgetDraw::done()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, WidgetRef)]
|
|
||||||
pub struct WechatDropDownRef(WidgetRef);
|
|
||||||
|
|
||||||
impl WechatDropDownRef {
|
impl WechatDropDownRef {
|
||||||
pub fn item_clicked(&mut self, item_id: &[LiveId], actions: &WidgetActions) -> bool {
|
pub fn item_clicked(&mut self, item_id: &[LiveId], actions: &Actions) -> bool {
|
||||||
if let Some(item) = actions.find_single_action(self.widget_uid()) {
|
if let Some(item) = actions.find_widget_action(self.widget_uid()) {
|
||||||
if let WechatDropDownAction::Select(_id, value) = item.action() {
|
if let WechatDropDownAction::Select(_id, value) = item.cast() {
|
||||||
return LiveValue::Bool(true) == value.enum_eq(item_id)
|
return LiveValue::Bool(true) == value.enum_eq(item_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,59 +165,23 @@ live_design! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Live)]
|
#[derive(Live, LiveHook, Widget)]
|
||||||
pub struct HeaderDropDownMenu {
|
pub struct HeaderDropDownMenu {
|
||||||
#[deref]
|
#[deref]
|
||||||
view: View,
|
view: View,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LiveHook for HeaderDropDownMenu {
|
|
||||||
fn before_live_design(cx: &mut Cx) {
|
|
||||||
register_widget!(cx, HeaderDropDownMenu);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for HeaderDropDownMenu {
|
impl Widget for HeaderDropDownMenu {
|
||||||
fn handle_widget_event_with(
|
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
|
||||||
&mut self,
|
|
||||||
cx: &mut Cx,
|
|
||||||
event: &Event,
|
|
||||||
dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem),
|
|
||||||
) {
|
|
||||||
let uid = self.widget_uid();
|
let uid = self.widget_uid();
|
||||||
self.handle_event_with(cx, event, &mut |cx, action: StackViewAction| {
|
let actions = cx.capture_actions(|cx| self.view.handle_event(cx, event, scope));
|
||||||
dispatch_action(cx, WidgetActionItem::new(action.into(), uid));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn redraw(&mut self, cx: &mut Cx) {
|
|
||||||
self.view.redraw(cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn walk(&mut self, cx: &mut Cx) -> Walk {
|
|
||||||
self.view.walk(cx)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find_widgets(&mut self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet) {
|
|
||||||
self.view.find_widgets(path, cached, results);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_walk_widget(&mut self, cx: &mut Cx2d, walk: Walk) -> WidgetDraw {
|
|
||||||
self.view.draw_walk_widget(cx, walk)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HeaderDropDownMenu {
|
|
||||||
pub fn handle_event_with(
|
|
||||||
&mut self,
|
|
||||||
cx: &mut Cx,
|
|
||||||
event: &Event,
|
|
||||||
dispatch_action: &mut dyn FnMut(&mut Cx, StackViewAction),
|
|
||||||
) {
|
|
||||||
let actions = self.view.handle_widget_event(cx, event);
|
|
||||||
|
|
||||||
if self.wechat_drop_down(id!(menu)).item_clicked(id!(AddContact), &actions) {
|
if self.wechat_drop_down(id!(menu)).item_clicked(id!(AddContact), &actions) {
|
||||||
dispatch_action(cx, StackViewAction::ShowAddContact);
|
cx.widget_action(uid, &scope.path, StackViewAction::ShowAddContact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {
|
||||||
|
self.view.draw_walk(cx, scope, walk)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,21 @@ live_design! {
|
||||||
import makepad_widgets::theme_desktop_dark::*;
|
import makepad_widgets::theme_desktop_dark::*;
|
||||||
import crate::shared::styles::*;
|
import crate::shared::styles::*;
|
||||||
|
|
||||||
DrawBg = {{DrawBg}} {
|
MenuItem = {{MenuItem}} {
|
||||||
|
align: {y: 0.5},
|
||||||
|
padding: {left: 5., top: 10., bottom: 10., right: 5.},
|
||||||
|
spacing: 5.,
|
||||||
|
width: Fill,
|
||||||
|
height: Fit
|
||||||
|
|
||||||
|
draw_bg: {
|
||||||
instance color: #4
|
instance color: #4
|
||||||
instance color_selected: #5
|
instance color_selected: #5
|
||||||
instance border_radius: 4.0
|
instance border_radius: 4.0
|
||||||
|
|
||||||
|
instance selected: 0.0
|
||||||
|
instance hover: 0.0
|
||||||
|
|
||||||
fn pixel(self) -> vec4 {
|
fn pixel(self) -> vec4 {
|
||||||
let sdf = Sdf2d::viewport(self.pos * self.rect_size)
|
let sdf = Sdf2d::viewport(self.pos * self.rect_size)
|
||||||
sdf.box(
|
sdf.box(
|
||||||
|
@ -26,8 +36,10 @@ live_design! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawName = {{DrawName}} {
|
draw_name: {
|
||||||
text_style: <REGULAR_TEXT>{font_size: 9},
|
text_style: <REGULAR_TEXT>{font_size: 9},
|
||||||
|
instance selected: 0.0
|
||||||
|
instance hover: 0.0
|
||||||
|
|
||||||
fn get_color(self) -> vec4 {
|
fn get_color(self) -> vec4 {
|
||||||
return mix(
|
return mix(
|
||||||
|
@ -42,13 +54,6 @@ live_design! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem = {{MenuItem}} {
|
|
||||||
align: {y: 0.5},
|
|
||||||
padding: {left: 5., top: 10., bottom: 10., right: 5.},
|
|
||||||
spacing: 5.,
|
|
||||||
width: Fill,
|
|
||||||
height: Fit
|
|
||||||
|
|
||||||
icon_walk: {width: 15., height: Fit, margin: {bottom: 3.}}
|
icon_walk: {width: 15., height: Fit, margin: {bottom: 3.}}
|
||||||
draw_icon: {
|
draw_icon: {
|
||||||
color: #f2f2f2;
|
color: #f2f2f2;
|
||||||
|
@ -152,29 +157,7 @@ live_design! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Live, LiveHook)]
|
#[derive(Live, LiveRegister, WidgetWrap)]
|
||||||
#[repr(C)]
|
|
||||||
struct DrawBg {
|
|
||||||
#[deref]
|
|
||||||
draw_super: DrawQuad,
|
|
||||||
#[live]
|
|
||||||
selected: f32,
|
|
||||||
#[live]
|
|
||||||
hover: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Live, LiveHook)]
|
|
||||||
#[repr(C)]
|
|
||||||
struct DrawName {
|
|
||||||
#[deref]
|
|
||||||
draw_super: DrawText,
|
|
||||||
#[live]
|
|
||||||
selected: f32,
|
|
||||||
#[live]
|
|
||||||
hover: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Live)]
|
|
||||||
pub struct PopupMenu {
|
pub struct PopupMenu {
|
||||||
#[live]
|
#[live]
|
||||||
draw_list: DrawList2d,
|
draw_list: DrawList2d,
|
||||||
|
@ -182,9 +165,9 @@ pub struct PopupMenu {
|
||||||
#[live]
|
#[live]
|
||||||
menu_item: Option<LivePtr>,
|
menu_item: Option<LivePtr>,
|
||||||
|
|
||||||
#[live]
|
#[live] #[redraw]
|
||||||
draw_bg: DrawQuad,
|
draw_bg: DrawQuad,
|
||||||
#[live]
|
#[live] #[redraw]
|
||||||
draw_icon: DrawIcon,
|
draw_icon: DrawIcon,
|
||||||
#[live]
|
#[live]
|
||||||
icon_walk: Walk,
|
icon_walk: Walk,
|
||||||
|
@ -213,10 +196,6 @@ pub struct PopupMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LiveHook for PopupMenu {
|
impl LiveHook for PopupMenu {
|
||||||
fn before_live_design(cx: &mut Cx) {
|
|
||||||
register_widget!(cx, PopupMenu)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn after_apply(&mut self, cx: &mut Cx, from: ApplyFrom, index: usize, nodes: &[LiveNode]) {
|
fn after_apply(&mut self, cx: &mut Cx, from: ApplyFrom, index: usize, nodes: &[LiveNode]) {
|
||||||
if let Some(index) = nodes.child_by_name(index, live_id!(list_node).as_field()) {
|
if let Some(index) = nodes.child_by_name(index, live_id!(list_node).as_field()) {
|
||||||
for (_, node) in self.menu_items.iter_mut() {
|
for (_, node) in self.menu_items.iter_mut() {
|
||||||
|
@ -228,28 +207,14 @@ impl LiveHook for PopupMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget for PopupMenu {
|
impl Widget for PopupMenu {
|
||||||
fn handle_widget_event_with(
|
fn handle_event(&mut self, _cx: &mut Cx, _event: &Event, _scope: &mut Scope) {
|
||||||
&mut self,
|
|
||||||
_cx: &mut Cx,
|
|
||||||
_event: &Event,
|
|
||||||
_dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem),
|
|
||||||
) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_walk_widget(&mut self, cx: &mut Cx2d, walk: Walk) -> WidgetDraw {
|
fn draw_walk(&mut self, cx: &mut Cx2d, _scope: &mut Scope, walk: Walk) -> DrawStep {
|
||||||
self.draw_bg.begin(cx, walk, self.layout);
|
self.draw_bg.begin(cx, walk, self.layout);
|
||||||
self.draw_icon.draw_walk(cx, self.icon_walk);
|
self.draw_icon.draw_walk(cx, self.icon_walk);
|
||||||
self.draw_bg.end(cx);
|
self.draw_bg.end(cx);
|
||||||
WidgetDraw::done()
|
DrawStep::done()
|
||||||
}
|
|
||||||
|
|
||||||
fn walk(&mut self, _cx: &mut Cx) -> Walk {
|
|
||||||
self.walk
|
|
||||||
}
|
|
||||||
|
|
||||||
fn redraw(&mut self, cx: &mut Cx) {
|
|
||||||
self.draw_bg.redraw(cx);
|
|
||||||
self.draw_icon.redraw(cx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,19 +312,19 @@ impl PopupMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Live, LiveHook)]
|
#[derive(Live, LiveHook, LiveRegister, WidgetWrap)]
|
||||||
pub struct MenuItem {
|
pub struct MenuItem {
|
||||||
#[layout]
|
#[layout]
|
||||||
layout: Layout,
|
layout: Layout,
|
||||||
#[walk]
|
#[walk]
|
||||||
walk: Walk,
|
walk: Walk,
|
||||||
|
|
||||||
#[live]
|
#[live] #[redraw]
|
||||||
draw_bg: DrawBg,
|
draw_bg: DrawQuad,
|
||||||
#[live]
|
#[live] #[redraw]
|
||||||
draw_name: DrawName,
|
draw_name: DrawText,
|
||||||
|
|
||||||
#[live]
|
#[live] #[redraw]
|
||||||
draw_icon: DrawIcon,
|
draw_icon: DrawIcon,
|
||||||
#[live]
|
#[live]
|
||||||
icon_walk: Walk,
|
icon_walk: Walk,
|
||||||
|
@ -377,7 +342,7 @@ pub struct MenuItem {
|
||||||
selected: f32,
|
selected: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone)]
|
#[derive(Default, Clone, Debug)]
|
||||||
pub enum MenuItemAction {
|
pub enum MenuItemAction {
|
||||||
WasSweeped,
|
WasSweeped,
|
||||||
WasSelected,
|
WasSelected,
|
||||||
|
@ -385,7 +350,7 @@ pub enum MenuItemAction {
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, WidgetAction, Debug)]
|
#[derive(Clone, DefaultNone, Debug)]
|
||||||
pub enum PopupMenuAction {
|
pub enum PopupMenuAction {
|
||||||
WasSweeped(MenuItemId),
|
WasSweeped(MenuItemId),
|
||||||
WasSelected(MenuItemId),
|
WasSelected(MenuItemId),
|
||||||
|
|
|
@ -20,7 +20,6 @@ live_design! {
|
||||||
clip_y: true,
|
clip_y: true,
|
||||||
align: {y: 0.5}
|
align: {y: 0.5}
|
||||||
empty_message: "Search"
|
empty_message: "Search"
|
||||||
// text: "Here"
|
|
||||||
draw_bg: {
|
draw_bg: {
|
||||||
color: #fff
|
color: #fff
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ live_design! {
|
||||||
visible: false
|
visible: false
|
||||||
width: Fill, height: Fill
|
width: Fill, height: Fill
|
||||||
flow: Down
|
flow: Down
|
||||||
// flow: Overlay
|
|
||||||
show_bg: true
|
show_bg: true
|
||||||
draw_bg: {
|
draw_bg: {
|
||||||
color: #fff
|
color: #fff
|
||||||
|
@ -41,6 +40,7 @@ live_design! {
|
||||||
header = <Header> {}
|
header = <Header> {}
|
||||||
|
|
||||||
// TBD Adjust this based on actual screen size
|
// TBD Adjust this based on actual screen size
|
||||||
|
// offset: 400.0
|
||||||
offset: 2.0
|
offset: 2.0
|
||||||
|
|
||||||
animator: {
|
animator: {
|
||||||
|
@ -51,7 +51,7 @@ live_design! {
|
||||||
from: {all: Forward {duration: 0.3}}
|
from: {all: Forward {duration: 0.3}}
|
||||||
// Bug: Constants are not working as part of an live state value
|
// Bug: Constants are not working as part of an live state value
|
||||||
// apply: {offset: 400.0}
|
// apply: {offset: 400.0}
|
||||||
apply: {offset: 0.0}
|
apply: {offset: 2.0}
|
||||||
}
|
}
|
||||||
|
|
||||||
show = {
|
show = {
|
||||||
|
@ -71,7 +71,7 @@ live_design! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Live)]
|
#[derive(Live, LiveHook, Widget)]
|
||||||
pub struct StackNavigationView {
|
pub struct StackNavigationView {
|
||||||
#[deref]
|
#[deref]
|
||||||
view:View,
|
view:View,
|
||||||
|
@ -83,75 +83,35 @@ pub struct StackNavigationView {
|
||||||
animator: Animator,
|
animator: Animator,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LiveHook for StackNavigationView {
|
|
||||||
fn before_live_design(cx: &mut Cx) {
|
|
||||||
register_widget!(cx, StackNavigationView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for StackNavigationView {
|
impl Widget for StackNavigationView {
|
||||||
fn walk(&mut self, cx: &mut Cx) -> Walk {
|
fn handle_event(&mut self, cx:&mut Cx, event:&Event, scope:&mut Scope) {
|
||||||
self.view.walk(cx)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn redraw(&mut self, cx: &mut Cx) {
|
|
||||||
self.view.redraw(cx)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find_widgets(&mut self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet) {
|
|
||||||
self.view.find_widgets(path, cached, results);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_widget_event_with(
|
|
||||||
&mut self,
|
|
||||||
cx: &mut Cx,
|
|
||||||
event: &Event,
|
|
||||||
dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem),
|
|
||||||
) {
|
|
||||||
self.handle_event_with(cx, event, dispatch_action);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_walk_widget(&mut self, cx: &mut Cx2d, walk: Walk) -> WidgetDraw {
|
|
||||||
self.view.draw_walk_widget(
|
|
||||||
cx,
|
|
||||||
walk.with_abs_pos(DVec2 {
|
|
||||||
x: self.offset,
|
|
||||||
y: 0.,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl StackNavigationView {
|
|
||||||
pub fn handle_event_with(
|
|
||||||
&mut self,
|
|
||||||
cx: &mut Cx,
|
|
||||||
event: &Event,
|
|
||||||
dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem),
|
|
||||||
) {
|
|
||||||
if self.animator_handle_event(cx, event).is_animating() {
|
if self.animator_handle_event(cx, event).is_animating() {
|
||||||
self.view.redraw(cx);
|
self.view.redraw(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
let actions = self.view.handle_widget_event(cx, event);
|
let actions = cx.capture_actions(|cx| self.view.handle_event(cx, event, scope));
|
||||||
if self.button(id!(left_button)).clicked(&actions) {
|
if self.button(id!(left_button)).clicked(&actions) {
|
||||||
self.animator_play(cx, id!(slide.hide));
|
self.animator_play(cx, id!(slide.hide));
|
||||||
}
|
}
|
||||||
|
|
||||||
for action in actions.into_iter() {
|
|
||||||
dispatch_action(cx, action);
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.animator.animator_in_state(cx, id!(slide.hide))
|
if self.animator.animator_in_state(cx, id!(slide.hide))
|
||||||
&& !self.animator.is_track_animating(cx, id!(slide))
|
&& !self.animator.is_track_animating(cx, id!(slide))
|
||||||
{
|
{
|
||||||
self.apply_over(cx, live! {visible: false});
|
self.apply_over(cx, live! {visible: false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, WidgetRef)]
|
fn draw_walk(&mut self, cx:&mut Cx2d, scope:&mut Scope, walk:Walk) -> DrawStep{
|
||||||
pub struct StackNavigationViewRef(pub WidgetRef);
|
self.view.draw_walk(
|
||||||
|
cx,
|
||||||
|
scope,
|
||||||
|
walk.with_abs_pos(DVec2 {
|
||||||
|
x: self.offset,
|
||||||
|
y: 0.,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl StackNavigationViewRef {
|
impl StackNavigationViewRef {
|
||||||
pub fn show(&mut self, cx: &mut Cx) {
|
pub fn show(&mut self, cx: &mut Cx) {
|
||||||
|
@ -186,42 +146,39 @@ enum ActiveStackView {
|
||||||
Active(LiveId),
|
Active(LiveId),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Live)]
|
#[derive(Live, LiveRegisterWidget, WidgetRef)]
|
||||||
pub struct StackNavigation {
|
pub struct StackNavigation {
|
||||||
#[deref]
|
#[deref]
|
||||||
view: View,
|
view: View,
|
||||||
|
|
||||||
#[rust]
|
#[rust]
|
||||||
active_stack_view: ActiveStackView,
|
active_stack_view: ActiveStackView,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LiveHook for StackNavigation {
|
impl LiveHook for StackNavigation {
|
||||||
fn before_live_design(cx: &mut Cx) {
|
|
||||||
register_widget!(cx, StackNavigation);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn after_new_from_doc(&mut self, _cx: &mut Cx) {
|
fn after_new_from_doc(&mut self, _cx: &mut Cx) {
|
||||||
self.active_stack_view = ActiveStackView::None;
|
self.active_stack_view = ActiveStackView::None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget for StackNavigation {
|
impl Widget for StackNavigation {
|
||||||
fn handle_widget_event_with(
|
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
|
||||||
&mut self,
|
|
||||||
cx: &mut Cx,
|
|
||||||
event: &Event,
|
|
||||||
dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem),
|
|
||||||
) {
|
|
||||||
let mut actions = vec![];
|
|
||||||
|
|
||||||
for widget_ref in self.get_active_views(cx).iter() {
|
for widget_ref in self.get_active_views(cx).iter() {
|
||||||
for a in widget_ref.handle_widget_event(cx, event) {
|
widget_ref.handle_event(cx, event, scope);
|
||||||
actions.push(a);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for action in actions.into_iter() {
|
fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {
|
||||||
dispatch_action(cx, action);
|
for widget_ref in self.get_active_views(cx.cx).iter() {
|
||||||
|
widget_ref.draw_walk(cx, scope, walk) ?;
|
||||||
}
|
}
|
||||||
|
DrawStep::done()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WidgetNode for StackNavigation {
|
||||||
|
fn walk(&mut self, cx:&mut Cx) -> Walk{
|
||||||
|
self.view.walk(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn redraw(&mut self, cx: &mut Cx) {
|
fn redraw(&mut self, cx: &mut Cx) {
|
||||||
|
@ -231,18 +188,11 @@ impl Widget for StackNavigation {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_widgets(&mut self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet) {
|
fn find_widgets(&mut self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet) {
|
||||||
// We're only usingView widget ability to find widgets
|
|
||||||
self.view.find_widgets(path, cached, results);
|
self.view.find_widgets(path, cached, results);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_walk_widget(&mut self, cx: &mut Cx2d, walk: Walk) -> WidgetDraw {
|
|
||||||
for widget_ref in self.get_active_views(cx.cx).iter() {
|
|
||||||
widget_ref.draw_walk_widget(cx, walk) ?;
|
|
||||||
}
|
|
||||||
WidgetDraw::done()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl StackNavigation {
|
impl StackNavigation {
|
||||||
pub fn show_stack_view_by_id(&mut self, stack_view_id: LiveId, cx: &mut Cx) {
|
pub fn show_stack_view_by_id(&mut self, stack_view_id: LiveId, cx: &mut Cx) {
|
||||||
if let ActiveStackView::None = self.active_stack_view {
|
if let ActiveStackView::None = self.active_stack_view {
|
||||||
|
@ -277,9 +227,6 @@ impl StackNavigation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, WidgetRef, Debug)]
|
|
||||||
pub struct StackNavigationRef(pub WidgetRef);
|
|
||||||
|
|
||||||
impl StackNavigationRef {
|
impl StackNavigationRef {
|
||||||
pub fn show_stack_view_by_id(&mut self, stack_view_id: LiveId, cx: &mut Cx) {
|
pub fn show_stack_view_by_id(&mut self, stack_view_id: LiveId, cx: &mut Cx) {
|
||||||
if let Some(mut inner) = self.borrow_mut() {
|
if let Some(mut inner) = self.borrow_mut() {
|
||||||
|
@ -287,9 +234,9 @@ impl StackNavigationRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_stack_view_actions(&mut self, cx: &mut Cx, actions: &WidgetActions, destinations: &HashMap<StackViewAction, LiveId>) {
|
pub fn handle_stack_view_actions(&mut self, cx: &mut Cx, actions: &Actions, destinations: &HashMap<StackViewAction, LiveId>) {
|
||||||
for action in actions {
|
for action in actions {
|
||||||
let stack_view_action = action.action();
|
let stack_view_action = action.as_widget_action().cast();
|
||||||
if let Some(stack_view_id) = destinations.get(&stack_view_action) {
|
if let Some(stack_view_id) = destinations.get(&stack_view_action) {
|
||||||
self.show_stack_view_by_id(*stack_view_id, cx);
|
self.show_stack_view_by_id(*stack_view_id, cx);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use makepad_widgets::*;
|
use makepad_widgets::*;
|
||||||
|
|
||||||
#[derive(Clone, WidgetAction, Eq, Hash, PartialEq)]
|
#[derive(Clone, DefaultNone, Eq, Hash, PartialEq, Debug)]
|
||||||
pub enum StackViewAction {
|
pub enum StackViewAction {
|
||||||
None,
|
None,
|
||||||
ShowAddContact,
|
ShowAddContact,
|
||||||
ShowMoments,
|
ShowMoments,
|
||||||
ShowMyProfile,
|
|
||||||
ShowCounterScreen,
|
ShowCounterScreen,
|
||||||
|
ShowMyProfile,
|
||||||
ShowChat,
|
ShowChat,
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,53 +14,25 @@ live_design! {
|
||||||
import crate::shared::search_bar::SearchBar;
|
import crate::shared::search_bar::SearchBar;
|
||||||
import crate::shared::custom_button::CustomButton;
|
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")
|
|
||||||
|
|
||||||
Welcome = {{Welcome}} {
|
Welcome = {{Welcome}} {
|
||||||
view: {
|
// show_bg: true
|
||||||
width: Fill, height: Fill
|
|
||||||
spacing: 10.
|
|
||||||
draw_bg: {
|
draw_bg: {
|
||||||
color: #000
|
color: #f00 //Color Red
|
||||||
}
|
|
||||||
WelcomeInfo = <View> {
|
|
||||||
width: Fill, height: Fill
|
|
||||||
flow: Right,
|
|
||||||
spacing: 10.,
|
|
||||||
// padding: {top: 100., bottom: 100., right: 10., left: 10.}
|
|
||||||
align: {
|
|
||||||
x: 0.5,
|
|
||||||
y: 0.5
|
|
||||||
},
|
|
||||||
show_bg: true
|
|
||||||
draw_bg: {
|
|
||||||
color: #fff
|
|
||||||
}
|
}
|
||||||
<View> {
|
<View> {
|
||||||
width: Fill height: Fill
|
|
||||||
show_bg: false
|
|
||||||
// align:{ x: 0.5 }
|
|
||||||
align: {x: 0.5, y: 0.5}
|
align: {x: 0.5, y: 0.5}
|
||||||
container = <RoundedView> {
|
container = <RoundedView> {
|
||||||
width: 360
|
width: 360
|
||||||
height: 400
|
height: 400
|
||||||
flow: Down
|
flow: Down
|
||||||
align: {x: 0.5, y: 0.5}
|
align: {x: 0.5, y: 0.5}
|
||||||
// margin: {left: 200.0, right: 200.0, top: 100.0, bottom: 100.0}
|
|
||||||
spacing: 2.0
|
spacing: 2.0
|
||||||
draw_bg: {
|
draw_bg: {
|
||||||
color: #ddd,
|
color: #ddd,
|
||||||
// border_width: 1.0,
|
|
||||||
// border_color: #000,
|
|
||||||
radius: (CARD_CORNER_RADIUS)
|
radius: (CARD_CORNER_RADIUS)
|
||||||
}
|
}
|
||||||
<View> {
|
<View> {
|
||||||
width: Fill, height: Fill
|
width: Fit, height: Fill
|
||||||
flow: Down,
|
flow: Down,
|
||||||
align: {x: 0, y: 0.5},
|
align: {x: 0, y: 0.5},
|
||||||
padding: {top: 5., left: 10., right: 10.}, spacing: 20.
|
padding: {top: 5., left: 10., right: 10.}, spacing: 20.
|
||||||
|
@ -91,9 +63,6 @@ live_design! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WelcomeScreen = <View> {
|
WelcomeScreen = <View> {
|
||||||
|
@ -102,75 +71,33 @@ live_design! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Live)]
|
#[derive(Live, LiveHook, Widget)]
|
||||||
pub struct Welcome {
|
pub struct Welcome {
|
||||||
#[live]
|
#[deref] view: View
|
||||||
view:View,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LiveHook for Welcome {
|
|
||||||
fn before_live_design(cx: &mut Cx) {
|
|
||||||
register_widget!(cx, Welcome);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget for Welcome {
|
impl Widget for Welcome {
|
||||||
fn handle_widget_event_with(
|
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
|
||||||
&mut self,
|
let actions = cx.capture_actions(|cx| self.view.handle_event(cx, event, scope));
|
||||||
cx: &mut Cx,
|
|
||||||
event: &Event,
|
|
||||||
dispatch_action: &mut dyn FnMut(&mut Cx, WidgetActionItem),
|
|
||||||
) {
|
|
||||||
let uid = self.widget_uid();
|
|
||||||
self.handle_event_with(cx, event, &mut |cx, action: StackViewAction| {
|
|
||||||
dispatch_action(cx, WidgetActionItem::new(action.into(), uid));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn redraw(&mut self, cx: &mut Cx) {
|
|
||||||
self.view.redraw(cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find_widgets(&mut self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet) {
|
|
||||||
self.view.find_widgets(path, cached, results);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_walk_widget(&mut self, cx: &mut Cx2d, walk: Walk) -> WidgetDraw {
|
|
||||||
self.view.draw_walk_widget(cx, walk)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Welcome {
|
|
||||||
fn handle_event_with(
|
|
||||||
&mut self,
|
|
||||||
cx: &mut Cx,
|
|
||||||
event: &Event,
|
|
||||||
dispatch_action: &mut dyn FnMut(&mut Cx, StackViewAction),
|
|
||||||
) {
|
|
||||||
let actions = self.view.handle_widget_event(cx, event);
|
|
||||||
|
|
||||||
// if self
|
// if self
|
||||||
// .view
|
// .view
|
||||||
// .clickable_view(id!(welcome_frame))
|
// .clickable_view(id!(my_profile_frame))
|
||||||
// .clicked(&actions)
|
// .clicked(&actions)
|
||||||
// {
|
// {
|
||||||
// dispatch_action(cx, StackViewAction::ShowCounterScreen);
|
// let uid = self.widget_uid();
|
||||||
// // let input11 = self.view.text_input(id!(message_input));
|
// cx.widget_action(uid, &scope.path, StackViewAction::ShowMyProfile);
|
||||||
// let user_prompt1 = self.view.text_input(id!(message_input.input)).text();
|
|
||||||
|
|
||||||
// log!("WELCOME BUTTON CLICKED: {}", user_prompt1);
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if self.view.button(id!(welcome_frame)).clicked(&actions)
|
if self.view.button(id!(welcome_frame)).clicked(&actions)
|
||||||
{
|
{
|
||||||
dispatch_action(cx, StackViewAction::ShowCounterScreen);
|
let uid = self.widget_uid();
|
||||||
|
cx.widget_action(uid, &scope.path, StackViewAction::ShowCounterScreen);
|
||||||
|
// dispatch_action(cx, StackViewAction::ShowCounterScreen);
|
||||||
let user_prompt1 = self.view.text_input(id!(message_input.input)).text();
|
let user_prompt1 = self.view.text_input(id!(message_input.input)).text();
|
||||||
log!("WELCOME BUTTON CLICKED: {}", user_prompt1);
|
log!("WELCOME BUTTON CLICKED: {}", user_prompt1);
|
||||||
|
|
||||||
// log!("BUTTON CLICKED {}", self.counter);
|
|
||||||
// self.counter += 1;
|
|
||||||
// let label = self.view.label(id!(label1));
|
|
||||||
// label.set_text_and_redraw(cx,&format!("Counter: {}", self.counter));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {
|
||||||
|
self.view.draw_walk(cx, scope, walk)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue