yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::layout_designer::LayoutDesignerWindow Class Reference

Main window for the WYSIWYG layout designer. More...

#include <layout_designer_window.h>

Classes

struct  PalettePanel
 

Public Member Functions

 LayoutDesignerWindow ()=default
 
 LayoutDesignerWindow (yaze::editor::LayoutManager *layout_manager, PanelManager *panel_manager, yaze::editor::EditorManager *editor_manager)
 
void Initialize (PanelManager *panel_manager, yaze::editor::LayoutManager *layout_manager=nullptr, yaze::editor::EditorManager *editor_manager=nullptr)
 Initialize the designer with manager references.
 
void Open ()
 Open the designer window.
 
void Close ()
 Close the designer window.
 
bool IsOpen () const
 Check if designer window is open.
 
void Draw ()
 Draw the designer window (call every frame)
 
void NewLayout ()
 Create a new empty layout.
 
void LoadLayout (const std::string &filepath)
 Load a layout from JSON file.
 
void SaveLayout (const std::string &filepath)
 Save current layout to JSON file.
 
void ImportFromRuntime ()
 Import layout from current runtime state.
 
void ImportPanelDesign (const std::string &panel_id)
 Import a specific panel's design from runtime.
 
void ExportCode (const std::string &filepath)
 Export layout as C++ code.
 
void PreviewLayout ()
 Apply current layout to the application (live preview)
 

Private Member Functions

void DrawMenuBar ()
 
void DrawToolbar ()
 
void DrawPalette ()
 
void DrawCanvas ()
 
void DrawProperties ()
 
void DrawTreeView ()
 
void DrawCodePreview ()
 
void DrawWidgetPalette ()
 
void DrawWidgetCanvas ()
 
void DrawWidgetProperties ()
 
void DrawWidgetTree ()
 
void DrawWidgetCodePreview ()
 
void DrawThemeProperties ()
 
void HandleCanvasDragDrop ()
 
void DrawDockNode (DockNode *node, const ImVec2 &pos, const ImVec2 &size)
 
void DrawDropZones (const ImVec2 &pos, const ImVec2 &size, DockNode *target_node)
 
bool IsMouseOverRect (const ImVec2 &rect_min, const ImVec2 &rect_max) const
 
ImGuiDir GetDropZone (const ImVec2 &mouse_pos, const ImVec2 &rect_min, const ImVec2 &rect_max) const
 
void ResetDropState ()
 
std::optional< PalettePanelResolvePanelById (const std::string &panel_id) const
 
void AddPanelToTarget (const PalettePanel &panel)
 
void DrawPanelProperties (LayoutPanel *panel)
 
void DrawNodeProperties (DockNode *node)
 
std::string GenerateDockBuilderCode () const
 
std::string GenerateLayoutPresetCode () const
 
void DrawDockNodeTree (DockNode *node, int &node_index)
 
void DeleteNode (DockNode *node)
 
void DeletePanel (LayoutPanel *panel)
 
void PushUndoState ()
 
void Undo ()
 
void Redo ()
 
std::vector< PalettePanelGetAvailablePanels () const
 
void RefreshPanelCache ()
 
bool MatchesSearchFilter (const PalettePanel &panel) const
 

Private Attributes

std::vector< std::unique_ptr< LayoutDefinition > > undo_stack_
 
std::vector< std::unique_ptr< LayoutDefinition > > redo_stack_
 
bool is_open_ = false
 
bool show_code_preview_ = false
 
bool show_tree_view_ = true
 
DesignMode design_mode_ = DesignMode::PanelLayout
 
std::unique_ptr< LayoutDefinitioncurrent_layout_
 
std::unique_ptr< PanelDesigncurrent_panel_design_
 
std::string selected_panel_for_design_
 
ThemeProperties theme_properties_
 
ThemePropertiesPanel theme_panel_
 
bool show_theme_panel_ = false
 
LayoutPanelselected_panel_ = nullptr
 
DockNodeselected_node_ = nullptr
 
DockNodelast_drop_node_for_preview_ = nullptr
 
WidgetDefinitionselected_widget_ = nullptr
 
bool is_dragging_panel_ = false
 
PalettePanel dragging_panel_
 
ImVec2 drop_zone_pos_
 
ImVec2 drop_zone_size_
 
ImGuiDir drop_direction_ = ImGuiDir_None
 
DockNodedrop_target_node_ = nullptr
 
yaze::editor::LayoutManagerlayout_manager_ = nullptr
 
yaze::editor::EditorManagereditor_manager_ = nullptr
 
PanelManagerpanel_manager_ = nullptr
 
char search_filter_ [256] = ""
 
std::string selected_category_filter_ = "All"
 
char widget_search_filter_ [256] = ""
 
std::string selected_widget_category_ = "All"
 
std::vector< PalettePanelpanel_cache_
 
bool panel_cache_dirty_ = true
 
ImVec2 canvas_scroll_ = ImVec2(0, 0)
 
float canvas_zoom_ = 1.0f
 

Static Private Attributes

static constexpr size_t kMaxUndoSteps = 50
 

Detailed Description

Main window for the WYSIWYG layout designer.

Provides a visual interface for designing ImGui panel layouts:

  • Panel Layout Mode: Drag-and-drop panel placement, dock splits
  • Widget Design Mode: Design internal panel layouts with widgets
  • Properties editing
  • Code generation
  • Import/Export

Definition at line 43 of file layout_designer_window.h.

Constructor & Destructor Documentation

◆ LayoutDesignerWindow() [1/2]

yaze::editor::layout_designer::LayoutDesignerWindow::LayoutDesignerWindow ( )
default

◆ LayoutDesignerWindow() [2/2]

yaze::editor::layout_designer::LayoutDesignerWindow::LayoutDesignerWindow ( yaze::editor::LayoutManager * layout_manager,
PanelManager * panel_manager,
yaze::editor::EditorManager * editor_manager )
inlineexplicit

Definition at line 46 of file layout_designer_window.h.

Member Function Documentation

◆ Initialize()

void yaze::editor::layout_designer::LayoutDesignerWindow::Initialize ( PanelManager * panel_manager,
yaze::editor::LayoutManager * layout_manager = nullptr,
yaze::editor::EditorManager * editor_manager = nullptr )

Initialize the designer with manager references.

Parameters
panel_managerReference to PanelManager for importing panels

Definition at line 154 of file layout_designer_window.cc.

References editor_manager_, layout_manager_, LOG_INFO, and panel_manager_.

Referenced by yaze::editor::EditorManager::Initialize().

◆ Open()

void yaze::editor::layout_designer::LayoutDesignerWindow::Open ( )

Open the designer window.

Definition at line 163 of file layout_designer_window.cc.

References current_layout_, is_open_, and NewLayout().

Referenced by yaze::editor::EditorManager::OpenLayoutDesigner().

Here is the call graph for this function:

◆ Close()

void yaze::editor::layout_designer::LayoutDesignerWindow::Close ( )

Close the designer window.

Definition at line 170 of file layout_designer_window.cc.

References is_open_.

Referenced by DrawMenuBar().

◆ IsOpen()

bool yaze::editor::layout_designer::LayoutDesignerWindow::IsOpen ( ) const
inline

Check if designer window is open.

Definition at line 72 of file layout_designer_window.h.

References is_open_.

Referenced by yaze::editor::EditorManager::Update().

◆ Draw()

◆ NewLayout()

void yaze::editor::layout_designer::LayoutDesignerWindow::NewLayout ( )

Create a new empty layout.

Definition at line 1403 of file layout_designer_window.cc.

References LOG_INFO.

Referenced by DrawCanvas(), DrawMenuBar(), DrawToolbar(), and Open().

◆ LoadLayout()

void yaze::editor::layout_designer::LayoutDesignerWindow::LoadLayout ( const std::string & filepath)

Load a layout from JSON file.

Definition at line 1411 of file layout_designer_window.cc.

References LOG_ERROR, and LOG_INFO.

◆ SaveLayout()

void yaze::editor::layout_designer::LayoutDesignerWindow::SaveLayout ( const std::string & filepath)

Save current layout to JSON file.

Definition at line 1427 of file layout_designer_window.cc.

References LOG_ERROR, and LOG_INFO.

◆ ImportFromRuntime()

◆ ImportPanelDesign()

void yaze::editor::layout_designer::LayoutDesignerWindow::ImportPanelDesign ( const std::string & panel_id)

Import a specific panel's design from runtime.

Parameters
panel_idThe panel ID to import

Definition at line 1479 of file layout_designer_window.cc.

References LOG_ERROR, and LOG_INFO.

Referenced by DrawMenuBar().

◆ ExportCode()

void yaze::editor::layout_designer::LayoutDesignerWindow::ExportCode ( const std::string & filepath)

Export layout as C++ code.

Definition at line 1508 of file layout_designer_window.cc.

References LOG_INFO.

◆ PreviewLayout()

void yaze::editor::layout_designer::LayoutDesignerWindow::PreviewLayout ( )

Apply current layout to the application (live preview)

Definition at line 1513 of file layout_designer_window.cc.

References LOG_INFO, and LOG_WARN.

Referenced by DrawMenuBar(), and DrawToolbar().

◆ DrawMenuBar()

◆ DrawToolbar()

◆ DrawPalette()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawPalette ( )
private

◆ DrawCanvas()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawCanvas ( )
private

◆ DrawProperties()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawProperties ( )
private

Definition at line 803 of file layout_designer_window.cc.

References current_layout_, DrawNodeProperties(), DrawPanelProperties(), DrawTreeView(), ICON_MD_TUNE, selected_node_, selected_panel_, and show_tree_view_.

Referenced by Draw().

Here is the call graph for this function:

◆ DrawTreeView()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawTreeView ( )
private

Definition at line 882 of file layout_designer_window.cc.

References current_layout_, DrawDockNodeTree(), and ICON_MD_ACCOUNT_TREE.

Referenced by DrawProperties().

Here is the call graph for this function:

◆ DrawCodePreview()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawCodePreview ( )
private

◆ DrawWidgetPalette()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawWidgetPalette ( )
private

◆ DrawWidgetCanvas()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawWidgetCanvas ( )
private

◆ DrawWidgetProperties()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawWidgetProperties ( )
private

Definition at line 2010 of file layout_designer_window.cc.

References yaze::editor::layout_designer::GetWidgetTypeName(), ICON_MD_TUNE, and LOG_INFO.

Referenced by Draw().

Here is the call graph for this function:

◆ DrawWidgetTree()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawWidgetTree ( )
private

Definition at line 2100 of file layout_designer_window.cc.

References yaze::editor::layout_designer::GetWidgetTypeIcon(), and ICON_MD_ACCOUNT_TREE.

Here is the call graph for this function:

◆ DrawWidgetCodePreview()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawWidgetCodePreview ( )
private

Definition at line 2120 of file layout_designer_window.cc.

Referenced by DrawCodePreview().

◆ DrawThemeProperties()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawThemeProperties ( )
private

Definition at line 2131 of file layout_designer_window.cc.

References ICON_MD_PALETTE.

Referenced by Draw().

◆ HandleCanvasDragDrop()

void yaze::editor::layout_designer::LayoutDesignerWindow::HandleCanvasDragDrop ( )
private

◆ DrawDockNode()

◆ DrawDropZones()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawDropZones ( const ImVec2 & pos,
const ImVec2 & size,
DockNode * target_node )
private

Definition at line 1541 of file layout_designer_window.cc.

References LOG_INFO, and LOG_WARN.

Referenced by DrawDockNode().

◆ IsMouseOverRect()

bool yaze::editor::layout_designer::LayoutDesignerWindow::IsMouseOverRect ( const ImVec2 & rect_min,
const ImVec2 & rect_max ) const
private

Definition at line 1642 of file layout_designer_window.cc.

Referenced by DrawDockNode().

◆ GetDropZone()

ImGuiDir yaze::editor::layout_designer::LayoutDesignerWindow::GetDropZone ( const ImVec2 & mouse_pos,
const ImVec2 & rect_min,
const ImVec2 & rect_max ) const
private

Definition at line 1649 of file layout_designer_window.cc.

◆ ResetDropState()

void yaze::editor::layout_designer::LayoutDesignerWindow::ResetDropState ( )
private

Definition at line 1679 of file layout_designer_window.cc.

Referenced by DrawCanvas().

◆ ResolvePanelById()

◆ AddPanelToTarget()

◆ DrawPanelProperties()

◆ DrawNodeProperties()

void yaze::editor::layout_designer::LayoutDesignerWindow::DrawNodeProperties ( DockNode * node)
private

◆ GenerateDockBuilderCode()

◆ GenerateLayoutPresetCode()

std::string yaze::editor::layout_designer::LayoutDesignerWindow::GenerateLayoutPresetCode ( ) const
private

Definition at line 1048 of file layout_designer_window.cc.

References current_layout_.

Referenced by DrawCodePreview().

◆ DrawDockNodeTree()

◆ DeleteNode()

◆ DeletePanel()

void yaze::editor::layout_designer::LayoutDesignerWindow::DeletePanel ( LayoutPanel * panel)
private

Definition at line 1231 of file layout_designer_window.cc.

References current_layout_, PushUndoState(), and selected_panel_.

Referenced by DrawDockNodeTree().

Here is the call graph for this function:

◆ PushUndoState()

void yaze::editor::layout_designer::LayoutDesignerWindow::PushUndoState ( )
private

Definition at line 1259 of file layout_designer_window.cc.

References current_layout_, kMaxUndoSteps, redo_stack_, and undo_stack_.

Referenced by DeleteNode(), and DeletePanel().

◆ Undo()

void yaze::editor::layout_designer::LayoutDesignerWindow::Undo ( )
private

◆ Redo()

void yaze::editor::layout_designer::LayoutDesignerWindow::Redo ( )
private

◆ GetAvailablePanels()

◆ RefreshPanelCache()

void yaze::editor::layout_designer::LayoutDesignerWindow::RefreshPanelCache ( )
private

Definition at line 1363 of file layout_designer_window.cc.

◆ MatchesSearchFilter()

Member Data Documentation

◆ undo_stack_

std::vector<std::unique_ptr<LayoutDefinition> > yaze::editor::layout_designer::LayoutDesignerWindow::undo_stack_
private

Definition at line 177 of file layout_designer_window.h.

Referenced by PushUndoState(), Redo(), and Undo().

◆ redo_stack_

std::vector<std::unique_ptr<LayoutDefinition> > yaze::editor::layout_designer::LayoutDesignerWindow::redo_stack_
private

Definition at line 178 of file layout_designer_window.h.

Referenced by PushUndoState(), Redo(), and Undo().

◆ kMaxUndoSteps

constexpr size_t yaze::editor::layout_designer::LayoutDesignerWindow::kMaxUndoSteps = 50
staticconstexprprivate

Definition at line 179 of file layout_designer_window.h.

Referenced by PushUndoState().

◆ is_open_

bool yaze::editor::layout_designer::LayoutDesignerWindow::is_open_ = false
private

Definition at line 186 of file layout_designer_window.h.

Referenced by Close(), Draw(), IsOpen(), and Open().

◆ show_code_preview_

bool yaze::editor::layout_designer::LayoutDesignerWindow::show_code_preview_ = false
private

Definition at line 187 of file layout_designer_window.h.

Referenced by Draw(), DrawCodePreview(), DrawMenuBar(), and DrawToolbar().

◆ show_tree_view_

bool yaze::editor::layout_designer::LayoutDesignerWindow::show_tree_view_ = true
private

Definition at line 188 of file layout_designer_window.h.

Referenced by DrawMenuBar(), and DrawProperties().

◆ design_mode_

DesignMode yaze::editor::layout_designer::LayoutDesignerWindow::design_mode_ = DesignMode::PanelLayout
private

Definition at line 191 of file layout_designer_window.h.

Referenced by Draw(), DrawCodePreview(), and DrawToolbar().

◆ current_layout_

std::unique_ptr<LayoutDefinition> yaze::editor::layout_designer::LayoutDesignerWindow::current_layout_
private

◆ current_panel_design_

std::unique_ptr<PanelDesign> yaze::editor::layout_designer::LayoutDesignerWindow::current_panel_design_
private

Definition at line 197 of file layout_designer_window.h.

Referenced by DrawCodePreview(), and DrawToolbar().

◆ selected_panel_for_design_

std::string yaze::editor::layout_designer::LayoutDesignerWindow::selected_panel_for_design_
private

Definition at line 198 of file layout_designer_window.h.

◆ theme_properties_

ThemeProperties yaze::editor::layout_designer::LayoutDesignerWindow::theme_properties_
private

Definition at line 201 of file layout_designer_window.h.

◆ theme_panel_

ThemePropertiesPanel yaze::editor::layout_designer::LayoutDesignerWindow::theme_panel_
private

Definition at line 202 of file layout_designer_window.h.

◆ show_theme_panel_

bool yaze::editor::layout_designer::LayoutDesignerWindow::show_theme_panel_ = false
private

Definition at line 203 of file layout_designer_window.h.

Referenced by Draw(), and DrawMenuBar().

◆ selected_panel_

LayoutPanel* yaze::editor::layout_designer::LayoutDesignerWindow::selected_panel_ = nullptr
private

◆ selected_node_

DockNode* yaze::editor::layout_designer::LayoutDesignerWindow::selected_node_ = nullptr
private

◆ last_drop_node_for_preview_

DockNode* yaze::editor::layout_designer::LayoutDesignerWindow::last_drop_node_for_preview_ = nullptr
private

Definition at line 208 of file layout_designer_window.h.

◆ selected_widget_

WidgetDefinition* yaze::editor::layout_designer::LayoutDesignerWindow::selected_widget_ = nullptr
private

Definition at line 211 of file layout_designer_window.h.

◆ is_dragging_panel_

bool yaze::editor::layout_designer::LayoutDesignerWindow::is_dragging_panel_ = false
private

Definition at line 214 of file layout_designer_window.h.

Referenced by DrawCanvas(), and DrawPalette().

◆ dragging_panel_

PalettePanel yaze::editor::layout_designer::LayoutDesignerWindow::dragging_panel_
private

Definition at line 215 of file layout_designer_window.h.

Referenced by DrawPalette().

◆ drop_zone_pos_

ImVec2 yaze::editor::layout_designer::LayoutDesignerWindow::drop_zone_pos_
private

Definition at line 216 of file layout_designer_window.h.

◆ drop_zone_size_

ImVec2 yaze::editor::layout_designer::LayoutDesignerWindow::drop_zone_size_
private

Definition at line 217 of file layout_designer_window.h.

◆ drop_direction_

ImGuiDir yaze::editor::layout_designer::LayoutDesignerWindow::drop_direction_ = ImGuiDir_None
private

Definition at line 218 of file layout_designer_window.h.

◆ drop_target_node_

DockNode* yaze::editor::layout_designer::LayoutDesignerWindow::drop_target_node_ = nullptr
private

Definition at line 219 of file layout_designer_window.h.

◆ layout_manager_

yaze::editor::LayoutManager* yaze::editor::layout_designer::LayoutDesignerWindow::layout_manager_ = nullptr
private

Definition at line 222 of file layout_designer_window.h.

Referenced by Initialize().

◆ editor_manager_

yaze::editor::EditorManager* yaze::editor::layout_designer::LayoutDesignerWindow::editor_manager_ = nullptr
private

Definition at line 223 of file layout_designer_window.h.

Referenced by Initialize().

◆ panel_manager_

PanelManager* yaze::editor::layout_designer::LayoutDesignerWindow::panel_manager_ = nullptr
private

Definition at line 225 of file layout_designer_window.h.

Referenced by DrawMenuBar(), GetAvailablePanels(), and Initialize().

◆ search_filter_

char yaze::editor::layout_designer::LayoutDesignerWindow::search_filter_[256] = ""
private

Definition at line 228 of file layout_designer_window.h.

Referenced by DrawPalette().

◆ selected_category_filter_

std::string yaze::editor::layout_designer::LayoutDesignerWindow::selected_category_filter_ = "All"
private

Definition at line 229 of file layout_designer_window.h.

Referenced by DrawPalette().

◆ widget_search_filter_

char yaze::editor::layout_designer::LayoutDesignerWindow::widget_search_filter_[256] = ""
private

Definition at line 232 of file layout_designer_window.h.

◆ selected_widget_category_

std::string yaze::editor::layout_designer::LayoutDesignerWindow::selected_widget_category_ = "All"
private

Definition at line 233 of file layout_designer_window.h.

◆ panel_cache_

std::vector<PalettePanel> yaze::editor::layout_designer::LayoutDesignerWindow::panel_cache_
mutableprivate

Definition at line 236 of file layout_designer_window.h.

Referenced by GetAvailablePanels().

◆ panel_cache_dirty_

bool yaze::editor::layout_designer::LayoutDesignerWindow::panel_cache_dirty_ = true
mutableprivate

Definition at line 237 of file layout_designer_window.h.

Referenced by GetAvailablePanels().

◆ canvas_scroll_

ImVec2 yaze::editor::layout_designer::LayoutDesignerWindow::canvas_scroll_ = ImVec2(0, 0)
private

Definition at line 240 of file layout_designer_window.h.

◆ canvas_zoom_

float yaze::editor::layout_designer::LayoutDesignerWindow::canvas_zoom_ = 1.0f
private

Definition at line 241 of file layout_designer_window.h.

Referenced by DrawCanvas(), and DrawMenuBar().


The documentation for this class was generated from the following files: