summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2015-12-17 12:34:30 +0100
committerTimm Bäder <mail@baedert.org>2015-12-18 16:20:19 +0100
commite8aa9b0440e03e7002323922f862342db51c5f32 (patch)
treef555d737510a59bd43ae64158b3a8947bf1bee0c
parent20a6ee30b7dd3f471b086d206c8cf51ff3341b48 (diff)
downloadgtk+-e8aa9b0440e03e7002323922f862342db51c5f32.tar.gz
Add a way to highlight resizing widgets
https://bugzilla.gnome.org/show_bug.cgi?id=759586
-rw-r--r--docs/reference/gtk/running.sgml4
-rw-r--r--gtk/gtkdebug.h3
-rw-r--r--gtk/gtkmain.c1
-rw-r--r--gtk/gtkwidget.c22
-rw-r--r--gtk/gtkwidgetprivate.h4
-rw-r--r--gtk/inspector/visual.c14
-rw-r--r--gtk/inspector/visual.ui34
7 files changed, 81 insertions, 1 deletions
diff --git a/docs/reference/gtk/running.sgml b/docs/reference/gtk/running.sgml
index a826dca828..7f3812046a 100644
--- a/docs/reference/gtk/running.sgml
+++ b/docs/reference/gtk/running.sgml
@@ -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
diff --git a/gtk/gtkdebug.h b/gtk/gtkdebug.h
index 40d42d797a..e78dd6837f 100644
--- a/gtk/gtkdebug.h
+++ b/gtk/gtkdebug.h
@@ -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
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 45134703fb..36237ae16c 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -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 */
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index ff7dc0d59f..e72b563f81 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -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) &&
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index e3f8a135de..18bc98030c 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -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;
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index d21a6b7f24..d96925637d 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -186,6 +186,19 @@ pixelcache_activate (GtkSwitch *sw)
}
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);
diff --git a/gtk/inspector/visual.ui b/gtk/inspector/visual.ui
index adb7cf290f..d00fdebc80 100644
--- a/gtk/inspector/visual.ui
+++ b/gtk/inspector/visual.ui
@@ -503,6 +503,40 @@
<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>
+ <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" id="touchscreen_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Simulate touchscreen</property>