Polyphase Game Engine
Loading...
Searching...
No Matches
EditorImgui.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4#include "EngineTypes.h"
5#include "PolyphaseAPI.h"
6
7#include <cstdint>
8#include <vector>
9#include "imgui.h"
10#include "misc/cpp/imgui_stdlib.h"
11
12class Object;
13class Property;
14struct AssetStub;
15
16typedef void(*FileBrowserCallbackFP)(const std::vector<std::string>& filePaths);
17
18
19void EditorImguiInit();
20void EditorImguiDraw();
21
28inline bool EditorShortcutModDown()
29{
30 return ImGui::IsKeyDown(ImGuiMod_Shortcut);
31}
32
39ImFont* GetEditorTerminalFont();
40
41// Queues a rebuild of the editor font atlas at 15px * textScale (0.75 - 2.0).
42// Applied at the start of the next frame.
43void RequestEditorFontRebuild(float textScale);
44float GetEditorTextScale();
45
46// 1.0, or the display's backing scale on Retina Macs.
47float GetDefaultEditorInterfaceScale();
48// Sets EngineConfig::mEditorInterfaceScale (clamped 0.5 - 3.0) and writes Config.ini.
49void ApplyEditorInterfaceScale(float scale);
50
51void EditorImguiShutdown();
52void EditorImguiPreShutdown();
53
54void EditorImguiGetViewport(uint32_t& x, uint32_t& y, uint32_t& width, uint32_t& height);
55bool EditorIsInterfaceVisible();
56bool EditorImguiIsViewportHovered();
57void EditorImguiGetViewportRect(float* outX, float* outY, float* outW, float* outH);
58void EditorOpenFileBrowser(FileBrowserCallbackFP callback, bool folderMode);
59void EditorSetFileBrowserDir(const std::string& dir);
60void EditorShowUnsavedAssetsModal(const std::vector<AssetStub*>& unsavedStubs);
61
72void EditorShowAlert(const char* title, const char* message);
73
74POLYPHASE_API void DrawAssetProperty(Property& prop, uint32_t index, Object* owner, PropertyOwnerType ownerType);
75
85void InvalidateAddNodeMenuCache();
86
95void InvalidateScriptPickerCache();
96
97// Animated progress modal for long-running editor operations (scene save,
98// asset save, enter/exit PIE, reload scripts). Long synchronous work in
99// these paths would otherwise freeze the UI; calling Pump() at safe
100// checkpoints renders one editor frame so the modal animates and the
101// status label updates. Only valid to call from non-ImGui contexts -- i.e.
102// from the deferred-end-of-frame dispatcher in EditorMain.cpp after
103// EditorImguiDraw has returned. Begin/SetStatus/Step/End perform their
104// own (throttled) pump.
105namespace EditorProgress
106{
107 // Open the modal. status text is shown immediately. If cancellable is
108 // true a Cancel button is rendered; loops should poll WasCancelled().
109 void Begin(const char* title, const char* status, bool cancellable = false);
110
111 // Update the status label and pump a frame (subject to ~60Hz throttle).
112 void SetStatus(const char* msg);
113
114 // Set the progress bar. Negative = indeterminate sine marquee; 0..1 =
115 // determinate fill. No pump (use SetStatus or Step to redraw).
116 void SetFraction(float f);
117
118 // Convenience for "Step N of M" loops: updates label + determinate
119 // fraction + pumps.
120 void Step(const char* msg, int done, int total);
121
122 // Force-render one editor frame. Throttled to ~60Hz; ignored when not
123 // active. Asserts if called inside an ImGui frame scope.
124 void Pump();
125
126 // Close the modal and render one final frame.
127 void End();
128
129 bool IsActive();
130 bool WasCancelled();
131}
132
133#endif
PropertyOwnerType
Definition EngineTypes.h:159
Export macros for Polyphase Engine symbols.
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
Definition Object.h:13
Definition Property.h:14
Definition Asset.h:94