summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2017-10-11 08:05:52 +0200
committerTimm Bäder <mail@baedert.org>2017-10-11 08:50:18 +0200
commitac7e1081b5a9bdbf105462127ac6c3ee12698fd4 (patch)
tree191ff2eef8edea6ea45be19867ee3400376ac568 /tests
parentabed139a5901738a24c00d835c395b70ebfd4571 (diff)
downloadgtk+-ac7e1081b5a9bdbf105462127ac6c3ee12698fd4.tar.gz
tests: Add testgridbaseline
Which shows that GtkGrid currently computes baselines for all rows even though not all of them might request a baseline.
Diffstat (limited to 'tests')
-rw-r--r--tests/meson.build1
-rw-r--r--tests/testgridbaseline.c58
2 files changed, 59 insertions, 0 deletions
diff --git a/tests/meson.build b/tests/meson.build
index ac0f3b67a3..b4ae0bb6fd 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -129,6 +129,7 @@ gtk_tests = [
['testgaction'],
['testwidgetfocus'],
['testcenterbox'],
+ ['testgridbaseline']
]
if os_linux
diff --git a/tests/testgridbaseline.c b/tests/testgridbaseline.c
new file mode 100644
index 0000000000..8c097bfd96
--- /dev/null
+++ b/tests/testgridbaseline.c
@@ -0,0 +1,58 @@
+#include <gtk/gtk.h>
+
+
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *window;
+ GtkWidget *grid;
+ GtkWidget *label1;
+ GtkWidget *label2;
+ GtkWidget *label3;
+ GtkWidget *label4;
+
+ g_setenv ("GTK_DEBUG", "baselines,layout", TRUE);
+ gtk_init ();
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ grid = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 30);
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 30);
+ gtk_container_add (GTK_CONTAINER (window), grid);
+
+ label1 = gtk_label_new ("Some Text");
+ label2 = gtk_label_new ("QQQQQQQQQ");
+ label3 = gtk_label_new ("Some Text");
+ label4 = gtk_label_new ("Some Text");
+
+ g_message ("label1: %p", label1);
+ g_message ("label2: %p", label2);
+ g_message ("label3: %p", label3);
+ g_message ("label4: %p", label4);
+
+ gtk_widget_set_valign (label1, GTK_ALIGN_BASELINE);
+ gtk_widget_set_valign (label2, GTK_ALIGN_BASELINE);
+ gtk_widget_set_valign (label3, GTK_ALIGN_START);
+ gtk_widget_set_valign (label4, GTK_ALIGN_START);
+
+ gtk_widget_set_margin_top (label1, 12);
+ gtk_widget_set_margin_bottom (label2, 18);
+ gtk_widget_set_margin_top (label3, 30);
+
+
+ /*
+ * Since none of the widgets in the second row request baseline alignment,
+ * GtkGrid should not compute or apply a baseline for those widgets.
+ */
+
+
+ gtk_grid_attach (GTK_GRID (grid), label1, 0, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), label2, 1, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), label3, 0, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), label4, 1, 1, 1, 1);
+
+ gtk_widget_show (window);
+ gtk_main ();
+ return 0;
+}