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 "Conf/Constants.h"
22#include "Core/AppSettings.h"
23#include "Core/Manager.h"
25#include "Keybinds/Keybinds.h"
26#include "Platform/Window.h"
27#include "Project/Project.h"
29#include "UI/Themes.h"
30#include "UI/UIManager.h"
31#include "Util/Ptr.h"
32#include "Util/UUID.h"
33
34#include <chrono>
35#include <functional>
36#include <string>
37
38namespace FuncDoodle {
51 public:
60 static Application* Get() { return s_Instance; };
65 void Run();
70 void InitImGui();
75 void RenderImGui();
76
81 void RenderFrame(double dt);
88 void OpenFileDialog(std::function<void()> done);
95 void SaveFileDialog(std::function<void()> done);
100 void ReadProjectFile();
105 void SaveProjectFile();
110 void RegisterKeybinds();
123 return m_UiManager.GetPopups().IsOpen("save_changes");
124 }
125
130 void HideCursor();
135 void ShowCursor();
136
143 static void ApplyThemeStyle(const ImGuiStyle& themeStyle) {
144 ImGuiStyle& style = ImGui::GetStyle();
145 style = themeStyle;
146 if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
147 style.WindowRounding = 1.0f;
148 }
149 }
150
157 static void ApplyThemeUuid(const FuncDoodle::UUID& uuid) {
158 auto it = FuncDoodle::Themes::g_Themes.find(uuid);
159 if (it != FuncDoodle::Themes::g_Themes.end()) {
160 ApplyThemeStyle(it->second.Style);
161 return;
162 }
163 auto defUuid = FuncDoodle::UUID::FromString(
165 auto defIt = FuncDoodle::Themes::g_Themes.find(defUuid);
166 if (defIt != FuncDoodle::Themes::g_Themes.end()) {
167 ApplyThemeStyle(defIt->second.Style);
168 }
169 }
170
177 std::chrono::time_point<std::chrono::high_resolution_clock>
179 return m_LastFrame;
180 }
181
189
224 bool GetShouldClose() const { return m_ShouldClose; }
231 UUID GetTheme() { return m_Theme; }
238 void SetTheme(UUID theme) { m_Theme = theme; }
245 void SetFrameLimit(double frameLimit) {
246 m_Settings.FrameLimit = frameLimit;
247 }
248
254 void SetShouldClose(bool shouldClose) { m_ShouldClose = shouldClose; }
255
276 double GetFrameTime() const { return 1.0 / m_Settings.FrameLimit; }
311 std::filesystem::path GetThemesPath() { return m_ThemesPath; }
325 void SetExportFormat(ExportFormat format) { m_ExportFormat = format; }
326
334
344
350 [[nodiscard]] Platform::Window GetWindow() const { return m_Window; }
351
358 void UpdateFPS(double deltaTime);
366 void DropCallback(int count, const char** paths);
371 void Update();
378 void Save(bool exit = false);
383 void CloseCurrentProject();
390 void SaveAt(const char* path);
396
402 inline double GetDt() { return m_DeltaTime; }
403
410 void Rotate(int32_t deg);
411
412 // lol idk what to call this
418 enum class Where { Before = 0, After = 1 };
425 void Import(Where where);
426
438 void MoveCurrentSelection(Direction direction);
447 static bool IsPosInFrame(ImVec2 pos);
448
449 private:
450 std::string m_FilePath;
462 bool m_ShouldClose = false;
463 bool m_ShowTests = true;
464 double m_FrameLimitCache = 1000.0;
465 double m_LastFrameTime = 0.0;
466 std::chrono::time_point<std::chrono::high_resolution_clock> m_LastFrame;
467 double m_FPS = 0.0;
468 std::array<float, 3> m_CacheBGCol;
469 std::filesystem::path m_ThemesPath;
472 };
473} // namespace FuncDoodle
Runtime configuration and user-adjustable application settings.
Centralized asset management system for images, audio, and fonts.
Global constants used throughout FuncDoodle.
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:245
void SetCacheProj(SharedPtr< ProjectFile > proj)
Sets the cached project reference.
Definition App.h:210
UIManager & GetUiManager()
Returns the top-level UI manager.
Definition App.h:297
Platform::Window m_Window
Definition App.h:457
static void ApplyThemeUuid(const FuncDoodle::UUID &uuid)
Applies a theme by UUID, falling back to the default theme.
Definition App.h:157
void Update()
Updates per-frame application state outside direct rendering.
Definition App.cc:207
void SetExportFormat(ExportFormat format)
Sets the export format identifier.
Definition App.h:325
ExportFormat m_ExportFormat
Definition App.h:460
UUID m_Theme
Definition App.h:461
std::chrono::time_point< std::chrono::high_resolution_clock > GetLastFrame()
Returns the last frame time.
Definition App.h:178
void SaveAt(const char *path)
Saves the current project at an explicit path.
Definition App.cc:512
static void ApplyThemeStyle(const ImGuiStyle &themeStyle)
Applies an ImGui style to the application.
Definition App.h:143
KeybindsRegistry & GetKeybinds()
Returns the application keybind registry.
Definition App.h:283
void RegisterKeybinds()
Registers application-level keybinds.
Definition App.cc:271
double GetFrameTime() const
Returns target frame time derived from the frame limit.
Definition App.h:276
void SetTheme(UUID theme)
Sets the current theme UUID.
Definition App.h:238
SharedPtr< ProjectFile > GetCurProj()
Returns the currently open project.
Definition App.h:188
~Application()
Definition App.cc:308
double m_FrameLimitCache
Definition App.h:464
void Import(Where where)
Imports content relative to the current frame.
Definition App.cc:567
void RenderFrame(double dt)
Renders the current framebuffer.
Definition App.cc:224
ExportFormat & GetExportFormatPtr()
Returns a mutable reference to the export format field.
Definition App.h:304
void Rotate(int32_t deg)
Rotates the active frame or selection by degrees.
Definition App.cc:452
void OpenFileDialog(std::function< void()> done)
Opens the project open dialog.
Definition App.cc:390
AssetLoader * GetAssetLoader()
Returns the global asset loader.
Definition App.h:217
std::chrono::time_point< std::chrono::high_resolution_clock > m_LastFrame
Definition App.h:466
KeybindsRegistry m_Keybinds
Definition App.h:453
double GetDt()
Get deltaTime.
Definition App.h:402
Application()
Definition App.cc:35
static bool IsPosInFrame(ImVec2 pos)
Returns whether a screen-space point lies within the frame view.
Definition App.cc:534
AppSettings & GetSettings()
Returns mutable application settings.
Definition App.h:269
ExportFormat GetExportFormat() const
Returns the selected export format identifier.
Definition App.h:290
void DropCallback(int count, const char **paths)
Handles file-drop events from the window.
Definition App.cc:440
void RenderRotate()
Renders the rotate-project UI.
void UpdateFPS(double deltaTime)
Updates FPS tracking from frame delta time.
Definition App.cc:312
AnimationManager * GetManager()
Returns the animation manager.
Definition App.h:333
SharedPtr< EditorController > GetController()
Returns the shared editor controller.
Definition App.h:341
UIManager m_UiManager
Definition App.h:451
SharedPtr< ProjectFile > m_CacheProj
Definition App.h:455
AppSettings m_Settings
Definition App.h:452
void DeleteCurrentSelection()
Deletes the active selection contents.
Definition App.cc:348
static Application * Get()
Returns the active application singleton.
Definition App.h:60
UUID GetTheme()
Returns the currently selected theme UUID.
Definition App.h:231
Where
Controls whether imported content is inserted before or after the current frame.
Definition App.h:418
@ After
Definition App.h:418
@ Before
Definition App.h:418
std::array< float, 3 > m_CacheBGCol
Definition App.h:468
void ShowCursor()
Shows the application cursor.
Definition App.cc:627
double m_LastFrameTime
Definition App.h:465
SharedPtr< EditorController > m_EditorController
Definition App.h:459
double m_FPS
Definition App.h:467
bool m_ShowTests
Definition App.h:463
void CloseCurrentProject()
Releases the active project and clears dependent UI state.
Definition App.cc:502
Platform::Window * GetWindow()
Returns the mutable application window.
Definition App.h:262
static Application * s_Instance
Definition App.h:471
std::filesystem::path GetThemesPath()
Returns the directory used for theme files.
Definition App.h:311
bool m_ShouldClose
Definition App.h:462
UniquePtr< AnimationManager > m_Manager
Definition App.h:456
void SaveFileDialog(std::function< void()> done)
Opens the project save dialog.
Definition App.cc:396
void MoveCurrentSelection(Direction direction)
Moves the active selection by one step.
Definition App.cc:520
void InitImGui()
Initializes ImGui for the application window.
Definition App.cc:118
Platform::Window GetWindow() const
Returns a copy of the application window wrapper.
Definition App.h:350
void ReadProjectFile()
Reads the currently selected project file from disk.
Definition App.cc:406
SharedPtr< ProjectFile > m_CurrentProj
Definition App.h:454
void SaveProjectFile()
Saves the current project using its active path.
Definition App.cc:426
void SetCurProj(SharedPtr< ProjectFile > proj)
Sets the currently open project.
Definition App.h:196
void HideCursor()
Hides the application cursor.
Definition App.cc:623
bool GetShouldClose() const
Returns whether the application should exit.
Definition App.h:224
std::filesystem::path m_ThemesPath
Definition App.h:469
UniquePtr< AssetLoader > m_AssetLoader
Definition App.h:458
SharedPtr< ProjectFile > GetCacheProj()
Returns the cached project used during prompts and swaps.
Definition App.h:203
void OpenSaveChangesDialog()
Opens the unsaved-changes confirmation dialog.
Definition App.cc:436
double & GetFrameLimitCache()
Returns the cached previous frame limit.
Definition App.h:318
bool SaveChangesDialogOpen()
Returns whether the save-changes dialog is open.
Definition App.h:122
std::string m_FilePath
Definition App.h:450
double m_DeltaTime
Definition App.h:470
void Run()
Runs the main application loop.
Definition App.cc:195
void Save(bool exit=false)
Saves the current project and optionally exits.
Definition App.cc:467
void RenderImGui()
Renders one ImGui frame.
Definition App.cc:366
void SetShouldClose(bool shouldClose)
Sets whether the application should exit.
Definition App.h:254
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:262
Abstraction over a GLFW window with input, rendering, and lifecycle utilities.
Definition Window.h:61
Renders main FuncDoodle UI.
Definition UIManager.h:39
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
ExportFormat
Definition Constants.h:288
@ MP4
Definition Constants.h:290
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