inspector: More tweaks to the recorder

Put the two left columns in a stack, and add
an empty page there. This will let us add
other recording types in the future, with
their own pages.
This commit is contained in:
Matthias Clasen 2021-12-14 19:51:35 -05:00
parent 6dbe6b42c2
commit 1028ca0841
2 changed files with 84 additions and 51 deletions

View File

@ -39,6 +39,7 @@
#include <gtk/gtktreelistmodel.h> #include <gtk/gtktreelistmodel.h>
#include <gtk/gtktreemodel.h> #include <gtk/gtktreemodel.h>
#include <gtk/gtktreeview.h> #include <gtk/gtktreeview.h>
#include <gtk/gtkstack.h>
#include <gsk/gskrendererprivate.h> #include <gsk/gskrendererprivate.h>
#include <gsk/gskrendernodeprivate.h> #include <gsk/gskrendernodeprivate.h>
#include <gsk/gskroundedrectprivate.h> #include <gsk/gskroundedrectprivate.h>
@ -70,6 +71,7 @@ struct _GtkInspectorRecorder
GtkWidget *render_node_save_button; GtkWidget *render_node_save_button;
GtkWidget *render_node_clip_button; GtkWidget *render_node_clip_button;
GtkWidget *node_property_tree; GtkWidget *node_property_tree;
GtkWidget *recording_data_stack;
GtkTreeModel *render_node_properties; GtkTreeModel *render_node_properties;
GtkInspectorRecording *recording; /* start recording if recording or NULL if not */ GtkInspectorRecording *recording; /* start recording if recording or NULL if not */
@ -433,7 +435,10 @@ recording_selected (GtkSingleSelection *selection,
GtkInspectorRecording *recording; GtkInspectorRecording *recording;
if (recorder->recordings == NULL) if (recorder->recordings == NULL)
return; {
gtk_stack_set_visible_child_name (GTK_STACK (recorder->recording_data_stack), "no_data");
return;
}
recording = gtk_single_selection_get_selected_item (selection); recording = gtk_single_selection_get_selected_item (selection);
@ -443,6 +448,8 @@ recording_selected (GtkSingleSelection *selection,
GskRenderNode *node; GskRenderNode *node;
GdkPaintable *paintable; GdkPaintable *paintable;
gtk_stack_set_visible_child_name (GTK_STACK (recorder->recording_data_stack), "frame_data");
node = gtk_inspector_render_recording_get_node (GTK_INSPECTOR_RENDER_RECORDING (recording)); node = gtk_inspector_render_recording_get_node (GTK_INSPECTOR_RENDER_RECORDING (recording));
gsk_render_node_get_bounds (node, &bounds); gsk_render_node_get_bounds (node, &bounds);
paintable = gtk_render_node_paintable_new (node, &bounds); paintable = gtk_render_node_paintable_new (node, &bounds);
@ -456,6 +463,7 @@ recording_selected (GtkSingleSelection *selection,
} }
else else
{ {
gtk_stack_set_visible_child_name (GTK_STACK (recorder->recording_data_stack), "no_data");
gtk_picture_set_paintable (GTK_PICTURE (recorder->render_node_view), NULL); gtk_picture_set_paintable (GTK_PICTURE (recorder->render_node_view), NULL);
g_list_store_remove_all (recorder->render_node_root_model); g_list_store_remove_all (recorder->render_node_root_model);
} }
@ -1511,6 +1519,7 @@ gtk_inspector_recorder_class_init (GtkInspectorRecorderClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, render_node_save_button); gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, render_node_save_button);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, render_node_clip_button); gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, render_node_clip_button);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, node_property_tree); gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, node_property_tree);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, recording_data_stack);
gtk_widget_class_bind_template_callback (widget_class, recordings_clear_all); gtk_widget_class_bind_template_callback (widget_class, recordings_clear_all);
gtk_widget_class_bind_template_callback (widget_class, recording_selected); gtk_widget_class_bind_template_callback (widget_class, recording_selected);

View File

@ -86,76 +86,100 @@
<object class="GtkSeparator"/> <object class="GtkSeparator"/>
</child> </child>
<child> <child>
<object class="GtkScrolledWindow"> <object class="GtkStack" id="recording_data_stack">
<property name="hscrollbar-policy">never</property>
<property name="propagate-natural-width">1</property>
<child> <child>
<object class="GtkListView" id="render_node_list"> <object class="GtkStackPage">
<property name="vexpand">1</property> <property name="name">no_data</property>
<property name="hexpand">1</property> <property name="child">
<object class="GtkLabel">
<property name="label">No data.</property>
<property name="halign">center</property>
<property name="valign">center</property>
</object>
</property>
</object> </object>
</child> </child>
</object>
</child>
<child>
<object class="GtkSeparator"/>
</child>
<child>
<object class="GtkPaned" id="render_paned">
<property name="orientation">vertical</property>
<property name="position">300</property>
<property name="wide-handle">1</property>
<child> <child>
<object class="GtkScrolledWindow"> <object class="GtkStackPage">
<child> <property name="name">frame_data</property>
<object class="GtkTreeView" id="node_property_tree"> <property name="child">
<property name="activate-on-single-click">1</property> <object class="GtkPaned">
<signal name="row-activated" handler="node_property_activated"/> <property name="position">400</property>
<property name="wide-handle">1</property>
<child> <child>
<object class="GtkTreeViewColumn"> <object class="GtkScrolledWindow">
<property name="title" translatable="yes">Property</property> <property name="propagate-natural-width">1</property>
<child> <child>
<object class="GtkCellRendererText"> <object class="GtkListView" id="render_node_list">
<property name="yalign">0</property> <property name="vexpand">1</property>
<property name="hexpand">1</property>
</object> </object>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child> </child>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkTreeViewColumn"> <object class="GtkPaned" id="render_paned">
<property name="title" translatable="yes">Value</property> <property name="orientation">vertical</property>
<property name="position">200</property>
<property name="wide-handle">1</property>
<child> <child>
<object class="GtkCellRendererText"> <object class="GtkScrolledWindow">
<property name="yalign">0</property> <property name="propagate-natural-width">1</property>
<property name="wrap-mode">word</property> <child>
<property name="max-width-chars">50</property> <object class="GtkTreeView" id="node_property_tree">
<property name="activate-on-single-click">1</property>
<signal name="row-activated" handler="node_property_activated"/>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">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" translatable="yes">Value</property>
<child>
<object class="GtkCellRendererText">
<property name="yalign">0</property>
<property name="wrap-mode">word</property>
<property name="max-width-chars">50</property>
</object>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererPixbuf">
<property name="xalign">0</property>
</object>
<attributes>
<attribute name="visible">2</attribute>
<attribute name="texture">3</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object> </object>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child> </child>
<child> <child>
<object class="GtkCellRendererPixbuf"> <object class="GtkPicture" id="render_node_view">
<property name="xalign">0</property> <property name="hexpand">1</property>
<property name="vexpand">1</property>
</object> </object>
<attributes>
<attribute name="visible">2</attribute>
<attribute name="texture">3</attribute>
</attributes>
</child> </child>
</object> </object>
</child> </child>
</object> </object>
</child> </property>
</object>
</child>
<child>
<object class="GtkPicture" id="render_node_view">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
</object> </object>
</child> </child>
</object> </object>