Skip to content

Commit

Permalink
added: outline for bottom panel struct
Browse files Browse the repository at this point in the history
  • Loading branch information
micutio committed Nov 18, 2020
1 parent 6a4ed92 commit f126b1f
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions src/ui/interactable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,46 @@ use tcod::input::Event;
/// Interactables are UI elements that can be interacted with via the mouse.
/// To realise that, this trait provides the interface for a callback that can handle mouse events.
trait Interactable {

/// Returns the element layout (min_x, min_y, max_x, max_y) as absolute screen coordinates.
fn get_layout_abs() -> (i32, i32, i32, i32);
fn get_layout_abs(&self) -> (i32, i32, i32, i32);

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

/// Handle a mouse event.
// TODO: How to do different return values, e.g.: selected option or no return values?
fn callback(event: Event::Mouse);
}
fn callback(&self, event: Event);
}

pub struct BottomPanel {
ui_elements: Vec<Box<dyn Interactable>>,
}

impl BottomPanel {
fn new() -> Self {
BottomPanel {
ui_elements: Vec::new(),
}
}
}

impl Interactable for BottomPanel {
fn get_layout_abs(&self) -> (i32, i32, i32, i32) {
unimplemented!()
}

fn get_layout_rel(&self) -> (i32, i32, i32, i32) {
unimplemented!()
}

fn callback(&self, event: Event) {
// unimplemented!()
if let Event::Mouse(m) = event {
if m.lbutton_pressed {
unimplemented!()
}
}
}
}

0 comments on commit f126b1f

Please sign in to comment.