2016-10-29 19:11:23 +00:00
|
|
|
/*
|
2016-10-30 05:11:38 +00:00
|
|
|
* Copyright (c) 2016 Red Hat, Inc.
|
2016-10-29 19:11:23 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "recorder.h"
|
|
|
|
|
2020-05-03 23:31:11 +00:00
|
|
|
#include <gtk/gtkbinlayout.h>
|
2016-11-20 02:53:26 +00:00
|
|
|
#include <gtk/gtkbox.h>
|
2021-08-20 03:52:10 +00:00
|
|
|
#include <gtk/gtkdragsource.h>
|
|
|
|
#include <gtk/gtkeventcontroller.h>
|
2016-12-21 05:50:39 +00:00
|
|
|
#include <gtk/gtkfilechooserdialog.h>
|
2020-06-29 20:37:14 +00:00
|
|
|
#include <gtk/gtksignallistitemfactory.h>
|
2016-10-30 05:11:38 +00:00
|
|
|
#include <gtk/gtklabel.h>
|
|
|
|
#include <gtk/gtklistbox.h>
|
2020-06-29 20:37:14 +00:00
|
|
|
#include <gtk/gtklistitem.h>
|
2019-10-14 04:50:40 +00:00
|
|
|
#include <gtk/gtklistview.h>
|
2020-06-21 22:03:39 +00:00
|
|
|
#include <gtk/gtkliststore.h>
|
2016-12-21 05:50:39 +00:00
|
|
|
#include <gtk/gtkmessagedialog.h>
|
2018-09-05 14:40:51 +00:00
|
|
|
#include <gtk/gtkpicture.h>
|
2017-09-28 22:17:38 +00:00
|
|
|
#include <gtk/gtkpopover.h>
|
2019-10-14 04:50:40 +00:00
|
|
|
#include <gtk/gtksingleselection.h>
|
2016-11-20 02:53:26 +00:00
|
|
|
#include <gtk/gtktogglebutton.h>
|
2019-10-14 04:18:25 +00:00
|
|
|
#include <gtk/gtktreeexpander.h>
|
2018-09-05 03:53:33 +00:00
|
|
|
#include <gtk/gtktreelistmodel.h>
|
|
|
|
#include <gtk/gtktreemodel.h>
|
2016-11-01 00:21:02 +00:00
|
|
|
#include <gtk/gtktreeview.h>
|
2016-11-20 02:52:56 +00:00
|
|
|
#include <gsk/gskrendererprivate.h>
|
2016-11-19 01:59:10 +00:00
|
|
|
#include <gsk/gskrendernodeprivate.h>
|
2017-09-29 01:41:24 +00:00
|
|
|
#include <gsk/gskroundedrectprivate.h>
|
2019-03-01 05:35:55 +00:00
|
|
|
#include <gsk/gsktransformprivate.h>
|
2016-10-30 05:11:38 +00:00
|
|
|
|
2018-03-15 01:36:13 +00:00
|
|
|
#include <glib/gi18n-lib.h>
|
2017-11-02 20:39:00 +00:00
|
|
|
#include <gdk/gdktextureprivate.h>
|
2017-09-01 15:55:23 +00:00
|
|
|
#include "gtk/gtkdebug.h"
|
2020-01-28 14:03:42 +00:00
|
|
|
#include "gtk/gtkbuiltiniconprivate.h"
|
2018-09-05 03:53:33 +00:00
|
|
|
#include "gtk/gtkrendernodepaintableprivate.h"
|
2017-09-01 15:55:23 +00:00
|
|
|
|
2016-10-30 05:11:38 +00:00
|
|
|
#include "recording.h"
|
|
|
|
#include "renderrecording.h"
|
2016-11-20 00:41:43 +00:00
|
|
|
#include "startrecording.h"
|
2016-10-30 05:11:38 +00:00
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
struct _GtkInspectorRecorder
|
2016-10-29 19:11:23 +00:00
|
|
|
{
|
2020-07-18 02:37:24 +00:00
|
|
|
GtkWidget parent;
|
|
|
|
|
2016-10-31 15:38:19 +00:00
|
|
|
GListModel *recordings;
|
2018-09-05 03:53:33 +00:00
|
|
|
GtkTreeListModel *render_node_model;
|
2019-10-14 04:50:40 +00:00
|
|
|
GListStore *render_node_root_model;
|
|
|
|
GtkSingleSelection *render_node_selection;
|
2016-11-01 00:21:02 +00:00
|
|
|
|
2020-07-18 02:44:01 +00:00
|
|
|
GtkWidget *box;
|
2016-10-30 05:11:38 +00:00
|
|
|
GtkWidget *recordings_list;
|
2016-10-31 15:38:19 +00:00
|
|
|
GtkWidget *render_node_view;
|
2018-09-05 03:53:33 +00:00
|
|
|
GtkWidget *render_node_list;
|
2016-12-21 05:50:39 +00:00
|
|
|
GtkWidget *render_node_save_button;
|
2021-04-03 01:38:14 +00:00
|
|
|
GtkWidget *render_node_clip_button;
|
2016-11-19 01:59:10 +00:00
|
|
|
GtkWidget *node_property_tree;
|
|
|
|
GtkTreeModel *render_node_properties;
|
2016-11-01 17:03:16 +00:00
|
|
|
|
2016-11-20 00:41:43 +00:00
|
|
|
GtkInspectorRecording *recording; /* start recording if recording or NULL if not */
|
2017-09-01 15:55:23 +00:00
|
|
|
|
|
|
|
gboolean debug_nodes;
|
2016-11-01 00:21:02 +00:00
|
|
|
};
|
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
typedef struct _GtkInspectorRecorderClass
|
|
|
|
{
|
|
|
|
GtkWidgetClass parent;
|
|
|
|
} GtkInspectorRecorderClass;
|
|
|
|
|
|
|
|
|
2016-11-01 17:03:16 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_RECORDING,
|
2017-09-01 15:55:23 +00:00
|
|
|
PROP_DEBUG_NODES,
|
2016-11-01 17:03:16 +00:00
|
|
|
LAST_PROP
|
|
|
|
};
|
|
|
|
|
|
|
|
static GParamSpec *props[LAST_PROP] = { NULL, };
|
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
G_DEFINE_TYPE (GtkInspectorRecorder, gtk_inspector_recorder, GTK_TYPE_WIDGET)
|
2016-10-29 19:11:23 +00:00
|
|
|
|
2018-09-05 03:53:33 +00:00
|
|
|
static GListModel *
|
|
|
|
create_render_node_list_model (GskRenderNode **nodes,
|
|
|
|
guint n_nodes)
|
2016-11-01 17:32:50 +00:00
|
|
|
{
|
2018-09-05 03:53:33 +00:00
|
|
|
GListStore *store;
|
|
|
|
guint i;
|
2016-11-01 17:32:50 +00:00
|
|
|
|
2018-09-05 03:53:33 +00:00
|
|
|
/* can't put render nodes into list models - they're not GObjects */
|
|
|
|
store = g_list_store_new (GDK_TYPE_PAINTABLE);
|
|
|
|
|
|
|
|
for (i = 0; i < n_nodes; i++)
|
|
|
|
{
|
|
|
|
graphene_rect_t bounds;
|
|
|
|
|
|
|
|
gsk_render_node_get_bounds (nodes[i], &bounds);
|
|
|
|
GdkPaintable *paintable = gtk_render_node_paintable_new (nodes[i], &bounds);
|
|
|
|
g_list_store_append (store, paintable);
|
|
|
|
g_object_unref (paintable);
|
|
|
|
}
|
|
|
|
|
|
|
|
return G_LIST_MODEL (store);
|
2016-11-01 17:32:50 +00:00
|
|
|
}
|
|
|
|
|
2018-09-05 03:53:33 +00:00
|
|
|
static GListModel *
|
|
|
|
create_list_model_for_render_node (GskRenderNode *node)
|
2016-10-31 15:38:19 +00:00
|
|
|
{
|
2018-09-05 03:53:33 +00:00
|
|
|
switch (gsk_render_node_get_node_type (node))
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case GSK_NOT_A_RENDER_NODE:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return NULL;
|
2016-11-02 02:06:25 +00:00
|
|
|
|
2018-09-05 03:53:33 +00:00
|
|
|
case GSK_CAIRO_NODE:
|
|
|
|
case GSK_TEXT_NODE:
|
|
|
|
case GSK_TEXTURE_NODE:
|
|
|
|
case GSK_COLOR_NODE:
|
|
|
|
case GSK_LINEAR_GRADIENT_NODE:
|
|
|
|
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
2020-09-12 02:55:37 +00:00
|
|
|
case GSK_RADIAL_GRADIENT_NODE:
|
|
|
|
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
|
2020-12-02 23:47:54 +00:00
|
|
|
case GSK_CONIC_GRADIENT_NODE:
|
2018-09-05 03:53:33 +00:00
|
|
|
case GSK_BORDER_NODE:
|
|
|
|
case GSK_INSET_SHADOW_NODE:
|
|
|
|
case GSK_OUTSET_SHADOW_NODE:
|
|
|
|
/* no children */
|
|
|
|
return NULL;
|
2016-11-02 02:06:25 +00:00
|
|
|
|
2018-09-05 03:53:33 +00:00
|
|
|
case GSK_TRANSFORM_NODE:
|
|
|
|
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_transform_node_get_child (node) }, 1);
|
|
|
|
|
|
|
|
case GSK_OPACITY_NODE:
|
|
|
|
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_opacity_node_get_child (node) }, 1);
|
|
|
|
|
|
|
|
case GSK_COLOR_MATRIX_NODE:
|
|
|
|
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_color_matrix_node_get_child (node) }, 1);
|
|
|
|
|
|
|
|
case GSK_BLUR_NODE:
|
|
|
|
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_blur_node_get_child (node) }, 1);
|
|
|
|
|
|
|
|
case GSK_REPEAT_NODE:
|
|
|
|
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_repeat_node_get_child (node) }, 1);
|
|
|
|
|
|
|
|
case GSK_CLIP_NODE:
|
|
|
|
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_clip_node_get_child (node) }, 1);
|
|
|
|
|
|
|
|
case GSK_ROUNDED_CLIP_NODE:
|
|
|
|
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_rounded_clip_node_get_child (node) }, 1);
|
|
|
|
|
|
|
|
case GSK_SHADOW_NODE:
|
|
|
|
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_shadow_node_get_child (node) }, 1);
|
|
|
|
|
|
|
|
case GSK_BLEND_NODE:
|
|
|
|
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_blend_node_get_bottom_child (node),
|
|
|
|
gsk_blend_node_get_top_child (node) }, 2);
|
|
|
|
|
|
|
|
case GSK_CROSS_FADE_NODE:
|
|
|
|
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_cross_fade_node_get_start_child (node),
|
|
|
|
gsk_cross_fade_node_get_end_child (node) }, 2);
|
|
|
|
|
2020-09-18 15:46:57 +00:00
|
|
|
case GSK_GL_SHADER_NODE:
|
|
|
|
{
|
|
|
|
GListStore *store = g_list_store_new (GDK_TYPE_PAINTABLE);
|
|
|
|
|
|
|
|
for (guint i = 0; i < gsk_gl_shader_node_get_n_children (node); i++)
|
|
|
|
{
|
|
|
|
GskRenderNode *child = gsk_gl_shader_node_get_child (node, i);
|
|
|
|
graphene_rect_t bounds;
|
|
|
|
GdkPaintable *paintable;
|
|
|
|
|
|
|
|
gsk_render_node_get_bounds (child, &bounds);
|
|
|
|
paintable = gtk_render_node_paintable_new (child, &bounds);
|
|
|
|
g_list_store_append (store, paintable);
|
|
|
|
g_object_unref (paintable);
|
|
|
|
}
|
|
|
|
|
|
|
|
return G_LIST_MODEL (store);
|
|
|
|
}
|
|
|
|
|
2018-09-05 03:53:33 +00:00
|
|
|
case GSK_CONTAINER_NODE:
|
|
|
|
{
|
|
|
|
GListStore *store;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
/* can't put render nodes into list models - they're not GObjects */
|
|
|
|
store = g_list_store_new (GDK_TYPE_PAINTABLE);
|
|
|
|
|
|
|
|
for (i = 0; i < gsk_container_node_get_n_children (node); i++)
|
|
|
|
{
|
|
|
|
GskRenderNode *child = gsk_container_node_get_child (node, i);
|
|
|
|
graphene_rect_t bounds;
|
|
|
|
GdkPaintable *paintable;
|
|
|
|
|
|
|
|
gsk_render_node_get_bounds (child, &bounds);
|
|
|
|
paintable = gtk_render_node_paintable_new (child, &bounds);
|
|
|
|
g_list_store_append (store, paintable);
|
|
|
|
g_object_unref (paintable);
|
|
|
|
}
|
|
|
|
|
|
|
|
return G_LIST_MODEL (store);
|
|
|
|
}
|
|
|
|
|
|
|
|
case GSK_DEBUG_NODE:
|
|
|
|
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_debug_node_get_child (node) }, 1);
|
2016-10-31 15:38:19 +00:00
|
|
|
}
|
2018-09-05 03:53:33 +00:00
|
|
|
}
|
2016-11-01 00:21:02 +00:00
|
|
|
|
2018-09-05 03:53:33 +00:00
|
|
|
static GListModel *
|
|
|
|
create_list_model_for_render_node_paintable (gpointer paintable,
|
|
|
|
gpointer unused)
|
|
|
|
{
|
|
|
|
GskRenderNode *node = gtk_render_node_paintable_get_render_node (paintable);
|
2018-01-18 00:12:27 +00:00
|
|
|
|
2018-09-05 03:53:33 +00:00
|
|
|
return create_list_model_for_render_node (node);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
recordings_clear_all (GtkButton *button,
|
|
|
|
GtkInspectorRecorder *recorder)
|
|
|
|
{
|
2020-07-18 02:37:24 +00:00
|
|
|
g_list_store_remove_all (G_LIST_STORE (recorder->recordings));
|
2016-11-01 00:21:02 +00:00
|
|
|
}
|
|
|
|
|
2016-12-18 17:17:17 +00:00
|
|
|
static const char *
|
|
|
|
node_type_name (GskRenderNodeType type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case GSK_NOT_A_RENDER_NODE:
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return "Unknown";
|
|
|
|
case GSK_CONTAINER_NODE:
|
|
|
|
return "Container";
|
2018-04-23 22:41:48 +00:00
|
|
|
case GSK_DEBUG_NODE:
|
|
|
|
return "Debug";
|
2016-12-18 17:17:17 +00:00
|
|
|
case GSK_CAIRO_NODE:
|
|
|
|
return "Cairo";
|
|
|
|
case GSK_COLOR_NODE:
|
|
|
|
return "Color";
|
|
|
|
case GSK_LINEAR_GRADIENT_NODE:
|
|
|
|
return "Linear Gradient";
|
|
|
|
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
|
|
|
return "Repeating Linear Gradient";
|
2020-09-12 02:55:37 +00:00
|
|
|
case GSK_RADIAL_GRADIENT_NODE:
|
|
|
|
return "Radial Gradient";
|
|
|
|
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
|
|
|
|
return "Repeating Radial Gradient";
|
2020-12-02 23:47:54 +00:00
|
|
|
case GSK_CONIC_GRADIENT_NODE:
|
|
|
|
return "Conic Gradient";
|
2016-12-18 17:17:17 +00:00
|
|
|
case GSK_BORDER_NODE:
|
|
|
|
return "Border";
|
2017-11-04 15:03:03 +00:00
|
|
|
case GSK_TEXTURE_NODE:
|
2016-12-18 17:17:17 +00:00
|
|
|
return "Texture";
|
2016-12-19 04:13:42 +00:00
|
|
|
case GSK_INSET_SHADOW_NODE:
|
|
|
|
return "Inset Shadow";
|
2016-12-19 14:39:43 +00:00
|
|
|
case GSK_OUTSET_SHADOW_NODE:
|
|
|
|
return "Outset Shadow";
|
2016-12-18 17:17:17 +00:00
|
|
|
case GSK_TRANSFORM_NODE:
|
|
|
|
return "Transform";
|
|
|
|
case GSK_OPACITY_NODE:
|
|
|
|
return "Opacity";
|
2016-12-31 00:13:19 +00:00
|
|
|
case GSK_COLOR_MATRIX_NODE:
|
|
|
|
return "Color Matrix";
|
2017-01-01 18:52:18 +00:00
|
|
|
case GSK_REPEAT_NODE:
|
|
|
|
return "Repeat";
|
2016-12-18 17:17:17 +00:00
|
|
|
case GSK_CLIP_NODE:
|
|
|
|
return "Clip";
|
|
|
|
case GSK_ROUNDED_CLIP_NODE:
|
|
|
|
return "Rounded Clip";
|
2016-12-18 23:45:35 +00:00
|
|
|
case GSK_SHADOW_NODE:
|
|
|
|
return "Shadow";
|
2016-12-18 17:17:17 +00:00
|
|
|
case GSK_BLEND_NODE:
|
|
|
|
return "Blend";
|
|
|
|
case GSK_CROSS_FADE_NODE:
|
|
|
|
return "CrossFade";
|
2017-08-29 21:28:10 +00:00
|
|
|
case GSK_TEXT_NODE:
|
|
|
|
return "Text";
|
2017-09-03 03:49:34 +00:00
|
|
|
case GSK_BLUR_NODE:
|
|
|
|
return "Blur";
|
2020-09-18 15:46:57 +00:00
|
|
|
case GSK_GL_SHADER_NODE:
|
|
|
|
return "GL Shader";
|
2016-12-18 17:17:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-24 01:46:44 +00:00
|
|
|
static char *
|
|
|
|
node_name (GskRenderNode *node)
|
|
|
|
{
|
|
|
|
switch (gsk_render_node_get_node_type (node))
|
|
|
|
{
|
|
|
|
case GSK_NOT_A_RENDER_NODE:
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
case GSK_CONTAINER_NODE:
|
|
|
|
case GSK_CAIRO_NODE:
|
|
|
|
case GSK_LINEAR_GRADIENT_NODE:
|
|
|
|
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
2020-09-12 02:55:37 +00:00
|
|
|
case GSK_RADIAL_GRADIENT_NODE:
|
|
|
|
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
|
2020-12-02 23:47:54 +00:00
|
|
|
case GSK_CONIC_GRADIENT_NODE:
|
2018-04-24 01:46:44 +00:00
|
|
|
case GSK_BORDER_NODE:
|
|
|
|
case GSK_INSET_SHADOW_NODE:
|
|
|
|
case GSK_OUTSET_SHADOW_NODE:
|
|
|
|
case GSK_TRANSFORM_NODE:
|
|
|
|
case GSK_OPACITY_NODE:
|
|
|
|
case GSK_COLOR_MATRIX_NODE:
|
|
|
|
case GSK_REPEAT_NODE:
|
|
|
|
case GSK_CLIP_NODE:
|
|
|
|
case GSK_ROUNDED_CLIP_NODE:
|
|
|
|
case GSK_SHADOW_NODE:
|
|
|
|
case GSK_BLEND_NODE:
|
|
|
|
case GSK_CROSS_FADE_NODE:
|
|
|
|
case GSK_TEXT_NODE:
|
|
|
|
case GSK_BLUR_NODE:
|
2020-09-18 15:46:57 +00:00
|
|
|
case GSK_GL_SHADER_NODE:
|
2018-04-24 01:46:44 +00:00
|
|
|
return g_strdup (node_type_name (gsk_render_node_get_node_type (node)));
|
|
|
|
|
|
|
|
case GSK_DEBUG_NODE:
|
|
|
|
return g_strdup (gsk_debug_node_get_message (node));
|
|
|
|
|
|
|
|
case GSK_COLOR_NODE:
|
2020-11-16 23:59:36 +00:00
|
|
|
return gdk_rgba_to_string (gsk_color_node_get_color (node));
|
2018-04-24 01:46:44 +00:00
|
|
|
|
|
|
|
case GSK_TEXTURE_NODE:
|
|
|
|
{
|
|
|
|
GdkTexture *texture = gsk_texture_node_get_texture (node);
|
|
|
|
return g_strdup_printf ("%dx%d Texture", gdk_texture_get_width (texture), gdk_texture_get_height (texture));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-20 03:52:10 +00:00
|
|
|
static GdkContentProvider *
|
|
|
|
prepare_render_node_drag (GtkDragSource *source,
|
|
|
|
double x,
|
|
|
|
double y,
|
|
|
|
GtkListItem *list_item)
|
|
|
|
{
|
|
|
|
GtkTreeListRow *row_item;
|
|
|
|
GdkPaintable *paintable;
|
|
|
|
GskRenderNode *node;
|
|
|
|
|
|
|
|
row_item = gtk_list_item_get_item (list_item);
|
|
|
|
if (row_item == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
paintable = gtk_tree_list_row_get_item (row_item);
|
|
|
|
node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
|
|
|
|
|
|
|
|
return gdk_content_provider_new_typed (GSK_TYPE_RENDER_NODE, node);
|
|
|
|
}
|
|
|
|
|
2019-10-14 04:50:40 +00:00
|
|
|
static void
|
2020-06-29 20:37:14 +00:00
|
|
|
setup_widget_for_render_node (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *list_item)
|
2019-10-14 04:50:40 +00:00
|
|
|
{
|
|
|
|
GtkWidget *expander, *box, *child;
|
2021-08-20 03:52:10 +00:00
|
|
|
GtkDragSource *source;
|
2019-10-14 04:50:40 +00:00
|
|
|
|
|
|
|
/* expander */
|
|
|
|
expander = gtk_tree_expander_new ();
|
|
|
|
gtk_list_item_set_child (list_item, expander);
|
2021-08-20 03:52:10 +00:00
|
|
|
source = gtk_drag_source_new ();
|
|
|
|
g_signal_connect (source, "prepare", G_CALLBACK (prepare_render_node_drag), list_item);
|
|
|
|
gtk_widget_add_controller (expander, GTK_EVENT_CONTROLLER (source));
|
2019-10-14 04:50:40 +00:00
|
|
|
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
|
|
|
|
gtk_tree_expander_set_child (GTK_TREE_EXPANDER (expander), box);
|
|
|
|
|
|
|
|
/* icon */
|
|
|
|
child = gtk_image_new ();
|
|
|
|
gtk_box_append (GTK_BOX (box), child);
|
|
|
|
|
|
|
|
/* name */
|
|
|
|
child = gtk_label_new (NULL);
|
|
|
|
gtk_box_append (GTK_BOX (box), child);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-06-29 20:37:14 +00:00
|
|
|
bind_widget_for_render_node (GtkSignalListItemFactory *factory,
|
|
|
|
GtkListItem *list_item)
|
2018-09-05 03:53:33 +00:00
|
|
|
{
|
|
|
|
GdkPaintable *paintable;
|
|
|
|
GskRenderNode *node;
|
2019-10-14 04:50:40 +00:00
|
|
|
GtkTreeListRow *row_item;
|
|
|
|
GtkWidget *expander, *box, *child;
|
2018-09-05 03:53:33 +00:00
|
|
|
char *name;
|
|
|
|
|
2019-10-14 04:50:40 +00:00
|
|
|
row_item = gtk_list_item_get_item (list_item);
|
2018-09-05 03:53:33 +00:00
|
|
|
paintable = gtk_tree_list_row_get_item (row_item);
|
|
|
|
node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
|
|
|
|
|
|
|
|
/* expander */
|
2019-10-14 04:50:40 +00:00
|
|
|
expander = gtk_list_item_get_child (list_item);
|
2019-10-14 04:18:25 +00:00
|
|
|
gtk_tree_expander_set_list_row (GTK_TREE_EXPANDER (expander), row_item);
|
2019-10-14 04:50:40 +00:00
|
|
|
box = gtk_tree_expander_get_child (GTK_TREE_EXPANDER (expander));
|
2018-09-05 03:53:33 +00:00
|
|
|
|
2018-09-05 04:34:03 +00:00
|
|
|
/* icon */
|
2019-10-14 04:50:40 +00:00
|
|
|
child = gtk_widget_get_first_child (box);
|
|
|
|
gtk_image_set_from_paintable (GTK_IMAGE (child), paintable);
|
2018-09-05 04:34:03 +00:00
|
|
|
|
|
|
|
/* name */
|
2018-09-05 03:53:33 +00:00
|
|
|
name = node_name (node);
|
2019-10-14 04:50:40 +00:00
|
|
|
child = gtk_widget_get_last_child (box);
|
|
|
|
gtk_label_set_label (GTK_LABEL (child), name);
|
2018-09-05 03:53:33 +00:00
|
|
|
g_free (name);
|
|
|
|
|
|
|
|
g_object_unref (paintable);
|
|
|
|
}
|
|
|
|
|
2018-04-24 01:46:44 +00:00
|
|
|
static void
|
2018-09-05 03:53:33 +00:00
|
|
|
recordings_list_row_selected (GtkListBox *box,
|
|
|
|
GtkListBoxRow *row,
|
|
|
|
GtkInspectorRecorder *recorder)
|
2018-04-24 01:46:44 +00:00
|
|
|
{
|
2018-09-05 03:53:33 +00:00
|
|
|
GtkInspectorRecording *recording;
|
|
|
|
|
2021-01-17 15:55:53 +00:00
|
|
|
if (recorder->recordings == NULL)
|
|
|
|
return;
|
|
|
|
|
2018-09-05 03:53:33 +00:00
|
|
|
if (row)
|
2020-07-18 02:37:24 +00:00
|
|
|
recording = g_list_model_get_item (recorder->recordings, gtk_list_box_row_get_index (row));
|
2018-09-05 03:53:33 +00:00
|
|
|
else
|
|
|
|
recording = NULL;
|
|
|
|
|
|
|
|
if (GTK_INSPECTOR_IS_RENDER_RECORDING (recording))
|
2018-04-24 01:46:44 +00:00
|
|
|
{
|
2018-09-05 14:40:51 +00:00
|
|
|
graphene_rect_t bounds;
|
|
|
|
GskRenderNode *node;
|
|
|
|
GdkPaintable *paintable;
|
2018-04-24 01:46:44 +00:00
|
|
|
|
2018-09-05 14:40:51 +00:00
|
|
|
node = gtk_inspector_render_recording_get_node (GTK_INSPECTOR_RENDER_RECORDING (recording));
|
|
|
|
gsk_render_node_get_bounds (node, &bounds);
|
|
|
|
paintable = gtk_render_node_paintable_new (node, &bounds);
|
2020-07-18 02:37:24 +00:00
|
|
|
gtk_picture_set_paintable (GTK_PICTURE (recorder->render_node_view), paintable);
|
2018-09-05 03:53:33 +00:00
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
g_list_store_splice (recorder->render_node_root_model,
|
|
|
|
0, g_list_model_get_n_items (G_LIST_MODEL (recorder->render_node_root_model)),
|
2019-10-14 04:50:40 +00:00
|
|
|
(gpointer[1]) { paintable },
|
|
|
|
1);
|
2018-09-05 14:40:51 +00:00
|
|
|
g_object_unref (paintable);
|
2018-04-24 01:46:44 +00:00
|
|
|
}
|
2018-09-05 03:53:33 +00:00
|
|
|
else
|
|
|
|
{
|
2020-07-18 02:37:24 +00:00
|
|
|
gtk_picture_set_paintable (GTK_PICTURE (recorder->render_node_view), NULL);
|
|
|
|
g_list_store_remove_all (recorder->render_node_root_model);
|
2018-09-05 03:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (recording)
|
|
|
|
g_object_unref (recording);
|
2018-04-24 01:46:44 +00:00
|
|
|
}
|
|
|
|
|
2018-03-15 01:36:13 +00:00
|
|
|
static GdkTexture *
|
|
|
|
get_color_texture (const GdkRGBA *color)
|
2017-09-28 22:37:47 +00:00
|
|
|
{
|
2018-03-15 01:36:13 +00:00
|
|
|
GdkTexture *texture;
|
|
|
|
guchar pixel[4];
|
|
|
|
guchar *data;
|
|
|
|
GBytes *bytes;
|
2020-06-27 09:04:03 +00:00
|
|
|
int width = 30;
|
|
|
|
int height = 30;
|
|
|
|
int i;
|
2018-03-15 01:36:13 +00:00
|
|
|
|
|
|
|
pixel[0] = round (color->red * 255);
|
|
|
|
pixel[1] = round (color->green * 255);
|
|
|
|
pixel[2] = round (color->blue * 255);
|
|
|
|
pixel[3] = round (color->alpha * 255);
|
|
|
|
|
|
|
|
data = g_malloc (4 * width * height);
|
|
|
|
for (i = 0; i < width * height; i++)
|
|
|
|
{
|
|
|
|
memcpy (data + 4 * i, pixel, 4);
|
|
|
|
}
|
2017-09-28 22:37:47 +00:00
|
|
|
|
2018-03-15 01:36:13 +00:00
|
|
|
bytes = g_bytes_new_take (data, 4 * width * height);
|
|
|
|
texture = gdk_memory_texture_new (width,
|
|
|
|
height,
|
|
|
|
GDK_MEMORY_R8G8B8A8,
|
|
|
|
bytes,
|
|
|
|
width * 4);
|
|
|
|
g_bytes_unref (bytes);
|
2017-09-28 22:37:47 +00:00
|
|
|
|
2018-03-15 01:36:13 +00:00
|
|
|
return texture;
|
2017-09-28 22:37:47 +00:00
|
|
|
}
|
|
|
|
|
2018-03-15 01:36:13 +00:00
|
|
|
static GdkTexture *
|
|
|
|
get_linear_gradient_texture (gsize n_stops, const GskColorStop *stops)
|
2017-09-29 01:06:35 +00:00
|
|
|
{
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
cairo_t *cr;
|
|
|
|
cairo_pattern_t *pattern;
|
2018-03-15 01:36:13 +00:00
|
|
|
GdkTexture *texture;
|
2017-09-29 01:06:35 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 90, 30);
|
|
|
|
cr = cairo_create (surface);
|
|
|
|
|
|
|
|
pattern = cairo_pattern_create_linear (0, 0, 90, 0);
|
|
|
|
for (i = 0; i < n_stops; i++)
|
|
|
|
{
|
|
|
|
cairo_pattern_add_color_stop_rgba (pattern,
|
|
|
|
stops[i].offset,
|
|
|
|
stops[i].color.red,
|
|
|
|
stops[i].color.green,
|
|
|
|
stops[i].color.blue,
|
|
|
|
stops[i].color.alpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
cairo_set_source (cr, pattern);
|
|
|
|
cairo_pattern_destroy (pattern);
|
|
|
|
cairo_rectangle (cr, 0, 0, 90, 30);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
2018-03-15 01:36:13 +00:00
|
|
|
texture = gdk_texture_new_for_surface (surface);
|
|
|
|
cairo_surface_destroy (surface);
|
|
|
|
|
|
|
|
return texture;
|
2017-09-29 01:06:35 +00:00
|
|
|
}
|
|
|
|
|
2017-09-29 01:41:24 +00:00
|
|
|
static void
|
|
|
|
add_text_row (GtkListStore *store,
|
|
|
|
const char *name,
|
|
|
|
const char *text)
|
|
|
|
{
|
|
|
|
gtk_list_store_insert_with_values (store, NULL, -1,
|
|
|
|
0, name,
|
|
|
|
1, text,
|
|
|
|
2, FALSE,
|
|
|
|
3, NULL,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_color_row (GtkListStore *store,
|
|
|
|
const char *name,
|
|
|
|
const GdkRGBA *color)
|
|
|
|
{
|
|
|
|
char *text;
|
2018-03-15 01:36:13 +00:00
|
|
|
GdkTexture *texture;
|
2017-09-29 01:41:24 +00:00
|
|
|
|
|
|
|
text = gdk_rgba_to_string (color);
|
2018-03-15 01:36:13 +00:00
|
|
|
texture = get_color_texture (color);
|
2017-09-29 01:41:24 +00:00
|
|
|
gtk_list_store_insert_with_values (store, NULL, -1,
|
|
|
|
0, name,
|
|
|
|
1, text,
|
|
|
|
2, TRUE,
|
2018-03-15 01:36:13 +00:00
|
|
|
3, texture,
|
2017-09-29 01:41:24 +00:00
|
|
|
-1);
|
|
|
|
g_free (text);
|
2018-03-15 01:36:13 +00:00
|
|
|
g_object_unref (texture);
|
2017-09-29 01:41:24 +00:00
|
|
|
}
|
|
|
|
|
2020-09-18 15:46:57 +00:00
|
|
|
static void
|
|
|
|
add_int_row (GtkListStore *store,
|
|
|
|
const char *name,
|
|
|
|
int value)
|
|
|
|
{
|
|
|
|
char *text = g_strdup_printf ("%d", value);
|
|
|
|
add_text_row (store, name, text);
|
|
|
|
g_free (text);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_uint_row (GtkListStore *store,
|
|
|
|
const char *name,
|
|
|
|
guint value)
|
|
|
|
{
|
|
|
|
char *text = g_strdup_printf ("%u", value);
|
|
|
|
add_text_row (store, name, text);
|
|
|
|
g_free (text);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_boolean_row (GtkListStore *store,
|
|
|
|
const char *name,
|
|
|
|
gboolean value)
|
|
|
|
{
|
|
|
|
add_text_row (store, name, value ? "TRUE" : "FALSE");
|
|
|
|
}
|
|
|
|
|
2017-09-29 01:41:24 +00:00
|
|
|
static void
|
|
|
|
add_float_row (GtkListStore *store,
|
|
|
|
const char *name,
|
|
|
|
float value)
|
|
|
|
{
|
|
|
|
char *text = g_strdup_printf ("%.2f", value);
|
|
|
|
add_text_row (store, name, text);
|
|
|
|
g_free (text);
|
|
|
|
}
|
|
|
|
|
2016-11-19 01:59:10 +00:00
|
|
|
static void
|
|
|
|
populate_render_node_properties (GtkListStore *store,
|
|
|
|
GskRenderNode *node)
|
|
|
|
{
|
|
|
|
graphene_rect_t bounds;
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
gtk_list_store_clear (store);
|
|
|
|
|
|
|
|
gsk_render_node_get_bounds (node, &bounds);
|
|
|
|
|
2017-09-29 01:41:24 +00:00
|
|
|
add_text_row (store, "Type", node_type_name (gsk_render_node_get_node_type (node)));
|
2016-12-18 17:17:17 +00:00
|
|
|
|
2017-09-28 22:17:38 +00:00
|
|
|
tmp = g_strdup_printf ("%.2f x %.2f + %.2f + %.2f",
|
2016-11-19 01:59:10 +00:00
|
|
|
bounds.size.width,
|
|
|
|
bounds.size.height,
|
|
|
|
bounds.origin.x,
|
|
|
|
bounds.origin.y);
|
2017-09-29 01:41:24 +00:00
|
|
|
add_text_row (store, "Bounds", tmp);
|
2016-11-19 01:59:10 +00:00
|
|
|
g_free (tmp);
|
|
|
|
|
2017-09-28 21:16:41 +00:00
|
|
|
switch (gsk_render_node_get_node_type (node))
|
2017-09-28 19:08:08 +00:00
|
|
|
{
|
2017-09-28 22:17:38 +00:00
|
|
|
case GSK_CAIRO_NODE:
|
|
|
|
{
|
2018-03-15 01:36:13 +00:00
|
|
|
GdkTexture *texture;
|
2018-05-01 19:17:26 +00:00
|
|
|
cairo_surface_t *drawn_surface;
|
|
|
|
cairo_t *cr;
|
2017-09-28 22:17:38 +00:00
|
|
|
gboolean show_inline;
|
|
|
|
|
2018-05-01 19:17:26 +00:00
|
|
|
drawn_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
|
|
|
ceilf (node->bounds.size.width),
|
|
|
|
ceilf (node->bounds.size.height));
|
|
|
|
cr = cairo_create (drawn_surface);
|
|
|
|
cairo_save (cr);
|
|
|
|
cairo_translate (cr, -node->bounds.origin.x, -node->bounds.origin.y);
|
|
|
|
gsk_render_node_draw (node, cr);
|
|
|
|
cairo_restore (cr);
|
|
|
|
|
|
|
|
cairo_destroy (cr);
|
2018-03-15 01:36:13 +00:00
|
|
|
|
2018-05-01 19:17:26 +00:00
|
|
|
texture = gdk_texture_new_for_surface (drawn_surface);
|
|
|
|
cairo_surface_destroy (drawn_surface);
|
|
|
|
|
|
|
|
show_inline = gdk_texture_get_height (texture) <= 40 &&
|
|
|
|
gdk_texture_get_width (texture) <= 100;
|
|
|
|
|
|
|
|
gtk_list_store_insert_with_values (store, NULL, -1,
|
|
|
|
0, "Surface",
|
|
|
|
1, show_inline ? "" : "Yes (click to show)",
|
|
|
|
2, show_inline,
|
|
|
|
3, texture,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_TEXTURE_NODE:
|
|
|
|
{
|
|
|
|
GdkTexture *texture = g_object_ref (gsk_texture_node_get_texture (node));
|
|
|
|
gboolean show_inline;
|
2017-09-28 22:17:38 +00:00
|
|
|
|
2018-03-15 01:36:13 +00:00
|
|
|
show_inline = gdk_texture_get_height (texture) <= 40 &&
|
|
|
|
gdk_texture_get_width (texture) <= 100;
|
2017-09-28 22:17:38 +00:00
|
|
|
|
|
|
|
gtk_list_store_insert_with_values (store, NULL, -1,
|
2018-05-01 19:17:26 +00:00
|
|
|
0, "Texture",
|
|
|
|
1, show_inline ? "" : "Yes (click to show)",
|
|
|
|
2, show_inline,
|
|
|
|
3, texture,
|
|
|
|
-1);
|
2017-09-28 22:17:38 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-09-28 21:16:41 +00:00
|
|
|
case GSK_COLOR_NODE:
|
2020-11-16 23:59:36 +00:00
|
|
|
add_color_row (store, "Color", gsk_color_node_get_color (node));
|
2017-09-28 21:16:41 +00:00
|
|
|
break;
|
|
|
|
|
2017-09-29 01:06:35 +00:00
|
|
|
case GSK_LINEAR_GRADIENT_NODE:
|
|
|
|
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
|
|
|
{
|
2020-11-16 23:59:36 +00:00
|
|
|
const graphene_point_t *start = gsk_linear_gradient_node_get_start (node);
|
|
|
|
const graphene_point_t *end = gsk_linear_gradient_node_get_end (node);
|
2017-09-29 01:06:35 +00:00
|
|
|
const gsize n_stops = gsk_linear_gradient_node_get_n_color_stops (node);
|
2020-11-16 23:59:36 +00:00
|
|
|
const GskColorStop *stops = gsk_linear_gradient_node_get_color_stops (node, NULL);
|
2017-09-29 01:06:35 +00:00
|
|
|
int i;
|
|
|
|
GString *s;
|
2018-03-15 01:36:13 +00:00
|
|
|
GdkTexture *texture;
|
2017-09-29 01:06:35 +00:00
|
|
|
|
2017-09-29 01:41:24 +00:00
|
|
|
tmp = g_strdup_printf ("%.2f %.2f ⟶ %.2f %.2f", start->x, start->y, end->x, end->y);
|
|
|
|
add_text_row (store, "Direction", tmp);
|
|
|
|
g_free (tmp);
|
2017-09-29 01:06:35 +00:00
|
|
|
|
|
|
|
s = g_string_new ("");
|
|
|
|
for (i = 0; i < n_stops; i++)
|
|
|
|
{
|
2017-09-29 01:41:24 +00:00
|
|
|
tmp = gdk_rgba_to_string (&stops[i].color);
|
2017-09-29 01:06:35 +00:00
|
|
|
g_string_append_printf (s, "%.2f, %s\n", stops[i].offset, tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
}
|
|
|
|
|
2018-03-15 01:36:13 +00:00
|
|
|
texture = get_linear_gradient_texture (n_stops, stops);
|
2017-09-29 01:06:35 +00:00
|
|
|
gtk_list_store_insert_with_values (store, NULL, -1,
|
|
|
|
0, "Color Stops",
|
|
|
|
1, s->str,
|
|
|
|
2, TRUE,
|
2018-03-15 01:36:13 +00:00
|
|
|
3, texture,
|
2017-09-29 01:06:35 +00:00
|
|
|
-1);
|
|
|
|
g_string_free (s, TRUE);
|
2018-03-15 01:36:13 +00:00
|
|
|
g_object_unref (texture);
|
2017-09-29 01:06:35 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2020-09-12 02:55:37 +00:00
|
|
|
case GSK_RADIAL_GRADIENT_NODE:
|
|
|
|
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
|
2020-09-16 04:49:38 +00:00
|
|
|
{
|
2020-11-16 23:59:36 +00:00
|
|
|
const graphene_point_t *center = gsk_radial_gradient_node_get_center (node);
|
2020-09-16 04:49:38 +00:00
|
|
|
const float start = gsk_radial_gradient_node_get_start (node);
|
|
|
|
const float end = gsk_radial_gradient_node_get_end (node);
|
|
|
|
const float hradius = gsk_radial_gradient_node_get_hradius (node);
|
|
|
|
const float vradius = gsk_radial_gradient_node_get_vradius (node);
|
|
|
|
const gsize n_stops = gsk_radial_gradient_node_get_n_color_stops (node);
|
2020-11-16 23:59:36 +00:00
|
|
|
const GskColorStop *stops = gsk_radial_gradient_node_get_color_stops (node, NULL);
|
2020-09-16 04:49:38 +00:00
|
|
|
int i;
|
|
|
|
GString *s;
|
|
|
|
GdkTexture *texture;
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%.2f, %.2f", center->x, center->y);
|
|
|
|
add_text_row (store, "Center", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%.2f ⟶ %.2f", start, end);
|
|
|
|
add_text_row (store, "Direction", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%.2f, %.2f", hradius, vradius);
|
|
|
|
add_text_row (store, "Radius", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
2020-12-02 23:47:54 +00:00
|
|
|
s = g_string_new ("");
|
|
|
|
for (i = 0; i < n_stops; i++)
|
|
|
|
{
|
|
|
|
tmp = gdk_rgba_to_string (&stops[i].color);
|
|
|
|
g_string_append_printf (s, "%.2f, %s\n", stops[i].offset, tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
texture = get_linear_gradient_texture (n_stops, stops);
|
|
|
|
gtk_list_store_insert_with_values (store, NULL, -1,
|
|
|
|
0, "Color Stops",
|
|
|
|
1, s->str,
|
|
|
|
2, TRUE,
|
|
|
|
3, texture,
|
|
|
|
-1);
|
|
|
|
g_string_free (s, TRUE);
|
|
|
|
g_object_unref (texture);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_CONIC_GRADIENT_NODE:
|
|
|
|
{
|
|
|
|
const graphene_point_t *center = gsk_conic_gradient_node_get_center (node);
|
|
|
|
const float rotation = gsk_conic_gradient_node_get_rotation (node);
|
|
|
|
const gsize n_stops = gsk_conic_gradient_node_get_n_color_stops (node);
|
|
|
|
const GskColorStop *stops = gsk_conic_gradient_node_get_color_stops (node, NULL);
|
|
|
|
gsize i;
|
|
|
|
GString *s;
|
|
|
|
GdkTexture *texture;
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%.2f, %.2f", center->x, center->y);
|
|
|
|
add_text_row (store, "Center", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%.2f", rotation);
|
|
|
|
add_text_row (store, "Rotation", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
2020-09-16 04:49:38 +00:00
|
|
|
s = g_string_new ("");
|
|
|
|
for (i = 0; i < n_stops; i++)
|
|
|
|
{
|
|
|
|
tmp = gdk_rgba_to_string (&stops[i].color);
|
|
|
|
g_string_append_printf (s, "%.2f, %s\n", stops[i].offset, tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
texture = get_linear_gradient_texture (n_stops, stops);
|
|
|
|
gtk_list_store_insert_with_values (store, NULL, -1,
|
|
|
|
0, "Color Stops",
|
|
|
|
1, s->str,
|
|
|
|
2, TRUE,
|
|
|
|
3, texture,
|
|
|
|
-1);
|
|
|
|
g_string_free (s, TRUE);
|
|
|
|
g_object_unref (texture);
|
|
|
|
}
|
2020-09-12 02:55:37 +00:00
|
|
|
break;
|
|
|
|
|
2017-09-28 21:16:41 +00:00
|
|
|
case GSK_TEXT_NODE:
|
|
|
|
{
|
2020-11-16 23:59:36 +00:00
|
|
|
const PangoFont *font = gsk_text_node_get_font (node);
|
|
|
|
const GdkRGBA *color = gsk_text_node_get_color (node);
|
2019-05-19 02:08:29 +00:00
|
|
|
const graphene_point_t *offset = gsk_text_node_get_offset (node);
|
2017-09-28 21:16:41 +00:00
|
|
|
PangoFontDescription *desc;
|
|
|
|
GString *s;
|
|
|
|
|
2017-10-20 07:12:19 +00:00
|
|
|
desc = pango_font_describe ((PangoFont *)font);
|
2017-09-29 01:41:24 +00:00
|
|
|
tmp = pango_font_description_to_string (desc);
|
|
|
|
add_text_row (store, "Font", tmp);
|
|
|
|
g_free (tmp);
|
2017-09-28 21:16:41 +00:00
|
|
|
pango_font_description_free (desc);
|
|
|
|
|
2020-12-21 18:11:46 +00:00
|
|
|
s = g_string_sized_new (0);
|
|
|
|
gsk_text_node_serialize_glyphs (node, s);
|
2017-09-29 01:41:24 +00:00
|
|
|
add_text_row (store, "Glyphs", s->str);
|
2017-09-28 21:16:41 +00:00
|
|
|
g_string_free (s, TRUE);
|
|
|
|
|
2019-05-19 02:08:29 +00:00
|
|
|
tmp = g_strdup_printf ("%.2f %.2f", offset->x, offset->y);
|
2017-09-29 01:41:24 +00:00
|
|
|
add_text_row (store, "Position", tmp);
|
|
|
|
g_free (tmp);
|
2017-09-28 21:16:41 +00:00
|
|
|
|
2017-09-29 01:41:24 +00:00
|
|
|
add_color_row (store, "Color", color);
|
2017-09-28 21:16:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-09-28 22:58:18 +00:00
|
|
|
case GSK_BORDER_NODE:
|
|
|
|
{
|
|
|
|
const char *name[4] = { "Top", "Right", "Bottom", "Left" };
|
2020-11-16 23:59:36 +00:00
|
|
|
const float *widths = gsk_border_node_get_widths (node);
|
|
|
|
const GdkRGBA *colors = gsk_border_node_get_colors (node);
|
2017-09-28 22:58:18 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
2018-03-15 01:36:13 +00:00
|
|
|
GdkTexture *texture;
|
2017-09-29 01:41:24 +00:00
|
|
|
char *text;
|
2017-09-28 22:58:18 +00:00
|
|
|
|
2018-03-15 01:36:13 +00:00
|
|
|
texture = get_color_texture (&colors[i]);
|
2017-09-28 22:58:18 +00:00
|
|
|
text = gdk_rgba_to_string (&colors[i]);
|
2017-09-29 01:41:24 +00:00
|
|
|
tmp = g_strdup_printf ("%.2f, %s", widths[i], text);
|
2017-09-28 22:58:18 +00:00
|
|
|
gtk_list_store_insert_with_values (store, NULL, -1,
|
|
|
|
0, name[i],
|
2017-09-29 01:41:24 +00:00
|
|
|
1, tmp,
|
2017-09-28 22:58:18 +00:00
|
|
|
2, TRUE,
|
2018-03-15 01:36:13 +00:00
|
|
|
3, texture,
|
2017-09-28 22:58:18 +00:00
|
|
|
-1);
|
|
|
|
g_free (text);
|
2017-09-29 01:41:24 +00:00
|
|
|
g_free (tmp);
|
2018-03-15 01:36:13 +00:00
|
|
|
g_object_unref (texture);
|
2017-09-28 22:58:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-09-28 23:14:32 +00:00
|
|
|
case GSK_OPACITY_NODE:
|
2017-09-29 01:41:24 +00:00
|
|
|
add_float_row (store, "Opacity", gsk_opacity_node_get_opacity (node));
|
2017-09-28 23:14:32 +00:00
|
|
|
break;
|
|
|
|
|
2017-09-28 23:20:25 +00:00
|
|
|
case GSK_CROSS_FADE_NODE:
|
2017-09-29 01:41:24 +00:00
|
|
|
add_float_row (store, "Progress", gsk_cross_fade_node_get_progress (node));
|
2017-09-28 23:20:25 +00:00
|
|
|
break;
|
|
|
|
|
2017-09-28 23:40:03 +00:00
|
|
|
case GSK_BLEND_NODE:
|
|
|
|
{
|
|
|
|
GskBlendMode mode = gsk_blend_node_get_blend_mode (node);
|
2017-09-29 01:41:24 +00:00
|
|
|
tmp = g_enum_to_string (GSK_TYPE_BLEND_MODE, mode);
|
|
|
|
add_text_row (store, "Blendmode", tmp);
|
|
|
|
g_free (tmp);
|
2017-09-28 23:40:03 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-09-28 23:48:42 +00:00
|
|
|
case GSK_BLUR_NODE:
|
2017-09-29 01:41:24 +00:00
|
|
|
add_float_row (store, "Radius", gsk_blur_node_get_radius (node));
|
|
|
|
break;
|
|
|
|
|
2020-09-18 15:46:57 +00:00
|
|
|
case GSK_GL_SHADER_NODE:
|
|
|
|
{
|
|
|
|
GskGLShader *shader = gsk_gl_shader_node_get_shader (node);
|
|
|
|
GBytes *args = gsk_gl_shader_node_get_args (node);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
add_int_row (store, "Required textures", gsk_gl_shader_get_n_textures (shader));
|
|
|
|
for (i = 0; i < gsk_gl_shader_get_n_uniforms (shader); i++)
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
char *title;
|
|
|
|
|
|
|
|
name = gsk_gl_shader_get_uniform_name (shader, i);
|
|
|
|
title = g_strdup_printf ("Uniform %s", name);
|
|
|
|
|
|
|
|
switch (gsk_gl_shader_get_uniform_type (shader, i))
|
|
|
|
{
|
|
|
|
case GSK_GL_UNIFORM_TYPE_NONE:
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_GL_UNIFORM_TYPE_FLOAT:
|
|
|
|
add_float_row (store, title,
|
|
|
|
gsk_gl_shader_get_arg_float (shader, args, i));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_GL_UNIFORM_TYPE_INT:
|
|
|
|
add_int_row (store, title,
|
|
|
|
gsk_gl_shader_get_arg_int (shader, args, i));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_GL_UNIFORM_TYPE_UINT:
|
|
|
|
add_uint_row (store, title,
|
|
|
|
gsk_gl_shader_get_arg_uint (shader, args, i));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_GL_UNIFORM_TYPE_BOOL:
|
|
|
|
add_boolean_row (store, title,
|
|
|
|
gsk_gl_shader_get_arg_bool (shader, args, i));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_GL_UNIFORM_TYPE_VEC2:
|
|
|
|
{
|
|
|
|
graphene_vec2_t v;
|
|
|
|
gsk_gl_shader_get_arg_vec2 (shader, args, i, &v);
|
|
|
|
float x = graphene_vec2_get_x (&v);
|
|
|
|
float y = graphene_vec2_get_x (&v);
|
|
|
|
char *s = g_strdup_printf ("%.2f %.2f", x, y);
|
|
|
|
add_text_row (store, title, s);
|
|
|
|
g_free (s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_GL_UNIFORM_TYPE_VEC3:
|
|
|
|
{
|
|
|
|
graphene_vec3_t v;
|
|
|
|
gsk_gl_shader_get_arg_vec3 (shader, args, i, &v);
|
|
|
|
float x = graphene_vec3_get_x (&v);
|
|
|
|
float y = graphene_vec3_get_y (&v);
|
|
|
|
float z = graphene_vec3_get_z (&v);
|
|
|
|
char *s = g_strdup_printf ("%.2f %.2f %.2f", x, y, z);
|
|
|
|
add_text_row (store, title, s);
|
|
|
|
g_free (s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_GL_UNIFORM_TYPE_VEC4:
|
|
|
|
{
|
|
|
|
graphene_vec4_t v;
|
|
|
|
gsk_gl_shader_get_arg_vec4 (shader, args, i, &v);
|
|
|
|
float x = graphene_vec4_get_x (&v);
|
|
|
|
float y = graphene_vec4_get_y (&v);
|
|
|
|
float z = graphene_vec4_get_z (&v);
|
|
|
|
float w = graphene_vec4_get_w (&v);
|
|
|
|
char *s = g_strdup_printf ("%.2f %.2f %.2f %.2f", x, y, z, w);
|
|
|
|
add_text_row (store, title, s);
|
|
|
|
g_free (s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_free (title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-09-29 01:41:24 +00:00
|
|
|
case GSK_INSET_SHADOW_NODE:
|
2017-09-28 23:48:42 +00:00
|
|
|
{
|
2020-11-16 23:59:36 +00:00
|
|
|
const GdkRGBA *color = gsk_inset_shadow_node_get_color (node);
|
2017-09-29 01:41:24 +00:00
|
|
|
float dx = gsk_inset_shadow_node_get_dx (node);
|
|
|
|
float dy = gsk_inset_shadow_node_get_dy (node);
|
|
|
|
float spread = gsk_inset_shadow_node_get_spread (node);
|
|
|
|
float radius = gsk_inset_shadow_node_get_blur_radius (node);
|
2017-09-28 23:48:42 +00:00
|
|
|
|
2017-09-29 01:41:24 +00:00
|
|
|
add_color_row (store, "Color", color);
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%.2f %.2f", dx, dy);
|
|
|
|
add_text_row (store, "Offset", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
add_float_row (store, "Spread", spread);
|
|
|
|
add_float_row (store, "Radius", radius);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_OUTSET_SHADOW_NODE:
|
|
|
|
{
|
2020-11-16 23:59:36 +00:00
|
|
|
const GskRoundedRect *outline = gsk_outset_shadow_node_get_outline (node);
|
|
|
|
const GdkRGBA *color = gsk_outset_shadow_node_get_color (node);
|
2017-09-29 01:41:24 +00:00
|
|
|
float dx = gsk_outset_shadow_node_get_dx (node);
|
|
|
|
float dy = gsk_outset_shadow_node_get_dy (node);
|
|
|
|
float spread = gsk_outset_shadow_node_get_spread (node);
|
|
|
|
float radius = gsk_outset_shadow_node_get_blur_radius (node);
|
|
|
|
float rect[12];
|
|
|
|
|
|
|
|
gsk_rounded_rect_to_float (outline, rect);
|
|
|
|
tmp = g_strdup_printf ("%.2f x %.2f + %.2f + %.2f",
|
|
|
|
rect[2], rect[3], rect[0], rect[1]);
|
|
|
|
add_text_row (store, "Outline", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
add_color_row (store, "Color", color);
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%.2f %.2f", dx, dy);
|
|
|
|
add_text_row (store, "Offset", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
add_float_row (store, "Spread", spread);
|
|
|
|
add_float_row (store, "Radius", radius);
|
2017-09-28 23:48:42 +00:00
|
|
|
}
|
|
|
|
break;
|
2017-09-29 01:41:24 +00:00
|
|
|
|
2017-10-08 12:43:03 +00:00
|
|
|
case GSK_REPEAT_NODE:
|
|
|
|
{
|
2020-11-16 23:59:36 +00:00
|
|
|
const graphene_rect_t *child_bounds = gsk_repeat_node_get_child_bounds (node);
|
2017-10-08 12:43:03 +00:00
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%.2f x %.2f + %.2f + %.2f",
|
|
|
|
child_bounds->size.width,
|
|
|
|
child_bounds->size.height,
|
|
|
|
child_bounds->origin.x,
|
|
|
|
child_bounds->origin.y);
|
|
|
|
add_text_row (store, "Child Bounds", tmp);
|
|
|
|
g_free (tmp);
|
2017-10-23 09:24:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_COLOR_MATRIX_NODE:
|
|
|
|
{
|
2020-11-16 23:59:36 +00:00
|
|
|
const graphene_matrix_t *matrix = gsk_color_matrix_node_get_color_matrix (node);
|
|
|
|
const graphene_vec4_t *offset = gsk_color_matrix_node_get_color_offset (node);
|
2017-10-23 09:24:49 +00:00
|
|
|
|
|
|
|
tmp = g_strdup_printf ("% .2f % .2f % .2f % .2f\n"
|
|
|
|
"% .2f % .2f % .2f % .2f\n"
|
|
|
|
"% .2f % .2f % .2f % .2f\n"
|
|
|
|
"% .2f % .2f % .2f % .2f",
|
|
|
|
graphene_matrix_get_value (matrix, 0, 0),
|
|
|
|
graphene_matrix_get_value (matrix, 0, 1),
|
|
|
|
graphene_matrix_get_value (matrix, 0, 2),
|
|
|
|
graphene_matrix_get_value (matrix, 0, 3),
|
|
|
|
graphene_matrix_get_value (matrix, 1, 0),
|
|
|
|
graphene_matrix_get_value (matrix, 1, 1),
|
|
|
|
graphene_matrix_get_value (matrix, 1, 2),
|
|
|
|
graphene_matrix_get_value (matrix, 1, 3),
|
|
|
|
graphene_matrix_get_value (matrix, 2, 0),
|
|
|
|
graphene_matrix_get_value (matrix, 2, 1),
|
|
|
|
graphene_matrix_get_value (matrix, 2, 2),
|
|
|
|
graphene_matrix_get_value (matrix, 2, 3),
|
|
|
|
graphene_matrix_get_value (matrix, 3, 0),
|
|
|
|
graphene_matrix_get_value (matrix, 3, 1),
|
|
|
|
graphene_matrix_get_value (matrix, 3, 2),
|
|
|
|
graphene_matrix_get_value (matrix, 3, 3));
|
|
|
|
add_text_row (store, "Matrix", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
tmp = g_strdup_printf ("%.2f %.2f %.2f %.2f",
|
|
|
|
graphene_vec4_get_x (offset),
|
|
|
|
graphene_vec4_get_y (offset),
|
|
|
|
graphene_vec4_get_z (offset),
|
|
|
|
graphene_vec4_get_w (offset));
|
|
|
|
add_text_row (store, "Offset", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
}
|
2017-10-08 12:43:03 +00:00
|
|
|
break;
|
|
|
|
|
2017-10-06 19:19:42 +00:00
|
|
|
case GSK_CLIP_NODE:
|
2017-10-24 13:20:00 +00:00
|
|
|
{
|
2020-11-16 23:59:36 +00:00
|
|
|
const graphene_rect_t *clip = gsk_clip_node_get_clip (node);
|
2017-10-24 13:20:00 +00:00
|
|
|
tmp = g_strdup_printf ("%.2f x %.2f + %.2f + %.2f",
|
|
|
|
clip->size.width,
|
|
|
|
clip->size.height,
|
|
|
|
clip->origin.x,
|
|
|
|
clip->origin.y);
|
|
|
|
add_text_row (store, "Clip", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-10-06 19:19:42 +00:00
|
|
|
case GSK_ROUNDED_CLIP_NODE:
|
2017-10-24 13:20:00 +00:00
|
|
|
{
|
2020-11-16 23:59:36 +00:00
|
|
|
const GskRoundedRect *clip = gsk_rounded_clip_node_get_clip (node);
|
2017-10-24 13:20:00 +00:00
|
|
|
tmp = g_strdup_printf ("%.2f x %.2f + %.2f + %.2f",
|
|
|
|
clip->bounds.size.width,
|
|
|
|
clip->bounds.size.height,
|
|
|
|
clip->bounds.origin.x,
|
|
|
|
clip->bounds.origin.y);
|
|
|
|
add_text_row (store, "Clip", tmp);
|
|
|
|
g_free (tmp);
|
2017-12-06 14:54:19 +00:00
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%.2f x %.2f", clip->corner[0].width, clip->corner[0].height);
|
|
|
|
add_text_row (store, "Top Left Corner Size", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%.2f x %.2f", clip->corner[1].width, clip->corner[1].height);
|
|
|
|
add_text_row (store, "Top Right Corner Size", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%.2f x %.2f", clip->corner[2].width, clip->corner[2].height);
|
|
|
|
add_text_row (store, "Bottom Right Corner Size", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
tmp = g_strdup_printf ("%.2f x %.2f", clip->corner[3].width, clip->corner[3].height);
|
|
|
|
add_text_row (store, "Bottom Left Corner Size", tmp);
|
|
|
|
g_free (tmp);
|
2017-10-24 13:20:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_CONTAINER_NODE:
|
|
|
|
tmp = g_strdup_printf ("%d", gsk_container_node_get_n_children (node));
|
|
|
|
add_text_row (store, "Children", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
break;
|
|
|
|
|
2018-04-23 22:41:48 +00:00
|
|
|
case GSK_DEBUG_NODE:
|
|
|
|
add_text_row (store, "Message", gsk_debug_node_get_message (node));
|
|
|
|
break;
|
|
|
|
|
2017-10-28 18:30:03 +00:00
|
|
|
case GSK_SHADOW_NODE:
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < gsk_shadow_node_get_n_shadows (node); i++)
|
|
|
|
{
|
|
|
|
char *label;
|
|
|
|
char *value;
|
2020-11-16 23:59:36 +00:00
|
|
|
const GskShadow *shadow = gsk_shadow_node_get_shadow (node, i);
|
2017-10-28 18:30:03 +00:00
|
|
|
|
|
|
|
label = g_strdup_printf ("Color %d", i);
|
|
|
|
add_color_row (store, label, &shadow->color);
|
|
|
|
g_free (label);
|
|
|
|
|
|
|
|
label = g_strdup_printf ("Offset %d", i);
|
|
|
|
value = g_strdup_printf ("%.2f %.2f", shadow->dx, shadow->dy);
|
|
|
|
add_text_row (store, label, value);
|
|
|
|
g_free (value);
|
|
|
|
g_free (label);
|
|
|
|
|
|
|
|
label = g_strdup_printf ("Radius %d", i);
|
|
|
|
add_float_row (store, label, shadow->radius);
|
|
|
|
g_free (label);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-10-24 13:20:00 +00:00
|
|
|
case GSK_TRANSFORM_NODE:
|
2019-02-19 03:16:00 +00:00
|
|
|
{
|
2019-02-19 05:52:36 +00:00
|
|
|
static const char * category_names[] = {
|
2019-03-01 06:51:23 +00:00
|
|
|
[GSK_TRANSFORM_CATEGORY_UNKNOWN] = "unknown",
|
|
|
|
[GSK_TRANSFORM_CATEGORY_ANY] = "any",
|
|
|
|
[GSK_TRANSFORM_CATEGORY_3D] = "3D",
|
|
|
|
[GSK_TRANSFORM_CATEGORY_2D] = "2D",
|
|
|
|
[GSK_TRANSFORM_CATEGORY_2D_AFFINE] = "2D affine",
|
|
|
|
[GSK_TRANSFORM_CATEGORY_2D_TRANSLATE] = "2D translate",
|
|
|
|
[GSK_TRANSFORM_CATEGORY_IDENTITY] = "identity"
|
2019-02-19 05:52:36 +00:00
|
|
|
};
|
2019-03-01 05:35:55 +00:00
|
|
|
GskTransform *transform;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
transform = gsk_transform_node_get_transform (node);
|
|
|
|
s = gsk_transform_to_string (transform);
|
|
|
|
add_text_row (store, "Matrix", s);
|
|
|
|
g_free (s);
|
2019-03-01 06:51:23 +00:00
|
|
|
add_text_row (store, "Category", category_names[gsk_transform_get_category (transform)]);
|
2019-02-19 03:16:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_NOT_A_RENDER_NODE:
|
2017-10-06 19:19:42 +00:00
|
|
|
default:
|
|
|
|
break;
|
2017-09-28 19:08:08 +00:00
|
|
|
}
|
2016-11-19 01:59:10 +00:00
|
|
|
}
|
|
|
|
|
2018-09-05 03:53:33 +00:00
|
|
|
static GskRenderNode *
|
|
|
|
get_selected_node (GtkInspectorRecorder *recorder)
|
|
|
|
{
|
|
|
|
GtkTreeListRow *row_item;
|
|
|
|
GdkPaintable *paintable;
|
|
|
|
GskRenderNode *node;
|
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
row_item = gtk_single_selection_get_selected_item (recorder->render_node_selection);
|
2019-10-14 04:50:40 +00:00
|
|
|
if (row_item == NULL)
|
2018-09-05 03:53:33 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
paintable = gtk_tree_list_row_get_item (row_item);
|
|
|
|
node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
|
|
|
|
g_object_unref (paintable);
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2016-11-01 00:21:02 +00:00
|
|
|
static void
|
2018-09-05 03:53:33 +00:00
|
|
|
render_node_list_selection_changed (GtkListBox *list,
|
|
|
|
GtkListBoxRow *row,
|
2016-11-01 00:21:02 +00:00
|
|
|
GtkInspectorRecorder *recorder)
|
|
|
|
{
|
|
|
|
GskRenderNode *node;
|
2018-09-05 14:40:51 +00:00
|
|
|
GdkPaintable *paintable;
|
|
|
|
GtkTreeListRow *row_item;
|
2016-11-01 00:21:02 +00:00
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
row_item = gtk_single_selection_get_selected_item (recorder->render_node_selection);
|
2021-04-03 01:38:14 +00:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (recorder->render_node_save_button, row_item != NULL);
|
|
|
|
gtk_widget_set_sensitive (recorder->render_node_clip_button, row_item != NULL);
|
|
|
|
|
2019-10-14 04:50:40 +00:00
|
|
|
if (row_item == NULL)
|
|
|
|
return;
|
2016-11-01 00:21:02 +00:00
|
|
|
|
2018-09-05 14:40:51 +00:00
|
|
|
paintable = gtk_tree_list_row_get_item (row_item);
|
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
gtk_picture_set_paintable (GTK_PICTURE (recorder->render_node_view), paintable);
|
2018-09-05 14:40:51 +00:00
|
|
|
node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
|
2020-07-18 02:37:24 +00:00
|
|
|
populate_render_node_properties (GTK_LIST_STORE (recorder->render_node_properties), node);
|
2018-09-05 14:40:51 +00:00
|
|
|
|
|
|
|
g_object_unref (paintable);
|
2016-10-31 15:38:19 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 05:50:39 +00:00
|
|
|
static void
|
|
|
|
render_node_save_response (GtkWidget *dialog,
|
2020-06-27 09:04:03 +00:00
|
|
|
int response,
|
2016-12-21 05:50:39 +00:00
|
|
|
GskRenderNode *node)
|
|
|
|
{
|
|
|
|
gtk_widget_hide (dialog);
|
|
|
|
|
|
|
|
if (response == GTK_RESPONSE_ACCEPT)
|
|
|
|
{
|
|
|
|
GBytes *bytes = gsk_render_node_serialize (node);
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
if (!g_file_replace_contents (gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog)),
|
|
|
|
g_bytes_get_data (bytes, NULL),
|
|
|
|
g_bytes_get_size (bytes),
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&error))
|
|
|
|
{
|
|
|
|
GtkWidget *message_dialog;
|
|
|
|
|
|
|
|
message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_window_get_transient_for (GTK_WINDOW (dialog))),
|
|
|
|
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_INFO,
|
|
|
|
GTK_BUTTONS_OK,
|
|
|
|
_("Saving RenderNode failed"));
|
|
|
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
|
|
|
|
"%s", error->message);
|
2020-05-09 14:26:22 +00:00
|
|
|
g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
2016-12-21 05:50:39 +00:00
|
|
|
gtk_widget_show (message_dialog);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_bytes_unref (bytes);
|
|
|
|
}
|
|
|
|
|
2020-05-09 14:26:22 +00:00
|
|
|
gtk_window_destroy (GTK_WINDOW (dialog));
|
2016-12-21 05:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
render_node_save (GtkButton *button,
|
|
|
|
GtkInspectorRecorder *recorder)
|
|
|
|
{
|
|
|
|
GskRenderNode *node;
|
|
|
|
GtkWidget *dialog;
|
2018-04-24 01:46:44 +00:00
|
|
|
char *filename, *nodename;
|
2016-12-21 05:50:39 +00:00
|
|
|
|
2018-09-05 03:53:33 +00:00
|
|
|
node = get_selected_node (recorder);
|
|
|
|
if (node == NULL)
|
2016-12-21 05:50:39 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
dialog = gtk_file_chooser_dialog_new ("",
|
2019-05-20 04:47:50 +00:00
|
|
|
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (recorder))),
|
2016-12-21 05:50:39 +00:00
|
|
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("_Save"), GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL);
|
2018-04-24 01:46:44 +00:00
|
|
|
nodename = node_name (node);
|
|
|
|
filename = g_strdup_printf ("%s.node", nodename);
|
|
|
|
g_free (nodename);
|
2016-12-21 05:50:39 +00:00
|
|
|
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename);
|
|
|
|
g_free (filename);
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
|
|
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
|
|
|
g_signal_connect (dialog, "response", G_CALLBACK (render_node_save_response), node);
|
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
|
2021-04-03 01:38:14 +00:00
|
|
|
static void
|
|
|
|
render_node_clip (GtkButton *button,
|
|
|
|
GtkInspectorRecorder *recorder)
|
|
|
|
{
|
|
|
|
GskRenderNode *node;
|
|
|
|
GdkClipboard *clipboard;
|
|
|
|
GBytes *bytes;
|
|
|
|
GdkContentProvider *content;
|
|
|
|
|
|
|
|
node = get_selected_node (recorder);
|
|
|
|
if (node == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bytes = gsk_render_node_serialize (node);
|
|
|
|
content = gdk_content_provider_new_for_bytes ("text/plain;charset=utf-8", bytes);
|
|
|
|
|
|
|
|
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (recorder));
|
|
|
|
|
|
|
|
gdk_clipboard_set_content (clipboard, content);
|
|
|
|
|
|
|
|
g_object_unref (content);
|
|
|
|
g_bytes_unref (bytes);
|
|
|
|
}
|
|
|
|
|
2020-08-30 12:59:13 +00:00
|
|
|
static void
|
|
|
|
toggle_dark_mode (GtkToggleButton *button,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *picture = data;
|
|
|
|
|
|
|
|
if (gtk_toggle_button_get_active (button))
|
|
|
|
{
|
|
|
|
gtk_widget_add_css_class (picture, "dark");
|
|
|
|
gtk_widget_remove_css_class (picture, "light");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_remove_css_class (picture, "dark");
|
|
|
|
gtk_widget_add_css_class (picture, "light");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-30 05:11:38 +00:00
|
|
|
static GtkWidget *
|
|
|
|
gtk_inspector_recorder_recordings_list_create_widget (gpointer item,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkInspectorRecording *recording = GTK_INSPECTOR_RECORDING (item);
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
2016-11-20 00:41:43 +00:00
|
|
|
if (GTK_INSPECTOR_IS_RENDER_RECORDING (recording))
|
|
|
|
{
|
2016-11-20 02:53:26 +00:00
|
|
|
cairo_region_t *region;
|
|
|
|
GtkWidget *hbox, *label, *button;
|
|
|
|
|
|
|
|
widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
|
|
|
|
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (widget), hbox);
|
2016-11-20 02:53:26 +00:00
|
|
|
|
|
|
|
region = cairo_region_create_rectangle (
|
|
|
|
gtk_inspector_render_recording_get_area (GTK_INSPECTOR_RENDER_RECORDING (recording)));
|
|
|
|
cairo_region_subtract (region,
|
|
|
|
gtk_inspector_render_recording_get_clip_region (GTK_INSPECTOR_RENDER_RECORDING (recording)));
|
|
|
|
cairo_region_destroy (region);
|
2017-01-19 11:26:56 +00:00
|
|
|
|
2020-06-27 09:15:51 +00:00
|
|
|
label = gtk_label_new ("<b>Frame</b>");
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
|
|
|
|
gtk_widget_set_hexpand (label, TRUE);
|
2016-11-20 02:53:26 +00:00
|
|
|
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (hbox), label);
|
2016-11-20 02:53:26 +00:00
|
|
|
|
|
|
|
button = gtk_toggle_button_new ();
|
2020-04-17 04:20:09 +00:00
|
|
|
gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
|
2016-11-20 02:53:26 +00:00
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (button), "view-more-symbolic");
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (hbox), button);
|
2016-11-20 02:53:26 +00:00
|
|
|
|
|
|
|
label = gtk_label_new (gtk_inspector_render_recording_get_profiler_info (GTK_INSPECTOR_RENDER_RECORDING (recording)));
|
2017-01-19 11:26:56 +00:00
|
|
|
gtk_widget_hide (label);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (widget), label);
|
2016-11-20 02:53:26 +00:00
|
|
|
g_object_bind_property (button, "active", label, "visible", 0);
|
2016-11-20 00:41:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-20 02:53:26 +00:00
|
|
|
widget = gtk_label_new ("<b>Start of Recording</b>");
|
|
|
|
gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
|
2016-11-20 00:41:43 +00:00
|
|
|
}
|
2016-10-30 05:11:38 +00:00
|
|
|
|
2020-02-26 01:57:20 +00:00
|
|
|
gtk_widget_set_margin_start (widget, 6);
|
|
|
|
gtk_widget_set_margin_end (widget, 6);
|
|
|
|
gtk_widget_set_margin_top (widget, 6);
|
|
|
|
gtk_widget_set_margin_bottom (widget, 6);
|
|
|
|
|
2016-10-30 05:11:38 +00:00
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
|
2017-09-28 22:17:38 +00:00
|
|
|
static void
|
|
|
|
node_property_activated (GtkTreeView *tv,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeViewColumn *col,
|
|
|
|
GtkInspectorRecorder *recorder)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GdkRectangle rect;
|
2018-03-15 01:36:13 +00:00
|
|
|
GdkTexture *texture;
|
2017-09-28 22:17:38 +00:00
|
|
|
gboolean visible;
|
|
|
|
GtkWidget *popover;
|
|
|
|
GtkWidget *image;
|
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (recorder->render_node_properties), &iter, path);
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (recorder->render_node_properties), &iter,
|
2017-09-28 22:17:38 +00:00
|
|
|
2, &visible,
|
2018-03-15 01:36:13 +00:00
|
|
|
3, &texture,
|
2017-09-28 22:17:38 +00:00
|
|
|
-1);
|
|
|
|
gtk_tree_view_get_cell_area (tv, path, col, &rect);
|
|
|
|
gtk_tree_view_convert_bin_window_to_widget_coords (tv, rect.x, rect.y, &rect.x, &rect.y);
|
|
|
|
|
2018-03-15 01:36:13 +00:00
|
|
|
if (texture == NULL || visible)
|
2017-09-28 22:17:38 +00:00
|
|
|
return;
|
|
|
|
|
2020-02-24 12:21:46 +00:00
|
|
|
popover = gtk_popover_new ();
|
|
|
|
gtk_widget_set_parent (popover, GTK_WIDGET (tv));
|
2017-09-28 22:17:38 +00:00
|
|
|
gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
|
|
|
|
|
2018-03-16 03:29:42 +00:00
|
|
|
image = gtk_image_new_from_paintable (GDK_PAINTABLE (texture));
|
2020-02-26 01:57:20 +00:00
|
|
|
gtk_widget_set_margin_start (image, 20);
|
|
|
|
gtk_widget_set_margin_end (image, 20);
|
|
|
|
gtk_widget_set_margin_top (image, 20);
|
|
|
|
gtk_widget_set_margin_bottom (image, 20);
|
2020-05-02 02:22:20 +00:00
|
|
|
gtk_popover_set_child (GTK_POPOVER (popover), image);
|
2017-09-28 22:17:38 +00:00
|
|
|
gtk_popover_popup (GTK_POPOVER (popover));
|
|
|
|
|
2020-05-09 14:33:02 +00:00
|
|
|
g_signal_connect (popover, "unmap", G_CALLBACK (gtk_widget_unparent), NULL);
|
2017-09-28 22:17:38 +00:00
|
|
|
|
2018-03-15 01:36:13 +00:00
|
|
|
g_object_unref (texture);
|
2017-09-28 22:17:38 +00:00
|
|
|
}
|
|
|
|
|
2016-11-01 17:03:16 +00:00
|
|
|
static void
|
|
|
|
gtk_inspector_recorder_get_property (GObject *object,
|
|
|
|
guint param_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkInspectorRecorder *recorder = GTK_INSPECTOR_RECORDER (object);
|
|
|
|
|
|
|
|
switch (param_id)
|
|
|
|
{
|
|
|
|
case PROP_RECORDING:
|
2020-07-18 02:37:24 +00:00
|
|
|
g_value_set_boolean (value, recorder->recording != NULL);
|
2016-11-01 17:03:16 +00:00
|
|
|
break;
|
|
|
|
|
2017-09-01 15:55:23 +00:00
|
|
|
case PROP_DEBUG_NODES:
|
2020-07-18 02:37:24 +00:00
|
|
|
g_value_set_boolean (value, recorder->debug_nodes);
|
2017-09-01 15:55:23 +00:00
|
|
|
break;
|
|
|
|
|
2016-11-01 17:03:16 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_inspector_recorder_set_property (GObject *object,
|
|
|
|
guint param_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkInspectorRecorder *recorder = GTK_INSPECTOR_RECORDER (object);
|
|
|
|
|
|
|
|
switch (param_id)
|
|
|
|
{
|
|
|
|
case PROP_RECORDING:
|
|
|
|
gtk_inspector_recorder_set_recording (recorder, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
|
2017-09-01 15:55:23 +00:00
|
|
|
case PROP_DEBUG_NODES:
|
|
|
|
gtk_inspector_recorder_set_debug_nodes (recorder, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
|
2016-11-01 17:03:16 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-05 03:53:33 +00:00
|
|
|
static void
|
|
|
|
gtk_inspector_recorder_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GtkInspectorRecorder *recorder = GTK_INSPECTOR_RECORDER (object);
|
|
|
|
|
2020-07-18 02:44:01 +00:00
|
|
|
g_clear_pointer (&recorder->box, gtk_widget_unparent);
|
2020-07-18 02:37:24 +00:00
|
|
|
g_clear_object (&recorder->render_node_model);
|
|
|
|
g_clear_object (&recorder->render_node_root_model);
|
|
|
|
g_clear_object (&recorder->render_node_selection);
|
2018-09-05 03:53:33 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_inspector_recorder_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2016-10-29 19:11:23 +00:00
|
|
|
static void
|
|
|
|
gtk_inspector_recorder_class_init (GtkInspectorRecorderClass *klass)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2016-11-01 17:03:16 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->get_property = gtk_inspector_recorder_get_property;
|
|
|
|
object_class->set_property = gtk_inspector_recorder_set_property;
|
2018-09-05 03:53:33 +00:00
|
|
|
object_class->dispose = gtk_inspector_recorder_dispose;
|
2016-11-01 17:03:16 +00:00
|
|
|
|
|
|
|
props[PROP_RECORDING] =
|
|
|
|
g_param_spec_boolean ("recording",
|
|
|
|
"Recording",
|
|
|
|
"Whether the recorder is currently recording",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE);
|
2017-09-01 15:55:23 +00:00
|
|
|
props[PROP_DEBUG_NODES] =
|
|
|
|
g_param_spec_boolean ("debug-nodes",
|
|
|
|
"Debug nodes",
|
|
|
|
"Whether to insert extra debug nodes in the tree",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE);
|
2016-11-01 17:03:16 +00:00
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, LAST_PROP, props);
|
2016-10-29 19:11:23 +00:00
|
|
|
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/recorder.ui");
|
|
|
|
|
2020-07-18 02:44:01 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, box);
|
2020-07-18 02:37:24 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, recordings);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, recordings_list);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, render_node_view);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, render_node_list);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, render_node_save_button);
|
2021-04-03 01:38:14 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, render_node_clip_button);
|
2020-07-18 02:37:24 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, node_property_tree);
|
2016-10-31 15:38:19 +00:00
|
|
|
|
2016-11-01 17:32:50 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, recordings_clear_all);
|
2016-10-31 15:38:19 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, recordings_list_row_selected);
|
2016-12-21 05:50:39 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, render_node_save);
|
2021-04-03 01:38:14 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, render_node_clip);
|
2017-09-28 22:17:38 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, node_property_activated);
|
2020-08-30 12:59:13 +00:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, toggle_dark_mode);
|
2020-05-03 23:31:11 +00:00
|
|
|
|
|
|
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
2016-10-29 19:11:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-11-01 00:21:02 +00:00
|
|
|
gtk_inspector_recorder_init (GtkInspectorRecorder *recorder)
|
2016-10-29 19:11:23 +00:00
|
|
|
{
|
2019-10-14 04:50:40 +00:00
|
|
|
GtkListItemFactory *factory;
|
2016-11-01 00:21:02 +00:00
|
|
|
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (recorder));
|
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
gtk_list_box_bind_model (GTK_LIST_BOX (recorder->recordings_list),
|
|
|
|
recorder->recordings,
|
2016-11-01 00:21:02 +00:00
|
|
|
gtk_inspector_recorder_recordings_list_create_widget,
|
2016-11-20 02:53:26 +00:00
|
|
|
recorder,
|
2016-11-01 00:21:02 +00:00
|
|
|
NULL);
|
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
recorder->render_node_root_model = g_list_store_new (GDK_TYPE_PAINTABLE);
|
2020-07-26 20:38:53 +00:00
|
|
|
recorder->render_node_model = gtk_tree_list_model_new (g_object_ref (G_LIST_MODEL (recorder->render_node_root_model)),
|
|
|
|
FALSE,
|
2019-10-14 04:50:40 +00:00
|
|
|
TRUE,
|
|
|
|
create_list_model_for_render_node_paintable,
|
|
|
|
NULL, NULL);
|
2020-07-26 21:16:15 +00:00
|
|
|
recorder->render_node_selection = gtk_single_selection_new (g_object_ref (G_LIST_MODEL (recorder->render_node_model)));
|
2020-07-18 02:37:24 +00:00
|
|
|
g_signal_connect (recorder->render_node_selection, "notify::selected-item", G_CALLBACK (render_node_list_selection_changed), recorder);
|
2019-10-14 04:50:40 +00:00
|
|
|
|
2020-06-29 20:37:14 +00:00
|
|
|
factory = gtk_signal_list_item_factory_new ();
|
|
|
|
g_signal_connect (factory, "setup", G_CALLBACK (setup_widget_for_render_node), NULL);
|
|
|
|
g_signal_connect (factory, "bind", G_CALLBACK (bind_widget_for_render_node), NULL);
|
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
gtk_list_view_set_factory (GTK_LIST_VIEW (recorder->render_node_list), factory);
|
2019-10-14 04:50:40 +00:00
|
|
|
g_object_unref (factory);
|
2020-07-18 02:37:24 +00:00
|
|
|
gtk_list_view_set_model (GTK_LIST_VIEW (recorder->render_node_list),
|
2020-08-31 21:06:48 +00:00
|
|
|
GTK_SELECTION_MODEL (recorder->render_node_selection));
|
2019-10-14 04:50:40 +00:00
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
recorder->render_node_properties = GTK_TREE_MODEL (gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_TEXTURE));
|
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (recorder->node_property_tree), recorder->render_node_properties);
|
|
|
|
g_object_unref (recorder->render_node_properties);
|
2016-10-29 19:11:23 +00:00
|
|
|
}
|
|
|
|
|
2016-11-19 19:55:08 +00:00
|
|
|
static void
|
|
|
|
gtk_inspector_recorder_add_recording (GtkInspectorRecorder *recorder,
|
|
|
|
GtkInspectorRecording *recording)
|
|
|
|
{
|
2020-07-18 02:37:24 +00:00
|
|
|
g_list_store_append (G_LIST_STORE (recorder->recordings), recording);
|
2016-11-19 19:55:08 +00:00
|
|
|
}
|
|
|
|
|
2016-11-20 00:41:43 +00:00
|
|
|
void
|
|
|
|
gtk_inspector_recorder_set_recording (GtkInspectorRecorder *recorder,
|
|
|
|
gboolean recording)
|
|
|
|
{
|
|
|
|
if (gtk_inspector_recorder_is_recording (recorder) == recording)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (recording)
|
|
|
|
{
|
2020-07-18 02:37:24 +00:00
|
|
|
recorder->recording = gtk_inspector_start_recording_new ();
|
|
|
|
gtk_inspector_recorder_add_recording (recorder, recorder->recording);
|
2016-11-20 00:41:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-18 02:37:24 +00:00
|
|
|
g_clear_object (&recorder->recording);
|
2016-11-20 00:41:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (recorder), props[PROP_RECORDING]);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gtk_inspector_recorder_is_recording (GtkInspectorRecorder *recorder)
|
|
|
|
{
|
2020-07-18 02:37:24 +00:00
|
|
|
return recorder->recording != NULL;
|
2016-11-20 00:41:43 +00:00
|
|
|
}
|
|
|
|
|
2016-10-30 05:11:38 +00:00
|
|
|
void
|
|
|
|
gtk_inspector_recorder_record_render (GtkInspectorRecorder *recorder,
|
|
|
|
GtkWidget *widget,
|
2016-11-20 02:52:56 +00:00
|
|
|
GskRenderer *renderer,
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *surface,
|
2016-10-30 05:11:38 +00:00
|
|
|
const cairo_region_t *region,
|
|
|
|
GskRenderNode *node)
|
|
|
|
{
|
|
|
|
GtkInspectorRecording *recording;
|
|
|
|
GdkFrameClock *frame_clock;
|
|
|
|
|
2016-11-01 17:03:16 +00:00
|
|
|
if (!gtk_inspector_recorder_is_recording (recorder))
|
|
|
|
return;
|
|
|
|
|
2016-10-30 05:11:38 +00:00
|
|
|
frame_clock = gtk_widget_get_frame_clock (widget);
|
|
|
|
|
|
|
|
recording = gtk_inspector_render_recording_new (gdk_frame_clock_get_frame_time (frame_clock),
|
2016-11-20 02:52:56 +00:00
|
|
|
gsk_renderer_get_profiler (renderer),
|
2016-10-30 05:11:38 +00:00
|
|
|
&(GdkRectangle) { 0, 0,
|
2018-03-21 10:49:14 +00:00
|
|
|
gdk_surface_get_width (surface),
|
|
|
|
gdk_surface_get_height (surface) },
|
2016-10-30 05:11:38 +00:00
|
|
|
region,
|
|
|
|
node);
|
2016-11-19 19:55:08 +00:00
|
|
|
gtk_inspector_recorder_add_recording (recorder, recording);
|
2016-10-30 05:11:38 +00:00
|
|
|
g_object_unref (recording);
|
|
|
|
}
|
|
|
|
|
2017-09-01 15:55:23 +00:00
|
|
|
void
|
|
|
|
gtk_inspector_recorder_set_debug_nodes (GtkInspectorRecorder *recorder,
|
|
|
|
gboolean debug_nodes)
|
|
|
|
{
|
|
|
|
guint flags;
|
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
if (recorder->debug_nodes == debug_nodes)
|
2017-09-01 15:55:23 +00:00
|
|
|
return;
|
|
|
|
|
2020-07-18 02:37:24 +00:00
|
|
|
recorder->debug_nodes = debug_nodes;
|
2017-09-01 15:55:23 +00:00
|
|
|
|
|
|
|
flags = gtk_get_debug_flags ();
|
|
|
|
|
|
|
|
if (debug_nodes)
|
|
|
|
flags |= GTK_DEBUG_SNAPSHOT;
|
|
|
|
else
|
|
|
|
flags &= ~GTK_DEBUG_SNAPSHOT;
|
|
|
|
|
|
|
|
gtk_set_debug_flags (flags);
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (recorder), props[PROP_DEBUG_NODES]);
|
|
|
|
}
|
|
|
|
|
2016-10-29 19:11:23 +00:00
|
|
|
// vim: set et sw=2 ts=2:
|