[cairo-commit] svgslides/src svgslides-4suite,1.8,1.9
Carl Worth
commit at pdx.freedesktop.org
Tue Apr 26 11:47:17 PDT 2005
- Previous message: [cairo-commit] svgslides/example example-inverse.svg, 1.1,
1.2 example-title.svg, 1.2, 1.3 example.svg, 1.1,
1.2 example.xml, 1.3, 1.4
- Next message: [cairo-commit] svgslides ChangeLog,1.69,1.70
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: cworth
Update of /cvs/cairo/svgslides/src
In directory gabe:/tmp/cvs-serv2141/src
Modified Files:
svgslides-4suite
Log Message:
* example/example-inverse.svg:
* example/example-title.svg:
* example/example.svg: Add URL and presentation title to theme.
* example/example.xml: Add URL. Add slide to demonstrate
alignment.
* src/svgslides-4suite: Add support for a slide-number
variable. Add support for left/center/right alignment of list
items. Add support for spitting out an SVG group tag.
Index: svgslides-4suite
===================================================================
RCS file: /cvs/cairo/svgslides/src/svgslides-4suite,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- svgslides-4suite 21 Apr 2005 12:35:53 -0000 1.8
+++ svgslides-4suite 26 Apr 2005 18:47:15 -0000 1.9
@@ -136,8 +136,10 @@
def substitute_variable (variable):
variable_name = variable.getAttributeNS (SS, 'variable')
-# value = slide.getAttributeNS (None, u''+variable_name)
- value = get_attr_inherited (slide, variable_name)
+ if variable_name == u'slide-number':
+ value = `slide_num`
+ else:
+ value = get_attr_inherited (slide, variable_name)
variable.replaceChild (doc.createTextNode (value), variable.firstChild)
def substitute_region (region):
@@ -203,7 +205,6 @@
return root
def transform_li (li, root):
- # XXX: Theme designer should be able to draw a custom bullet
bullet_radius = font_size / 6
bullet = get_attr_inherited (li, 'bullet')
@@ -223,14 +224,26 @@
circle.setAttributeNS (None, u'cx', `li.x + bullet_radius`)
circle.setAttributeNS (None, u'cy', `li.y + font_size / 1.5`)
circle.setAttributeNS (None, u'r', `bullet_radius`)
+
+ align = get_attr_inherited (li, 'align')
values = do_xpath (li, u'text()')
text = doc.createElementNS (SVG, 'text')
root.appendChild (text)
for v in values:
text.appendChild (doc.createTextNode (v.nodeValue))
- text.setAttributeNS (None, u'x', `li.x + 3 * bullet_radius`)
- text.setAttributeNS (None, u'y', `li.y + font_size`)
+
+ x = li.x + 3 * bullet_radius
+ y = li.y + font_size
+ if align == 'center':
+ x += region_width / 2
+ text.setAttributeNS (None, u'text-anchor', u'middle')
+ elif align == 'right':
+ x += region_width
+ text.setAttributeNS (None, u'text-anchor', u'end')
+
+ text.setAttributeNS (None, u'x', `x`)
+ text.setAttributeNS (None, u'y', `y`)
return root
def transform_img (img, root):
@@ -276,6 +289,33 @@
return root
+ def transform_group (group, root):
+ x = get_attr_float (group, 'x', 0.0)
+ y = get_attr_float (group, 'y', 0.0)
+ width = get_attr_float (group, 'width', region_width)
+ height = get_attr_float (group, 'height', region_height)
+
+ x_offset = x * region_width
+
+ x_align = get_attr (group, 'x-align', 'left')
+ if x_align == 'right':
+ x_offset -= width
+ elif x_align == 'center':
+ x_offset -= width / 2
+
+ y_offset = y * region_height
+
+ y_align = get_attr (group, 'y-align', 'top')
+ if y_align == 'bottom':
+ y_offset -= height
+ elif y_align == 'center':
+ y_offset -= height / 2
+
+ group.setAttributeNS (None, u'transform', 'translate('+`x_offset`+','+`y_offset`+')')
+ root.appendChild (group)
+
+ return root
+
def transform_content_node (node, root):
if node.nodeName == u'ul':
return transform_ul (node, root)
@@ -283,6 +323,8 @@
return transform_li (node, root)
if node.nodeName == u'img':
return transform_img (node, root)
+ if node.nodeName == u'g':
+ return transform_group (node, root)
return root
def transform_content_nodes (nodes, root):
- Previous message: [cairo-commit] svgslides/example example-inverse.svg, 1.1,
1.2 example-title.svg, 1.2, 1.3 example.svg, 1.1,
1.2 example.xml, 1.3, 1.4
- Next message: [cairo-commit] svgslides ChangeLog,1.69,1.70
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list