[gtk+/wip/baseline3: 3/17] Add GTK_DEBUG=baselines support
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baseline3: 3/17] Add GTK_DEBUG=baselines support
- Date: Tue, 26 Mar 2013 15:39:37 +0000 (UTC)
commit eda436a4be798915525adcab572dfbe7c0a8ff9d
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 fbf8293..65617a5 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -172,7 +172,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 90965d2..1fa84bc 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6266,6 +6266,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]