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
6#include <cstdint>
7#include <vector>
8#include "imgui.h"
9#include "misc/cpp/imgui_stdlib.h"
10
11class Object;
12class Property;
13struct AssetStub;
14
15typedef void(*FileBrowserCallbackFP)(const std::vector<std::string>& filePaths);
16
17
18void EditorImguiInit();
19void EditorImguiDraw();
20
27ImFont* GetEditorTerminalFont();
28
29void EditorImguiShutdown();
30void EditorImguiPreShutdown();
31
32void EditorImguiGetViewport(uint32_t& x, uint32_t& y, uint32_t& width, uint32_t& height);
33bool EditorIsInterfaceVisible();
34bool EditorImguiIsViewportHovered();
35void EditorOpenFileBrowser(FileBrowserCallbackFP callback, bool folderMode);
36void EditorSetFileBrowserDir(const std::string& dir);
37void EditorShowUnsavedAssetsModal(const std::vector<AssetStub*>& unsavedStubs);
38
39void DrawAssetProperty(Property& prop, uint32_t index, Object* owner, PropertyOwnerType ownerType);
40
41// Animated progress modal for long-running editor operations (scene save,
42// asset save, enter/exit PIE, reload scripts). Long synchronous work in
43// these paths would otherwise freeze the UI; calling Pump() at safe
44// checkpoints renders one editor frame so the modal animates and the
45// status label updates. Only valid to call from non-ImGui contexts -- i.e.
46// from the deferred-end-of-frame dispatcher in EditorMain.cpp after
47// EditorImguiDraw has returned. Begin/SetStatus/Step/End perform their
48// own (throttled) pump.
49namespace EditorProgress
50{
51 // Open the modal. status text is shown immediately. If cancellable is
52 // true a Cancel button is rendered; loops should poll WasCancelled().
53 void Begin(const char* title, const char* status, bool cancellable = false);
54
55 // Update the status label and pump a frame (subject to ~60Hz throttle).
56 void SetStatus(const char* msg);
57
58 // Set the progress bar. Negative = indeterminate sine marquee; 0..1 =
59 // determinate fill. No pump (use SetStatus or Step to redraw).
60 void SetFraction(float f);
61
62 // Convenience for "Step N of M" loops: updates label + determinate
63 // fraction + pumps.
64 void Step(const char* msg, int done, int total);
65
66 // Force-render one editor frame. Throttled to ~60Hz; ignored when not
67 // active. Asserts if called inside an ImGui frame scope.
68 void Pump();
69
70 // Close the modal and render one final frame.
71 void End();
72
73 bool IsActive();
74 bool WasCancelled();
75}
76
77#endif
PropertyOwnerType
Definition EngineTypes.h:148
Definition Object.h:13
Definition Property.h:14
Definition Asset.h:82