@@ -19,17 +19,15 @@ void DockSpaceManager::begin_frame() {
1919 ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse |
2020 ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove |
2121 ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus |
22- ImGuiWindowFlags_NoBackground;
22+ ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoInputs ;
2323
2424 ImGui::PushStyleVar (ImGuiStyleVar_WindowRounding, 0 .0f );
2525 ImGui::PushStyleVar (ImGuiStyleVar_WindowBorderSize, 0 .0f );
2626 ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding, ImVec2 (0 , 0 ));
2727 ImGui::Begin (" ##ConvoyShell" , nullptr , flags);
2828 ImGui::PopStyleVar (3 );
2929
30- if (!initialized_) {
31- build_initial_layout ();
32- }
30+ render_snap_zone_overlays ();
3331}
3432
3533void DockSpaceManager::end_frame () {
@@ -38,92 +36,33 @@ void DockSpaceManager::end_frame() {
3836
3937ImGuiID DockSpaceManager::get_zone_id (DockZone zone) const {
4038 switch (zone) {
41- case DockZone::Toolbar: return zone_toolbar_;
42- case DockZone::Canvas: return zone_canvas_;
39+ case DockZone::Toolbar: return zone_toolbar_;
40+ case DockZone::Canvas: return zone_canvas_;
4341 case DockZone::Inspector: return zone_inspect_;
44- case DockZone::Bottom: return zone_bottom_;
42+ case DockZone::Bottom: return zone_bottom_;
4543 }
4644 return 0 ;
4745}
4846
4947void DockSpaceManager::build_initial_layout () {
50- ImGuiID main_id = ImGui::GetMainViewport ()->ID ;
51- ImGui::DockBuilderRemoveNode (main_id);
52- ImGui::DockBuilderAddNode (main_id, ImGuiDockNodeFlags_DockSpace);
53- root_id_ = main_id;
54-
55- build_artisan_layout ();
48+ current_preset_ = LayoutPreset::Artisan;
5649 initialized_ = true ;
5750}
5851
5952void DockSpaceManager::build_artisan_layout () {
60- ImGuiID remaining = root_id_;
61-
62- ImGuiID id_right = ImGui::DockBuilderSplitNode (remaining, ImGuiDir_Right, 0 .20f , nullptr , &remaining);
63- ImGuiID id_left = ImGui::DockBuilderSplitNode (remaining, ImGuiDir_Left, 0 .10f , nullptr , &remaining);
64- ImGuiID id_bottom = ImGui::DockBuilderSplitNode (remaining, ImGuiDir_Down, 0 .15f , nullptr , &remaining);
65-
66- ImGui::DockBuilderDockWindow (" Architect" , remaining);
67- ImGui::DockBuilderDockWindow (" Inspector" , id_right);
68- ImGui::DockBuilderDockWindow (" Toolbar" , id_left);
69- ImGui::DockBuilderDockWindow (" Console" , id_bottom);
70-
71- ImGui::DockBuilderFinish (root_id_);
72-
73- zone_toolbar_ = id_left;
74- zone_canvas_ = remaining;
75- zone_inspect_ = id_right;
76- zone_bottom_ = id_bottom;
7753 current_preset_ = LayoutPreset::Artisan;
7854}
7955
8056void DockSpaceManager::build_level_design_layout () {
81- ImGui::DockBuilderRemoveNode (root_id_);
82- ImGui::DockBuilderAddNode (root_id_, ImGuiDockNodeFlags_DockSpace);
83-
84- ImGuiID remaining = root_id_;
85-
86- ImGuiID id_left = ImGui::DockBuilderSplitNode (remaining, ImGuiDir_Left, 0 .20f , nullptr , &remaining);
87- ImGuiID id_right = ImGui::DockBuilderSplitNode (remaining, ImGuiDir_Right, 0 .20f , nullptr , &remaining);
88-
89- ImGui::DockBuilderDockWindow (" Layers" , id_left);
90- ImGui::DockBuilderDockWindow (" Canvas" , remaining);
91- ImGui::DockBuilderDockWindow (" Tiles" , id_right);
92-
93- ImGui::DockBuilderFinish (root_id_);
94-
95- zone_toolbar_ = id_left;
96- zone_canvas_ = remaining;
97- zone_inspect_ = id_right;
98- zone_bottom_ = 0 ;
9957 current_preset_ = LayoutPreset::LevelDesign;
10058}
10159
10260void DockSpaceManager::build_debugging_layout () {
103- ImGui::DockBuilderRemoveNode (root_id_);
104- ImGui::DockBuilderAddNode (root_id_, ImGuiDockNodeFlags_DockSpace);
105-
106- ImGuiID remaining = root_id_;
107-
108- ImGuiID id_bottom = ImGui::DockBuilderSplitNode (remaining, ImGuiDir_Down, 0 .30f , nullptr , &remaining);
109- ImGuiID id_right = ImGui::DockBuilderSplitNode (remaining, ImGuiDir_Right, 0 .25f , nullptr , &remaining);
110-
111- ImGui::DockBuilderDockWindow (" Canvas" , remaining);
112- ImGui::DockBuilderDockWindow (" Properties" , id_right);
113- ImGui::DockBuilderDockWindow (" Console" , id_bottom);
114-
115- ImGui::DockBuilderFinish (root_id_);
116-
117- zone_toolbar_ = 0 ;
118- zone_canvas_ = remaining;
119- zone_inspect_ = id_right;
120- zone_bottom_ = id_bottom;
12161 current_preset_ = LayoutPreset::Debugging;
12262}
12363
12464void DockSpaceManager::switch_preset (LayoutPreset preset) {
12565 if (current_preset_ == preset) return ;
126-
12766 switch (preset) {
12867 case LayoutPreset::Artisan: build_artisan_layout (); break ;
12968 case LayoutPreset::LevelDesign: build_level_design_layout (); break ;
@@ -142,4 +81,35 @@ void DockSpaceManager::load_layout() {
14281 initialized_ = false ;
14382}
14483
145- } // namespace
84+ void DockSpaceManager::render_snap_zone_overlays () {
85+ if (!show_snap_zones_) return ;
86+
87+ ImGuiViewport* vp = ImGui::GetMainViewport ();
88+ float menu_h = ImGui::GetFrameHeight ();
89+ float x0 = vp->WorkPos .x ;
90+ float y0 = vp->WorkPos .y + menu_h;
91+ float w = vp->WorkSize .x ;
92+ float h = vp->WorkSize .y - menu_h;
93+
94+ float toolbar_w = w * 0 .10f ;
95+ float inspector_w = w * 0 .20f ;
96+ float bottom_h = h * 0 .15f ;
97+
98+ ImU32 zone_col = IM_COL32 (64 , 160 , 255 , 140 );
99+ ImU32 label_col = IM_COL32 (64 , 160 , 255 , 210 );
100+
101+ ImDrawList* dl = ImGui::GetForegroundDrawList ();
102+ float t = 2 .0f ;
103+
104+ dl->AddRect ({x0, y0}, {x0 + toolbar_w, y0 + h - bottom_h}, zone_col, 0 .0f , 0 , t);
105+ dl->AddRect ({x0 + toolbar_w, y0}, {x0 + w - inspector_w, y0 + h - bottom_h}, zone_col, 0 .0f , 0 , t);
106+ dl->AddRect ({x0 + w - inspector_w, y0}, {x0 + w, y0 + h - bottom_h}, zone_col, 0 .0f , 0 , t);
107+ dl->AddRect ({x0, y0 + h - bottom_h}, {x0 + w, y0 + h}, zone_col, 0 .0f , 0 , t);
108+
109+ dl->AddText ({x0 + 4 , y0 + 4 }, label_col, " Toolbar" );
110+ dl->AddText ({x0 + toolbar_w + 4 , y0 + 4 }, label_col, " Canvas" );
111+ dl->AddText ({x0 + w - inspector_w + 4 , y0 + 4 }, label_col, " Inspector" );
112+ dl->AddText ({x0 + 4 , y0 + h - bottom_h + 4 }, label_col, " Console" );
113+ }
114+
115+ } // namespace convoy
0 commit comments