@@ -24,6 +24,8 @@ import gio.Settings : GSettings = Settings;
24
24
25
25
import glib.Util;
26
26
27
+ import gobject.ObjectG;
28
+ import gobject.ParamSpec;
27
29
import gobject.Value;
28
30
29
31
import gtk.Application;
@@ -186,7 +188,7 @@ private:
186
188
* make it look somewhat attractive on Ubuntu and non Adwaita themes.
187
189
*/
188
190
Paned createPaned (Orientation orientation) {
189
- Paned result = new Paned (orientation);
191
+ Paned result = new TerminalPaned (orientation);
190
192
if (Version.checkVersion(3 , 16 , 0 ).length == 0 ) {
191
193
result.setWideHandle(gsSettings.getBoolean(SETTINGS_ENABLE_WIDE_HANDLE_KEY ));
192
194
}
@@ -1193,16 +1195,18 @@ public:
1193
1195
if (direction == " up" || direction == " left" )
1194
1196
increment = - increment;
1195
1197
while (parent ! is null ) {
1196
- Paned paned = cast (Paned ) parent;
1198
+ TerminalPaned paned = cast (TerminalPaned ) parent;
1197
1199
trace(" Testing Paned" );
1198
1200
if (paned ! is null ) {
1199
1201
if ((direction == " up" || direction == " down" ) && paned.getOrientation() == Orientation.VERTICAL ) {
1200
1202
trace(" Resizing " ~ direction);
1201
1203
paned.setPosition(paned.getPosition() + increment);
1204
+ paned.updateRatio();
1202
1205
return ;
1203
1206
} else if ((direction == " left" || direction == " right" ) && paned.getOrientation() == Orientation.HORIZONTAL ) {
1204
1207
trace(" Resizing " ~ direction);
1205
1208
paned.setPosition(paned.getPosition() + increment);
1209
+ paned.updateRatio();
1206
1210
return ;
1207
1211
}
1208
1212
}
@@ -1452,6 +1456,67 @@ private:
1452
1456
immutable bool PANED_RESIZE_MODE = false ;
1453
1457
immutable bool PANED_SHRINK_MODE = false ;
1454
1458
1459
+ /**
1460
+ * Subclass of Paned that maintains a precise ratio split between
1461
+ * children as the Paned is re-size (i.e. resizing the window the Paned is
1462
+ * a part of. GTK seems to grow one side versus the other for a slight amount
1463
+ * without this compensation in place.
1464
+ */
1465
+ class TerminalPaned : Paned {
1466
+
1467
+ private :
1468
+ double ratio = 0.5 ;
1469
+ int lastWidth, lastHeight;
1470
+
1471
+ void updatePosition (GdkRectangle* rect, Widget) {
1472
+ // tracef("TerminalPaned Size allocated, ratio %f", ratio);
1473
+ if (getOrientation() == Orientation.HORIZONTAL ) {
1474
+ if (lastWidth != getAllocatedWidth()) {
1475
+ int position = to! int (to! double (getAllocatedWidth()) * ratio);
1476
+ setPosition(position);
1477
+ // tracef("Position=%d, lastWidth=%d, AllocatedWidth=%d, rect.width=%d", position, lastWidth, getAllocatedWidth(), rect.width);
1478
+ lastWidth = getAllocatedWidth();
1479
+
1480
+ }
1481
+ } else {
1482
+ if (lastHeight != getAllocatedHeight()) {
1483
+ setPosition(to! int (getAllocatedHeight() * ratio));
1484
+ lastHeight = getAllocatedHeight();
1485
+ }
1486
+ }
1487
+ }
1488
+
1489
+ public :
1490
+ this (Orientation orientation) {
1491
+ super (orientation);
1492
+ addOnSizeAllocate(&updatePosition);
1493
+ addOnButtonRelease(delegate (Event event, Widget w) {
1494
+ updateRatio();
1495
+ return false ;
1496
+ });
1497
+ addOnAcceptPosition(delegate (Paned) {
1498
+ updateRatio();
1499
+ return false ;
1500
+ });
1501
+ }
1502
+
1503
+ void updateRatio () {
1504
+ // trace("Updating ratio");
1505
+ double newRatio = ratio;
1506
+ if (getOrientation() == Orientation.HORIZONTAL ) {
1507
+ newRatio = to! double (getChild1().getAllocatedWidth()) / to! double (getAllocatedWidth());
1508
+ // tracef("Child1 Width=%d, Paned Width=%d",getChild1().getAllocatedWidth(),getAllocatedWidth());
1509
+ } else {
1510
+ newRatio = to! double (getChild1().getAllocatedHeight()) / to! double (getHeight());
1511
+ // tracef("Child1 Height=%d, Paned Height=%d",getChild1().getAllocatedHeight(),getAllocatedHeight());
1512
+ }
1513
+ if (newRatio > 0.0 && newRatio < 1.0 ) {
1514
+ ratio = newRatio;
1515
+ // tracef("New TerminalPaned ratio %f", ratio);
1516
+ }
1517
+ }
1518
+ }
1519
+
1455
1520
/**
1456
1521
* used during session serialization to store any width/height/position elements
1457
1522
* as scaled entities so that if restoring a session in a smaller/larger space
0 commit comments