From de990614d702cb9202e39a22d0d3ddbba040441d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 4 Apr 2018 12:38:09 +0200 Subject: 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. --- gtk/inspector/window.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'gtk/inspector/window.c') 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 @@ -355,6 +355,30 @@ gtk_inspector_window_new (void) NULL)); } +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) { @@ -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; } -- cgit v1.2.1