From 872ad22f0043b282c9159797e45ea7795018cfd9 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 9 Jun 2015 10:23:19 +0200 Subject: [PATCH] testoverlay: Add test for overlay z ordering https://bugzilla.gnome.org/show_bug.cgi?id=750568 https://bugs.freedesktop.org/show_bug.cgi?id=90917 --- tests/testoverlay.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tests/testoverlay.c b/tests/testoverlay.c index c2c2cad..38fd784 100644 --- a/tests/testoverlay.c +++ b/tests/testoverlay.c @@ -458,6 +458,69 @@ test_input_stacking (void) return win; } +static void +reorder_overlay (GtkButton *button, GtkOverlay *overlay) +{ + gtk_overlay_reorder_overlay (overlay, gtk_widget_get_parent (GTK_WIDGET (button)), -1); +} + +static GtkWidget * +test_child_order (void) +{ + GtkWidget *win; + GtkWidget *overlay; + GtkWidget *button; + GtkWidget *label; + GtkWidget *ebox; + GdkRGBA color; + int i; + + win = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_title (GTK_WINDOW (win), "Child Order"); + + overlay = gtk_overlay_new (); + gtk_container_add (GTK_CONTAINER (win), overlay); + + for (i = 0; i < 4; i++) + { + char *colors[] = { + "rgba(255,0,0,0.8)", "rgba(0,255,0,0.8)", "rgba(0,0,255,0.8)", "rgba(255,0,255,0.8)" + }; + ebox = gtk_event_box_new (); + button = gtk_button_new_with_label (g_strdup_printf ("Child %d", i)); + g_signal_connect (button, "clicked", G_CALLBACK (reorder_overlay), overlay); + gtk_widget_set_margin_start (button, 20); + gtk_widget_set_margin_end (button, 20); + gtk_widget_set_margin_top (button, 10); + gtk_widget_set_margin_bottom (button, 10); + + gtk_container_add (GTK_CONTAINER (ebox), button); + + gdk_rgba_parse (&color, colors[i]); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + gtk_widget_override_background_color (ebox, 0, &color); + G_GNUC_END_IGNORE_DEPRECATIONS + gtk_widget_set_halign (ebox, (i == 0 || i == 3) ? GTK_ALIGN_START : GTK_ALIGN_END); + gtk_widget_set_valign (ebox, i < 2 ? GTK_ALIGN_START : GTK_ALIGN_END); + gtk_overlay_add_overlay (GTK_OVERLAY (overlay), ebox); + } + + ebox = gtk_event_box_new (); + gdk_rgba_parse (&color, "white"); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + gtk_widget_override_background_color (ebox, 0, &color); + G_GNUC_END_IGNORE_DEPRECATIONS + + label = gtk_label_new ("Main\n" + "Main\n" + "Main\n" + "Main\n"); + gtk_container_add (GTK_CONTAINER (ebox), label); + gtk_container_add (GTK_CONTAINER (overlay), ebox); + + return win; +} + int main (int argc, char *argv[]) @@ -470,6 +533,7 @@ main (int argc, char *argv[]) GtkWidget *win6; GtkWidget *win7; GtkWidget *win8; + GtkWidget *win9; gtk_init (&argc, &argv); @@ -500,6 +564,9 @@ main (int argc, char *argv[]) win8 = test_input_stacking (); gtk_widget_show_all (win8); + win9 = test_child_order (); + gtk_widget_show_all (win9); + gtk_main (); return 0; -- 2.4.2