Changeset 29756

Show
Ignore:
Timestamp:
20.02.2015 16:46:36 (5 years ago)
Author:
davidb
Message:

Latest version of extension developed by Jojo. Was originally committed to a different folder, which didn't link in with the INSTALL.sh script.

Location:
other-projects/nz-flag-design/trunk/main-form/svg-edit-local
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • other-projects/nz-flag-design/trunk/main-form/svg-edit-local/advanced-icon.xml

    r29632 r29756  
    1 <svg width="22" height="22" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> 
    2  <!-- Created with SVG-edit - http://svg-edit.googlecode.com/ --> 
    3  <title>Advanced Icon</title> 
    4  
    5  <g> 
    6   <title>Layer 1</title> 
    7   <path id="svg_4" d="m10.88436,0.22024c-5.99923,0 -10.86252,4.86325 -10.86252,10.86242c0,5.99921 4.86329,10.8625 10.86252,10.8625c5.99924,0 10.86249,-4.86329 10.86249,-10.8625c0,-5.99917 -4.86325,-10.86242 -10.86249,-10.86242zm6.26763,10.09119c-1.08453,1.24735 -2.7698,1.65986 -4.24897,1.18527l-5.37214,6.17793c-0.57253,0.65761 -1.56886,0.7249 -2.22634,0.15317s-0.72725,-1.56869 -0.15553,-2.22643l5.37953,-6.18466c-0.6672,-1.39387 -0.49098,-3.112 0.58844,-4.35266c1.02152,-1.17717 2.58048,-1.60772 3.99698,-1.25115l-2.05836,2.40053l0.67332,1.95902l2.03434,0.39532l2.06363,-2.4066c0.55914,1.35579 0.35347,2.96865 -0.67489,4.15027z" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="0" stroke="#000000" fill="#000000"/> 
    8  </g> 
    9  <g> 
    10   <title>Layer 2</title> 
    11   <text font-weight="bold" id="svg_1" transform="matrix(0.309621, 0, 0, 0.324142, 1.51575, -1.78249)" xml:space="preserve" text-anchor="middle" font-family="Serif" font-size="24" y="33.95683" x="14.44621" stroke-width="0" stroke="#000000" fill="#7f7f7f">A</text> 
    12   <text id="svg_6" font-weight="bold" transform="matrix(0.313888, 0, 0, 0.328609, 4.02574, 0.430566)" xml:space="preserve" text-anchor="middle" font-family="Serif" font-size="24" y="55.6743" x="34.96717" stroke-width="0" stroke="#000000" fill="#7f7f7f">S</text> 
    13  </g> 
     1<svg xmlns="http://www.w3.org/2000/svg"> 
     2<!--  
     3    Sample icons file. This file looks like an SVG file with groups as its 
     4    children. Each group element has an ID that must match the ID of the button given 
     5    in the extension. The SVG inside the group makes up the actual icon, and 
     6    needs use a viewBox instead of width/height for it to scale properly. 
     7     
     8    Multiple icons can be included, each within their own group. 
     9--> 
     10    <g id="advanced">  
     11        <svg width="290" height="290" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> 
     12            <!-- Created with SVG-edit - http://svg-edit.googlecode.com/ --> 
     13            <g> 
     14                <title>Show/Hide Advanced Features</title> 
     15                <ellipse ry="138.50001" rx="138.50001" id="svg_1" cy="158.8711" cx="149.06122" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="#000000"/> 
     16                <path d="m241.75288,145.3091c15.76646,-18.12448 18.9362,-42.8737 10.35747,-63.67463l-31.65828,36.91841l-31.20456,-6.06812l-10.34077,-30.0617l31.57887,-36.83224c-21.72498,-5.47167 -45.65585,1.12635 -61.35255,19.18442c-16.55795,19.04544 -19.26741,45.40413 -9.02255,66.80138l-82.52099,94.89539c-8.77747,10.08925 -7.711,25.38509 2.37802,34.16252c10.0892,8.77078 25.38839,7.71091 34.16911,-2.3783l82.42503,-94.79622c22.6888,7.30687 48.55409,0.98058 65.19121,-18.15091l0,0z" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="#ffffff" id="svg_19" transform="rotate(2.24623, 154.207, 155.149)"/> 
     17                <text font-weight="bold" transform="matrix(4.50803, 0, 0, 4.50803, -159.378, -305.57)" xml:space="preserve" text-anchor="middle" font-family="Serif" font-size="24" id="svg_3" y="97.5864" x="53.23026" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="0" stroke="#000000" fill="#bfbfbf">A</text> 
     18                <text font-weight="bold" id="svg_5" transform="matrix(4.50803, 0, 0, 4.50803, -159.378, -305.57)" xml:space="preserve" text-anchor="middle" font-family="Serif" font-size="24" y="125.42976" x="81.26555" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="0" stroke="#000000" fill="#bfbfbf">F</text> 
     19            </g> 
     20        </svg> 
     21    </g> 
    1422</svg> 
  • other-projects/nz-flag-design/trunk/main-form/svg-edit-local/ext-advanced.js

    r29632 r29756  
    99 * 
    1010 */ 
    11   
    12 /*  
    13     This is a very basic SVG-Edit extension. It adds a "Hello World" button in 
    14     the left panel. Clicking on the button, and then the canvas will show the 
    15     user the point on the canvas that was clicked on. 
    16 */ 
    17   
    18 svgEditor.addExtension("Advanced", function() {'use strict'; 
     11var advancedClicked = false; 
    1912 
     13svgEditor.addExtension("Advanced", function() {'use strict';                                      
     14                                                
    2015        return { 
    2116            name: "Advanced", 
    22             // For more notes on how to make an icon file, see the source of 
    23             // the helloworld-icon.xml 
     17            // The icon for 'advanced features' 
    2418            svgicons: svgEditor.curConfig.extPath + "advanced-icon.xml", 
    2519             
    2620            // Multiple buttons can be added in this array 
    2721            buttons: [{ 
    28                 // Must match the icon ID in helloworld-icon.xml 
     22                // Must match the icon ID in advanced-icon.xml 
    2923                id: "advanced",  
    3024                 
    31                 // This indicates that the button will be added to the "mode" 
    32                 // button panel on the left side 
    33                 type: "mode",  
     25                // This indicates that the button will be added independently to the buttons in the button 
     26                // panel on the left side (it will not be unselected when one of the other buttons is selected) 
     27                type: "context", 
     28                panel: "tools_left", 
    3429                 
    3530                // Tooltip text 
    36                 title: "Show Advanced Options",  
     31                title: "Show/Hide Advanced Features",  
    3732                 
    3833                // Events 
    3934                events: { 
    4035                    'click': function() { 
    41                         // The action taken when the button is clicked on. 
    42                         // For "mode" buttons, any other button will  
    43                         // automatically be de-pressed. 
    44                         if (svgCanvas.getMode() != "advanced") { 
    45                           svgCanvas.setMode("advanced"); 
     36                        // Toggle the advanced button 
     37                        if (advancedClicked == true) 
     38                        { 
     39                            advancedClicked = false; 
     40                            // Hide advanced features 
     41                            advancedButton(advancedClicked); 
    4642                        } 
    47                         else { 
    48                            
     43                        else 
     44                        { 
     45                            advancedClicked = true;  
     46                            // Hide advanced features 
     47                            advancedButton(advancedClicked); 
    4948                        } 
    5049                    } 
     
    5453            // on the editor canvas (not the tool panels) 
    5554            mouseDown: function() { 
    56                 // Check the mode on mousedown 
    57                 if(svgCanvas.getMode() == "advanced") { 
    58                  
    59                     // The returned object must include "started" with  
    60                     // a value of true in order for mouseUp to be triggered 
    61                     return {started: true}; 
    62                 } 
     55                advancedButton(advancedClicked); 
     56 
     57                // The returned object must include "started" with  
     58                // a value of true in order for mouseUp to be triggered 
     59                return {started: true}; 
    6360            }, 
    6461             
     
    6663            // to true (see above). Note that "opts" is an object with event info 
    6764            mouseUp: function(opts) { 
    68                 // Check the mode on mouseup 
    69                 if(svgCanvas.getMode() == "advanced") { 
    70                     var zoom = svgCanvas.getZoom(); 
    71                      
    72                     // Get the actual coordinate by dividing by the zoom value 
    73                     var x = opts.mouse_x / zoom; 
    74                     var y = opts.mouse_y / zoom; 
    75                      
    76                     var text = "These are advanced features!\n\nYou clicked here: "  
    77                         + x + ", " + y; 
    78                          
    79                     // Show the text using the custom alert function 
    80                     $.alert(text); 
    81                 } 
    82             } 
     65                //advancedButton(advancedClicked); 
     66            }, 
     67             
     68            elementChanged: function(opts) 
     69            { 
     70                advancedButton(advancedClicked); 
     71            }, 
     72             
     73            callback: function(opts) { 
     74                advancedClicked = false; 
     75                advancedButton(advancedClicked); 
     76            } 
    8377        }; 
    8478}); 
    8579 
     80// Function: advancedButton 
     81// Unless advanced button is selected, advanced features will be hidden 
     82this.advancedButton = function() { 
     83     
     84    // 'Advanced feature' elements 
     85    var elements = ['sidepanels', 'editor_panel', 'tool_move_top', 'tool_move_bottom', 'tool_topath', 'tool_reorient', 'tool_make_link', 'idLabel', 'tool_angle', 'tool_blur', 'tool_position', 'xy_panel', 'rect_width_tool', 'rect_height_tool', 'cornerRadiusLabel']; 
     86 
     87    // Toggle the display attributes of the selected advanced elements 
     88    for (var i = 0; i < elements.length; i++) { 
     89        if (advancedClicked == false) { 
     90            document.getElementById(elements[i]).style.display = 'none'; 
     91        } 
     92        else { 
     93            document.getElementById(elements[i]).style.display = 'block'; 
     94        } 
     95    } 
     96     
     97    // Remove strange extra 'tool_seps' when advanced features is not selected 
     98    if (advancedClicked == false) 
     99    { 
     100        $("#selected_panel :first-child").find(".tool_sep").css("display", "none") 
     101    } 
     102}