@@ -3,16 +3,46 @@ use tcod::input::Event;
3
3
/// Interactables are UI elements that can be interacted with via the mouse.
4
4
/// To realise that, this trait provides the interface for a callback that can handle mouse events.
5
5
trait Interactable {
6
-
7
6
/// Returns the element layout (min_x, min_y, max_x, max_y) as absolute screen coordinates.
8
- fn get_layout_abs ( ) -> ( i32 , i32 , i32 , i32 ) ;
7
+ fn get_layout_abs ( & self ) -> ( i32 , i32 , i32 , i32 ) ;
9
8
10
9
/// Returns the element layout (min_x, min_y, max_x, max_y) as coordinates relative to the
11
10
/// parent interactable. If there is no parent interactable this is identical to
12
11
/// `get_layout_abs()`
13
- fn get_layout_rel ( ) -> ( i32 , i32 , i32 , i32 ) ;
12
+ fn get_layout_rel ( & self ) -> ( i32 , i32 , i32 , i32 ) ;
14
13
15
14
/// Handle a mouse event.
16
15
// TODO: How to do different return values, e.g.: selected option or no return values?
17
- fn callback ( event : Event :: Mouse ) ;
18
- }
16
+ fn callback ( & self , event : Event ) ;
17
+ }
18
+
19
+ pub struct BottomPanel {
20
+ ui_elements : Vec < Box < dyn Interactable > > ,
21
+ }
22
+
23
+ impl BottomPanel {
24
+ fn new ( ) -> Self {
25
+ BottomPanel {
26
+ ui_elements : Vec :: new ( ) ,
27
+ }
28
+ }
29
+ }
30
+
31
+ impl Interactable for BottomPanel {
32
+ fn get_layout_abs ( & self ) -> ( i32 , i32 , i32 , i32 ) {
33
+ unimplemented ! ( )
34
+ }
35
+
36
+ fn get_layout_rel ( & self ) -> ( i32 , i32 , i32 , i32 ) {
37
+ unimplemented ! ( )
38
+ }
39
+
40
+ fn callback ( & self , event : Event ) {
41
+ // unimplemented!()
42
+ if let Event :: Mouse ( m) = event {
43
+ if m. lbutton_pressed {
44
+ unimplemented ! ( )
45
+ }
46
+ }
47
+ }
48
+ }
0 commit comments