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
use std::fmt::Debug;
use std::marker::PhantomData;
use crate::Menu;
use kas::{event, prelude::*};
#[derive(Clone, Debug, Default, Widget)]
#[handler(msg=M)]
pub struct Separator<M: Debug + 'static> {
#[widget_core]
core: CoreData,
_msg: PhantomData<M>,
}
impl Separator<event::VoidMsg> {
#[inline]
pub fn new() -> Self {
Separator {
core: Default::default(),
_msg: Default::default(),
}
}
}
impl<M: Debug> Separator<M> {
#[inline]
pub fn infer() -> Self {
Separator {
core: Default::default(),
_msg: Default::default(),
}
}
}
impl<M: Debug> Layout for Separator<M> {
fn size_rules(&mut self, size_handle: &mut dyn SizeHandle, axis: AxisInfo) -> SizeRules {
let margins = size_handle.frame_margins();
SizeRules::extract_fixed(axis, size_handle.separator(), margins)
}
fn draw(&self, draw_handle: &mut dyn DrawHandle, _: &event::ManagerState, _: bool) {
draw_handle.separator(self.core.rect);
}
}
impl<M: Debug> Menu for Separator<M> {}