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");
101 return absl::OkStatus();
105 const std::string& panels) {
108 if (!editor_name.empty()) {
119 switch (event.
type) {
157 return absl::InternalError(
"Window backend not initialized");
162 return absl::OkStatus();
172 const ImGuiViewport* viewport = ImGui::GetMainViewport();
179 float top_offset = 0.0f;
180#if defined(__APPLE__) && \
181 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
187 bottom_offset += safe.bottom;
192 ImVec2 dockspace_pos = viewport->WorkPos;
193 ImVec2 dockspace_size = viewport->WorkSize;
195 dockspace_pos.x += left_offset;
196 dockspace_pos.y += top_offset;
197 dockspace_size.x -= (left_offset + right_offset);
198 dockspace_size.y -= (bottom_offset + top_offset);
200 ImGui::SetNextWindowPos(dockspace_pos);
201 ImGui::SetNextWindowSize(dockspace_size);
202 ImGui::SetNextWindowViewport(viewport->ID);
205 bool show_menu_bar =
true;
209#if defined(__APPLE__) && \
210 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
211 show_menu_bar =
false;
214 ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking;
216 window_flags |= ImGuiWindowFlags_MenuBar;
218 window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse |
219 ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
220 window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus |
221 ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoBackground;
223 ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
224 ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
225 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
226 ImGui::Begin(
"DockSpaceWindow",
nullptr, window_flags);
227 ImGui::PopStyleVar(3);
236 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
238 mgr->SetMainDockspaceId(dockspace_id);
245 (void)mgr->MaybeReapplyStartupLayout(
249 dockspace_id, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_PassthruCentralNode);
262#if !defined(__APPLE__) || \
263 (TARGET_OS_IPHONE != 1 && TARGET_IPHONE_SIMULATOR != 1)
274#if defined(__APPLE__) && \
275 (TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1)
281 snap.
can_undo = editor->undo_manager().CanUndo();
282 snap.
can_redo = editor->undo_manager().CanRedo();
295 return absl::OkStatus();
309 sync_state.pending_layout_actions > 0;
310 if (in_transition && (sync_state.frame_id % 30 != 0)) {
333#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE
345 if (delta_time < 0.007f) {
346#if TARGET_OS_IPHONE != 1
387 auto result = test::CaptureHarnessScreenshot(request.preferred_path);
388 if (request.callback) {
389 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()
static TestManager & Get()
#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)