summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/evas_vg_node.c
blob: 029b9862233f44ad22eb9b67527bb61335905f03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#include "evas_common_private.h"
#include "evas_private.h"

#include <string.h>

#define MY_CLASS EVAS_VG_NODE_CLASS

typedef struct _Evas_VG_Node_Data Evas_VG_Node_Data;
struct _Evas_VG_Node_Data
{
   Eina_Matrix3 *m;
   Evas_VG_Node *mask;

   double x, y;
   int r, g, b, a;
   Eina_Bool visibility;
};

// FIXME:
// - share private structure with evas_object_vg
// - mark parent canvas evas_object dirty after any change on the object
// - add a virtual render function as part of the private data field

void
_evas_vg_node_transformation_set(Eo *obj EINA_UNUSED,
                                 Evas_VG_Node_Data *pd,
                                 const Eina_Matrix3 *m)
{
   if (!pd->m)
     {
        pd->m = malloc(sizeof (Eina_Matrix3));
        if (!pd->m) return ;
     }
   memcpy(pd->m, m, sizeof (Eina_Matrix3));
}

const Eina_Matrix3 *
_evas_vg_node_transformation_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd)
{
   return pd->m;
}

void
_evas_vg_node_origin_set(Eo *obj EINA_UNUSED,
                         Evas_VG_Node_Data *pd,
                         double x, double y)
{
   pd->x = x;
   pd->y = y;
}

void
_evas_vg_node_origin_get(Eo *obj EINA_UNUSED,
                         Evas_VG_Node_Data *pd,
                         double *x, double *y)
{
   if (x) *x = pd->x;
   if (y) *y = pd->y;
}

void
_evas_vg_node_visibility_set(Eo *obj EINA_UNUSED,
                             Evas_VG_Node_Data *pd,
                             Eina_Bool v)
{
   pd->visibility = v;
}

Eina_Bool
_evas_vg_node_visibility_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd)
{
   return pd->visibility;
}

void
_evas_vg_node_color_set(Eo *obj EINA_UNUSED,
                        Evas_VG_Node_Data *pd,
                        int r, int g, int b, int a)
{
   pd->r = r;
   pd->g = g;
   pd->b = b;
   pd->a = a;
}

void
_evas_vg_node_color_get(Eo *obj EINA_UNUSED,
                        Evas_VG_Node_Data *pd,
                        int *r, int *g, int *b, int *a)
{
   if (r) *r = pd->r;
   if (g) *g = pd->g;
   if (b) *b = pd->b;
   if (a) *a = pd->a;
}

void
_evas_vg_node_mask_set(Eo *obj EINA_UNUSED,
                       Evas_VG_Node_Data *pd,
                       Evas_VG_Node *r)
{
   Evas_VG_Node *tmp = pd->mask;

   pd->mask = eo_ref(r);
   eo_unref(tmp);
}

Evas_VG_Node*
_evas_vg_node_mask_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd)
{
   return pd->mask;
}

// Parent should be a container otherwise dismissing the stacking operation
void
_evas_vg_node_eo_base_constructor(Eo *obj, Evas_VG_Node_Data *pd)
{
   Eo *parent;

   eo_do_super(obj, MY_CLASS, eo_constructor());
   eo_do(obj, parent = eo_parent_get());
   if (!eo_isa(parent, EVAS_VG_CONTAINER_CLASS))
     eo_error_set(obj);
}

void
_evas_vg_node_eo_base_parent_set(Eo *obj, Evas_VG_Node_Data *pd, Eo *parent)
{
}

void
_evas_vg_node_raise(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED)
{
   Eo *parent;

   eo_do(obj, parent = eo_parent_get());
}

void
_evas_vg_node_stack_above(Eo *obj,
                          Evas_VG_Node_Data *pd EINA_UNUSED,
                          Evas_VG_Node *above)
{
   Eo *parent;

   eo_do(obj, parent = eo_parent_get());
}

void
_evas_vg_node_stack_below(Eo *obj,
                          Evas_VG_Node_Data *pd EINA_UNUSED,
                          Evas_Object *below)
{
   Eo *parent;

   eo_do(obj, parent = eo_parent_get());
}

void
_evas_vg_node_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED)
{
   Eo *parent;

   eo_do(obj, parent = eo_parent_get());
}

#include "evas_vg_node.eo.c"