Add GTK_DEBUG=baselines support

This draws red lines to show where the baselines are
This commit is contained in:
Alexander Larsson 2013-03-21 18:25:29 +01:00
parent 852cbb62b8
commit 77e0f18eda
3 changed files with 24 additions and 2 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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))
{