7#include <TargetConditionals.h>
12#include "absl/status/status.h"
25#include "imgui/imgui.h"
26#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE
29#if defined(__APPLE__) && \
30 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
43 if (app_config.headless) {
44 LOG_INFO(
"Controller",
"Using Null Window Backend (Headless Mode)");
49#if defined(__APPLE__) && \
50 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
57 return absl::InternalError(
"Failed to create window backend");
61 config.
title =
"Yet Another Zelda3 Editor";
66 if (app_config.service_mode) {
67 LOG_INFO(
"Controller",
"Starting in Service Mode (Hidden Window)");
76 return absl::InternalError(
"Failed to initialize renderer");
100 return absl::OkStatus();
104 const std::string& panels) {
107 if (!editor_name.empty()) {
118 switch (event.
type) {
153 return absl::InternalError(
"Window backend not initialized");
158 return absl::OkStatus();
168 const ImGuiViewport* viewport = ImGui::GetMainViewport();
175 float top_offset = 0.0f;
176#if defined(__APPLE__) && \
177 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
183 bottom_offset += safe.bottom;
188 ImVec2 dockspace_pos = viewport->WorkPos;
189 ImVec2 dockspace_size = viewport->WorkSize;
191 dockspace_pos.x += left_offset;
192 dockspace_pos.y += top_offset;
193 dockspace_size.x -= (left_offset + right_offset);
194 dockspace_size.y -= (bottom_offset + top_offset);
196 ImGui::SetNextWindowPos(dockspace_pos);
197 ImGui::SetNextWindowSize(dockspace_size);
198 ImGui::SetNextWindowViewport(viewport->ID);
201 bool show_menu_bar =
true;
205#if defined(__APPLE__) && \
206 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
207 show_menu_bar =
false;
210 ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking;
212 window_flags |= ImGuiWindowFlags_MenuBar;
214 window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse |
215 ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
216 window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus |
217 ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoBackground;
219 ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
220 ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
221 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
222 ImGui::Begin(
"DockSpaceWindow",
nullptr, window_flags);
223 ImGui::PopStyleVar(3);
226 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
228 dockspace_id, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_PassthruCentralNode);
241#if !defined(__APPLE__) || \
242 (TARGET_OS_IPHONE != 1 && TARGET_IPHONE_SIMULATOR != 1)
253#if defined(__APPLE__) && \
254 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
260 snap.
can_undo = editor->undo_manager().CanUndo();
261 snap.
can_redo = editor->undo_manager().CanRedo();
274 return absl::OkStatus();
288 sync_state.pending_layout_actions > 0;
289 if (in_transition && (sync_state.frame_id % 30 != 0)) {
312#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE
324 if (delta_time < 0.007f) {
325#if TARGET_OS_IPHONE != 1
366 auto result = test::CaptureHarnessScreenshot(request.preferred_path);
367 if (request.callback) {
368 request.callback(result);
static Application & Instance()
const AppConfig & GetConfig() const
std::queue< ScreenshotRequest > screenshot_requests_
editor::EditorManager editor_manager_
absl::Status LoadRomForTesting(const std::string &rom_path)
absl::Status OnEntry(std::string filename="")
void SetStartupEditor(const std::string &editor_name, const std::string &cards)
std::unique_ptr< platform::IWindowBackend > window_backend_
void ProcessScreenshotRequests() const
void RequestScreenshot(const ScreenshotRequest &request)
std::unique_ptr< gfx::IRenderer > renderer_
std::mutex screenshot_mutex_
static TimingManager & Get()
float Update()
Update the timing manager (call once per frame)
float GetRightLayoutOffset() const
Rom * GetCurrentRom() const override
UICoordinator * ui_coordinator()
void Initialize(gfx::IRenderer *renderer, const std::string &filename="")
float GetBottomLayoutOffset() const
void HandleHostVisibilityChanged(bool visible)
auto GetCurrentEditor() const -> Editor *
void SetAssetLoadMode(AssetLoadMode mode)
void OpenEditorAndPanelsFromFlags(const std::string &editor_name, const std::string &panels_str)
absl::Status Update()
Main update loop for the editor application.
AssetLoadMode asset_load_mode() const
auto emulator() -> emu::Emulator &
absl::Status OpenRomOrProject(const std::string &filename)
UiSyncState GetUiSyncStateSnapshot() const
float GetLeftLayoutOffset() const
bool IsMenuBarVisible() const
void DrawMenuBarRestoreButton()
void Initialize(IRenderer *renderer)
bool ProcessTextureQueueWithBudget(IRenderer *renderer, float budget_ms)
Process texture queue with a time budget.
void ProcessTextureQueue(IRenderer *renderer)
static RendererBackendType GetDefaultBackendType()
static std::unique_ptr< IRenderer > Create(RendererBackendType type=RendererBackendType::kDefault)
static void BeginEnhancedDockSpace(ImGuiID dockspace_id, const ImVec2 &size=ImVec2(0, 0), ImGuiDockNodeFlags flags=0)
static void EndEnhancedDockSpace()
static ThemeManager & Get()
static TestManager & Get()
#define LOG_INFO(category, format,...)
::yaze::EventBus * event_bus()
Get the current EventBus instance.
constexpr std::array< const char *, 14 > kEditorNames
size_t EditorTypeIndex(EditorType type)
@ Null
Null renderer for headless/server mode.
@ Metal
Metal renderer backend (Apple platforms)
SDL2/SDL3 compatibility layer.
#define RETURN_IF_ERROR(expr)
bool layout_rebuild_pending
static FrameGuiBeginEvent Create(float dt)