1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// a window menu implementation
use makepad_render::*;
use crate::widgetstyle::*;
#[derive(Clone)]
pub struct WindowMenu {
pub view: View,
pub item_draw: MenuItemDraw,
}
#[derive(Clone)]
pub struct MenuItemDraw {
pub text: Text,
pub item_bg: Quad,
//pub item_layout: LayoutId,
//pub name_color: ColorId,
//pub bg_color: ColorId,
//pub bg_over_color: ColorId,
//pub bg_selected_color: ColorId,
}
impl MenuItemDraw {
pub fn proto(cx: &mut Cx) -> Self {
Self {
text: Text {
wrapping: Wrapping::Word,
..Text::proto(cx)
},
//item_layout: Layout_window_menu::id(cx),
item_bg: Quad::proto(cx),
//name_color: Color_text_selected_focus::id(cx),
//bg_color: Color_bg_selected::id(cx),
//bg_over_color: Color_bg_odd::id(cx),
//bg_selected_color: Color_bg_selected_over::id(cx),
}
}
pub fn get_default_anim(&self, cx: &Cx) -> Anim {
Anim::new(Play::Chain {duration: 0.01}, vec![
Track::color(Quad::instance_color(), Ease::Lin, vec![
(1.0, Theme::color_bg_selected().get(cx))
])
])
}
pub fn get_default_anim_cut(&self, cx: &Cx) -> Anim {
Anim::new(Play::Cut {duration: 0.01}, vec![
Track::color(Quad::instance_color(), Ease::Lin, vec![
(0.0, Theme::color_bg_selected().get(cx))
])
])
}
pub fn get_over_anim(&self, cx: &Cx) -> Anim {
Anim::new(Play::Cut {duration: 0.02}, vec![
Track::color(Quad::instance_color(), Ease::Lin, vec![
(0., Theme::color_bg_odd().get(cx)),
])
])
}
pub fn text_style_menu_label() ->TextStyleId{uid!()}
pub fn style(cx:&mut Cx, _opt:&StyleOptions){
Self::text_style_menu_label().set(cx, Theme::text_style_normal().get(cx));
}
/*
pub fn draw_log_path(&mut self, cx: &mut Cx, path: &str, row: usize) {
self.text.color = self.path_color;
self.text.draw_text(cx, &format!("{}:{} - ", path, row));
}
pub fn draw_log_body(&mut self, cx: &mut Cx, body: &str) {
self.text.color = self.message_color;
if body.len()>500 {
self.text.draw_text(cx, &body[0..500]);
}
else {
self.text.draw_text(cx, &body);
}
}
pub fn draw_log_item(&mut self, cx: &mut Cx, list_item: &mut ListItem, log_item: &HubLogItem) {
self.item_bg.color = list_item.animator.last_color(cx.id("bg.color"));
let bg_inst = self.item_bg.begin_quad(cx, &self.get_line_layout());
match log_item {
HubLogItem::LocPanic(loc_msg) => {
self.code_icon.draw_icon_walk(cx, CodeIconType::Panic);
self.draw_log_path(cx, &loc_msg.path, loc_msg.row);
self.draw_log_body(cx, &loc_msg.body);
},
HubLogItem::LocError(loc_msg) => {
self.code_icon.draw_icon_walk(cx, CodeIconType::Error);
self.draw_log_path(cx, &loc_msg.path, loc_msg.row);
self.draw_log_body(cx, &loc_msg.body);
},
HubLogItem::LocWarning(loc_msg) => {
self.code_icon.draw_icon_walk(cx, CodeIconType::Warning);
self.draw_log_path(cx, &loc_msg.path, loc_msg.row);
self.draw_log_body(cx, &loc_msg.body);
},
HubLogItem::LocMessage(loc_msg) => {
self.draw_log_path(cx, &loc_msg.path, loc_msg.row);
self.draw_log_body(cx, &loc_msg.body);
},
HubLogItem::Error(msg) => {
self.code_icon.draw_icon_walk(cx, CodeIconType::Error);
self.draw_log_body(cx, &msg);
},
HubLogItem::Warning(msg) => {
self.code_icon.draw_icon_walk(cx, CodeIconType::Warning);
self.draw_log_body(cx, &msg);
},
HubLogItem::Message(msg) => {
self.draw_log_body(cx, &msg);
}
}
let bg_area = self.item_bg.end_quad(cx, &bg_inst);
list_item.animator.update_area_refs(cx, bg_area);
}*/
}
#[derive(Clone)]
pub enum WindowMenuEvent {
SelectItem {
},
None,
}
impl WindowMenu {
pub fn proto(cx: &mut Cx) -> Self {
Self {
item_draw: MenuItemDraw::proto(cx),
view: View::proto(cx),
}
}
pub fn handle_window_menu(&mut self, _cx: &mut Cx, _event: &mut Event, _menu: &Menu) -> WindowMenuEvent {
WindowMenuEvent::None
}
pub fn draw_window_menu(&mut self, _cx: &mut Cx, _menu: &Menu) {
}
}