summaryrefslogtreecommitdiff
path: root/gtk/inspector/window.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2018-04-04 12:38:09 +0200
committerBenjamin Otte <otte@redhat.com>2018-04-05 14:57:10 +0200
commitde990614d702cb9202e39a22d0d3ddbba040441d (patch)
treea15915b7ef50a3a6760450101d60ae4f677fdd9e /gtk/inspector/window.c
parentcbf26fbd02f365c0dfe8b210ffd8fe4c18a16e06 (diff)
downloadgtk+-de990614d702cb9202e39a22d0d3ddbba040441d.tar.gz
inspector: Introduce so-called "overlays"
Overlays are drawings that get rendered on top of the inspected window. The only overlay in existence so far is the highlight overlay, which is used to highlight widgets and replaces the "draw" signal handler used previously.
Diffstat (limited to 'gtk/inspector/window.c')
-rw-r--r--gtk/inspector/window.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index 428de723c6..13b0ff7b6c 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -356,6 +356,30 @@ gtk_inspector_window_new (void)
}
void
+gtk_inspector_window_add_overlay (GtkInspectorWindow *iw,
+ GtkInspectorOverlay *overlay)
+{
+ iw->overlays = g_list_prepend (iw->overlays, g_object_ref (overlay));
+
+ gtk_inspector_overlay_queue_draw (overlay);
+}
+
+void
+gtk_inspector_window_remove_overlay (GtkInspectorWindow *iw,
+ GtkInspectorOverlay *overlay)
+{
+ GList *item;
+
+ item = g_list_find (iw->overlays, overlay);
+ if (item == NULL)
+ return;
+
+ gtk_inspector_overlay_queue_draw (overlay);
+
+ iw->overlays = g_list_delete_link (iw->overlays, item);
+}
+
+void
gtk_inspector_window_rescan (GtkWidget *widget)
{
GtkInspectorWindow *iw = GTK_INSPECTOR_WINDOW (widget);
@@ -393,6 +417,23 @@ gtk_inspector_prepare_render (GtkWidget *widget,
region,
node);
+ if (iw->overlays)
+ {
+ GtkSnapshot *snapshot;
+ GList *l;
+
+ snapshot = gtk_snapshot_new (FALSE, "Inspector Overlay");
+ gtk_snapshot_append_node (snapshot, node);
+
+ for (l = iw->overlays; l; l = l->next)
+ {
+ gtk_inspector_overlay_snapshot (l->data, snapshot, widget);
+ }
+
+ gsk_render_node_unref (node);
+ node = gtk_snapshot_free_to_node (snapshot);
+ }
+
return node;
}