[Dextrose] [PATCH] New suggestion for arrow drawing in Paint activity.olpc4170
Gonzalo Odiard
gonzalo at laptop.org
Wed Oct 20 14:22:22 EDT 2010
I think it's better to modify the tool to enable draw a arrow from one point
to another in every direction, diagonals too.
Then you can use a property in the tool palette to change the size of the
arrow.
I think this will ne a little more difficult to implement, but more
expressive and powerful.
I suggest send a mail before starting to work with a ticket, to agree in the
strategy to implement.
Many times the tickets don't have sufficient information or are outdated.
Gonzalo
On Wed, Oct 20, 2010 at 6:32 PM, Anurag Chowdhury <anurag at seeta.in> wrote:
> In the paint activity's shape tool we were able to make only horizontal
> arrows,
> so now we have added a new tool which makes vertical arrows.
>
> ---
> Area.py | 8 ++++++++
> Desenho.py | 31 +++++++++++++++++++++++++++++++
> toolbox.py | 21 +++++++++++++++++++++
> 3 files changed, 60 insertions(+), 0 deletions(-)
>
> diff --git a/Area.py b/Area.py
> index 2dca7da..56c4267 100644
> --- a/Area.py
> +++ b/Area.py
> @@ -438,6 +438,10 @@ class Area(gtk.DrawingArea):
> elif self.tool['name'] == 'arrow':
> self.configure_line(self.line_size)
> self.d.arrow(widget,coords,True,self.tool['fill'])
> +
> + elif self.tool['name'] == 'vertical arrow':
> + self.d.arrow_vertical(widget,coords,False,\
> + self.tool['fill'])
> + self.enableUndo(widget)
>
> elif self.tool['name'] == 'parallelogram':
> self.configure_line(self.line_size)
> @@ -541,6 +545,10 @@ class Area(gtk.DrawingArea):
> elif self.tool['name'] == 'arrow':
> self.d.arrow(widget,coords,False,self.tool['fill'])
> self.enableUndo(widget)
> +
> + elif self.tool['name'] == 'vertical arrow':
> +
> self.d.arrow_vertical(widget,coords,False,self.tool['fill'])
> + self.enableUndo(widget)
>
> elif self.tool['name'] == 'parallelogram':
> self.d.parallelogram(widget,coords,False,self.tool['fill'])
> diff --git a/Desenho.py b/Desenho.py
> index c9a134b..e90a45c 100644
> --- a/Desenho.py
> +++ b/Desenho.py
> @@ -298,6 +298,37 @@ class Desenho:
> pixmap.draw_polygon(widget.gc_line,False,points)
> widget.queue_draw()
>
> + def arrow_vertical(self, widget, coords, temp, fill):
> + """Draw a arrow.
> +
> + @param self -- Desenho.Desenho instance
> + @param widget -- Area object (GtkDrawingArea)
> + @param coords -- Two value tuple
> + @param temp -- switch between pixmap and pixmap_temp
> + @param fill -- Fill object
> +
> + """
> + if temp == True:
> + pixmap = widget.pixmap_temp
> + else:
> + pixmap = widget.pixmap
> + width, height = widget.window.get_size()
> +
> + x = widget.oldx - coords[0]
> + y = widget.oldy - coords[1]
> + points = [(widget.oldx,widget.oldy),\
> +(widget.oldx+x,widget.oldy-int(y/6)),\
> +(widget.oldx+int(x/2),widget.oldy-int(y/6)),\
> +(widget.oldx+int(x/2),widget.oldy-y),\
> +(widget.oldx-int(x/2),widget.oldy-y),\
> +(widget.oldx-int(x/2),widget.oldy-int(y/6)),\
> +(widget.oldx-x,widget.oldy-int(y/6))]
> + pixmap.draw_drawable(widget.gc,widget.pixmap,0,0,0,0,width,height)
> + if fill == True:
> + pixmap.draw_polygon(widget.gc,True,points)
> + pixmap.draw_polygon(widget.gc_line,False,points)
> + widget.queue_draw()
> +
>
> def parallelogram(self, widget, coords, temp, fill):
> """Draw a parallelogram.
> diff --git a/toolbox.py b/toolbox.py
> index 299181b..520e5f0 100644
> --- a/toolbox.py
> +++ b/toolbox.py
> @@ -613,6 +613,15 @@ class ShapesToolbar(gtk.Toolbar):
> 'fill' : True,
> 'vertices' : 5
> }
> + _SHAPE_ARROW_VERTICAL= {
> + 'name' : 'vertical arrow',
> + 'line size' : 5,
> + 'fill color' : None,
> + 'stroke color' : None,
> + 'line shape' : 'circle',
> + 'fill' : True,
> + 'vertices' : 5
> + }
> _SHAPE_CURVE = {
> 'name' : 'curve',
> 'line size' : 2,
> @@ -795,6 +804,13 @@ class ShapesToolbar(gtk.Toolbar):
> self._configure_palette_shape_arrow()
> except:
> logging.debug('Could not create palette for Shape Arrow')
> +
> + self._shape_arrow_vertical = DrawToolButton\
> +
> ('tool-shape-arrow-vertical',activity.tool_group,_('Arrow-Vertical'))
> + self.insert(self._shape_arrow_vertical, -1)
> + try:
> + self._configure_palette_shape_arrow_vertical()
> + except:
> + logging.debug('Could not create palette for Shape Vertical
> Arrow')
>
> self._shape_star = DrawToolButton('tool-shape-star',
> activity.tool_group,_('Star'))
> self.insert(self._shape_star, -1)
> @@ -819,6 +835,7 @@ class ShapesToolbar(gtk.Toolbar):
>
>
> self._shape_arrow.connect('clicked', self.set_tool,
> self._SHAPE_ARROW)
> + self._shape_arrow_vertical.connect('clicked', self.set_tool,\
> + self._SHAPE_ARROW_VERTICAL)
> self._shape_ellipse.connect('clicked', self.set_tool,
> self._SHAPE_ELLIPSE)
> self._shape_freeform.connect('clicked', self.set_tool,
> self._SHAPE_FREEFORM)
> self._shape_heart.connect('clicked', self.set_tool,
> self._SHAPE_HEART)
> @@ -908,6 +925,10 @@ class ShapesToolbar(gtk.Toolbar):
> logging.debug('Creating palette to shape arrow')
> self._create_simple_palette(self._shape_arrow, self._SHAPE_ARROW)
>
> + def _configure_palette_shape_arrow_vertical(self):
> + logging.debug('Creating palette to shape Vertical arrow')
> + self._create_simple_palette(self._shape_arrow_vertical,\
> + self._SHAPE_ARROW_VERTICAL)
> +
> def _configure_palette_shape_star(self):
> logging.debug('Creating palette to shape star')
>
> --
> 1.7.2.3
> _______________________________________________
> Dextrose mailing list
> Dextrose at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/dextrose
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/dextrose/attachments/20101020/1d217344/attachment.html>
More information about the Dextrose
mailing list