[gtk+] Add GTK_DEBUG=baselines support



commit 77e0f18edaddabbad9ea89e0c1820f7f8ff7066e
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Mar 21 18:25:29 2013 +0100

    Add GTK_DEBUG=baselines support
    
    This draws red lines to show where the baselines are

 gtk/gtkdebug.h  |  3 ++-
 gtk/gtkmain.c   |  3 ++-
 gtk/gtkwidget.c | 20 ++++++++++++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkdebug.h b/gtk/gtkdebug.h
index ecc9a70..f9e01e5 100644
--- a/gtk/gtkdebug.h
+++ b/gtk/gtkdebug.h
@@ -47,7 +47,8 @@ typedef enum {
   GTK_DEBUG_PRINTING        = 1 << 10,
   GTK_DEBUG_BUILDER         = 1 << 11,
   GTK_DEBUG_SIZE_REQUEST    = 1 << 12,
-  GTK_DEBUG_NO_CSS_CACHE    = 1 << 13
+  GTK_DEBUG_NO_CSS_CACHE    = 1 << 13,
+  GTK_DEBUG_BASELINES       = 1 << 14
 } GtkDebugFlag;
 
 #ifdef G_ENABLE_DEBUG
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 36a5604..eeef8ed 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -171,7 +171,8 @@ static const GDebugKey gtk_debug_keys[] = {
   {"printing", GTK_DEBUG_PRINTING},
   {"builder", GTK_DEBUG_BUILDER},
   {"size-request", GTK_DEBUG_SIZE_REQUEST},
-  {"no-css-cache", GTK_DEBUG_NO_CSS_CACHE}
+  {"no-css-cache", GTK_DEBUG_NO_CSS_CACHE},
+  {"baselines", GTK_DEBUG_BASELINES}
 };
 #endif /* G_ENABLE_DEBUG */
 
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index bbfdefa..30c3cc5 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6383,6 +6383,26 @@ _gtk_widget_draw_internal (GtkWidget *widget,
                      0, cr,
                      &result);
 
+#ifdef G_ENABLE_DEBUG
+      if (G_UNLIKELY (gtk_get_debug_flags () & GTK_DEBUG_BASELINES))
+       {
+         gint baseline = gtk_widget_get_allocated_baseline (widget);
+         gint width = gtk_widget_get_allocated_width (widget);
+
+         if (baseline != -1)
+           {
+             cairo_save (cr);
+             cairo_new_path (cr);
+             cairo_move_to (cr, 0, baseline+0.5);
+             cairo_line_to (cr, width, baseline+0.5);
+             cairo_set_line_width (cr, 1.0);
+             cairo_set_source_rgba (cr, 1.0, 0, 0, 0.25);
+             cairo_stroke (cr);
+             cairo_restore (cr);
+           }
+       }
+#endif
+
       if (cairo_status (cr) &&
           _gtk_cairo_get_event (cr))
         {


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