FuncDoodle
Loading...
Searching...
No Matches
App.h
Go to the documentation of this file.
1
9
10#pragma once
11
19
20#include "Asset/AssetLoader.h"
21#include "Core/AppSettings.h"
22#include "Core/Manager.h"
24#include "Keybinds/Keybinds.h"
25#include "Platform/Window.h"
26#include "Project/Project.h"
28#include "UI/Themes.h"
29#include "UI/UIManager.h"
30#include "Util/Ptr.h"
31#include "Util/UUID.h"
32
33#include <chrono>
34#include <functional>
35#include <string>
36
37namespace FuncDoodle {
50 public:
59 static Application* Get() { return s_Instance; };
64 void Run();
69 void InitImGui();
74 void RenderImGui();
81 void OpenFileDialog(std::function<void()> done);
88 void SaveFileDialog(std::function<void()> done);
93 void ReadProjectFile();
98 void SaveProjectFile();
103 void RegisterKeybinds();
116 return m_UiManager.GetPopups().IsOpen("save_changes");
117 }
118
123 void HideCursor();
128 void ShowCursor();
129
136 static void ApplyThemeStyle(const ImGuiStyle& themeStyle) {
137 ImGuiStyle& style = ImGui::GetStyle();
138 style = themeStyle;
139 if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
140 style.WindowRounding = 1.0f;
141 }
142 }
143
150 static void ApplyThemeUuid(const FuncDoodle::UUID& uuid) {
151 auto it = FuncDoodle::Themes::g_Themes.find(uuid);
152 if (it != FuncDoodle::Themes::g_Themes.end()) {
153 ApplyThemeStyle(it->second.Style);
154 return;
155 }
156 auto defUuid = FuncDoodle::UUID::FromString(
158 auto defIt = FuncDoodle::Themes::g_Themes.find(defUuid);
159 if (defIt != FuncDoodle::Themes::g_Themes.end()) {
160 ApplyThemeStyle(defIt->second.Style);
161 }
162 }
163
205 bool GetShouldClose() const { return m_ShouldClose; }
212 UUID GetTheme() { return m_Theme; }
219 void SetTheme(UUID theme) { m_Theme = theme; }
226 void SetFrameLimit(double frameLimit) {
227 m_Settings.FrameLimit = frameLimit;
228 }
229
235 void SetShouldClose(bool shouldClose) { m_ShouldClose = shouldClose; }
236
257 double GetFrameTime() const { return 1.0 / m_Settings.FrameLimit; }
271 int GetExportFormat() const { return m_ExportFormat; }
292 std::filesystem::path GetThemesPath() { return m_ThemesPath; }
306 void SetExportFormat(int format) { m_ExportFormat = format; }
307
315
325
331 [[nodiscard]] Platform::Window GetWindow() const { return m_Window; }
332
339 void UpdateFPS(double deltaTime);
347 void DropCallback(int count, const char** paths);
352 void Update();
359 void Save(bool exit = false);
364 void CloseCurrentProject();
371 void SaveAt(const char* path);
383 void Rotate(int32_t deg);
384
385 // lol idk what to call this
391 enum class Where { Before = 0, After = 1 };
398 void Import(Where where);
399
411 void MoveCurrentSelection(Direction direction);
420 static bool IsPosInFrame(ImVec2 pos);
421
422 private:
423 std::string m_FilePath;
435 bool m_ShouldClose = false;
436 bool m_ShowTests = true;
437 double m_FrameLimitCache = 1000.0;
438 double m_LastFrameTime = 0.0;
439 std::chrono::time_point<std::chrono::high_resolution_clock> m_LastFrame;
440 double m_FPS = 0.0;
441 std::array<float, 3> m_CacheBGCol;
442 std::filesystem::path m_ThemesPath;
444 };
445} // namespace FuncDoodle
Runtime configuration and user-adjustable application settings.
Centralized asset management system for images, audio, and fonts.
Core editor logic handling canvas interaction, painting tools, and stroke management.
Keyboard input system including key masks, shortcuts, and keybind registry.
Defines AnimationManager, the central coordinator for animation playback, timeline UI,...
Central registry for UI popup state management.
Defines the ProjectFile class, which manages animation project data.
Convenience type aliases for standard smart pointers.
std::unique_ptr< T > UniquePtr
Alias for an exclusively owned smart pointer.
Definition Ptr.h:28
std::shared_ptr< T > SharedPtr
Alias for a reference-counted shared smart pointer.
Definition Ptr.h:31
Theme system for FuncDoodle UI styling.
Central UI rendering manager for FuncDoodle.
Defines a custom 16-byte UUID (universally unique identifier).
GLFW-based window abstraction for FuncDoodle.
Responsible for registering keybinds for animations, rendering timeline, logs window,...
Definition Manager.h:70
void SetFrameLimit(double frameLimit)
Sets the main-loop frame cap.
Definition App.h:226
void SetCacheProj(SharedPtr< ProjectFile > proj)
Sets the cached project reference.
Definition App.h:191
UIManager & GetUiManager()
Returns the top-level UI manager.
Definition App.h:278
Platform::Window m_Window
Definition App.h:430
static void ApplyThemeUuid(const FuncDoodle::UUID &uuid)
Applies a theme by UUID, falling back to the default theme.
Definition App.h:150
void Update()
Updates per-frame application state outside direct rendering.
Definition App.cc:202
UUID m_Theme
Definition App.h:434
void SaveAt(const char *path)
Saves the current project at an explicit path.
Definition App.cc:486
static void ApplyThemeStyle(const ImGuiStyle &themeStyle)
Applies an ImGui style to the application.
Definition App.h:136
KeybindsRegistry & GetKeybinds()
Returns the application keybind registry.
Definition App.h:264
int m_ExportFormat
Definition App.h:433
void RegisterKeybinds()
Registers application-level keybinds.
Definition App.cc:260
double GetFrameTime() const
Returns target frame time derived from the frame limit.
Definition App.h:257
void SetTheme(UUID theme)
Sets the current theme UUID.
Definition App.h:219
SharedPtr< ProjectFile > GetCurProj()
Returns the currently open project.
Definition App.h:170
~Application()
Definition App.cc:283
double m_FrameLimitCache
Definition App.h:437
void Import(Where where)
Imports content relative to the current frame.
Definition App.cc:541
int & GetExportFormatPtr()
Returns a mutable reference to the export format field.
Definition App.h:285
void Rotate(int32_t deg)
Rotates the active frame or selection by degrees.
Definition App.cc:427
void OpenFileDialog(std::function< void()> done)
Opens the project open dialog.
Definition App.cc:365
AssetLoader * GetAssetLoader()
Returns the global asset loader.
Definition App.h:198
std::chrono::time_point< std::chrono::high_resolution_clock > m_LastFrame
Definition App.h:439
KeybindsRegistry m_Keybinds
Definition App.h:426
Application()
Definition App.cc:48
static bool IsPosInFrame(ImVec2 pos)
Returns whether a screen-space point lies within the frame view.
Definition App.cc:508
AppSettings & GetSettings()
Returns mutable application settings.
Definition App.h:250
void DropCallback(int count, const char **paths)
Handles file-drop events from the window.
Definition App.cc:415
void RenderRotate()
Renders the rotate-project UI.
void UpdateFPS(double deltaTime)
Updates FPS tracking from frame delta time.
Definition App.cc:287
AnimationManager * GetManager()
Returns the animation manager.
Definition App.h:314
SharedPtr< EditorController > GetController()
Returns the shared editor controller.
Definition App.h:322
UIManager m_UiManager
Definition App.h:424
void SetExportFormat(int format)
Sets the export format identifier.
Definition App.h:306
SharedPtr< ProjectFile > m_CacheProj
Definition App.h:428
AppSettings m_Settings
Definition App.h:425
void DeleteCurrentSelection()
Deletes the active selection contents.
Definition App.cc:323
static Application * Get()
Returns the active application singleton.
Definition App.h:59
UUID GetTheme()
Returns the currently selected theme UUID.
Definition App.h:212
Where
Controls whether imported content is inserted before or after the current frame.
Definition App.h:391
@ After
Definition App.h:391
@ Before
Definition App.h:391
std::array< float, 3 > m_CacheBGCol
Definition App.h:441
void ShowCursor()
Shows the application cursor.
Definition App.cc:601
double m_LastFrameTime
Definition App.h:438
SharedPtr< EditorController > m_EditorController
Definition App.h:432
double m_FPS
Definition App.h:440
bool m_ShowTests
Definition App.h:436
void CloseCurrentProject()
Releases the active project and clears dependent UI state.
Definition App.cc:477
Platform::Window * GetWindow()
Returns the mutable application window.
Definition App.h:243
static Application * s_Instance
Definition App.h:443
std::filesystem::path GetThemesPath()
Returns the directory used for theme files.
Definition App.h:292
bool m_ShouldClose
Definition App.h:435
UniquePtr< AnimationManager > m_Manager
Definition App.h:429
void SaveFileDialog(std::function< void()> done)
Opens the project save dialog.
Definition App.cc:371
void MoveCurrentSelection(Direction direction)
Moves the active selection by one step.
Definition App.cc:494
void InitImGui()
Initializes ImGui for the application window.
Definition App.cc:113
Platform::Window GetWindow() const
Returns a copy of the application window wrapper.
Definition App.h:331
void ReadProjectFile()
Reads the currently selected project file from disk.
Definition App.cc:381
SharedPtr< ProjectFile > m_CurrentProj
Definition App.h:427
void SaveProjectFile()
Saves the current project using its active path.
Definition App.cc:401
void SetCurProj(SharedPtr< ProjectFile > proj)
Sets the currently open project.
Definition App.h:177
void HideCursor()
Hides the application cursor.
Definition App.cc:597
int GetExportFormat() const
Returns the selected export format identifier.
Definition App.h:271
bool GetShouldClose() const
Returns whether the application should exit.
Definition App.h:205
std::filesystem::path m_ThemesPath
Definition App.h:442
UniquePtr< AssetLoader > m_AssetLoader
Definition App.h:431
SharedPtr< ProjectFile > GetCacheProj()
Returns the cached project used during prompts and swaps.
Definition App.h:184
void OpenSaveChangesDialog()
Opens the unsaved-changes confirmation dialog.
Definition App.cc:411
double & GetFrameLimitCache()
Returns the cached previous frame limit.
Definition App.h:299
bool SaveChangesDialogOpen()
Returns whether the save-changes dialog is open.
Definition App.h:115
std::string m_FilePath
Definition App.h:423
void Run()
Runs the main application loop.
Definition App.cc:190
void Save(bool exit=false)
Saves the current project and optionally exits.
Definition App.cc:442
void RenderImGui()
Renders one ImGui frame.
Definition App.cc:341
void SetShouldClose(bool shouldClose)
Sets whether the application should exit.
Definition App.h:235
Convenient abstraction that's responsible for loading assets at a given assetsPath.
Definition AssetLoader.h:37
Stores and persists all keybinds used in FuncDoodle (default + user-defined).
Definition Keybinds.h:250
Abstraction over a GLFW window with input, rendering, and lifecycle utilities.
Definition Window.h:61
Renders main FuncDoodle UI.
Definition UIManager.h:38
Represents a single 16-byte opaque uuid-like unique identifier.
Definition UUID.h:31
static UUID FromString(const char *str)
Parses a UUID from a string representation.
Definition UUID.cc:50
constexpr const char * s_DefaultTheme
UUID string of the built-in default theme.
Definition Themes.h:41
std::map< UUID, CustomTheme > g_Themes
Definition Themes.h:73
The FuncDoodle C++ namespace.
Definition Common.h:12
Direction
Direction used for moving a selection.
Definition Direction.h:23
Represents the application's current settings and loaded from imgui.ini.
Definition AppSettings.h:22