[lasem/properties] [SVG] Property list WIP.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [lasem/properties] [SVG] Property list WIP.
- Date: Thu, 30 Jul 2009 20:22:30 +0000 (UTC)
commit f8403e8eb276e3a8b17f8b90b5976d2a0b7514a7
Author: Emmanuel Pacaud <emmanuel pacaud lapp in2p3 fr>
Date: Thu Jul 30 22:22:06 2009 +0200
[SVG] Property list WIP.
src/lsmsvgclippathelement.c | 9 +++-
src/lsmsvgelement.c | 87 +++++++++++++++++++++++++++++++------------
src/lsmsvgelement.h | 6 ++-
src/lsmsvggradientelement.c | 9 ++--
src/lsmsvgmaskelement.c | 7 ++-
src/lsmsvgpatternelement.c | 7 ++-
src/lsmsvgstyle.c | 5 ++
src/lsmsvgstyle.h | 7 ++-
src/lsmsvgsvgelement.c | 2 +
src/lsmsvgview.c | 27 +++++++++++++
src/lsmsvgview.h | 4 +-
11 files changed, 127 insertions(+), 43 deletions(-)
---
diff --git a/src/lsmsvgclippathelement.c b/src/lsmsvgclippathelement.c
index 2e35276..e7275ec 100644
--- a/src/lsmsvgclippathelement.c
+++ b/src/lsmsvgclippathelement.c
@@ -50,8 +50,10 @@ _clip_path_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
}
#endif
+/*static void*/
+/*_clip_path_element_render_clip (LsmSvgElement *self, LsmSvgView *view)*/
static void
-_clip_path_element_render_clip (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_clip_path_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgClipPathElement *clip = LSM_SVG_CLIP_PATH_ELEMENT (self);
gboolean is_object_bounding_box;
@@ -118,8 +120,9 @@ lsm_svg_clip_path_element_class_init (LsmSvgClipPathElementClass *klass)
d_node_class->get_node_name = _clip_path_element_get_node_name;
/* s_element_class->update = _clip_path_element_update;*/
- s_element_class->render_clip = _clip_path_element_render_clip;
- s_element_class->render = NULL;
+/* s_element_class->render_clip = _clip_path_element_render_clip;*/
+/* s_element_class->render = NULL;*/
+ s_element_class->render = lsm_svg_clip_path_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
diff --git a/src/lsmsvgelement.c b/src/lsmsvgelement.c
index 0060e7a..80cdf18 100644
--- a/src/lsmsvgelement.c
+++ b/src/lsmsvgelement.c
@@ -24,6 +24,8 @@
#include <lsmproperties.h>
#include <lsmdomdocument.h>
#include <lsmsvgelement.h>
+#include <lsmsvgpatternelement.h>
+#include <lsmsvgclippathelement.h>
#include <lsmsvgview.h>
#include <string.h>
@@ -40,12 +42,12 @@ lsm_svg_element_can_append_child (LsmDomNode *self, LsmDomNode *child)
static gboolean
lsm_svg_element_child_changed (LsmDomNode *parent, LsmDomNode *child)
{
- LsmSvgElement *element = LSM_SVG_ELEMENT (parent);
+/* LsmSvgElement *element = LSM_SVG_ELEMENT (parent);*/
- if (element->need_children_update)
- return FALSE;
+/* if (element->need_children_update)*/
+/* return FALSE;*/
- element->need_children_update = TRUE;
+/* element->need_children_update = TRUE;*/
return TRUE;
}
@@ -154,10 +156,16 @@ void
lsm_svg_element_render (LsmSvgElement *element, LsmSvgView *view)
{
LsmSvgElementClass *element_class;
+ const LsmSvgStyle *parent_style;
+ LsmSvgStyle *style;
g_return_if_fail (LSM_IS_SVG_ELEMENT (element));
+ parent_style = lsm_svg_view_get_current_style (view);
+ style = lsm_svg_style_duplicate (parent_style);
+ lsm_svg_style_apply_property_bag (style, &element->property_bag);
+ lsm_svg_view_push_style (view, style);
lsm_svg_view_push_element (view, element);
element_class = LSM_SVG_ELEMENT_GET_CLASS (element);
@@ -170,42 +178,73 @@ lsm_svg_element_render (LsmSvgElement *element, LsmSvgView *view)
}
lsm_svg_view_pop_element (view);
+ lsm_svg_view_pop_style (view);
}
-void
-lsm_svg_element_render_paint (LsmSvgElement *element, LsmSvgView *view)
+static void
+lsm_svg_element_enable_rendering (LsmSvgElement *element)
{
LsmSvgElementClass *element_class;
g_return_if_fail (LSM_IS_SVG_ELEMENT (element));
element_class = LSM_SVG_ELEMENT_GET_CLASS (element);
- if (element_class->render_paint != NULL) {
- lsm_debug ("[LsmSvgElement::render_paint] Render %s (%s)",
- lsm_dom_node_get_node_name (LSM_DOM_NODE (element)),
- element->id.value != NULL ? element->id.value : "no id");
+ g_return_if_fail (element_class->enable_rendering != NULL);
- element_class->render_paint (element, view);
- }
+ element_class->enable_rendering (element);
}
void
-lsm_svg_element_render_clip (LsmSvgElement *element, LsmSvgView *view)
+lsm_svg_element_render_paint (LsmSvgElement *element, LsmSvgView *view)
{
- LsmSvgElementClass *element_class;
+ g_return_if_fail (LSM_IS_SVG_PATTERN_ELEMENT (element));
- g_return_if_fail (LSM_IS_SVG_ELEMENT (element));
+ lsm_svg_element_enable_rendering (element);
+ lsm_svg_element_render (element, view);
+}
- element_class = LSM_SVG_ELEMENT_GET_CLASS (element);
- if (element_class->render_clip != NULL) {
- lsm_debug ("[LsmSvgElement::render_clip] Render %s (%s)",
- lsm_dom_node_get_node_name (LSM_DOM_NODE (element)),
- element->id.value != NULL ? element->id.value : "no id");
+void lsm_svg_element_render_clip (LsmSvgElement *element, LsmSvgView *view)
+{
+ g_return_if_fail (LSM_IS_SVG_CLIP_PATH_ELEMENT (element));
- element_class->render_clip (element, view);
- }
+ lsm_svg_element_enable_rendering (element);
+ lsm_svg_element_render (element, view);
}
+/*void*/
+/*lsm_svg_element_render_paint (LsmSvgElement *element, LsmSvgView *view)*/
+/*{*/
+/* LsmSvgElementClass *element_class;*/
+
+/* g_return_if_fail (LSM_IS_SVG_ELEMENT (element));*/
+
+/* element_class = LSM_SVG_ELEMENT_GET_CLASS (element);*/
+/* if (element_class->render_paint != NULL) {*/
+/* lsm_debug ("[LsmSvgElement::render_paint] Render %s (%s)",*/
+/* lsm_dom_node_get_node_name (LSM_DOM_NODE (element)),*/
+/* element->id.value != NULL ? element->id.value : "no id");*/
+
+/* element_class->render_paint (element, view);*/
+/* }*/
+/*}*/
+
+/*void*/
+/*lsm_svg_element_render_clip (LsmSvgElement *element, LsmSvgView *view)*/
+/*{*/
+/* LsmSvgElementClass *element_class;*/
+
+/* g_return_if_fail (LSM_IS_SVG_ELEMENT (element));*/
+
+/* element_class = LSM_SVG_ELEMENT_GET_CLASS (element);*/
+/* if (element_class->render_clip != NULL) {*/
+/* lsm_debug ("[LsmSvgElement::render_clip] Render %s (%s)",*/
+/* lsm_dom_node_get_node_name (LSM_DOM_NODE (element)),*/
+/* element->id.value != NULL ? element->id.value : "no id");*/
+
+/* element_class->render_clip (element, view);*/
+/* }*/
+/*}*/
+
void
lsm_svg_element_get_extents (LsmSvgElement *element, LsmSvgView *view, LsmExtents *extents)
{
@@ -233,7 +272,7 @@ lsm_svg_element_get_extents (LsmSvgElement *element, LsmSvgView *view, LsmExtent
static void
lsm_svg_element_init (LsmSvgElement *element)
{
- element->need_update = TRUE;
+/* element->need_update = TRUE;*/
}
static void
@@ -290,7 +329,7 @@ lsm_svg_element_class_init (LsmSvgElementClass *s_element_class)
/* s_element_class->update = NULL;*/
s_element_class->render = _render;
- s_element_class->render_paint = NULL;
+/* s_element_class->render_paint = NULL;*/
s_element_class->attribute_manager = lsm_attribute_manager_new (G_N_ELEMENTS (lsm_svg_attribute_infos),
lsm_svg_attribute_infos);
diff --git a/src/lsmsvgelement.h b/src/lsmsvgelement.h
index 5682d4f..e8f0611 100644
--- a/src/lsmsvgelement.h
+++ b/src/lsmsvgelement.h
@@ -53,8 +53,8 @@ struct _LsmSvgElement {
/* View */
- gboolean need_update;
- gboolean need_children_update;
+// gboolean need_update;
+// gboolean need_children_update;
};
struct _LsmSvgElementClass {
@@ -64,6 +64,7 @@ struct _LsmSvgElementClass {
LsmAttributeManager *attribute_manager;
// void (*update) (LsmSvgElement *element, LsmSvgStyle *style);
+ void (*enable_rendering) (LsmSvgElement *element);
void (*render) (LsmSvgElement *element, LsmSvgView *view);
void (*render_paint) (LsmSvgElement *element, LsmSvgView *view);
void (*render_clip) (LsmSvgElement *element, LsmSvgView *view);
@@ -73,6 +74,7 @@ struct _LsmSvgElementClass {
GType lsm_svg_element_get_type (void);
//void lsm_svg_element_update (LsmSvgElement *element, const LsmSvgStyle *style);
+//void lsm_svg_element_enable_rendering(LsmSvgElement *self);
void lsm_svg_element_render (LsmSvgElement *element, LsmSvgView *view);
void lsm_svg_element_render_paint (LsmSvgElement *element, LsmSvgView *view);
void lsm_svg_element_render_clip (LsmSvgElement *element, LsmSvgView *view);
diff --git a/src/lsmsvggradientelement.c b/src/lsmsvggradientelement.c
index 3487ccf..32deac1 100644
--- a/src/lsmsvggradientelement.c
+++ b/src/lsmsvggradientelement.c
@@ -57,7 +57,7 @@ _gradient_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
#endif
static void
-_gradient_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_gradient_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgGradientElement *gradient = LSM_SVG_GRADIENT_ELEMENT (self);
LsmDomNode *iter;
@@ -145,9 +145,10 @@ lsm_svg_gradient_element_class_init (LsmSvgGradientElementClass *klass)
d_node_class->can_append_child = lsm_svg_gradient_element_can_append_child;
/* s_element_class->update = _gradient_element_update;*/
- s_element_class->render_paint = s_element_class->render;
- s_element_class->render = NULL;
- s_graphic_class->graphic_render = _gradient_element_graphic_render;
+/* s_element_class->render_paint = s_element_class->render;*/
+/* s_element_class->render = NULL;*/
+/* s_element_class->render = lsm_svg_gradient_element_render;*/
+ s_graphic_class->graphic_render = lsm_svg_gradient_element_graphic_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
diff --git a/src/lsmsvgmaskelement.c b/src/lsmsvgmaskelement.c
index 17db8e9..45025df 100644
--- a/src/lsmsvgmaskelement.c
+++ b/src/lsmsvgmaskelement.c
@@ -71,7 +71,7 @@ _mask_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
#endif
static void
-_mask_element_render_paint (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_mask_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgMaskElement *mask = LSM_SVG_MASK_ELEMENT (self);
gboolean is_object_bounding_box;
@@ -220,8 +220,9 @@ lsm_svg_mask_element_class_init (LsmSvgMaskElementClass *klass)
d_node_class->get_node_name = _mask_element_get_node_name;
/* s_element_class->update = _mask_element_update;*/
- s_element_class->render_paint = _mask_element_render_paint;
- s_element_class->render = NULL;
+/* s_element_class->render_paint = _mask_element_render_paint;*/
+/* s_element_class->render = NULL;*/
+ s_element_class->render = lsm_svg_mask_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
diff --git a/src/lsmsvgpatternelement.c b/src/lsmsvgpatternelement.c
index a36eb55..35acbcb 100644
--- a/src/lsmsvgpatternelement.c
+++ b/src/lsmsvgpatternelement.c
@@ -76,7 +76,7 @@ _pattern_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
#endif
static void
-_pattern_element_render_paint (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_pattern_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgPatternElement *pattern = LSM_SVG_PATTERN_ELEMENT (self);
gboolean is_object_bounding_box;
@@ -270,8 +270,9 @@ lsm_svg_pattern_element_class_init (LsmSvgPatternElementClass *klass)
d_node_class->get_node_name = _pattern_element_get_node_name;
/* s_element_class->update = _pattern_element_update;*/
- s_element_class->render_paint = _pattern_element_render_paint;
- s_element_class->render = NULL;
+/* s_element_class->render_paint = _pattern_element_render_paint;*/
+/* s_element_class->render = NULL;*/
+ s_element_class->render = lsm_svg_pattern_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
diff --git a/src/lsmsvgstyle.c b/src/lsmsvgstyle.c
index 05acdab..06cd53b 100644
--- a/src/lsmsvgstyle.c
+++ b/src/lsmsvgstyle.c
@@ -420,3 +420,8 @@ lsm_svg_style_duplicate (const LsmSvgStyle *from)
return style;
}
+
+void
+lsm_svg_style_apply_property_bag (LsmSvgStyle *style, LsmPropertyBag *property_bag)
+{
+}
diff --git a/src/lsmsvgstyle.h b/src/lsmsvgstyle.h
index 8614697..f7a7f5e 100644
--- a/src/lsmsvgstyle.h
+++ b/src/lsmsvgstyle.h
@@ -188,9 +188,10 @@ struct _LsmSvgStyle {
#endif
-LsmSvgStyle * lsm_svg_style_new (void);
-void lsm_svg_style_free (LsmSvgStyle *style);
-LsmSvgStyle * lsm_svg_style_duplicate (const LsmSvgStyle *style);
+LsmSvgStyle * lsm_svg_style_new (void);
+void lsm_svg_style_free (LsmSvgStyle *style);
+LsmSvgStyle * lsm_svg_style_duplicate (const LsmSvgStyle *style);
+void lsm_svg_style_apply_property_bag (LsmSvgStyle *style, LsmPropertyBag *property_bag);
G_END_DECLS
diff --git a/src/lsmsvgsvgelement.c b/src/lsmsvgsvgelement.c
index f04e3ff..bb5c76a 100644
--- a/src/lsmsvgsvgelement.c
+++ b/src/lsmsvgsvgelement.c
@@ -191,9 +191,11 @@ lsm_svg_svg_element_get_default_style (LsmSvgSvgElement *svg_element)
void
lsm_svg_svg_element_render (LsmSvgSvgElement *svg, LsmSvgView *view)
{
+ lsm_svg_view_push_style (view, svg->default_style);
lsm_svg_view_push_viewbox (view, &svg->svg_box);
lsm_svg_element_render (LSM_SVG_ELEMENT (svg), view);
lsm_svg_view_pop_viewbox (view);
+ lsm_svg_view_pop_style (view);
}
LsmDomNode *
diff --git a/src/lsmsvgview.c b/src/lsmsvgview.c
index 518093b..ea1234e 100644
--- a/src/lsmsvgview.c
+++ b/src/lsmsvgview.c
@@ -1306,6 +1306,33 @@ lsm_svg_view_pop_element (LsmSvgView *view)
view->element_stack = g_slist_delete_link (view->element_stack, view->element_stack);
}
+void
+lsm_svg_view_push_style (LsmSvgView *view, const LsmSvgStyle *style)
+{
+ g_return_if_fail (LSM_IS_SVG_VIEW (view));
+ g_return_if_fail (style != NULL);
+
+ view->style_stack = g_slist_prepend (view->style_stack, (void *) style);
+ view->style = style;
+}
+
+void lsm_svg_view_pop_style (LsmSvgView *view)
+{
+ g_return_if_fail (LSM_IS_SVG_VIEW (view));
+ g_return_if_fail (view->style_stack != NULL);
+
+ view->style_stack = g_slist_delete_link (view->style_stack, view->style_stack);
+ view->style = view->style_stack != NULL ? view->style_stack->data : NULL;
+}
+
+const LsmSvgStyle *
+lsm_svg_view_get_current_style (LsmSvgView *view)
+{
+ g_return_val_if_fail (LSM_IS_SVG_VIEW (view), NULL);
+
+ return view->style;
+}
+
#if 0
static void
lsm_svg_view_push_clip (LsmSvgView *view, char *clip_path, LsmSvgFillRule clip_rule)
diff --git a/src/lsmsvgview.h b/src/lsmsvgview.h
index 8b375ec..abbbfd8 100644
--- a/src/lsmsvgview.h
+++ b/src/lsmsvgview.h
@@ -129,7 +129,9 @@ void lsm_svg_view_pop_element (LsmSvgView *view);
//void lsm_svg_view_pop_group_opacity (LsmSvgView *view);
void lsm_svg_view_push_style (LsmSvgView *view, const LsmSvgStyle *style);
-void lsm_svg_view_pop_style (LsmSvgView *view, const LsmSvgStyle *style);
+void lsm_svg_view_pop_style (LsmSvgView *view);
+
+const LsmSvgStyle * lsm_svg_view_get_current_style (LsmSvgView *view);
//void lsm_svg_view_push_mask_attributes (LsmSvgView *view, const LsmSvgMaskAttributeBag *mask);
//void lsm_svg_view_pop_mask_attributes (LsmSvgView *view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]