forked from AuroraMiddleware/gtk
inspector: Show render node properties
This commit is contained in:
parent
aa74d96532
commit
295066dad8
@ -25,6 +25,7 @@
|
||||
#include <gtk/gtklistbox.h>
|
||||
#include <gtk/gtktreeselection.h>
|
||||
#include <gtk/gtktreeview.h>
|
||||
#include <gsk/gskrendernodeprivate.h>
|
||||
|
||||
#include "gtktreemodelrendernode.h"
|
||||
#include "recording.h"
|
||||
@ -39,6 +40,8 @@ struct _GtkInspectorRecorderPrivate
|
||||
GtkWidget *recordings_list;
|
||||
GtkWidget *render_node_view;
|
||||
GtkWidget *render_node_tree;
|
||||
GtkWidget *node_property_tree;
|
||||
GtkTreeModel *render_node_properties;
|
||||
|
||||
guint recording : 1;
|
||||
};
|
||||
@ -122,6 +125,88 @@ render_node_list_get_value (GtkTreeModelRenderNode *model,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
populate_render_node_properties (GtkListStore *store,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
graphene_matrix_t m;
|
||||
graphene_rect_t bounds;
|
||||
GString *s;
|
||||
int i;
|
||||
char *tmp;
|
||||
GEnumClass *class;
|
||||
|
||||
gtk_list_store_clear (store);
|
||||
|
||||
gsk_render_node_get_transform (node, &m);
|
||||
|
||||
s = g_string_new ("");
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
g_string_append (s, "\n");
|
||||
g_string_append_printf (s, "| %+.6f %+.6f %+.6f %+.6f |",
|
||||
graphene_matrix_get_value (&m, i, 0),
|
||||
graphene_matrix_get_value (&m, i, 1),
|
||||
graphene_matrix_get_value (&m, i, 2),
|
||||
graphene_matrix_get_value (&m, i, 3));
|
||||
}
|
||||
|
||||
gtk_list_store_insert_with_values (store, NULL, -1,
|
||||
0, "Transform",
|
||||
1, s->str,
|
||||
-1);
|
||||
|
||||
g_string_free (s, TRUE);
|
||||
|
||||
gsk_render_node_get_bounds (node, &bounds);
|
||||
|
||||
tmp = g_strdup_printf ("%.6f x %.6f + %.6f + %.6f",
|
||||
bounds.size.width,
|
||||
bounds.size.height,
|
||||
bounds.origin.x,
|
||||
bounds.origin.y);
|
||||
gtk_list_store_insert_with_values (store, NULL, -1,
|
||||
0, "Bounds",
|
||||
1, tmp,
|
||||
-1);
|
||||
g_free (tmp);
|
||||
|
||||
tmp = g_strdup_printf ("%.2f", gsk_render_node_get_opacity (node));
|
||||
gtk_list_store_insert_with_values (store, NULL, -1,
|
||||
0, "Opacity",
|
||||
1, tmp,
|
||||
-1);
|
||||
g_free (tmp);
|
||||
|
||||
gtk_list_store_insert_with_values (store, NULL, -1,
|
||||
0, "Has Surface",
|
||||
1, gsk_render_node_has_surface (node) ? "TRUE" : "FALSE",
|
||||
-1);
|
||||
|
||||
gtk_list_store_insert_with_values (store, NULL, -1,
|
||||
0, "Has Texture",
|
||||
1, gsk_render_node_has_texture (node) ? "TRUE" : "FALSE",
|
||||
-1);
|
||||
|
||||
class = g_type_class_ref (gsk_blend_mode_get_type ());
|
||||
for (i = 0; i < class->n_values; i++)
|
||||
{
|
||||
if (class->values[i].value == gsk_render_node_get_blend_mode (node))
|
||||
{
|
||||
tmp = g_strdup (class->values[i].value_nick);
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_type_class_unref (class);
|
||||
|
||||
gtk_list_store_insert_with_values (store, NULL, -1,
|
||||
0, "Blendmode",
|
||||
1, tmp,
|
||||
-1);
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
static void
|
||||
render_node_list_selection_changed (GtkTreeSelection *selection,
|
||||
GtkInspectorRecorder *recorder)
|
||||
@ -135,6 +220,8 @@ render_node_list_selection_changed (GtkTreeSelection *selection,
|
||||
|
||||
node = gtk_tree_model_render_node_get_node_from_iter (GTK_TREE_MODEL_RENDER_NODE (priv->render_node_model), &iter);
|
||||
gtk_render_node_view_set_render_node (GTK_RENDER_NODE_VIEW (priv->render_node_view), node);
|
||||
|
||||
populate_render_node_properties (GTK_LIST_STORE (priv->render_node_properties), node);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
@ -219,6 +306,7 @@ gtk_inspector_recorder_class_init (GtkInspectorRecorderClass *klass)
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorRecorder, recordings_list);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorRecorder, render_node_view);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorRecorder, render_node_tree);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorRecorder, node_property_tree);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, recordings_clear_all);
|
||||
gtk_widget_class_bind_template_callback (widget_class, recordings_list_row_selected);
|
||||
@ -245,6 +333,9 @@ gtk_inspector_recorder_init (GtkInspectorRecorder *recorder)
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->render_node_tree), priv->render_node_model);
|
||||
g_object_unref (priv->render_node_model);
|
||||
|
||||
priv->render_node_properties = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING));
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->node_property_tree), priv->render_node_properties);
|
||||
g_object_unref (priv->render_node_properties);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,21 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface domain="gtk40">
|
||||
<object class="GListStore" id="recordings">
|
||||
</object>
|
||||
<object class="GListStore" id="recordings"/>
|
||||
<template class="GtkInspectorRecorder" parent="GtkBin">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="visible">1</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="visible">1</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="margin">6</property>
|
||||
<child>
|
||||
<object class="GtkToggleButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="visible">1</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="icon-name">media-record-symbolic</property>
|
||||
<property name="active" bind-source="GtkInspectorRecorder" bind-property="recording" bind-flags="bidirectional|sync-create"/>
|
||||
@ -23,58 +21,63 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="visible">1</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="icon-name">edit-clear-all-symbolic</property>
|
||||
<signal name="clicked" handler="recordings_clear_all"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkPaned">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="position">250</property>
|
||||
<property name="position-set">1</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="hscrollbar-policy">automatic</property>
|
||||
<property name="vscrollbar-policy">automatic</property>
|
||||
<property name="propagate-natural-width">1</property>
|
||||
<child>
|
||||
<object class="GtkListBox" id="recordings_list">
|
||||
<property name="visible">True</property>
|
||||
<property name="selection-mode">single</property>
|
||||
<signal name="row-selected" handler="recordings_list_row_selected"/>
|
||||
<child type="center">
|
||||
<object class="GtkStackSwitcher">
|
||||
<property name="visible">1</property>
|
||||
<property name="stack">render_stack</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="shrink">False</property>
|
||||
<property name="resize">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkPaned" id="paned">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="position">250</property>
|
||||
<property name="position-set">1</property>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">1</property>
|
||||
<style>
|
||||
<class name="view"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">1</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="hscrollbar-policy">automatic</property>
|
||||
<property name="vscrollbar-policy">automatic</property>
|
||||
<property name="visible">1</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="propagate-natural-width">1</property>
|
||||
<style>
|
||||
<class name="sidebar"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkListBox" id="recordings_list">
|
||||
<property name="visible">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<signal name="row-selected" handler="recordings_list_row_selected"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">1</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">1</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="propagate-natural-width">1</property>
|
||||
<style>
|
||||
<class name="sidebar"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="render_node_tree">
|
||||
<property name="visible">True</property>
|
||||
<property name="visible">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<property name="search-column">0</property>
|
||||
<property name="enable-search">0</property>
|
||||
<property name="headers-visible">0</property>
|
||||
@ -85,7 +88,7 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="render_node_name_column">
|
||||
<property name="resizable">True</property>
|
||||
<property name="resizable">1</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
@ -98,29 +101,67 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="shrink">False</property>
|
||||
<property name="resize">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkStack" id="render_stack">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkRenderNodeView" id="render_node_view">
|
||||
<property name="visible">True</property>
|
||||
<property name="expand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="shrink">False</property>
|
||||
<property name="resize">True</property>
|
||||
<property name="name">render</property>
|
||||
<property name="title">Render</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="node_property_tree">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="title">Property</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText">
|
||||
<property name="yalign">0</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="title">Value</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText">
|
||||
<property name="yalign">0</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="shrink">False</property>
|
||||
<property name="resize">True</property>
|
||||
<property name="name">properties</property>
|
||||
<property name="title">Properties</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
|
Loading…
Reference in New Issue
Block a user