7#include <TargetConditionals.h>
12#include "absl/status/status.h"
26#include "imgui/imgui.h"
27#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE
30#if defined(__APPLE__) && \
31 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
44 if (app_config.headless) {
45 LOG_INFO(
"Controller",
"Using Null Window Backend (Headless Mode)");
50#if defined(__APPLE__) && \
51 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
58 return absl::InternalError(
"Failed to create window backend");
62 config.
title =
"Yet Another Zelda3 Editor";
67 if (app_config.service_mode) {
68 LOG_INFO(
"Controller",
"Starting in Service Mode (Hidden Window)");
77 return absl::InternalError(
"Failed to initialize renderer");
87#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE && \
88 !defined(YAZE_GUI_TEST_TARGET)
110 return absl::OkStatus();
114 const std::string& panels) {
117 if (!editor_name.empty()) {
128 switch (event.
type) {
166 return absl::InternalError(
"Window backend not initialized");
171 return absl::OkStatus();
181 const ImGuiViewport* viewport = ImGui::GetMainViewport();
188 float top_offset = 0.0f;
189#if defined(__APPLE__) && \
190 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
196 bottom_offset += safe.bottom;
201 ImVec2 dockspace_pos = viewport->WorkPos;
202 ImVec2 dockspace_size = viewport->WorkSize;
204 dockspace_pos.x += left_offset;
205 dockspace_pos.y += top_offset;
206 dockspace_size.x -= (left_offset + right_offset);
207 dockspace_size.y -= (bottom_offset + top_offset);
209 ImGui::SetNextWindowPos(dockspace_pos);
210 ImGui::SetNextWindowSize(dockspace_size);
211 ImGui::SetNextWindowViewport(viewport->ID);
214 bool show_menu_bar =
true;
218#if defined(__APPLE__) && \
219 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
220 show_menu_bar =
false;
223 ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking;
225 window_flags |= ImGuiWindowFlags_MenuBar;
227 window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse |
228 ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
229 window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus |
230 ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoBackground;
232 ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
233 ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
234 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
235 ImGui::Begin(
"DockSpaceWindow",
nullptr, window_flags);
236 ImGui::PopStyleVar(3);
245 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
247 mgr->SetMainDockspaceId(dockspace_id);
254 (void)mgr->MaybeReapplyStartupLayout(
258 dockspace_id, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_PassthruCentralNode);
271#if !defined(__APPLE__) || \
272 (TARGET_OS_IPHONE != 1 && TARGET_IPHONE_SIMULATOR != 1)
283#if defined(__APPLE__) && \
284 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
290 snap.
can_undo = editor->undo_manager().CanUndo();
291 snap.
can_redo = editor->undo_manager().CanRedo();
304 return absl::OkStatus();
318 sync_state.pending_layout_actions > 0;
319 if (in_transition && (sync_state.frame_id % 30 != 0)) {
342#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE
354 if (delta_time < 0.007f) {
355#if TARGET_OS_IPHONE != 1
362#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE && \
363 !defined(YAZE_GUI_TEST_TARGET)
375#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE && \
376 !defined(YAZE_GUI_TEST_TARGET)
408 auto result = test::CaptureHarnessScreenshot(request.preferred_path,
409 request.reveal_to_user);
410 if (request.callback) {
411 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
auto GetCurrentEditor() const -> Editor *override
void HandleHostVisibilityChanged(bool visible)
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()
void DestroyUITestingContext()
static TestManager & Get()
void InitializeUITesting()
#define LOG_INFO(category, format,...)
::yaze::EventBus * event_bus()
Get the current EventBus instance.
UserSettings * user_settings()
Get the current UserSettings instance.
LayoutManager * layout_manager()
Get the shared LayoutManager 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)