Commit e8aa9b04 authored by Timm Bäder's avatar Timm Bäder 👎

Add a way to highlight resizing widgets

https://bugzilla.gnome.org/show_bug.cgi?id=759586
parent 20a6ee30
......@@ -214,6 +214,10 @@ additional environment variables.
<term>updates</term>
<listitem><para>Visual feedback about window updates</para></listitem>
</varlistentry>
<varlistentry>
<term>resize</term>
<listitem><para>Highlight resizing widgets</para></listitem>
</varlistentry>
</variablelist>
The special value <literal>all</literal> can be used to turn on all
......
......@@ -54,7 +54,8 @@ typedef enum {
GTK_DEBUG_NO_PIXEL_CACHE = 1 << 16,
GTK_DEBUG_INTERACTIVE = 1 << 17,
GTK_DEBUG_TOUCHSCREEN = 1 << 18,
GTK_DEBUG_ACTIONS = 1 << 19
GTK_DEBUG_ACTIONS = 1 << 19,
GTK_DEBUG_RESIZE = 1 << 20
} GtkDebugFlag;
#ifdef G_ENABLE_DEBUG
......
......@@ -181,6 +181,7 @@ static const GDebugKey gtk_debug_keys[] = {
{"interactive", GTK_DEBUG_INTERACTIVE},
{"touchscreen", GTK_DEBUG_TOUCHSCREEN},
{"actions", GTK_DEBUG_ACTIONS},
{"resize", GTK_DEBUG_RESIZE}
};
#endif /* G_ENABLE_DEBUG */
......
......@@ -4356,6 +4356,9 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->alloc_needed = TRUE;
priv->alloc_needed_on_child = TRUE;
priv->focus_on_click = TRUE;
#ifdef G_ENABLE_DEBUG
priv->highlight_resize = FALSE;
#endif
switch (_gtk_widget_get_direction (widget))
{
......@@ -5927,6 +5930,9 @@ gtk_widget_size_allocate_with_baseline (GtkWidget *widget,
gtk_widget_push_verify_invariants (widget);
#ifdef G_ENABLE_DEBUG
priv->highlight_resize = TRUE;
gtk_widget_queue_draw (widget);
if (gtk_widget_get_resize_needed (widget))
{
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);
}
}
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
if (cairo_status (cr) &&
......
......@@ -45,6 +45,10 @@ struct _GtkWidgetPrivate
guint direction : 2;
#ifdef G_ENABLE_DEBUG
guint highlight_resize : 1;
#endif
guint in_destruction : 1;
guint toplevel : 1;
guint anchored : 1;
......
......@@ -185,6 +185,19 @@ pixelcache_activate (GtkSwitch *sw)
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
fill_gtk (const gchar *path,
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, baselines_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_surface_activate);
gtk_widget_class_bind_template_callback (widget_class, texture_rectangle_activate);
......
......@@ -492,6 +492,40 @@
</child>
</object>
</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>
<object class="GtkListBoxRow">
<property name="visible">True</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment