chenbo007 / svg-edit

Automatically exported from code.google.com/p/svg-edit
0 stars 0 forks source link

Add Resizing Grips for Selected Element #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently the only way to resize an element is to delete it and then redraw
it.  This is a major flaw in the UI of any editor.

1) turn the "selectedOutline" SVG element into a group <g> and nest the
rectangle within it

2) Add a 'grip' to the corners of the selected outline for outlines of
rect, circle, ellipse, line (not necessary for text?)

3) when mouseover the corner grips, the cursor changes to the appropriate
diagonal resize cursor

4) Add a 'grip' to the midpoints along the lines of the selected outline

5) when mouseover the side grips, the cursor chagnes to the appropriate
resize cursor (vertical/horizontal)

6) when mousedown on a grip, track in mousemove the new bounds and update
the selectedOutline as well as the transform value (similar to dragging)

7) when mouseup from a grip, calculate the new size and then calculate the
dimensions that need to change on the element:
  a) rect's x, y, width and height
  b) circle's cx, cy, r
  c) ellipse's cx, cy, rx, ry
  d) line's x1, y1, x2, y2
  e) path - must recalculate all coordinates for the path segments

The reason why #7 is important is to avoid having to have a bunch of
transform attributes in our SVG source once a resize is complete (same
logic is behind the dragging code).

When/if we get into grouping objects then we might want to consider using
the transform attributes.

Original issue reported on code.google.com by codedr...@gmail.com on 17 Jun 2009 at 10:10

GoogleCodeExporter commented 9 years ago

Original comment by codedr...@gmail.com on 18 Jun 2009 at 5:06

GoogleCodeExporter commented 9 years ago
r156 is a start on this - the grips are now visible, but they do not do 
anything. 
This covers reqt 1, 2 and 4.

Original comment by codedr...@gmail.com on 18 Jun 2009 at 5:09

GoogleCodeExporter commented 9 years ago
Implemented all requirements in r173.  This is a big diff but it's partially 
because
I moved some code into a function and moved another function to a different 
location
in the file.

Anyway, please report any bugs with resizing as new Issues.

Original comment by codedr...@gmail.com on 23 Jun 2009 at 5:19