refactor: Introduced a SessionCardRegistry and WindowDelegate for better session management in the editor.
Benefits: - Streamlines the build process by allowing for multiple Protobuf targets, enhancing compatibility and maintainability. - Improves session management capabilities within the editor, leading to a more organized and efficient user experience. - Enhance Protobuf target handling in CMake configuration - Updated CMake files to support multiple Protobuf targets, improving flexibility in linking. - Adjusted target link libraries across various components (yaze, yaze_core_lib, yaze_editor, etc.) to utilize the new
This commit is contained in:
96
src/app/editor/system/window_delegate.h
Normal file
96
src/app/editor/system/window_delegate.h
Normal file
@@ -0,0 +1,96 @@
|
||||
#ifndef YAZE_APP_EDITOR_SYSTEM_WINDOW_DELEGATE_H_
|
||||
#define YAZE_APP_EDITOR_SYSTEM_WINDOW_DELEGATE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
/**
|
||||
* @class WindowDelegate
|
||||
* @brief Low-level window operations with minimal dependencies
|
||||
*
|
||||
* Provides window management functionality extracted from EditorManager:
|
||||
* - Window visibility management
|
||||
* - Docking operations
|
||||
* - Layout persistence
|
||||
* - Focus management
|
||||
*
|
||||
* This class has minimal dependencies (only ImGui and absl) to avoid
|
||||
* linker issues and circular dependencies.
|
||||
*/
|
||||
class WindowDelegate {
|
||||
public:
|
||||
WindowDelegate() = default;
|
||||
~WindowDelegate() = default;
|
||||
|
||||
// Window visibility management
|
||||
void ShowAllWindows();
|
||||
void HideAllWindows();
|
||||
void ShowWindow(const std::string& window_id);
|
||||
void HideWindow(const std::string& window_id);
|
||||
void ToggleWindow(const std::string& window_id);
|
||||
bool IsWindowVisible(const std::string& window_id) const;
|
||||
|
||||
// Focus and positioning
|
||||
void FocusWindow(const std::string& window_id);
|
||||
void MaximizeWindow(const std::string& window_id);
|
||||
void RestoreWindow(const std::string& window_id);
|
||||
void CenterWindow(const std::string& window_id);
|
||||
|
||||
// Docking operations
|
||||
void DockWindow(const std::string& window_id, ImGuiDir dock_direction);
|
||||
void UndockWindow(const std::string& window_id);
|
||||
void SetDockSpace(const std::string& dock_space_id, const ImVec2& size = ImVec2(0, 0));
|
||||
|
||||
// Layout management
|
||||
absl::Status SaveLayout(const std::string& preset_name);
|
||||
absl::Status LoadLayout(const std::string& preset_name);
|
||||
absl::Status ResetLayout();
|
||||
std::vector<std::string> GetAvailableLayouts() const;
|
||||
|
||||
// Window state queries
|
||||
std::vector<std::string> GetVisibleWindows() const;
|
||||
std::vector<std::string> GetHiddenWindows() const;
|
||||
ImVec2 GetWindowSize(const std::string& window_id) const;
|
||||
ImVec2 GetWindowPosition(const std::string& window_id) const;
|
||||
|
||||
// Batch operations
|
||||
void ShowWindowsInCategory(const std::string& category);
|
||||
void HideWindowsInCategory(const std::string& category);
|
||||
void ShowOnlyWindow(const std::string& window_id); // Hide all others
|
||||
|
||||
// Window registration (for tracking)
|
||||
void RegisterWindow(const std::string& window_id, const std::string& category = "");
|
||||
void UnregisterWindow(const std::string& window_id);
|
||||
|
||||
// Layout presets
|
||||
void LoadDeveloperLayout();
|
||||
void LoadDesignerLayout();
|
||||
void LoadModderLayout();
|
||||
void LoadMinimalLayout();
|
||||
|
||||
private:
|
||||
// Window registry for tracking
|
||||
struct WindowInfo {
|
||||
std::string id;
|
||||
std::string category;
|
||||
bool is_registered = false;
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, WindowInfo> registered_windows_;
|
||||
|
||||
// Helper methods
|
||||
bool IsWindowRegistered(const std::string& window_id) const;
|
||||
std::string GetLayoutFilePath(const std::string& preset_name) const;
|
||||
void ApplyLayoutToWindow(const std::string& window_id, const std::string& layout_data);
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_EDITOR_SYSTEM_WINDOW_DELEGATE_H_
|
||||
Reference in New Issue
Block a user