-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added: preliminary trait definition for interactable UI elements
Showing
2 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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); | ||
|
||
/// 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); | ||
|
||
/// Handle a mouse event. | ||
// TODO: How to do different return values, e.g.: selected option or no return values? | ||
fn callback(event: Event::Mouse); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ pub mod game_frontend; | |
pub mod game_input; | ||
|
||
mod color_palette; | ||
mod interactable; |