ottie: Add printing
Add and implement ottie_object_print and ottie_creation_to_bytes.
This commit is contained in:
@@ -28,6 +28,7 @@ ottie_private_sources = files([
|
||||
'ottiestrokeshape.c',
|
||||
'ottietransform.c',
|
||||
'ottietrimshape.c',
|
||||
'ottieprinter.c',
|
||||
])
|
||||
|
||||
ottie_public_headers = files([
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ottiecolorvalueprivate.h"
|
||||
|
||||
#include "ottieparserprivate.h"
|
||||
#include "ottieprinterprivate.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
@@ -69,6 +70,7 @@ ottie_color_value_interpolate (const GdkRGBA *start,
|
||||
#define OTTIE_KEYFRAMES_DIMENSIONS 4
|
||||
#define OTTIE_KEYFRAMES_PARSE_FUNC ottie_color_value_parse_one
|
||||
#define OTTIE_KEYFRAMES_INTERPOLATE_FUNC ottie_color_value_interpolate
|
||||
#define OTTIE_KEYFRAMES_PRINT_FUNC ottie_printer_add_color
|
||||
#include "ottiekeyframesimpl.c"
|
||||
|
||||
void
|
||||
@@ -147,3 +149,18 @@ ottie_color_value_parse (JsonReader *reader,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_color_value_print (OttieColorValue *self,
|
||||
const char *name,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
ottie_printer_start_object (printer, name);
|
||||
|
||||
ottie_printer_add_boolean (printer, "a", !self->is_static);
|
||||
if (self->is_static)
|
||||
ottie_printer_add_color (printer, "k", &self->static_value);
|
||||
else
|
||||
ottie_color_keyframes_print (self->keyframes, printer);
|
||||
|
||||
ottie_printer_end_object (printer);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <json-glib/json-glib.h>
|
||||
|
||||
#include "ottieprinterprivate.h"
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@@ -48,6 +49,9 @@ void ottie_color_value_get (OttieColorValue
|
||||
gboolean ottie_color_value_parse (JsonReader *reader,
|
||||
gsize offset,
|
||||
gpointer data);
|
||||
void ottie_color_value_print (OttieColorValue *self,
|
||||
const char *name,
|
||||
OttiePrinter *printer);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -276,3 +276,13 @@ ottie_composition_parse_layers (JsonReader *reader,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_composition_print (OttiePrinter *printer,
|
||||
OttieComposition *composition)
|
||||
{
|
||||
for (int i = 0; i < ottie_layer_list_get_size (&composition->layers); i++)
|
||||
{
|
||||
OttieObject *obj = OTTIE_OBJECT (ottie_layer_list_get (&composition->layers, i));
|
||||
ottie_object_print (obj, NULL, printer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,21 @@ ottie_composition_layer_render (OttieLayer *layer,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_composition_layer_print (OttieObject *obj,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttieCompositionLayer *self = OTTIE_COMPOSITION_LAYER (obj);
|
||||
|
||||
OTTIE_OBJECT_CLASS (ottie_composition_layer_parent_class)->print (obj, printer);
|
||||
|
||||
if (self->ref_id)
|
||||
ottie_printer_add_string (printer, "refId", self->ref_id);
|
||||
|
||||
ottie_printer_add_double (printer, "w", self->width);
|
||||
ottie_printer_add_double (printer, "h", self->height);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_composition_layer_dispose (GObject *object)
|
||||
{
|
||||
@@ -106,9 +121,12 @@ ottie_composition_layer_dispose (GObject *object)
|
||||
static void
|
||||
ottie_composition_layer_class_init (OttieCompositionLayerClass *klass)
|
||||
{
|
||||
OttieObjectClass *oobject_class = OTTIE_OBJECT_CLASS (klass);
|
||||
OttieLayerClass *layer_class = OTTIE_LAYER_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
oobject_class->print = ottie_composition_layer_print;
|
||||
|
||||
layer_class->update = ottie_composition_layer_update;
|
||||
layer_class->render = ottie_composition_layer_render;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define __OTTIE_COMPOSITION_PRIVATE_H__
|
||||
|
||||
#include "ottielayerprivate.h"
|
||||
#include "ottieprinterprivate.h"
|
||||
|
||||
#include <json-glib/json-glib.h>
|
||||
|
||||
@@ -41,6 +42,9 @@ gboolean ottie_composition_parse_layers (JsonReader
|
||||
gsize offset,
|
||||
gpointer data);
|
||||
|
||||
void ottie_composition_print (OttiePrinter *printer,
|
||||
OttieComposition *composition);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __OTTIE_COMPOSITION_PRIVATE_H__ */
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "ottielayerprivate.h"
|
||||
#include "ottieparserprivate.h"
|
||||
#include "ottiecompositionprivate.h"
|
||||
#include "ottieprinterprivate.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <json-glib/json-glib.h>
|
||||
@@ -758,3 +759,53 @@ ottie_creation_get_composition (OttieCreation *self)
|
||||
return self->layers;
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_creation_print (OttiePrinter *printer,
|
||||
OttieCreation *self)
|
||||
{
|
||||
const char *id;
|
||||
OttieComposition *composition;
|
||||
GHashTableIter iter;
|
||||
|
||||
ottie_printer_start_object (printer, NULL);
|
||||
|
||||
ottie_printer_add_double (printer, "fr", self->frame_rate);
|
||||
ottie_printer_add_double (printer, "w", self->width);
|
||||
ottie_printer_add_double (printer, "h", self->height);
|
||||
ottie_printer_add_string (printer, "nm", self->name);
|
||||
ottie_printer_add_double (printer, "ip", self->start_frame);
|
||||
ottie_printer_add_double (printer, "op", self->end_frame);
|
||||
ottie_printer_add_int (printer, "ddd", 0);
|
||||
|
||||
ottie_printer_start_array (printer, "assets");
|
||||
g_hash_table_iter_init (&iter, self->composition_assets);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *)&id, (gpointer *)&composition))
|
||||
{
|
||||
ottie_printer_start_object (printer, NULL);
|
||||
ottie_printer_add_string (printer, "id", id);
|
||||
ottie_printer_start_array (printer, "layers");
|
||||
ottie_composition_print (printer, composition);
|
||||
ottie_printer_end_array (printer);
|
||||
ottie_printer_end_object (printer);
|
||||
}
|
||||
|
||||
ottie_printer_end_array (printer);
|
||||
|
||||
ottie_printer_start_array (printer, "layers");
|
||||
ottie_composition_print (printer, self->layers);
|
||||
ottie_printer_end_array (printer);
|
||||
|
||||
ottie_printer_end_object (printer);
|
||||
}
|
||||
|
||||
GBytes *
|
||||
ottie_creation_to_bytes (OttieCreation *self)
|
||||
{
|
||||
OttiePrinter p;
|
||||
|
||||
ottie_printer_init (&p);
|
||||
|
||||
ottie_creation_print (&p, self);
|
||||
|
||||
return g_string_free_to_bytes (p.str);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,9 @@ gboolean ottie_creation_is_loading (OttieCreation
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean ottie_creation_is_prepared (OttieCreation *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GBytes * ottie_creation_to_bytes (OttieCreation *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const char * ottie_creation_get_name (OttieCreation *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
||||
@@ -58,6 +58,7 @@ ottie_double_value_interpolate (double start,
|
||||
#define OTTIE_KEYFRAMES_ELEMENT_TYPE double
|
||||
#define OTTIE_KEYFRAMES_PARSE_FUNC ottie_double_value_parse_value
|
||||
#define OTTIE_KEYFRAMES_INTERPOLATE_FUNC ottie_double_value_interpolate
|
||||
#define OTTIE_KEYFRAMES_PRINT_FUNC ottie_printer_add_double
|
||||
#include "ottiekeyframesimpl.c"
|
||||
|
||||
void
|
||||
@@ -119,3 +120,19 @@ ottie_double_value_parse (JsonReader *reader,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_double_value_print (OttieDoubleValue *self,
|
||||
const char *name,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
ottie_printer_start_object (printer, name);
|
||||
|
||||
ottie_printer_add_boolean (printer, "a", !self->is_static);
|
||||
if (self->is_static)
|
||||
ottie_printer_add_double (printer, "k", self->static_value);
|
||||
else
|
||||
ottie_double_keyframes_print (self->keyframes, printer);
|
||||
|
||||
ottie_printer_end_object (printer);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define __OTTIE_DOUBLE_VALUE_PRIVATE_H__
|
||||
|
||||
#include <json-glib/json-glib.h>
|
||||
#include "ottie/ottieprinterprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -47,6 +48,10 @@ gboolean ottie_double_value_parse (JsonReader
|
||||
gsize offset,
|
||||
gpointer data);
|
||||
|
||||
void ottie_double_value_print (OttieDoubleValue *self,
|
||||
const char *name,
|
||||
OttiePrinter *printer);
|
||||
|
||||
static inline gboolean
|
||||
ottie_double_value_is_static (OttieDoubleValue *self)
|
||||
{
|
||||
|
||||
@@ -85,6 +85,20 @@ ottie_ellipse_shape_render (OttieShape *shape,
|
||||
gsk_path_builder_free_to_path (builder));
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_ellipse_shape_print (OttieObject *obj,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttieEllipseShape *self = OTTIE_ELLIPSE_SHAPE (obj);
|
||||
|
||||
OTTIE_OBJECT_CLASS (ottie_ellipse_shape_parent_class)->print (obj, printer);
|
||||
|
||||
ottie_printer_add_string (printer, "ty", "el");
|
||||
ottie_printer_add_double (printer, "d", self->diellipseion);
|
||||
ottie_point_value_print (&self->position, "p", printer);
|
||||
ottie_point_value_print (&self->size, "s", printer);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_ellipse_shape_dispose (GObject *object)
|
||||
{
|
||||
@@ -99,9 +113,12 @@ ottie_ellipse_shape_dispose (GObject *object)
|
||||
static void
|
||||
ottie_ellipse_shape_class_init (OttieEllipseShapeClass *klass)
|
||||
{
|
||||
OttieObjectClass *oobject_class = OTTIE_OBJECT_CLASS (klass);
|
||||
OttieShapeClass *shape_class = OTTIE_SHAPE_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
oobject_class->print = ottie_ellipse_shape_print;
|
||||
|
||||
shape_class->render = ottie_ellipse_shape_render;
|
||||
|
||||
gobject_class->dispose = ottie_ellipse_shape_dispose;
|
||||
|
||||
@@ -77,6 +77,21 @@ ottie_fill_shape_render (OttieShape *shape,
|
||||
gsk_render_node_unref (color_node);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_fill_shape_print (OttieObject *obj,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttieFillShape *self = OTTIE_FILL_SHAPE (obj);
|
||||
|
||||
OTTIE_OBJECT_CLASS (ottie_fill_shape_parent_class)->print (obj, printer);
|
||||
|
||||
ottie_printer_add_string (printer, "ty", "fl");
|
||||
ottie_double_value_print (&self->opacity, "o", printer);
|
||||
ottie_color_value_print (&self->color, "c", printer);
|
||||
ottie_printer_add_int (printer, "bm", self->blend_mode);
|
||||
ottie_printer_add_int (printer, "r", self->fill_rule);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_fill_shape_dispose (GObject *object)
|
||||
{
|
||||
@@ -91,9 +106,12 @@ ottie_fill_shape_dispose (GObject *object)
|
||||
static void
|
||||
ottie_fill_shape_class_init (OttieFillShapeClass *klass)
|
||||
{
|
||||
OttieObjectClass *oobject_class = OTTIE_OBJECT_CLASS (klass);
|
||||
OttieShapeClass *shape_class = OTTIE_SHAPE_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
oobject_class->print = ottie_fill_shape_print;
|
||||
|
||||
shape_class->render = ottie_fill_shape_render;
|
||||
|
||||
gobject_class->dispose = ottie_fill_shape_dispose;
|
||||
|
||||
@@ -113,6 +113,19 @@ ottie_group_shape_render (OttieShape *shape,
|
||||
ottie_render_clear (&child_render);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_group_shape_print (OttieObject *obj,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttieGroupShape *self = OTTIE_GROUP_SHAPE (obj);
|
||||
|
||||
OTTIE_OBJECT_CLASS (ottie_group_shape_parent_class)->print (obj, printer);
|
||||
|
||||
ottie_printer_add_string (printer, "ty", "gr");
|
||||
ottie_printer_add_int (printer, "bm", self->blend_mode);
|
||||
ottie_group_shape_print_shapes (OTTIE_SHAPE (self), "it", printer);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_group_shape_dispose (GObject *object)
|
||||
{
|
||||
@@ -126,9 +139,12 @@ ottie_group_shape_dispose (GObject *object)
|
||||
static void
|
||||
ottie_group_shape_class_init (OttieGroupShapeClass *klass)
|
||||
{
|
||||
OttieObjectClass *oobject_class = OTTIE_OBJECT_CLASS (klass);
|
||||
OttieShapeClass *shape_class = OTTIE_SHAPE_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
oobject_class->print = ottie_group_shape_print;
|
||||
|
||||
shape_class->render = ottie_group_shape_render;
|
||||
|
||||
gobject_class->dispose = ottie_group_shape_dispose;
|
||||
@@ -245,3 +261,21 @@ ottie_group_shape_parse (JsonReader *reader)
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_group_shape_print_shapes (OttieShape *shape,
|
||||
const char *name,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttieGroupShape *self = OTTIE_GROUP_SHAPE (shape);
|
||||
|
||||
ottie_printer_start_array (printer, name);
|
||||
|
||||
for (gsize i = 0; i < ottie_shape_list_get_size (&self->shapes); i++)
|
||||
{
|
||||
OttieObject *obj = OTTIE_OBJECT (ottie_shape_list_get (&self->shapes, i));
|
||||
ottie_object_print (obj, NULL, printer);
|
||||
}
|
||||
|
||||
ottie_printer_end_array (printer);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,10 @@ gboolean ottie_group_shape_parse_shapes (JsonReader
|
||||
gsize offset,
|
||||
gpointer data);
|
||||
|
||||
void ottie_group_shape_print_shapes (OttieShape *shape,
|
||||
const char *name,
|
||||
OttiePrinter *printer);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __OTTIE_GROUP_SHAPE_PRIVATE_H__ */
|
||||
|
||||
@@ -364,6 +364,63 @@ ottie_keyframes(parse) (JsonReader *reader)
|
||||
return parse.keyframes;
|
||||
}
|
||||
|
||||
static inline void
|
||||
ottie_keyframes(print_control_point) (OttiePrinter *printer,
|
||||
const char *name,
|
||||
const OttieControlPoint *c)
|
||||
{
|
||||
ottie_printer_start_object (printer, name);
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append_printf (printer->str, "\"x\" : [");
|
||||
for (int i = 0; i < OTTIE_KEYFRAMES_DIMENSIONS; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
g_string_append (printer->str, ",");
|
||||
g_string_append_printf (printer->str, " %g", c->x[i]);
|
||||
}
|
||||
g_string_append_printf (printer->str, " ],\n");
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append_printf (printer->str, "\"y\" : [");
|
||||
for (int i = 0; i < OTTIE_KEYFRAMES_DIMENSIONS; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
g_string_append (printer->str, ",");
|
||||
g_string_append_printf (printer->str, " %g", c->x[i]);
|
||||
}
|
||||
g_string_append_printf (printer->str, " ]");
|
||||
printer->has_member = TRUE;
|
||||
ottie_printer_end_object (printer);
|
||||
}
|
||||
|
||||
#ifdef OTTIE_KEYFRAMES_PRINT_FUNC
|
||||
static inline void
|
||||
ottie_keyframes(print) (OttieKeyframes *self,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
ottie_printer_start_array (printer, "k");
|
||||
for (int i = 0; i < self->n_items; i++)
|
||||
{
|
||||
const OttieKeyframe *keyframe = &self->items[i];
|
||||
|
||||
ottie_printer_start_object (printer, NULL);
|
||||
|
||||
#ifdef OTTIE_KEYFRAMES_BY_VALUE
|
||||
OTTIE_KEYFRAMES_PRINT_FUNC (printer, "s", &keyframe->start_value);
|
||||
OTTIE_KEYFRAMES_PRINT_FUNC (printer, "e", &keyframe->end_value);
|
||||
#else
|
||||
OTTIE_KEYFRAMES_PRINT_FUNC (printer, "s", keyframe->start_value);
|
||||
OTTIE_KEYFRAMES_PRINT_FUNC (printer, "e", keyframe->end_value);
|
||||
#endif
|
||||
ottie_printer_add_double (printer, "t", keyframe->start_time);
|
||||
ottie_keyframes(print_control_point) (printer, "i", &keyframe->in);
|
||||
ottie_keyframes(print_control_point) (printer, "o", &keyframe->out);
|
||||
|
||||
ottie_printer_end_object (printer);
|
||||
}
|
||||
ottie_printer_end_array (printer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OTTIE_KEYFRAMES_NO_UNDEF
|
||||
|
||||
#undef _T_
|
||||
@@ -374,6 +431,7 @@ ottie_keyframes(parse) (JsonReader *reader)
|
||||
|
||||
#undef OTTIE_KEYFRAMES_COPY_FUNC
|
||||
#undef OTTIE_KEYFRAMES_PARSE_FUNC
|
||||
#undef OTTIE_KEYFRAMES_PRINT_FUNC
|
||||
#undef OTTIE_KEYFRAMES_BY_VALUE
|
||||
#undef OTTIE_KEYFRAMES_ELEMENT_TYPE
|
||||
#undef OTTIE_KEYFRAMES_FREE_FUNC
|
||||
|
||||
@@ -51,6 +51,33 @@ ottie_layer_default_render (OttieLayer *self,
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_layer_print (OttieObject *obj,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttieLayer *self = OTTIE_LAYER (obj);
|
||||
|
||||
OTTIE_OBJECT_CLASS (ottie_layer_parent_class)->print (obj, printer);
|
||||
|
||||
if (self->auto_orient != 0)
|
||||
ottie_printer_add_int (printer, "ao", self->auto_orient);
|
||||
if (self->blend_mode != GSK_BLEND_MODE_DEFAULT)
|
||||
ottie_printer_add_int (printer, "bm", self->blend_mode);
|
||||
if (self->layer_name != NULL)
|
||||
ottie_printer_add_string (printer, "ln", self->layer_name);
|
||||
ottie_object_print (OTTIE_OBJECT (self->transform), "ks", printer);
|
||||
ottie_printer_add_double (printer, "ip", self->start_frame);
|
||||
ottie_printer_add_int (printer, "op", self->end_frame);
|
||||
if (self->index != OTTIE_INT_UNSET)
|
||||
ottie_printer_add_int (printer, "ind", self->index);
|
||||
if (self->parent_index != OTTIE_INT_UNSET)
|
||||
ottie_printer_add_int (printer, "parent", self->parent_index);
|
||||
ottie_printer_add_double (printer, "st", self->start_time);
|
||||
if (self->stretch != 1)
|
||||
ottie_printer_add_double (printer, "sr", self->stretch);
|
||||
ottie_printer_add_int (printer, "ddd", 0);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_layer_dispose (GObject *object)
|
||||
{
|
||||
@@ -66,11 +93,14 @@ static void
|
||||
ottie_layer_class_init (OttieLayerClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
OttieObjectClass *oobject_class = OTTIE_OBJECT_CLASS (klass);
|
||||
|
||||
klass->update = ottie_layer_default_update;
|
||||
klass->render = ottie_layer_default_render;
|
||||
|
||||
gobject_class->dispose = ottie_layer_dispose;
|
||||
|
||||
oobject_class->print = ottie_layer_print;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -109,4 +139,3 @@ ottie_layer_render (OttieLayer *self,
|
||||
|
||||
ottie_render_end_object (render, OTTIE_OBJECT (self));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "ottie/ottieobjectprivate.h"
|
||||
#include "ottie/ottieparserprivate.h"
|
||||
#include "ottie/ottierenderprivate.h"
|
||||
#include "ottie/ottieprinterprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -61,6 +62,8 @@ struct _OttieLayerClass
|
||||
void (* render) (OttieLayer *layer,
|
||||
OttieRender *render,
|
||||
double timestamp);
|
||||
void (* print) (OttieLayer *layer,
|
||||
OttiePrinter *printer);
|
||||
};
|
||||
|
||||
GType ottie_layer_get_type (void) G_GNUC_CONST;
|
||||
|
||||
@@ -104,6 +104,17 @@ ottie_object_dispose (GObject *object)
|
||||
G_OBJECT_CLASS (ottie_object_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_object_default_print (OttieObject *self,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
if (self->name != NULL)
|
||||
ottie_printer_add_string (printer, "nm", self->name);
|
||||
|
||||
if (self->match_name != NULL)
|
||||
ottie_printer_add_string (printer, "mn", self->match_name);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_object_class_init (OttieObjectClass *class)
|
||||
{
|
||||
@@ -113,6 +124,8 @@ ottie_object_class_init (OttieObjectClass *class)
|
||||
gobject_class->get_property = ottie_object_get_property;
|
||||
gobject_class->dispose = ottie_object_dispose;
|
||||
|
||||
class->print = ottie_object_default_print;
|
||||
|
||||
properties[PROP_NAME] =
|
||||
g_param_spec_string ("name",
|
||||
P_("Name"),
|
||||
@@ -181,4 +194,14 @@ ottie_object_get_match_name (OttieObject *self)
|
||||
return self->match_name;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_object_print (OttieObject *self,
|
||||
const char *name,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
ottie_printer_start_object (printer, name);
|
||||
|
||||
OTTIE_OBJECT_GET_CLASS (self)->print (self, printer);
|
||||
|
||||
ottie_printer_end_object (printer);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "ottie/ottietypesprivate.h"
|
||||
#include "ottie/ottieprinterprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -46,6 +47,9 @@ struct _OttieObject
|
||||
struct _OttieObjectClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*print) (OttieObject *self,
|
||||
OttiePrinter *printer);
|
||||
};
|
||||
|
||||
GType ottie_object_get_type (void) G_GNUC_CONST;
|
||||
@@ -58,6 +62,10 @@ void ottie_object_set_match_name (OttieObject
|
||||
const char *match_name);
|
||||
const char * ottie_object_get_match_name (OttieObject *self);
|
||||
|
||||
void ottie_object_print (OttieObject *self,
|
||||
const char *name,
|
||||
OttiePrinter *printer);
|
||||
|
||||
#define OTTIE_PARSE_OPTIONS_OBJECT \
|
||||
{ "nm", ottie_parser_option_string, G_STRUCT_OFFSET (OttieObject, name) }, \
|
||||
{ "mn", ottie_parser_option_string, G_STRUCT_OFFSET (OttieObject, match_name) }
|
||||
|
||||
@@ -581,7 +581,7 @@ ottie_parser_option_transform (JsonReader *reader,
|
||||
t = ottie_transform_parse (reader);
|
||||
if (t == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
||||
target = (OttieShape **) ((guint8 *) data + offset);
|
||||
|
||||
g_clear_object (target);
|
||||
|
||||
@@ -55,6 +55,19 @@ ottie_path_shape_render (OttieShape *shape,
|
||||
self->direction));
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_path_shape_print (OttieObject *obj,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttiePathShape *self = OTTIE_PATH_SHAPE (obj);
|
||||
|
||||
OTTIE_OBJECT_CLASS (ottie_path_shape_parent_class)->print (obj, printer);
|
||||
|
||||
ottie_printer_add_string (printer, "ty", "sh");
|
||||
ottie_printer_add_double (printer, "d", self->direction);
|
||||
ottie_path_value_print (&self->path, "ks", printer);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_path_shape_dispose (GObject *object)
|
||||
{
|
||||
@@ -68,9 +81,12 @@ ottie_path_shape_dispose (GObject *object)
|
||||
static void
|
||||
ottie_path_shape_class_init (OttiePathShapeClass *klass)
|
||||
{
|
||||
OttieObjectClass *oobject_class = OTTIE_OBJECT_CLASS (klass);
|
||||
OttieShapeClass *shape_class = OTTIE_SHAPE_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
oobject_class->print = ottie_path_shape_print;
|
||||
|
||||
shape_class->render = ottie_path_shape_render;
|
||||
|
||||
gobject_class->dispose = ottie_path_shape_dispose;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ottiepathvalueprivate.h"
|
||||
|
||||
#include "ottieparserprivate.h"
|
||||
#include "ottie/ottieprinterprivate.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
@@ -289,6 +290,7 @@ ottie_path_interpolate (const OttiePath *start,
|
||||
#define OTTIE_KEYFRAMES_FREE_FUNC ottie_path_unref
|
||||
#define OTTIE_KEYFRAMES_PARSE_FUNC ottie_path_value_parse_one
|
||||
#define OTTIE_KEYFRAMES_INTERPOLATE_FUNC ottie_path_interpolate
|
||||
#define OTTIE_KEYFRAMES_PRINT_FUNC ottie_printer_add_path
|
||||
#include "ottiekeyframesimpl.c"
|
||||
|
||||
void
|
||||
@@ -400,3 +402,67 @@ ottie_path_value_parse (JsonReader *reader,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline void
|
||||
ottie_printer_add_curves (OttiePrinter *printer,
|
||||
OttieContour *contour,
|
||||
const char *name,
|
||||
gsize offset)
|
||||
{
|
||||
ottie_printer_start_array (printer, name);
|
||||
for (int i = 0; i < contour->n_curves; i++)
|
||||
{
|
||||
guchar *curve = (guchar *)&contour->curves[i];
|
||||
double *p = (double *)(curve + offset);
|
||||
|
||||
ottie_printer_start_array (printer, NULL);
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append_printf (printer->str, "%g,\n", p[0]);
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append_printf (printer->str, "%g\n", p[1]);
|
||||
ottie_printer_end_array (printer);
|
||||
}
|
||||
ottie_printer_end_array (printer);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_printer_add_contour (OttiePrinter *printer,
|
||||
OttieContour *contour)
|
||||
{
|
||||
ottie_printer_start_object (printer, NULL);
|
||||
ottie_printer_add_boolean (printer, "c", contour->closed);
|
||||
ottie_printer_add_curves (printer, contour, "v", G_STRUCT_OFFSET (OttieCurve, point));
|
||||
ottie_printer_add_curves (printer, contour, "i", G_STRUCT_OFFSET (OttieCurve, in));
|
||||
ottie_printer_add_curves (printer, contour, "o", G_STRUCT_OFFSET (OttieCurve, out));
|
||||
ottie_printer_end_object (printer);
|
||||
}
|
||||
|
||||
void
|
||||
ottie_printer_add_path (OttiePrinter *printer,
|
||||
const char *name,
|
||||
gpointer value)
|
||||
{
|
||||
OttiePath *path = value;
|
||||
|
||||
ottie_printer_start_array (printer, name);
|
||||
for (int i = 0; i < path->n_contours; i++)
|
||||
ottie_printer_add_contour (printer, path->contours[i]);
|
||||
ottie_printer_end_array (printer);
|
||||
printer->has_member = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_path_value_print (OttiePathValue *self,
|
||||
const char *name,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
ottie_printer_start_object (printer, name);
|
||||
|
||||
ottie_printer_add_boolean (printer, "a", !self->is_static);
|
||||
if (self->is_static)
|
||||
ottie_printer_add_path (printer, "k", self->static_value);
|
||||
else
|
||||
ottie_path_keyframes_print (self->keyframes, printer);
|
||||
|
||||
ottie_printer_end_object (printer);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <json-glib/json-glib.h>
|
||||
|
||||
#include <gsk/gsk.h>
|
||||
#include "ottieprinterprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -47,6 +48,10 @@ GskPath * ottie_path_value_get (OttiePathValue
|
||||
gboolean ottie_path_value_parse (JsonReader *reader,
|
||||
gsize offset,
|
||||
gpointer data);
|
||||
void ottie_path_value_print (OttiePathValue *self,
|
||||
const char *name,
|
||||
OttiePrinter *printer);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ottiepoint3dvalueprivate.h"
|
||||
|
||||
#include "ottieparserprivate.h"
|
||||
#include "ottieprinterprivate.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
@@ -54,6 +55,7 @@ ottie_point3d_value_parse_value (JsonReader *reader,
|
||||
#define OTTIE_KEYFRAMES_DIMENSIONS 3
|
||||
#define OTTIE_KEYFRAMES_PARSE_FUNC ottie_point3d_value_parse_value
|
||||
#define OTTIE_KEYFRAMES_INTERPOLATE_FUNC graphene_point3d_interpolate
|
||||
#define OTTIE_KEYFRAMES_PRINT_FUNC ottie_printer_add_point3d
|
||||
#include "ottiekeyframesimpl.c"
|
||||
|
||||
void
|
||||
@@ -152,3 +154,18 @@ ottie_point3d_value_parse (JsonReader *reader,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_point3d_value_print (OttiePoint3DValue *self,
|
||||
const char *name,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
ottie_printer_start_object (printer, name);
|
||||
|
||||
ottie_printer_add_boolean (printer, "a", !self->is_static);
|
||||
if (self->is_static)
|
||||
ottie_printer_add_point3d (printer, "k", &self->static_value);
|
||||
else
|
||||
ottie_point_keyframes_print (self->keyframes, printer);
|
||||
|
||||
ottie_printer_end_object (printer);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <json-glib/json-glib.h>
|
||||
#include <graphene.h>
|
||||
#include "ottieprinterprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -48,6 +49,11 @@ gboolean ottie_point3d_value_parse (JsonReader
|
||||
float default_value,
|
||||
gsize offset,
|
||||
gpointer data);
|
||||
void ottie_point3d_value_print (OttiePoint3DValue *self,
|
||||
const char *name,
|
||||
OttiePrinter *printer);
|
||||
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ottiepointvalueprivate.h"
|
||||
|
||||
#include "ottieparserprivate.h"
|
||||
#include "ottieprinterprivate.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
@@ -50,6 +51,7 @@ ottie_point_value_parse_value (JsonReader *reader,
|
||||
#define OTTIE_KEYFRAMES_DIMENSIONS 2
|
||||
#define OTTIE_KEYFRAMES_PARSE_FUNC ottie_point_value_parse_value
|
||||
#define OTTIE_KEYFRAMES_INTERPOLATE_FUNC graphene_point_interpolate
|
||||
#define OTTIE_KEYFRAMES_PRINT_FUNC ottie_printer_add_point
|
||||
#include "ottiekeyframesimpl.c"
|
||||
|
||||
void
|
||||
@@ -138,3 +140,18 @@ ottie_point_value_parse (JsonReader *reader,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_point_value_print (OttiePointValue *self,
|
||||
const char *name,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
ottie_printer_start_object (printer, name);
|
||||
|
||||
ottie_printer_add_boolean (printer, "a", !self->is_static);
|
||||
if (self->is_static)
|
||||
ottie_printer_add_point (printer, "k", &self->static_value);
|
||||
else
|
||||
ottie_point_keyframes_print (self->keyframes, printer);
|
||||
|
||||
ottie_printer_end_object (printer);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <json-glib/json-glib.h>
|
||||
#include <graphene.h>
|
||||
#include "ottieprinterprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -47,6 +48,10 @@ void ottie_point_value_get (OttiePointValue
|
||||
gboolean ottie_point_value_parse (JsonReader *reader,
|
||||
gsize offset,
|
||||
gpointer data);
|
||||
void ottie_point_value_print (OttiePointValue *self,
|
||||
const char *name,
|
||||
OttiePrinter *printer);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
155
ottie/ottieprinter.c
Normal file
155
ottie/ottieprinter.c
Normal file
@@ -0,0 +1,155 @@
|
||||
#include "ottieprinterprivate.h"
|
||||
|
||||
void
|
||||
ottie_printer_init (OttiePrinter *printer)
|
||||
{
|
||||
printer->str = g_string_new ("");
|
||||
printer->indent_level = 0;
|
||||
printer->has_member = FALSE;
|
||||
}
|
||||
|
||||
#define INDENT 2
|
||||
|
||||
void
|
||||
ottie_printer_indent (OttiePrinter *printer)
|
||||
{
|
||||
if (printer->indent_level > 0)
|
||||
g_string_append_printf (printer->str, "%*s", printer->indent_level * INDENT, " ");
|
||||
}
|
||||
|
||||
void
|
||||
ottie_printer_start_object (OttiePrinter *printer,
|
||||
const char *name)
|
||||
{
|
||||
if (printer->has_member)
|
||||
g_string_append (printer->str, ",\n");
|
||||
ottie_printer_indent (printer);
|
||||
if (name)
|
||||
g_string_append_printf (printer->str, "\"%s\" : ", name);
|
||||
g_string_append (printer->str, "{\n");
|
||||
printer->indent_level++;
|
||||
printer->has_member = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_printer_end_object (OttiePrinter *printer)
|
||||
{
|
||||
printer->indent_level--;
|
||||
if (printer->has_member)
|
||||
g_string_append (printer->str, "\n");
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append (printer->str, "}");
|
||||
printer->has_member = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_printer_start_array (OttiePrinter *printer,
|
||||
const char *name)
|
||||
{
|
||||
if (printer->has_member)
|
||||
g_string_append (printer->str, ",\n");
|
||||
ottie_printer_indent (printer);
|
||||
if (name)
|
||||
g_string_append_printf (printer->str, "\"%s\" : ", name);
|
||||
g_string_append (printer->str, "[\n");
|
||||
printer->indent_level++;
|
||||
printer->has_member = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_printer_end_array (OttiePrinter *printer)
|
||||
{
|
||||
printer->indent_level--;
|
||||
if (printer->has_member)
|
||||
g_string_append (printer->str, "\n");
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append (printer->str, "]");
|
||||
printer->has_member = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_printer_add_double (OttiePrinter *printer,
|
||||
const char *name,
|
||||
double value)
|
||||
{
|
||||
if (printer->has_member)
|
||||
g_string_append (printer->str, ",\n");
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append_printf (printer->str, "\"%s\" : %g", name, value);
|
||||
printer->has_member = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_printer_add_int (OttiePrinter *printer,
|
||||
const char *name,
|
||||
int value)
|
||||
{
|
||||
if (printer->has_member)
|
||||
g_string_append (printer->str, ",\n");
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append_printf (printer->str, "\"%s\" : %d", name, value);
|
||||
printer->has_member = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_printer_add_boolean (OttiePrinter *printer,
|
||||
const char *name,
|
||||
gboolean value)
|
||||
{
|
||||
if (printer->has_member)
|
||||
g_string_append (printer->str, ",\n");
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append_printf (printer->str, "\"%s\" : %s", name, value ? "true" : "false");
|
||||
printer->has_member = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_printer_add_string (OttiePrinter *printer,
|
||||
const char *name,
|
||||
const char *value)
|
||||
{
|
||||
if (printer->has_member)
|
||||
g_string_append (printer->str, ",\n");
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append_printf (printer->str, "\"%s\" : \"%s\"", name, value);
|
||||
printer->has_member = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_printer_add_color (OttiePrinter *printer,
|
||||
const char *name,
|
||||
const GdkRGBA *value)
|
||||
{
|
||||
if (printer->has_member)
|
||||
g_string_append (printer->str, ",\n");
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append_printf (printer->str, "\"%s\" : [ %g, %g, %g ]",
|
||||
name, value->red, value->green, value->blue);
|
||||
printer->has_member = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_printer_add_point (OttiePrinter *printer,
|
||||
const char *name,
|
||||
const graphene_point_t *value)
|
||||
{
|
||||
if (printer->has_member)
|
||||
g_string_append (printer->str, ",\n");
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append_printf (printer->str, "\"%s\" : [ %g, %g ]",
|
||||
name, value->x, value->y);
|
||||
printer->has_member = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ottie_printer_add_point3d (OttiePrinter *printer,
|
||||
const char *name,
|
||||
const graphene_point3d_t *value)
|
||||
{
|
||||
if (printer->has_member)
|
||||
g_string_append (printer->str, ",\n");
|
||||
ottie_printer_indent (printer);
|
||||
g_string_append_printf (printer->str, "\"%s\" : [ %g, %g, %g ]",
|
||||
name, value->x, value->y, value->z);
|
||||
printer->has_member = TRUE;
|
||||
}
|
||||
72
ottie/ottieprinterprivate.h
Normal file
72
ottie/ottieprinterprivate.h
Normal file
@@ -0,0 +1,72 @@
|
||||
|
||||
/*
|
||||
* Copyright © 2020 Red Hat, Inc
|
||||
*
|
||||
* 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.1 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/>.
|
||||
*
|
||||
* Authors: Matthias Clasen <mclasen@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef __OTTIE_PRINTER_PRIVATE_H__
|
||||
#define __OTTIE_PRINTER_PRIVATE_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <graphene.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GString *str;
|
||||
int indent_level;
|
||||
int has_member;
|
||||
} OttiePrinter;
|
||||
|
||||
void ottie_printer_init (OttiePrinter *printer);
|
||||
void ottie_printer_indent (OttiePrinter *printer);
|
||||
void ottie_printer_start_object (OttiePrinter *printer,
|
||||
const char *name);
|
||||
void ottie_printer_end_object (OttiePrinter *printer);
|
||||
void ottie_printer_start_array (OttiePrinter *printer,
|
||||
const char *name);
|
||||
void ottie_printer_end_array (OttiePrinter *printer);
|
||||
void ottie_printer_add_double (OttiePrinter *printer,
|
||||
const char *name,
|
||||
double value);
|
||||
void ottie_printer_add_int (OttiePrinter *printer,
|
||||
const char *name,
|
||||
int value);
|
||||
void ottie_printer_add_boolean (OttiePrinter *printer,
|
||||
const char *name,
|
||||
gboolean value);
|
||||
void ottie_printer_add_string (OttiePrinter *printer,
|
||||
const char *name,
|
||||
const char *value);
|
||||
void ottie_printer_add_color (OttiePrinter *printer,
|
||||
const char *name,
|
||||
const GdkRGBA *value);
|
||||
void ottie_printer_add_point (OttiePrinter *printer,
|
||||
const char *name,
|
||||
const graphene_point_t *value);
|
||||
void ottie_printer_add_point3d (OttiePrinter *printer,
|
||||
const char *name,
|
||||
const graphene_point3d_t *value);
|
||||
void ottie_printer_add_path (OttiePrinter *printer,
|
||||
const char *name,
|
||||
gpointer value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __OTTIE_PRINTER_PRIVATE_H__ */
|
||||
@@ -163,6 +163,21 @@ ottie_rect_shape_render (OttieShape *shape,
|
||||
gsk_path_builder_free_to_path (builder));
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_rect_shape_print (OttieObject *obj,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttieRectShape *self = OTTIE_RECT_SHAPE (obj);
|
||||
|
||||
OTTIE_OBJECT_CLASS (ottie_rect_shape_parent_class)->print (obj, printer);
|
||||
|
||||
ottie_printer_add_string (printer, "ty", "rc");
|
||||
ottie_printer_add_double (printer, "d", self->direction);
|
||||
ottie_point_value_print (&self->position, "p", printer);
|
||||
ottie_point_value_print (&self->size, "s", printer);
|
||||
ottie_double_value_print (&self->rounded, "r", printer);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_rect_shape_dispose (GObject *object)
|
||||
{
|
||||
@@ -178,9 +193,12 @@ ottie_rect_shape_dispose (GObject *object)
|
||||
static void
|
||||
ottie_rect_shape_class_init (OttieRectShapeClass *klass)
|
||||
{
|
||||
OttieObjectClass *oobject_class = OTTIE_OBJECT_CLASS (klass);
|
||||
OttieShapeClass *shape_class = OTTIE_SHAPE_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
oobject_class->print = ottie_rect_shape_print;
|
||||
|
||||
shape_class->render = ottie_rect_shape_render;
|
||||
|
||||
gobject_class->dispose = ottie_rect_shape_dispose;
|
||||
|
||||
@@ -44,6 +44,18 @@
|
||||
*/
|
||||
G_DEFINE_TYPE (OttieShape, ottie_shape, OTTIE_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
ottie_shape_print (OttieObject *obj,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttieShape *self = OTTIE_SHAPE (obj);
|
||||
|
||||
OTTIE_OBJECT_CLASS (ottie_shape_parent_class)->print (obj, printer);
|
||||
|
||||
if (self->hidden)
|
||||
ottie_printer_add_boolean (printer, "hd", self->hidden);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_shape_dispose (GObject *object)
|
||||
{
|
||||
@@ -56,8 +68,11 @@ static void
|
||||
ottie_shape_class_init (OttieShapeClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
OttieObjectClass *oobject_class = OTTIE_OBJECT_CLASS (class);
|
||||
|
||||
gobject_class->dispose = ottie_shape_dispose;
|
||||
|
||||
oobject_class->print = ottie_shape_print;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -58,6 +58,18 @@ ottie_shape_layer_render (OttieLayer *layer,
|
||||
timestamp);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_shape_layer_print (OttieObject *obj,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttieShapeLayer *self = OTTIE_SHAPE_LAYER (obj);
|
||||
|
||||
OTTIE_OBJECT_CLASS (ottie_shape_layer_parent_class)->print (obj, printer);
|
||||
|
||||
ottie_printer_add_int (printer, "ty", 4);
|
||||
ottie_group_shape_print_shapes (self->shapes, "shapes", printer);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_shape_layer_dispose (GObject *object)
|
||||
{
|
||||
@@ -71,9 +83,12 @@ ottie_shape_layer_dispose (GObject *object)
|
||||
static void
|
||||
ottie_shape_layer_class_init (OttieShapeLayerClass *klass)
|
||||
{
|
||||
OttieObjectClass *oobject_class = OTTIE_OBJECT_CLASS (klass);
|
||||
OttieLayerClass *layer_class = OTTIE_LAYER_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
oobject_class->print = ottie_shape_layer_print;
|
||||
|
||||
layer_class->render = ottie_shape_layer_render;
|
||||
|
||||
gobject_class->dispose = ottie_shape_layer_dispose;
|
||||
|
||||
@@ -91,6 +91,24 @@ ottie_stroke_shape_render (OttieShape *shape,
|
||||
gsk_stroke_free (stroke);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_stroke_shape_print (OttieObject *obj,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttieStrokeShape *self = OTTIE_STROKE_SHAPE (obj);
|
||||
|
||||
OTTIE_OBJECT_CLASS (ottie_stroke_shape_parent_class)->print (obj, printer);
|
||||
|
||||
ottie_printer_add_string (printer, "ty", "st");
|
||||
ottie_double_value_print (&self->line_width, "w", printer);
|
||||
ottie_double_value_print (&self->opacity, "o", printer);
|
||||
ottie_color_value_print (&self->color, "c", printer);
|
||||
ottie_printer_add_int (printer, "lc", self->line_cap);
|
||||
ottie_printer_add_int (printer, "lj", self->line_join);
|
||||
ottie_printer_add_double (printer, "ml", self->miter_limit);
|
||||
ottie_printer_add_int (printer, "bm", self->blend_mode);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_stroke_shape_dispose (GObject *object)
|
||||
{
|
||||
@@ -106,9 +124,12 @@ ottie_stroke_shape_dispose (GObject *object)
|
||||
static void
|
||||
ottie_stroke_shape_class_init (OttieStrokeShapeClass *klass)
|
||||
{
|
||||
OttieObjectClass *oobject_class = OTTIE_OBJECT_CLASS (klass);
|
||||
OttieShapeClass *shape_class = OTTIE_SHAPE_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
oobject_class->print = ottie_stroke_shape_print;
|
||||
|
||||
shape_class->render = ottie_stroke_shape_render;
|
||||
|
||||
gobject_class->dispose = ottie_stroke_shape_dispose;
|
||||
|
||||
@@ -62,6 +62,24 @@ ottie_transform_render (OttieShape *shape,
|
||||
gsk_transform_unref (transform);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_transform_print (OttieObject *obj,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttieTransform *self = OTTIE_TRANSFORM (obj);
|
||||
|
||||
OTTIE_OBJECT_CLASS (ottie_transform_parent_class)->print (obj, printer);
|
||||
|
||||
ottie_printer_add_string (printer, "ty", "tr");
|
||||
ottie_double_value_print (&self->opacity, "o", printer);
|
||||
ottie_double_value_print (&self->rotation, "r", printer);
|
||||
ottie_double_value_print (&self->skew, "sk", printer);
|
||||
ottie_double_value_print (&self->skew_angle, "sa", printer);
|
||||
ottie_point3d_value_print (&self->anchor, "a", printer);
|
||||
ottie_point3d_value_print (&self->position, "p", printer);
|
||||
ottie_point3d_value_print (&self->scale, "s", printer);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_transform_dispose (GObject *object)
|
||||
{
|
||||
@@ -89,9 +107,12 @@ ottie_transform_finalize (GObject *object)
|
||||
static void
|
||||
ottie_transform_class_init (OttieTransformClass *klass)
|
||||
{
|
||||
OttieObjectClass *oobject_class = OTTIE_OBJECT_CLASS (klass);
|
||||
OttieShapeClass *shape_class = OTTIE_SHAPE_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
oobject_class->print = ottie_transform_print;
|
||||
|
||||
shape_class->render = ottie_transform_render;
|
||||
|
||||
gobject_class->finalize = ottie_transform_finalize;
|
||||
@@ -126,7 +147,6 @@ ottie_transform_value_parse_scale (JsonReader *reader,
|
||||
return ottie_point3d_value_parse (reader, 100, offset, data);
|
||||
}
|
||||
|
||||
|
||||
OttieShape *
|
||||
ottie_transform_parse (JsonReader *reader)
|
||||
{
|
||||
|
||||
@@ -129,6 +129,21 @@ ottie_trim_shape_render (OttieShape *shape,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_trim_shape_print (OttieObject *obj,
|
||||
OttiePrinter *printer)
|
||||
{
|
||||
OttieTrimShape *self = OTTIE_TRIM_SHAPE (obj);
|
||||
|
||||
OTTIE_OBJECT_CLASS (ottie_trim_shape_parent_class)->print (obj, printer);
|
||||
|
||||
ottie_printer_add_string (printer, "ty", "tm");
|
||||
ottie_double_value_print (&self->start, "s", printer);
|
||||
ottie_double_value_print (&self->end, "e", printer);
|
||||
ottie_double_value_print (&self->offset, "o", printer);
|
||||
ottie_printer_add_int (printer, "m", self->mode);
|
||||
}
|
||||
|
||||
static void
|
||||
ottie_trim_shape_dispose (GObject *object)
|
||||
{
|
||||
@@ -144,9 +159,12 @@ ottie_trim_shape_dispose (GObject *object)
|
||||
static void
|
||||
ottie_trim_shape_class_init (OttieTrimShapeClass *klass)
|
||||
{
|
||||
OttieObjectClass *oobject_class = OTTIE_OBJECT_CLASS (klass);
|
||||
OttieShapeClass *shape_class = OTTIE_SHAPE_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
oobject_class->print = ottie_trim_shape_print;
|
||||
|
||||
shape_class->render = ottie_trim_shape_render;
|
||||
|
||||
gobject_class->dispose = ottie_trim_shape_dispose;
|
||||
|
||||
Reference in New Issue
Block a user