aboutsummaryrefslogtreecommitdiff
path: root/src/gui/tool_sidebar.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/tool_sidebar.rs')
-rw-r--r--src/gui/tool_sidebar.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/gui/tool_sidebar.rs b/src/gui/tool_sidebar.rs
index 7674c47..e6b8867 100644
--- a/src/gui/tool_sidebar.rs
+++ b/src/gui/tool_sidebar.rs
@@ -1,3 +1,8 @@
+//! The sidebar showing all tools available to the user. This toolbar handles changing the active tool
+//! based on the mouse input and (TODO!) keyboard inputs.
+// TODO: Currently, the keyboard shortcuts for tools are handled by the editor, but a lot speaks for
+// them being handled by the ToolSidebar instead.
+
use crate::math::{Rect, Surface, Vec2};
use crate::tool::ToolType;
use crate::Editor;
@@ -6,13 +11,16 @@ use raylib::rgui::RaylibDrawGui;
use raylib::{RaylibHandle, RaylibThread};
use std::mem;
+/// The file containing textures for all buttons describing the tools.
pub const BUTTON_FILE: &str = "assets/button/tool_buttons.png";
+/// Sidebar that renders and handles input for the tool activation buttons.
pub struct ToolSidebar {
button_texture: Texture2D,
}
impl ToolSidebar {
+ /// Create a new tool sidebar. There should be only one sidebar per program instance.
pub fn new(rl: &mut RaylibHandle, rlt: &RaylibThread) -> Self {
let button_texture = rl
.load_texture(rlt, BUTTON_FILE)
@@ -31,6 +39,9 @@ impl ToolSidebar {
Self::panel_rect(screen_height).contains_point(&mouse_pos)
}
+ /// Draw the tool buttons and encasing panel. Because of the way raylib works, this also handles
+ /// clicking on tool buttons, which may be changed in the future, should a different gui be
+ /// chosen.
pub fn draw(&self, screen_height: u16, rld: &mut impl RaylibDrawGui, editor: &mut Editor) {
rld.gui_panel(Self::panel_rect(screen_height));