Skip to content

Commit f126b1f

Browse files
committed
added: outline for bottom panel struct
1 parent 6a4ed92 commit f126b1f

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

src/ui/interactable.rs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,46 @@ use tcod::input::Event;
33
/// Interactables are UI elements that can be interacted with via the mouse.
44
/// To realise that, this trait provides the interface for a callback that can handle mouse events.
55
trait Interactable {
6-
76
/// 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);
98

109
/// Returns the element layout (min_x, min_y, max_x, max_y) as coordinates relative to the
1110
/// parent interactable. If there is no parent interactable this is identical to
1211
/// `get_layout_abs()`
13-
fn get_layout_rel() -> (i32, i32, i32, i32);
12+
fn get_layout_rel(&self) -> (i32, i32, i32, i32);
1413

1514
/// Handle a mouse event.
1615
// 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

Comments
 (0)