From d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Mon, 21 Dec 2020 01:22:15 +0100 Subject: Add previously missing docs where appropriate --- src/gui/tool_sidebar.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/gui/tool_sidebar.rs') 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)); -- cgit v1.2.3-70-g09d2