FuncDoodle
Loading...
Searching...
No Matches
ToolManager.h
Go to the documentation of this file.
1
15
16#pragma once
17
28
29#include "Project/Frame.h"
30
31#include "Asset/AssetLoader.h"
32
33#include "Conf/FuncPCH.h"
34#include "Keybinds/Keybinds.h"
35
36#include "Tool/Tool.h"
37
38namespace FuncDoodle {
46 enum class ColorChoice {
53
60 };
61
69 public:
83 void RegisterKeybinds();
88 void RenderTools();
93 void Buttons();
98 void Widgets();
103 void UpdateCursor();
108 void Cursor();
123 float* GetCol() { return m_FirstCol; }
124
132 float* GetSecCol() { return m_SecondaryCol; }
133
141 void SetCol(struct Col col) {
142 unsigned char colArr[3] = {col.r, col.g, col.b};
143 for (int j = 0; j < 3; j++) {
144 m_FirstCol[j] = static_cast<float>(colArr[j]) / 255.0f;
145 }
146 }
147
155 void SetSecCol(struct Col col) {
156 unsigned char colArr[3] = {col.r, col.g, col.b};
157 for (int j = 0; j < 3; j++) {
158 m_SecondaryCol[j] = static_cast<float>(colArr[j]) / 255.0f;
159 }
160 }
161
168 void SetCurCol(struct Col col) {
169 unsigned char colArr[3] = {col.r, col.g, col.b};
170
171 switch (m_CurrentColor) {
172 using enum ColorChoice;
173
174 case First:
175 for (int j = 0; j < 3; j++) {
176 m_FirstCol[j] = static_cast<float>(colArr[j]) / 255.0f;
177 }
178 break;
179 case Secondary:
180 for (int j = 0; j < 3; j++) {
181 m_SecondaryCol[j] =
182 static_cast<float>(colArr[j]) / 255.0f;
183 }
184 break;
185 }
186 }
187
194 float* GetCurCol() {
195 switch (m_CurrentColor) {
196 using enum ColorChoice;
197
198 case First:
199 return m_FirstCol;
200
201 case Secondary:
202 return m_SecondaryCol;
203 }
204 }
205
212 [[nodiscard]] int GetSize() const { return m_Size; }
213
221 [[nodiscard]] int GetTolerance() const { return m_Tolerance; }
222
229 void SetSize(int size) { m_Size = size; }
230
231 private:
233 float m_FirstCol[3] = {0.0f, 0.0f, 0.0f};
234 float m_SecondaryCol[3] = {0.0f, 0.0f, 0.0f};
236 int m_Size = 1;
237 uint8_t m_Tolerance = 1;
239 };
240} // namespace FuncDoodle
Centralized asset management system for images, audio, and fonts.
Logging system, assertion macros, platform utilities, and build/config macros.
Keyboard input system including key masks, shortcuts, and keybind registry.
Defines pixel color structures and frame/image data containers.
Defines editor tools, tool utilities, and tool-related keybinding logic.
Stores and persists all keybinds used in FuncDoodle (default + user-defined).
Definition Keybinds.h:262
float * GetCol()
Returns the tool color under the first color slot as normalized RGB values.
Definition ToolManager.h:123
void UpdateCursor()
Updates cursor state to match the active tool.
Definition ToolManager.cc:178
int GetSize() const
Returns the current tool size.
Definition ToolManager.h:212
void SetSize(int size)
Sets the current tool size.
Definition ToolManager.h:229
ColorChoice m_CurrentColor
Definition ToolManager.h:235
ToolType m_SelectedTool
Definition ToolManager.h:232
float m_SecondaryCol[3]
Definition ToolManager.h:234
uint8_t m_Tolerance
Definition ToolManager.h:237
float m_FirstCol[3]
Definition ToolManager.h:233
void SetCurCol(struct Col col)
Sets the CURRENT tool color from an 8-bit RGB color.
Definition ToolManager.h:168
void RegisterKeybinds()
Registers tool-selection keybinds.
Definition ToolManager.cc:54
void Widgets()
Renders tool configuration widgets.
Definition ToolManager.cc:67
int m_Size
Definition ToolManager.h:236
void Cursor()
Renders or updates the tool cursor overlay.
Definition ToolManager.cc:190
void Buttons()
Renders tool-selection buttons.
Definition ToolManager.cc:23
ToolManager(KeybindsRegistry &keybinds)
Creates a tool manager bound to the application keybind registry.
Definition ToolManager.cc:18
float * GetSecCol()
Returns the tool color under the secondary color slot as normalized RGB values.
Definition ToolManager.h:132
KeybindsRegistry & m_Keybinds
Definition ToolManager.h:238
int GetTolerance() const
Returns the current tool tolerance (only applicable to bucket tool).
Definition ToolManager.h:221
void SetCol(struct Col col)
Sets the tool color under the first color slot from an 8-bit RGB color.
Definition ToolManager.h:141
void SetSecCol(struct Col col)
Sets the tool color under the secondary color slot from an 8-bit RGB color.
Definition ToolManager.h:155
void RenderTools()
Renders the complete tool UI.
Definition ToolManager.cc:163
ToolType GetSelectedTool()
Returns the currently selected tool.
Definition ToolManager.h:115
float * GetCurCol()
Returns the CURRENT tool color as normalized RGB values.
Definition ToolManager.h:194
The FuncDoodle C++ namespace.
Definition Common.h:12
ColorChoice
Selects one of the editor color slots.
Definition ToolManager.h:46
@ Secondary
Secondary drawing color.
Definition ToolManager.h:59
@ First
Primary drawing color.
Definition ToolManager.h:52
ToolType
All available tools in the editor.
Definition Tool.h:33
@ Pencil
Definition Tool.h:34
A struct holding an RGB8 color.
Definition Frame.h:47
unsigned char r
Red channel in 8-bit RGB space.
Definition Frame.h:49
unsigned char g
Green channel in 8-bit RGB space.
Definition Frame.h:50
unsigned char b
Blue channel in 8-bit RGB space.
Definition Frame.h:51