[gtk/wip/otte/for-master: 3/4] paned: Compute the right handle size
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/for-master: 3/4] paned: Compute the right handle size
- Date: Sun, 21 Nov 2021 00:52:53 +0000 (UTC)
commit c025bc5098ea9806b96da336f1d377b5bc3892be
Author: Benjamin Otte <otte redhat com>
Date: Sun Nov 21 01:46:32 2021 +0100
paned: Compute the right handle size
Testcase included
Fixes #4469
gtk/gtkpaned.c | 29 ++++++++++-----
testsuite/reftests/meson.build | 3 ++
testsuite/reftests/paned-handle-size.css | 15 ++++++++
testsuite/reftests/paned-handle-size.ref.ui | 55 +++++++++++++++++++++++++++++
testsuite/reftests/paned-handle-size.ui | 40 +++++++++++++++++++++
5 files changed, 134 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index aebfd91ac7..51a35d95fc 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -1160,7 +1160,7 @@ gtk_paned_get_preferred_size_for_opposite_orientation (GtkWidget *widget,
int *natural)
{
GtkPaned *paned = GTK_PANED (widget);
- int for_start_child, for_end_child;
+ int for_start_child, for_end_child, for_handle;
int child_min, child_nat;
if (size > -1 &&
@@ -1168,22 +1168,21 @@ gtk_paned_get_preferred_size_for_opposite_orientation (GtkWidget *widget,
paned->end_child && gtk_widget_get_visible (paned->end_child))
{
int start_child_req, end_child_req;
- int handle_size;
gtk_widget_measure (paned->handle_widget,
- OPPOSITE_ORIENTATION (paned->orientation),
+ paned->orientation,
-1,
- NULL, &handle_size,
+ NULL, &for_handle,
NULL, NULL);
gtk_widget_measure (paned->start_child, paned->orientation, -1, &start_child_req, NULL, NULL, NULL);
gtk_widget_measure (paned->end_child, paned->orientation, -1, &end_child_req, NULL, NULL, NULL);
gtk_paned_compute_position (paned,
- size - handle_size, start_child_req, end_child_req,
+ size - for_handle, start_child_req, end_child_req,
NULL, NULL, &for_start_child);
- for_end_child = size - for_start_child - handle_size;
+ for_end_child = size - for_start_child - for_handle;
if (paned->shrink_start_child)
for_start_child = MAX (start_child_req, for_start_child);
@@ -1194,6 +1193,7 @@ gtk_paned_get_preferred_size_for_opposite_orientation (GtkWidget *widget,
{
for_start_child = size;
for_end_child = size;
+ for_handle = -1;
}
*minimum = *natural = 0;
@@ -1202,7 +1202,7 @@ gtk_paned_get_preferred_size_for_opposite_orientation (GtkWidget *widget,
{
gtk_widget_measure (paned->start_child,
OPPOSITE_ORIENTATION (paned->orientation),
- MAX (for_start_child, -1),
+ for_start_child,
&child_min, &child_nat,
NULL, NULL);
@@ -1214,7 +1214,20 @@ gtk_paned_get_preferred_size_for_opposite_orientation (GtkWidget *widget,
{
gtk_widget_measure (paned->end_child,
OPPOSITE_ORIENTATION (paned->orientation),
- MAX (for_end_child, -1),
+ for_end_child,
+ &child_min, &child_nat,
+ NULL, NULL);
+
+ *minimum = MAX (*minimum, child_min);
+ *natural = MAX (*natural, child_nat);
+ }
+
+ if (paned->start_child && gtk_widget_get_visible (paned->start_child) &&
+ paned->end_child && gtk_widget_get_visible (paned->end_child))
+ {
+ gtk_widget_measure (paned->handle_widget,
+ OPPOSITE_ORIENTATION (paned->orientation),
+ for_handle,
&child_min, &child_nat,
NULL, NULL);
diff --git a/testsuite/reftests/meson.build b/testsuite/reftests/meson.build
index c87eb278dd..5f36c6ddb4 100644
--- a/testsuite/reftests/meson.build
+++ b/testsuite/reftests/meson.build
@@ -427,6 +427,9 @@ testdata = [
'opacity-initial.ui',
'overlay-no-main-widget.ref.ui',
'overlay-no-main-widget.ui',
+ 'paned-handle-size.css',
+ 'paned-handle-size.ref.ui',
+ 'paned-handle-size.ui',
'paned-undersized.css',
'paned-undersized.ref.ui',
'paned-undersized.ui',
diff --git a/testsuite/reftests/paned-handle-size.css b/testsuite/reftests/paned-handle-size.css
new file mode 100644
index 0000000000..502437c543
--- /dev/null
+++ b/testsuite/reftests/paned-handle-size.css
@@ -0,0 +1,15 @@
+paned separator,
+picture {
+ all: unset;
+ background: firebrick;
+}
+
+paned.vertical > separator {
+ min-width: 10px;
+ min-height: 20px;
+}
+
+paned.horizontal > separator {
+ min-width: 20px;
+ min-height: 10px;
+}
diff --git a/testsuite/reftests/paned-handle-size.ref.ui b/testsuite/reftests/paned-handle-size.ref.ui
new file mode 100644
index 0000000000..72a83a93c3
--- /dev/null
+++ b/testsuite/reftests/paned-handle-size.ref.ui
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="gtk40">
+ <object class="GtkWindow">
+ <property name="decorated">0</property>
+ <child>
+ <object class="GtkBox">
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="label">top left</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkPicture">
+ <property name="height-request">20</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="label">bottom left</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkPicture">
+ <property name="width-request">20</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="label">top right</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkPicture">
+ <property name="height-request">20</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="label">bottom right</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/testsuite/reftests/paned-handle-size.ui b/testsuite/reftests/paned-handle-size.ui
new file mode 100644
index 0000000000..c050dd2fde
--- /dev/null
+++ b/testsuite/reftests/paned-handle-size.ui
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="gtk40">
+ <object class="GtkWindow">
+ <property name="decorated">0</property>
+ <child>
+ <object class="GtkPaned">
+ <child>
+ <object class="GtkPaned">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="label">top left</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="label">bottom left</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkPaned">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="label">top right</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="label">bottom right</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]