yushiro / svg-edit

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

Select Icon Size repeatedly reset in svg-editor.js #617

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  Provide an alternate svg_edit_icons.svg file with alternative icons.
2.  Use svgEditor.ready() to override the default sizing ('s', 'm', 'l') with 
appropriate sizes for icons in Step #1 using $.resizeSvgIcons().
3.  Select an Item and the '#tool_select' icon is resized to the default 'm'.

What is the expected output? What do you see instead?

I would hope that there would be a way to have the svgEditor.ready() resizing 
become permanent.

Please provide any additional information below.

The error can be traced as such:

Selecting an item calls svgEditor.selectedChanged() which calls 
svgEditor.togglePathEditMode() which calls svgEditor.setIcon("#tool_select", 
type) which resizes the icon.

Alternative would be to assume that the two types of 'select' icons are the 
same size and only set the sizing on startup.  I'm willing to work on a fix, 
but I think it would require some discussion around when it can be assumed that 
icon sizes are set and subsequent changes only affect the source of the icon.

I'm currently getting around this by providing an extension that overrides the 
sizing override in selectedChanged.

My steps listed above work for other icons (e.g. Pen, Pencil, Rectangle) and 
only fails on Select.

Thanks!

Original issue reported on code.google.com by jacob.brookover on 22 Jul 2010 at 9:53

GoogleCodeExporter commented 9 years ago
Yeah, the whole icon resize thing is kind of ugly to have to deal with in 
situations like this...I'm actually experimenting with a new method of changing 
the UI size using CSS transforms (as they're supported in all current and 
previous versions of browsers), so I'm hoping that will solve this problem too.

Original comment by adeve...@gmail.com on 23 Jul 2010 at 3:26

GoogleCodeExporter commented 9 years ago
Let me continue this conversation from your email on the mailing list...

Guess I must not have understood your problem correctly. :) I'd assumed that 
the new behavior, which removes the resizing part of setIcon, would have 
prevented this from being a problem. The icon is simply replaced with another 
one at its original size, then the parent's CSS transform keeps it at the 
appropriate size.

So assuming this is still a problem, under what situation does it occur? Sorry 
if it's obvious, I may just be missing something.

Original comment by adeve...@gmail.com on 29 Jul 2010 at 6:45

GoogleCodeExporter commented 9 years ago
Loading an icon set via $.svgIcons() overwrites the width/height that is 
defined in the actual SVG file if width/height parameters that are provided - 
in svg-editor.js, that is 24 x 24 for the default tool set.

I modified your svg-edit-icons.svg with my new icons (of very inconsistent 
sizes) and pointed the editor to that file.  They're loaded as normal, with 
svg-editor.js sizing them to 24x24.  The icons that are stored in the array in 
$.svgIcons all get this new 24x24 size.  Then, they are automatically inserted 
into the page in the appropriate places.

I then call $.resizeSvgIcons() to size the icons in the page appropriately, but 
this only applies to the icons that are actually inserted into the body of the 
page - not those stored in the array in $.svgIcons.

This is normally not a problem since 99% of the icons don't change after that 
point.  The exception is #tool_select which is emptied and replaced in 
togglePathEditMode()->setIcon().  At that point, the original imported SVG code 
(with the original restricted size of 24x24) is reinserted into the page.

Does that help?  :)  

The two potential fixes I see are:
1.  Rewrite $.resizeSvgIcons() to carry the changes not only to the page, but 
also to the stored icon in the local array.  
2.  Don't overwrite the width/height in the source SVG file when importing (or 
provide an additional 'force' parameter that is NOT used in svg-editor.js).

As an aside, my boss and I both love $.svgIcons() - Very interesting technique 
:)

Thanks!

Original comment by jacob.brookover on 29 Jul 2010 at 10:10