[gtk+/extended-layout-jhs: 58/64] Improve contrast for currently selected widget, show pointer address of



commit a546be36c923fc3a02a495dcc56e0114d591f1f1
Author: Mathias Hasselmann <mathias hasselmann gmx de>
Date:   Mon Aug 20 18:42:26 2007 +0000

    Improve contrast for currently selected widget, show pointer address of
    
    2007-08-20  Mathias Hasselmann  <mathias hasselmann gmx de>
    
    	* tests/testextendedlayout.c: Improve contrast for currently
    	selected widget, show pointer address of widget in status bar.
    	Provider names in size-for-allocation test.
    
    svn path=/branches/extended-layout/; revision=18658

 ChangeLog.gtk-extended-layout |    6 ++
 tests/testextendedlayout.c    |  142 +++++++++++++++++++++++-----------------
 2 files changed, 88 insertions(+), 60 deletions(-)
---
diff --git a/ChangeLog.gtk-extended-layout b/ChangeLog.gtk-extended-layout
index aaed61f..c1ae315 100644
--- a/ChangeLog.gtk-extended-layout
+++ b/ChangeLog.gtk-extended-layout
@@ -1,5 +1,11 @@
 2007-08-20  Mathias Hasselmann  <mathias hasselmann gmx de>
 
+	* tests/testextendedlayout.c: Improve contrast for currently
+	selected widget, show pointer address of widget in status bar.
+	Provider names in size-for-allocation test.
+
+2007-08-20  Mathias Hasselmann  <mathias hasselmann gmx de>
+
 	* tests/testextendedlayout.c: Start real testing of height-for-width
 	and width-for-height.
 	* gtk/gtklabel.c, gtk/gtklabel.h, gtk/gtk.symbols: Add "full-size"
diff --git a/tests/testextendedlayout.c b/tests/testextendedlayout.c
index 5dd0f30..4bfdc2a 100644
--- a/tests/testextendedlayout.c
+++ b/tests/testextendedlayout.c
@@ -233,7 +233,8 @@ update_status (TestSuite *suite,
     g_string_append_printf (status, " (%s)", widget_name);
 
   g_string_append_printf (status,
-                          ":\nposition=%dx%d; size=%dx%d; requisition=%dx%d",
+                          "@%p:\nposition=%dx%d; size=%dx%d; requisition=%dx%d",
+                          child,
                           child->allocation.x,
                           child->allocation.y,
                           child->allocation.width,
@@ -920,8 +921,8 @@ natural_size_test_misc_new (TestSuite *suite,
 }
 
 static TestCase*
-height_for_width_test_new (TestSuite *suite,
-                           gboolean   vertical)
+size_for_allocation_test_new (TestSuite *suite,
+                              gboolean   vertical)
 {
   GtkWidget *box, *child;
   TestCase *test;
@@ -929,9 +930,12 @@ height_for_width_test_new (TestSuite *suite,
 
   if (vertical)
     {
-      test = test_case_new (suite, "Height for Width", NULL, gtk_hpaned_new ());
-      box = gtk_vbox_new (FALSE, 6);
+      test = test_case_new (suite,
+                            "Size for Allocation", 
+                            "Height for Width", 
+                            gtk_hpaned_new ());
 
+      box = gtk_vbox_new (FALSE, 6);
       child = gtk_label_new ("Move the handle to test\n"
                              "height-for-width requests");
 
@@ -939,9 +943,12 @@ height_for_width_test_new (TestSuite *suite,
     }
   else
     {
-      test = test_case_new (suite, "Width for Height", NULL, gtk_vpaned_new ());
-      box = gtk_hbox_new (FALSE, 6);
+      test = test_case_new (suite,
+                            "Size for Allocation", 
+                            "Width for Height",
+                            gtk_vpaned_new ());
 
+      box = gtk_hbox_new (FALSE, 6);
       child = gtk_label_new ("Move the handle to test\n"
                              "width-for-height requests");
     }
@@ -971,14 +978,20 @@ height_for_width_test_new (TestSuite *suite,
             gtk_label_set_angle (GTK_LABEL (child), vertical ? 180 : 270);
           else if (!vertical)
             gtk_label_set_angle (GTK_LABEL (child), 90);
+
+          set_widget_name (child, "%s-label-and-%g-degree",
+                           i > 0 ? "full-size" : "regular",
+                           gtk_label_get_angle (GTK_LABEL (child)));
         }
       else
         {       
           child = gtk_button_new ();
+          set_widget_name (child, "the-button");
           gtk_container_add (GTK_CONTAINER (child),
                              gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO,
                                                        GTK_ICON_SIZE_DIALOG));
           gtk_box_pack_start (GTK_BOX (box), child, TRUE, TRUE, 0);
+
         }
     }
 
@@ -1491,12 +1504,13 @@ test_case_compare_guides (const TestCase *self,
 }
 
 static const gchar*
-guide_type_get_color (GuideType type)
+guide_type_get_color (GuideType type,
+                      gboolean  is_current)
 {
   switch (type) 
     {
-      case GUIDE_BASELINE: return "#f00";
-      default: return "#ff0";
+      case GUIDE_BASELINE: return is_current ? "#f00" : "#00f";
+      default: return is_current ? "#000" : "#fff";
     }
 }
 
@@ -1505,8 +1519,8 @@ draw_guides (gpointer data)
 {
   TestCase *test = data;
   GdkDrawable *drawable;
-
   const GList *iter;
+  gint iteration;
 
   GdkGCValues values;
   GdkGC *gc;
@@ -1533,65 +1547,73 @@ draw_guides (gpointer data)
     test->suite->exteriour && gtk_toggle_button_get_active (
     GTK_TOGGLE_BUTTON (test->suite->exteriour));;
 
-  for (iter = test->guides; iter; iter = iter->next)
+  for (iteration = 0; iteration < 3; ++iteration)
     {
-      const Guide *guide = iter->data;
-      GdkRectangle extends;
-      gint num_baselines;
-      gint *baselines;
-      gint i;
-
-      if (guide->widget == test->suite->current)
+      for (iter = test->guides; iter; iter = iter->next)
         {
-          if (test->suite->timestamp < 3)
-            {
-              gdk_gc_set_fill (gc, GDK_TILED);
-              gdk_gc_set_function (gc, GDK_OR);
+          const Guide *guide = iter->data;
+          gboolean is_current = (guide->widget == test->suite->current);
+          GdkRectangle extends;
+          gint num_baselines;
+          gint *baselines;
+          gint i;
 
-              gdk_draw_rectangle (drawable, gc, TRUE, 
-                                  guide->widget->allocation.x,
-                                  guide->widget->allocation.y,
-                                  guide->widget->allocation.width,
-                                  guide->widget->allocation.height);
+          if (!is_current != !iteration)
+            continue;
 
-              gdk_gc_set_function (gc, GDK_COPY);
-              gdk_gc_set_fill (gc, GDK_SOLID);
-            }
-          else
+          if (is_current)
             {
-              continue;
+              if (test->suite->timestamp >= 3)
+                continue;
+
+              if (1 == iteration)
+                {
+                  gdk_gc_set_fill (gc, GDK_TILED);
+                  gdk_gc_set_function (gc, GDK_OR);
+
+                  gdk_draw_rectangle (drawable, gc, TRUE, 
+                                      guide->widget->allocation.x,
+                                      guide->widget->allocation.y,
+                                      guide->widget->allocation.width,
+                                      guide->widget->allocation.height);
+
+                  gdk_gc_set_function (gc, GDK_COPY);
+                  gdk_gc_set_fill (gc, GDK_SOLID);
+
+                  continue;
+                }
             }
-        }
 
-      gdk_color_parse (guide_type_get_color (guide->type), 
-                       &values.foreground);
+          gdk_color_parse (guide_type_get_color (guide->type, is_current),
+                           &values.foreground);
 
-      gdk_gc_set_rgb_fg_color (gc, &values.foreground);
+          gdk_gc_set_rgb_fg_color (gc, &values.foreground);
 
-      num_baselines = test_case_eval_guide (test, guide, &extends, &baselines);
+          num_baselines = test_case_eval_guide (test, guide, &extends, &baselines);
 
-      if (num_baselines > 0)
-        {
-          g_assert (NULL != baselines);
+          if (num_baselines > 0)
+            {
+              g_assert (NULL != baselines);
 
-          if (show_baselines)
-            for (i = 0; i < num_baselines; ++i)
-              draw_baselines (drawable, gc, test->widget, &extends, baselines[i]);
-        }
-      else if (num_baselines > -1)
-        {
-          if ((show_interiour && (
-               guide->type == GUIDE_INTERIOUR_VERTICAL ||
-               guide->type == GUIDE_INTERIOUR_HORIZONTAL ||
-               guide->type == GUIDE_INTERIOUR_BOTH)) ||
-              (show_exteriour && (
-               guide->type == GUIDE_EXTERIOUR_VERTICAL ||
-               guide->type == GUIDE_EXTERIOUR_HORIZONTAL ||
-               guide->type == GUIDE_EXTERIOUR_BOTH)))
-            draw_extends (drawable, gc, test->widget, &extends);
-        }
+              if (show_baselines)
+                for (i = 0; i < num_baselines; ++i)
+                  draw_baselines (drawable, gc, test->widget, &extends, baselines[i]);
+            }
+          else if (num_baselines > -1)
+            {
+              if ((show_interiour && (
+                   guide->type == GUIDE_INTERIOUR_VERTICAL ||
+                   guide->type == GUIDE_INTERIOUR_HORIZONTAL ||
+                   guide->type == GUIDE_INTERIOUR_BOTH)) ||
+                  (show_exteriour && (
+                   guide->type == GUIDE_EXTERIOUR_VERTICAL ||
+                   guide->type == GUIDE_EXTERIOUR_HORIZONTAL ||
+                   guide->type == GUIDE_EXTERIOUR_BOTH)))
+                draw_extends (drawable, gc, test->widget, &extends);
+            }
 
-      g_free (baselines);
+          g_free (baselines);
+        }
     }
 
   g_object_unref (gc);
@@ -2459,8 +2481,8 @@ test_suite_new (gchar *arg0)
   test_suite_append (self, natural_size_test_new (self, FALSE, TRUE));
   test_suite_append (self, natural_size_test_new (self, TRUE, TRUE));
   test_suite_append (self, natural_size_test_misc_new (self, arg0));
-  test_suite_append (self, height_for_width_test_new (self, TRUE));
-  test_suite_append (self, height_for_width_test_new (self, FALSE));
+  test_suite_append (self, size_for_allocation_test_new (self, TRUE));
+  test_suite_append (self, size_for_allocation_test_new (self, FALSE));
   test_suite_append (self, baseline_test_new (self));
   test_suite_append (self, baseline_test_bin_new (self));
   test_suite_append (self, baseline_test_hbox_new (self, FALSE));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]