@@ -46,14 +46,19 @@ private int SeparatorHeight
4646 private int separatorHeight ;
4747
4848 private Godot . Collections . Array < Container > _columns ;
49+ private Godot . Collections . Array < HSplitContainer > _columnSplitters ;
4950
5051 private Control _content ;
5152
53+ private static readonly StringName getTextMethod = "get_text" ;
54+ private static readonly int splitOffset = 10 ;
55+
5256 // Called when the node enters the scene tree for the first time.
5357 public override void _Ready ( )
5458 {
5559 _content = GetChild < Control > ( 0 ) ;
5660 _columns = new ( ) ;
61+ _columnSplitters = new ( ) ;
5762
5863 GetViewport ( ) . GuiFocusChanged += OnGuiFocusChanged ;
5964
@@ -85,7 +90,11 @@ public override void _Ready()
8590 node1 . AddChild ( _column ) ;
8691 node1 = _column ;
8792
88- _columns . Add ( _column . GetChild < Container > ( 0 ) ) ;
93+ var columnSplit = _column as HSplitContainer ;
94+ var columnContent = _column . GetChild < Container > ( 0 ) ;
95+ _columns . Add ( columnContent ) ;
96+ _columnSplitters . Add ( columnSplit ) ;
97+ columnContent . ChildEnteredTree += ( x ) => OnItemAdded ( columnContent , columnSplit , x ) ;
8998 }
9099 node . AddChild ( new Control ( ) ) ;
91100 node1 . AddChild ( new Control ( ) ) ;
@@ -101,6 +110,34 @@ public override void _Ready()
101110 }
102111 }
103112
113+ private void OnItemAdded ( Container column , HSplitContainer splitter , Node element )
114+ {
115+ // Leads to MemoryAccessViolation
116+
117+ //if (element is not Control ctrl)
118+ // return;
119+ //if (!element.HasMethod(getTextMethod))
120+ // return;
121+
122+ //var text = element.Call(getTextMethod).AsString();
123+ //if (string.IsNullOrEmpty(text))
124+ // return;
125+
126+ //var font = ctrl.HasThemeFont("normal_font") ? ctrl.GetThemeFont("normal_font") : null;
127+ //font ??= ctrl.HasThemeFont("font") ? ctrl.GetThemeFont("font") : ctrl.GetThemeDefaultFont();
128+ //var fontSize = ctrl.HasThemeFontSize("font_size") ? ctrl.GetThemeFontSize("font_size") : ctrl.GetThemeDefaultFontSize();
129+
130+ //var textWidth = font.GetStringSize(text, fontSize: fontSize).x;
131+ //var newOffset = (int)(textWidth + splitOffset /*- column.GetCombinedMinimumSize().x*/);
132+ //if (newOffset < 0)
133+ // return;
134+
135+ //var currentOffset = splitter.SplitOffset;
136+
137+ //if (newOffset > currentOffset)
138+ // splitter.Call("set_synced_offset", newOffset);
139+ }
140+
104141 private void OnGuiFocusChanged ( Control node )
105142 {
106143 var focussedRows = GetFocussedRows ( ) ;
0 commit comments