Add a way to highlight resizing widgets

https://bugzilla.gnome.org/show_bug.cgi?id=759586
This commit is contained in:
Timm Bäder 2015-12-17 12:34:30 +01:00
parent 20a6ee30b7
commit e8aa9b0440
7 changed files with 81 additions and 1 deletions

View File

@ -214,6 +214,10 @@ additional environment variables.
<term>updates</term> <term>updates</term>
<listitem><para>Visual feedback about window updates</para></listitem> <listitem><para>Visual feedback about window updates</para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>resize</term>
<listitem><para>Highlight resizing widgets</para></listitem>
</varlistentry>
</variablelist> </variablelist>
The special value <literal>all</literal> can be used to turn on all The special value <literal>all</literal> can be used to turn on all

View File

@ -54,7 +54,8 @@ typedef enum {
GTK_DEBUG_NO_PIXEL_CACHE = 1 << 16, GTK_DEBUG_NO_PIXEL_CACHE = 1 << 16,
GTK_DEBUG_INTERACTIVE = 1 << 17, GTK_DEBUG_INTERACTIVE = 1 << 17,
GTK_DEBUG_TOUCHSCREEN = 1 << 18, GTK_DEBUG_TOUCHSCREEN = 1 << 18,
GTK_DEBUG_ACTIONS = 1 << 19 GTK_DEBUG_ACTIONS = 1 << 19,
GTK_DEBUG_RESIZE = 1 << 20
} GtkDebugFlag; } GtkDebugFlag;
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG

View File

@ -181,6 +181,7 @@ static const GDebugKey gtk_debug_keys[] = {
{"interactive", GTK_DEBUG_INTERACTIVE}, {"interactive", GTK_DEBUG_INTERACTIVE},
{"touchscreen", GTK_DEBUG_TOUCHSCREEN}, {"touchscreen", GTK_DEBUG_TOUCHSCREEN},
{"actions", GTK_DEBUG_ACTIONS}, {"actions", GTK_DEBUG_ACTIONS},
{"resize", GTK_DEBUG_RESIZE}
}; };
#endif /* G_ENABLE_DEBUG */ #endif /* G_ENABLE_DEBUG */

View File

@ -4356,6 +4356,9 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->alloc_needed = TRUE; priv->alloc_needed = TRUE;
priv->alloc_needed_on_child = TRUE; priv->alloc_needed_on_child = TRUE;
priv->focus_on_click = TRUE; priv->focus_on_click = TRUE;
#ifdef G_ENABLE_DEBUG
priv->highlight_resize = FALSE;
#endif
switch (_gtk_widget_get_direction (widget)) switch (_gtk_widget_get_direction (widget))
{ {
@ -5927,6 +5930,9 @@ gtk_widget_size_allocate_with_baseline (GtkWidget *widget,
gtk_widget_push_verify_invariants (widget); gtk_widget_push_verify_invariants (widget);
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
priv->highlight_resize = TRUE;
gtk_widget_queue_draw (widget);
if (gtk_widget_get_resize_needed (widget)) if (gtk_widget_get_resize_needed (widget))
{ {
g_warning ("Allocating size to %s %p without calling gtk_widget_get_preferred_width/height(). " g_warning ("Allocating size to %s %p without calling gtk_widget_get_preferred_width/height(). "
@ -6978,6 +6984,22 @@ _gtk_widget_draw_internal (GtkWidget *widget,
cairo_restore (cr); cairo_restore (cr);
} }
} }
if (GTK_DEBUG_CHECK (RESIZE) &&
widget->priv->highlight_resize)
{
GtkAllocation alloc;
gtk_widget_get_allocation (widget, &alloc);
cairo_rectangle (cr, 0, 0, alloc.width, alloc.height);
cairo_set_source_rgba (cr, 1, 0, 0, 0.2);
cairo_fill (cr);
gtk_widget_queue_draw (widget);
widget->priv->highlight_resize = FALSE;
}
#endif #endif
if (cairo_status (cr) && if (cairo_status (cr) &&

View File

@ -45,6 +45,10 @@ struct _GtkWidgetPrivate
guint direction : 2; guint direction : 2;
#ifdef G_ENABLE_DEBUG
guint highlight_resize : 1;
#endif
guint in_destruction : 1; guint in_destruction : 1;
guint toplevel : 1; guint toplevel : 1;
guint anchored : 1; guint anchored : 1;

View File

@ -185,6 +185,19 @@ pixelcache_activate (GtkSwitch *sw)
redraw_everything (); redraw_everything ();
} }
static void
widget_resize_activate (GtkSwitch *sw)
{
guint flags = gtk_get_debug_flags ();
if (gtk_switch_get_active (sw))
flags |= GTK_DEBUG_RESIZE;
else
flags &= ~GTK_DEBUG_RESIZE;
gtk_set_debug_flags (flags);
}
static void static void
fill_gtk (const gchar *path, fill_gtk (const gchar *path,
GHashTable *t) GHashTable *t)
@ -699,6 +712,7 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
gtk_widget_class_bind_template_callback (widget_class, rendering_mode_changed); gtk_widget_class_bind_template_callback (widget_class, rendering_mode_changed);
gtk_widget_class_bind_template_callback (widget_class, baselines_activate); gtk_widget_class_bind_template_callback (widget_class, baselines_activate);
gtk_widget_class_bind_template_callback (widget_class, pixelcache_activate); gtk_widget_class_bind_template_callback (widget_class, pixelcache_activate);
gtk_widget_class_bind_template_callback (widget_class, widget_resize_activate);
gtk_widget_class_bind_template_callback (widget_class, software_gl_activate); gtk_widget_class_bind_template_callback (widget_class, software_gl_activate);
gtk_widget_class_bind_template_callback (widget_class, software_surface_activate); gtk_widget_class_bind_template_callback (widget_class, software_surface_activate);
gtk_widget_class_bind_template_callback (widget_class, texture_rectangle_activate); gtk_widget_class_bind_template_callback (widget_class, texture_rectangle_activate);

View File

@ -492,6 +492,40 @@
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="margin">10</property>
<property name="spacing">40</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Show Widget Resizes</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkSwitch" id="widget_resize_switch">
<property name="visible">True</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
<signal name="notify::active" handler="widget_resize_activate"/>
</object>
<packing>
<property name="expand">True</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child> <child>
<object class="GtkListBoxRow"> <object class="GtkListBoxRow">
<property name="visible">True</property> <property name="visible">True</property>