17#include "imgui/imgui.h"
18#include "imgui/imgui_internal.h"
31 [
this](
const JumpToRoomRequestEvent& event) {
36 [
this](
const JumpToMapRequestEvent& event) {
41 [
this](
const JumpToMessageRequestEvent& event) {
46 [
this](
const JumpToAssemblySymbolRequestEvent& event) {
50 LOG_INFO(
"EditorActivator",
"Subscribed to navigation events");
57 LOG_WARN(
"EditorActivator",
"Not initialized, cannot switch editor");
62 ImGuiContext* imgui_ctx = ImGui::GetCurrentContext();
63 const bool frame_active = imgui_ctx !=
nullptr && imgui_ctx->WithinFrameScope;
66 [
this, editor_type, force_visible, from_dialog]() {
84 switch (editor_type) {
98 "Failed to prepare editor: " + std::string(status.message()),
111 for (
auto* editor : editor_set->active_editors_) {
112 if (editor->type() == editor_type) {
114 editor->set_active(
true);
116 editor->toggle_active();
120 if (*editor->active()) {
145 if (old_category != new_category) {
160 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
161 deps_.layout_manager->InitializeEditorLayout(type, dockspace_id);
170 EditorSet* editor_set) {
175 for (
auto* other : editor_set->active_editors_) {
179 std::string new_category =
181 if (old_category != new_category) {
191 bool force_visible) {
222 ImGuiContext* ctx = ImGui::GetCurrentContext();
224 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
229 LOG_INFO(
"EditorActivator",
"Initialized emulator layout");
268 ImGuiContext* ctx = ImGui::GetCurrentContext();
269 if (!ctx || !ctx->WithinFrameScope) {
278 ImGuiID dockspace_id = ImGui::GetID(
"MainDockSpace");
280 LOG_INFO(
"EditorActivator",
"Initialized layout for editor type %d",
281 static_cast<int>(type));
296 std::string(status.message()),
307 editor_set->GetDungeonEditor()->add_room(room_id);
322 std::string(status.message()),
333 editor_set->GetOverworldEditor()->set_current_map(map_id);
350 std::string(status.message()),
360 if (
auto* message_editor = editor_set->GetMessageEditor()) {
361 if (!message_editor->OpenMessageById(message_id)) {
364 "Message ID not found: " + std::to_string(message_id),
386 std::string(status.message()),
396 if (
auto* asm_editor = editor_set->GetAssemblyEditor()) {
397 const auto status = asm_editor->JumpToReference(symbol);
401 "Assembly jump failed: " + std::string(status.message()),
HandlerId Subscribe(std::function< void(const T &)> handler)
void HandleNonEditorClassSwitch(EditorType type, bool force_visible)
void ActivatePanelBasedEditor(EditorType type, Editor *editor)
void JumpToAssemblySymbol(const std::string &symbol)
Jump to an assembly symbol definition in the Assembly editor.
void SwitchToEditor(EditorType type, bool force_visible=false, bool from_dialog=false)
Switch to an editor, optionally forcing visibility.
void Initialize(const Dependencies &deps)
void JumpToMessage(int message_id)
Jump to a specific message ID in the Message editor.
void InitializeEditorLayout(EditorType type)
Initialize the DockBuilder layout for an editor.
void JumpToDungeonRoom(int room_id)
Jump to a specific dungeon room.
void JumpToOverworldMap(int map_id)
Jump to a specific overworld map.
void DeactivatePanelBasedEditor(EditorType type, Editor *editor, EditorSet *editor_set)
static bool IsPanelBasedEditor(EditorType type)
static std::string GetEditorCategory(EditorType type)
bool IsLayoutInitialized(EditorType type) const
Check if a layout has been initialized for an editor.
void InitializeEditorLayout(EditorType type, ImGuiID dockspace_id)
Initialize the default layout for a specific editor type.
void OpenDrawer(DrawerType type)
Open a specific drawer.
DrawerType GetActiveDrawer() const
Get the currently active drawer type.
void CloseDrawer()
Close the currently active drawer.
void Show(const std::string &message, ToastType type=ToastType::kInfo, float ttl_seconds=3.0f)
bool IsEmulatorVisible() const
bool IsAsmEditorVisible() const
void SetEmulatorVisible(bool visible)
void SetAsmEditorVisible(bool visible)
void SetEditorSelectionVisible(bool visible)
void SetActiveCategory(const std::string &category, bool notify=true)
std::string GetActiveCategory() const
void OnEditorSwitch(const std::string &from_category, const std::string &to_category)
Handle editor/category switching for panel visibility.
bool OpenWindow(size_t session_id, const std::string &base_window_id)
void ClearWorkspaceTransitionState()
#define LOG_WARN(category, format,...)
#define LOG_INFO(category, format,...)
LayoutManager * layout_manager
std::function< EditorSet *()> get_current_editor_set
std::function< void(std::function< void()>)> queue_deferred_action
ToastManager * toast_manager
RightDrawerManager * right_drawer_manager
UICoordinator * ui_coordinator
std::function< size_t()> get_current_session_id
std::function< absl::Status(EditorType)> ensure_editor_assets_loaded
WorkspaceWindowManager * window_manager