mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 18:30:08 +00:00
inspector: Show roles for nodes
For some node types, the child nodes play different roles. E.g. for a mask node, one of the two children is the source, the other the mask. Show this information in the inspector.
This commit is contained in:
parent
740e485160
commit
bbb7b365d5
@ -236,9 +236,15 @@ static GParamSpec *props[LAST_PROP] = { NULL, };
|
|||||||
|
|
||||||
G_DEFINE_TYPE (GtkInspectorRecorder, gtk_inspector_recorder, GTK_TYPE_WIDGET)
|
G_DEFINE_TYPE (GtkInspectorRecorder, gtk_inspector_recorder, GTK_TYPE_WIDGET)
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GskRenderNode *node;
|
||||||
|
const char *role;
|
||||||
|
} RenderNode;
|
||||||
|
|
||||||
static GListModel *
|
static GListModel *
|
||||||
create_render_node_list_model (GskRenderNode **nodes,
|
create_render_node_list_model (RenderNode *nodes,
|
||||||
guint n_nodes)
|
guint n_nodes)
|
||||||
{
|
{
|
||||||
GListStore *store;
|
GListStore *store;
|
||||||
guint i;
|
guint i;
|
||||||
@ -249,9 +255,11 @@ create_render_node_list_model (GskRenderNode **nodes,
|
|||||||
for (i = 0; i < n_nodes; i++)
|
for (i = 0; i < n_nodes; i++)
|
||||||
{
|
{
|
||||||
graphene_rect_t bounds;
|
graphene_rect_t bounds;
|
||||||
|
GdkPaintable *paintable;
|
||||||
|
|
||||||
gsk_render_node_get_bounds (nodes[i], &bounds);
|
gsk_render_node_get_bounds (nodes[i].node, &bounds);
|
||||||
GdkPaintable *paintable = gtk_render_node_paintable_new (nodes[i], &bounds);
|
paintable = gtk_render_node_paintable_new (nodes[i].node, &bounds);
|
||||||
|
g_object_set_data (G_OBJECT (paintable), "role", (gpointer) nodes[i].role);
|
||||||
g_list_store_append (store, paintable);
|
g_list_store_append (store, paintable);
|
||||||
g_object_unref (paintable);
|
g_object_unref (paintable);
|
||||||
}
|
}
|
||||||
@ -286,46 +294,46 @@ create_list_model_for_render_node (GskRenderNode *node)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
case GSK_TRANSFORM_NODE:
|
case GSK_TRANSFORM_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_transform_node_get_child (node) }, 1);
|
return create_render_node_list_model (&(RenderNode) { gsk_transform_node_get_child (node), NULL }, 1);
|
||||||
|
|
||||||
case GSK_OPACITY_NODE:
|
case GSK_OPACITY_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_opacity_node_get_child (node) }, 1);
|
return create_render_node_list_model (&(RenderNode) { gsk_opacity_node_get_child (node), NULL }, 1);
|
||||||
|
|
||||||
case GSK_COLOR_MATRIX_NODE:
|
case GSK_COLOR_MATRIX_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_color_matrix_node_get_child (node) }, 1);
|
return create_render_node_list_model (&(RenderNode) { gsk_color_matrix_node_get_child (node), NULL }, 1);
|
||||||
|
|
||||||
case GSK_BLUR_NODE:
|
case GSK_BLUR_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_blur_node_get_child (node) }, 1);
|
return create_render_node_list_model (&(RenderNode) { gsk_blur_node_get_child (node), NULL }, 1);
|
||||||
|
|
||||||
case GSK_REPEAT_NODE:
|
case GSK_REPEAT_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_repeat_node_get_child (node) }, 1);
|
return create_render_node_list_model (&(RenderNode) { gsk_repeat_node_get_child (node), NULL }, 1);
|
||||||
|
|
||||||
case GSK_CLIP_NODE:
|
case GSK_CLIP_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_clip_node_get_child (node) }, 1);
|
return create_render_node_list_model (&(RenderNode) { gsk_clip_node_get_child (node), NULL }, 1);
|
||||||
|
|
||||||
case GSK_ROUNDED_CLIP_NODE:
|
case GSK_ROUNDED_CLIP_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_rounded_clip_node_get_child (node) }, 1);
|
return create_render_node_list_model (&(RenderNode) { gsk_rounded_clip_node_get_child (node), NULL }, 1);
|
||||||
|
|
||||||
case GSK_FILL_NODE:
|
case GSK_FILL_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_fill_node_get_child (node) }, 1);
|
return create_render_node_list_model (&(RenderNode) { gsk_fill_node_get_child (node), NULL }, 1);
|
||||||
|
|
||||||
case GSK_STROKE_NODE:
|
case GSK_STROKE_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_stroke_node_get_child (node) }, 1);
|
return create_render_node_list_model (&(RenderNode) { gsk_stroke_node_get_child (node), NULL }, 1);
|
||||||
|
|
||||||
case GSK_SHADOW_NODE:
|
case GSK_SHADOW_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_shadow_node_get_child (node) }, 1);
|
return create_render_node_list_model (&(RenderNode) { gsk_shadow_node_get_child (node), NULL }, 1);
|
||||||
|
|
||||||
case GSK_BLEND_NODE:
|
case GSK_BLEND_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_blend_node_get_bottom_child (node),
|
return create_render_node_list_model ((RenderNode[2]) { { gsk_blend_node_get_bottom_child (node), "Bottom" },
|
||||||
gsk_blend_node_get_top_child (node) }, 2);
|
{ gsk_blend_node_get_top_child (node), "Top" } }, 2);
|
||||||
|
|
||||||
case GSK_MASK_NODE:
|
case GSK_MASK_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_mask_node_get_source (node),
|
return create_render_node_list_model ((RenderNode[2]) { { gsk_mask_node_get_source (node), "Source" },
|
||||||
gsk_mask_node_get_mask (node) }, 2);
|
{ gsk_mask_node_get_mask (node), "Mask" } }, 2);
|
||||||
|
|
||||||
case GSK_CROSS_FADE_NODE:
|
case GSK_CROSS_FADE_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_cross_fade_node_get_start_child (node),
|
return create_render_node_list_model ((RenderNode[2]) { { gsk_cross_fade_node_get_start_child (node), "Start" },
|
||||||
gsk_cross_fade_node_get_end_child (node) }, 2);
|
{ gsk_cross_fade_node_get_end_child (node), "End" } }, 2);
|
||||||
|
|
||||||
case GSK_GL_SHADER_NODE:
|
case GSK_GL_SHADER_NODE:
|
||||||
{
|
{
|
||||||
@ -372,10 +380,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
|||||||
}
|
}
|
||||||
|
|
||||||
case GSK_DEBUG_NODE:
|
case GSK_DEBUG_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_debug_node_get_child (node) }, 1);
|
return create_render_node_list_model (&(RenderNode) { gsk_debug_node_get_child (node), NULL }, 1);
|
||||||
|
|
||||||
case GSK_SUBSURFACE_NODE:
|
case GSK_SUBSURFACE_NODE:
|
||||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_subsurface_node_get_child (node) }, 1);
|
return create_render_node_list_model (&(RenderNode) { gsk_subsurface_node_get_child (node), NULL }, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1031,7 +1039,8 @@ add_texture_rows (GListStore *store,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
populate_render_node_properties (GListStore *store,
|
populate_render_node_properties (GListStore *store,
|
||||||
GskRenderNode *node)
|
GskRenderNode *node,
|
||||||
|
const char *role)
|
||||||
{
|
{
|
||||||
graphene_rect_t bounds, opaque;
|
graphene_rect_t bounds, opaque;
|
||||||
|
|
||||||
@ -1039,6 +1048,9 @@ populate_render_node_properties (GListStore *store,
|
|||||||
|
|
||||||
gsk_render_node_get_bounds (node, &bounds);
|
gsk_render_node_get_bounds (node, &bounds);
|
||||||
|
|
||||||
|
if (role)
|
||||||
|
add_text_row (store, "Role", "%s", role);
|
||||||
|
|
||||||
add_text_row (store, "Type", "%s", node_type_name (gsk_render_node_get_node_type (node)));
|
add_text_row (store, "Type", "%s", node_type_name (gsk_render_node_get_node_type (node)));
|
||||||
|
|
||||||
add_text_row (store, "Bounds",
|
add_text_row (store, "Bounds",
|
||||||
@ -1954,6 +1966,7 @@ render_node_list_selection_changed (GtkListBox *list,
|
|||||||
GskRenderNode *node;
|
GskRenderNode *node;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
GtkTreeListRow *row_item;
|
GtkTreeListRow *row_item;
|
||||||
|
const char *role;
|
||||||
|
|
||||||
row_item = gtk_single_selection_get_selected_item (recorder->render_node_selection);
|
row_item = gtk_single_selection_get_selected_item (recorder->render_node_selection);
|
||||||
|
|
||||||
@ -1967,7 +1980,8 @@ render_node_list_selection_changed (GtkListBox *list,
|
|||||||
|
|
||||||
gtk_picture_set_paintable (GTK_PICTURE (recorder->render_node_view), paintable);
|
gtk_picture_set_paintable (GTK_PICTURE (recorder->render_node_view), paintable);
|
||||||
node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
|
node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
|
||||||
populate_render_node_properties (recorder->render_node_properties, node);
|
role = g_object_get_data (G_OBJECT (paintable), "role");
|
||||||
|
populate_render_node_properties (recorder->render_node_properties, node, role);
|
||||||
|
|
||||||
g_object_unref (paintable);
|
g_object_unref (paintable);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user