Skip to content

Commit

Permalink
Worked a bit on the selection markers
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Berg committed Mar 25, 2014
1 parent 7bc46d6 commit 7f02d71
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 18 deletions.
150 changes: 150 additions & 0 deletions editor/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*globals svgEditor*/
/*
The config.js file is intended for the setting of configuration or
preferences which must run early on; if this is not needed, it is
recommended that you create an extension instead (for greater
reusability and modularity).
*/

// CONFIG AND EXTENSION SETTING
/*
See defaultConfig and defaultExtensions in svg-editor.js for a list
of possible configuration settings.
See svg-editor.js for documentation on using setConfig().
*/

// URL OVERRIDE CONFIG
svgEditor.setConfig({
/**
To override the ability for URLs to set URL-based SVG content,
uncomment the following:
*/
// preventURLContentLoading: true,
/**
To override the ability for URLs to set other configuration (including
extensions), uncomment the following:
*/
// preventAllURLConfig: true,
/**
To override the ability for URLs to set their own extensions,
uncomment the following (note that if setConfig() is used in
extension code, it will still be additive to extensions,
however):
*/
// lockExtensions: true,
});

svgEditor.setConfig({
/*
Provide default values here which differ from that of the editor but
which the URL can override
*/
}, {allowInitialUserOverride: true});

// EXTENSION CONFIG
svgEditor.setConfig({
extensions: [
// 'ext-overview_window.js',
// 'ext-markers.js',
// 'ext-connector.js',
'ext-eyedropper.js',
// 'ext-shapes.js',
// 'ext-imagelib.js',
'ext-grid.js',
'ext-polygon.js',
'ext-star.js',
'ext-panning.js',
// 'ext-storage.js'
]
, noDefaultExtensions: true, // noDefaultExtensions can only be meaningfully used in config.js or in the URL
});

// OTHER CONFIG
svgEditor.setConfig({
// canvasName: 'default',
// canvas_expansion: 3,
initFill: {
color: 'bbccdd', // bluish
opacity: 1
},
initStroke: {
width: 1,
color: '444455', // slight gray
opacity: 1
},
// initOpacity: 1,
// colorPickerCSS: '',
// initTool: 'select',
// wireframe: false,
showlayers: false,
// no_save_warning: false,
// PATH CONFIGURATION
// imgPath: 'images/',
// langPath: 'locale/',
// extPath: 'extensions/',
// jGraduatePath: 'jgraduate/images/',
/*
Uncomment the following to allow at least same domain (embedded) access,
including file:// access.
Setting as `['*']` would allow any domain to access but would be unsafe to
data privacy and integrity.
*/
// allowedOrigins: [window.location.origin || 'null'], // May be 'null' (as a string) when used as a file:// URL
// DOCUMENT PROPERTIES
// dimensions: [640, 480],
// EDITOR OPTIONS
// gridSnapping: false,
// gridColor: '#000',
// baseUnit: 'px',
// snappingStep: 10,
// showRulers: true,
// EXTENSION-RELATED (GRID)
// showGrid: false, // Set by ext-grid.js
// EXTENSION-RELATED (STORAGE)
// noStorageOnLoad: false, // Some interaction with ext-storage.js; prevent even the loading of previously saved local storage
// forceStorage: false, // Some interaction with ext-storage.js; strongly discouraged from modification as it bypasses user privacy by preventing them from choosing whether to keep local storage or not
// emptyStorageOnDecline: true, // Used by ext-storage.js; empty any prior storage if the user declines to store
});

// PREF CHANGES
/**
setConfig() can also be used to set preferences in addition to
configuration (see defaultPrefs in svg-editor.js for a list of
possible settings), but at least if you are using ext-storage.js
to store preferences, it will probably be better to let your
users control these.
As with configuration, one may use allowInitialUserOverride, but
in the case of preferences, any previously stored preferences
will also thereby be enabled to override this setting (and at a
higher priority than any URL preference setting overrides).
Failing to use allowInitialUserOverride will ensure preferences
are hard-coded here regardless of URL or prior user storage setting.
*/
svgEditor.setConfig(
{
// lang: '', // Set dynamically within locale.js if not previously set
// iconsize: '', // Will default to 's' if the window height is smaller than the minimum height and 'm' otherwise
/**
* When showing the preferences dialog, svg-editor.js currently relies
* on curPrefs instead of $.pref, so allowing an override for bkgd_color
* means that this value won't have priority over block auto-detection as
* far as determining which color shows initially in the preferences
* dialog (though it can be changed and saved).
*/
// bkgd_color: '#FFF',
// bkgd_url: '',
// img_save: 'embed',
// Only shows in UI as far as alert notices
// save_notice_done: false,
// export_notice_done: false
}
);
svgEditor.setConfig(
{
// Indicate pref settings here if you wish to allow user storage or URL settings
// to be able to override your default preferences (unless other config options
// have already explicitly prevented one or the other)
},
{allowInitialUserOverride: true}
);
Empty file added editor/goo/extensions.js
Empty file.
150 changes: 150 additions & 0 deletions editor/goo/svg-editor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@

/* Layout */
#ruler_corner {
box-sizing:border-box;
height: 16px;
}

#ruler_x {
box-sizing:border-box;
right: 0;
}

#ruler_y {
box-sizing:border-box;
bottom: 41px;
}

.dropdown ul {
left:-15px;
}

#workarea {
right:0;
}

#tools_top {
left: 41px;
}

/* Styles */
body {
background-color:white;
}

#tools_left, .color_tool, #palette_holder {
background:transparent;
}

.tool_sep {
width:12px;
border:none;
background:transparent;
}

/* Buttons */

button {
cursor:pointer !important;
}

button:active, button:focus {
outline:none !important;
}

.tool_button,
.push_button,
.tool_button_current,
.push_button_pressed,
.buttondown,
.tools_flyout .tool_button {
border-radius:1px;
-webkit-border-radius:1px;
-moz-border-radius:1px;
box-shadow:none !important;
-moz-box-shadow:none !important;
-webkit-box-shadow:none !important;
background:transparent;
border:1px solid #ddd;
}

.tool_button_current,
.push_button_pressed,
.buttondown {
background:#eee !important;
}

.tools_flyout .tool_button {
background:white;
border-right-width:0;
}

.tools_flyout .tool_button:first-child {
border-top-left-radius: 2px;
border-bottom-left-radius: 2px;
}

.tools_flyout .tool_button:last-child {
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;
border-right-width:1px;
}


/* Dropdowns */

.dropdown li {
border:1px solid #ddd;
border-bottom-width:0;
background:white;
cursor:pointer;
}

.dropdown li:hover {
background:#eee;
}

.dropdown li.special:hover {
background:white;
}

.dropdown li:first-child {
border-top-left-radius: 2px;
border-top-right-radius: 2px;
}

.dropdown li:last-child {
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
border-bottom-width:1px;
}

.dropdown button {
border: 1px solid #ddd;
border-radius: 2px;
}

.dropdown button.down {
border: 1px solid #ddd;
background:#ddd;
}

/* Slider */
.ui-slider {
height:0;
margin:0 5px;
border-color:#bbb;
}

.ui-slider-horizontal .ui-slider-handle {
outline:none;
box-sizing:border-box;
height:10px;
width:10px;
border-radius:5px;
top:-5px;
}

.ui-slider-handle:hover {
outline:none;
}
31 changes: 17 additions & 14 deletions editor/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (!svgedit.select) {
var svgFactory_;
var config_;
var selectorManager_; // A Singleton
var gripRadius = svgedit.browser.isTouch() ? 10 : 4;
var gripRadius = svgedit.browser.isTouch() ? 10 : 3;

// Class: svgedit.select.Selector
// Private class for DOM element selection boxes
Expand Down Expand Up @@ -55,9 +55,9 @@ svgedit.select.Selector = function(id, elem) {
'attr': {
'id': ('selectedBox' + this.id),
'fill': 'none',
'stroke': '#22C',
'stroke': '#888',
'stroke-width': '1',
'stroke-dasharray': '5,5',
'stroke-dasharray': '1,2',
// need to specify this so that the rect is not selectable
'style': 'pointer-events:none'
}
Expand Down Expand Up @@ -183,8 +183,8 @@ svgedit.select.Selector.prototype.resize = function() {

var nbox = svgedit.math.transformBox(l*current_zoom, t*current_zoom, w*current_zoom, h*current_zoom, m),
aabox = nbox.aabox,
nbax = aabox.x - offset,
nbay = aabox.y - offset,
nbax = aabox.x - offset -.5,
nbay = aabox.y - offset -.5,
nbaw = aabox.width + (offset * 2),
nbah = aabox.height + (offset * 2);

Expand Down Expand Up @@ -247,8 +247,8 @@ svgedit.select.Selector.prototype.resize = function() {
var dir;
for (dir in this.gripCoords) {
var coords = this.gripCoords[dir];
selectedGrips[dir].setAttribute('cx', coords[0]);
selectedGrips[dir].setAttribute('cy', coords[1]);
selectedGrips[dir].setAttribute('x', coords[0]-1.5);
selectedGrips[dir].setAttribute('y', coords[1]-1.5);
}

// we want to go 20 pixels in the negative transformed y direction, ignoring scale
Expand Down Expand Up @@ -326,11 +326,14 @@ svgedit.select.SelectorManager.prototype.initGroup = function() {
var dir;
for (dir in this.selectorGrips) {
var grip = svgFactory_.createSVGElement({
'element': 'circle',
'element': 'rect',
'attr': {
'id': ('selectorGrip_resize_' + dir),
'fill': '#22C',
'r': gripRadius,
'fill': '#888',
// x:-gripRadius/2,
// y:-gripRadius/2,
height:'3',
width:'3',
'style': ('cursor:' + dir + '-resize'),
// This expands the mouse-able area of the grips making them
// easier to grab with the mouse.
Expand All @@ -352,7 +355,7 @@ svgedit.select.SelectorManager.prototype.initGroup = function() {
'element': 'line',
'attr': {
'id': ('selectorGrip_rotateconnector'),
'stroke': '#22C',
'stroke': '#222',
'stroke-width': '1'
}
})
Expand All @@ -363,10 +366,10 @@ svgedit.select.SelectorManager.prototype.initGroup = function() {
'element': 'circle',
'attr': {
'id': 'selectorGrip_rotate',
'fill': 'lime',
'fill': '#888',
'r': gripRadius,
'stroke': '#22C',
'stroke-width': 2,
'stroke': '#222',
'stroke-width': 1,
'style': 'cursor:url(' + config_.imgPath + 'rotate.png) 12 12, auto;'
}
})
Expand Down
Loading

0 comments on commit 7f02d71

Please sign in to comment.