aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorArne Dußin2020-12-21 01:22:15 +0100
committerArne Dußin2020-12-21 21:15:55 +0100
commitd7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4 (patch)
treee5633f4d3b18472922c943d759e9f58722ba4405 /src/gui
parent48f321a80970ebeb8374072b1d2e0a4d297aa348 (diff)
downloadgraf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.tar.gz
graf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.zip
Add previously missing docs where appropriate
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/dimension_indicator.rs6
-rw-r--r--src/gui/mod.rs9
-rw-r--r--src/gui/tool_sidebar.rs11
3 files changed, 25 insertions, 1 deletions
diff --git a/src/gui/dimension_indicator.rs b/src/gui/dimension_indicator.rs
index aa00f67..e8848fe 100644
--- a/src/gui/dimension_indicator.rs
+++ b/src/gui/dimension_indicator.rs
@@ -1,10 +1,13 @@
+//! An interface element that shows the size of the selected map items and provides a means to
+//! manually change the size of them in a precise manner should need be.
+
use crate::colours::DEFAULT_COLOURS;
use crate::map::Map;
use crate::math::{self, Rect, Vec2};
use crate::transform::Transform;
use nalgebra::{Matrix3, Vector2};
use raylib::drawing::RaylibDraw;
-use raylib::ffi::{Color, KeyboardKey};
+use raylib::ffi::KeyboardKey;
use raylib::RaylibHandle;
/// A state the [DimensionIndicator] is currently in. This determines the behaviour of it and what
@@ -218,6 +221,7 @@ impl DimensionIndicator {
self.bounds = bounds;
}
+ /// Draw the dimensions detected on the current selection.
pub fn draw(&self, rld: &mut impl RaylibDraw, transform: &Transform) {
/* Ignore a selection that has no non-null dimensions, since this usually
* indicates that there is nothing to be scaled.
diff --git a/src/gui/mod.rs b/src/gui/mod.rs
index 032d430..a94122e 100644
--- a/src/gui/mod.rs
+++ b/src/gui/mod.rs
@@ -1,3 +1,12 @@
+//! General graphical user interfaces
+//!
+//! This mod does not contain all graphical content on screen, but all user interfaces that is drawn
+//! that is not contained in a different category. This means all interface elements where it does not
+//! make sense to bind it to any other part of the program, for instance a tool or type of element.
+//! It also does *not* contain anything that does anything that is not triggered by the user, which
+//! means everything is called top-down from this module. A function in this module should not be
+//! called from any point in the program except the main loop, where the user input is polled.
+
pub mod dimension_indicator;
pub mod tool_sidebar;
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));