[gtk+] inspector: Show render node properties
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Show render node properties
- Date: Sat, 19 Nov 2016 01:59:32 +0000 (UTC)
commit 295066dad83d318be34b97e6d138da2f30e8a220
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Nov 18 20:59:10 2016 -0500
inspector: Show render node properties
gtk/inspector/recorder.c | 91 ++++++++++++++++++++++++++++
gtk/inspector/recorder.ui | 145 +++++++++++++++++++++++++++++----------------
2 files changed, 184 insertions(+), 52 deletions(-)
---
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index 8921086..c1027ad 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -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;
};
@@ -123,6 +126,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
diff --git a/gtk/inspector/recorder.ui b/gtk/inspector/recorder.ui
index e988d93..1ab80ee 100644
--- a/gtk/inspector/recorder.ui
+++ b/gtk/inspector/recorder.ui
@@ -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>
+ <child type="center">
+ <object class="GtkStackSwitcher">
+ <property name="visible">1</property>
+ <property name="stack">render_stack</property>
+ </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>
+ <object class="GtkBox">
+ <property name="visible">1</property>
+ <style>
+ <class name="view"/>
+ </style>
<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>
+ <object class="GtkFrame">
+ <property name="visible">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"/>
+ <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="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>
- <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>
- <style>
- <class name="view"/>
- </style>
+ <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="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,25 +101,63 @@
</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="GtkRenderNodeView" id="render_node_view">
+ <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="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="name">properties</property>
+ <property name="title">Properties</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="shrink">False</property>
- <property name="resize">True</property>
- </packing>
</child>
</object>
- <packing>
- <property name="shrink">False</property>
- <property name="resize">True</property>
- </packing>
</child>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]