Prechádzať zdrojové kódy

feat(gtk): improve split ratio handling

Implemented initial split ratio positioning using signal_map. This ensures split windows start at a reasonable 50/50 ratio rather than a hardcoded value.
Bernardo Magri 1 mesiac pred
rodič
commit
7d407ee874
2 zmenil súbory, kde vykonal 15 pridanie a 5 odobranie
  1. 3 2
      DEV_STATE.md
  2. 12 3
      src/gtk_editor.cpp

+ 3 - 2
DEV_STATE.md

@@ -74,10 +74,11 @@ Lumacs/
 - ✅ **Split Window Cursor Fix**: Fixed cursor movement to work in focused window rather than original active window
 - ✅ **Focus Jumping Fix**: Resolved issue where typing caused focus to jump back to previous window by using GestureClick instead of EventControllerFocus
 
+- ✅ **Split Ratio Improvement**: Implemented initial split ratio using signal_map with fallback
+
 ## Todo  
 1. **Phase 7**: Performance optimization and tuning
-2. **Phase 8**: Mouse support and advanced UI features  
-3. **Split Ratio Improvement**: Implement proper 50/50 split ratios without GTK signal issues
+2. **Phase 8**: Mouse support and advanced UI features
 
 ## Technical Debt/Notes
 - **Lua Bridge**: The lua_api.cpp contains the critical C++/Lua boundary code

+ 12 - 3
src/gtk_editor.cpp

@@ -434,9 +434,18 @@ protected:
             if (child1) paned->set_start_child(*child1);
             if (child2) paned->set_end_child(*child2);
             
-            // Set initial position based on ratio - use default 50/50 split for now
-            // TODO: Calculate proper size after widget is allocated
-            paned->set_position(300); // Reasonable default split position
+            // Set initial position based on ratio
+            // Use signal_map to set position when widget is ready
+            paned->signal_map().connect([paned, node](){
+                 int width = paned->get_width();
+                 int height = paned->get_height();
+                 int size = (paned->get_orientation() == Gtk::Orientation::HORIZONTAL) ? width : height;
+                 
+                 // Fallback if size not yet available
+                 if (size <= 1) size = 1000; // Assume a reasonable default window size
+                 
+                 paned->set_position(static_cast<int>(size * node->ratio));
+            });
             
             return paned;
         }