small changes to UI

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@224 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Pavol Rusnak 2009-06-29 14:38:30 +00:00
parent 54e20edef2
commit ece4974a91
4 changed files with 151 additions and 160 deletions

View File

@ -1,5 +1,5 @@
body {
background-color: #E8E8E8;
background: #E8E8E8;
}
#svg_editor {
@ -31,22 +31,15 @@ body {
vertical-align: middle;
width: 640px;
height: 480px;
border-left: 1px solid #FFFFFF;
border-top: 1px solid #FFFFFF;
border-right: 1px solid #808080;
border-bottom: 1px solid #808080;
}
#svg_editor div#palette_holder {
border: 2px solid #808080;
border-top: none;
overflow-x: scroll;
overflow-y: hidden;
position: absolute;
left: 75px;
right: 2px;
bottom: 22px;
height: 31px;
border: 1px solid #808080;
border-top: none;
margin-top: 2px;
}
#svg_editor #fill_color, #svg_editor #stroke_color {
@ -72,12 +65,12 @@ body {
#svg_editor div#workarea {
position:absolute;
top: 70px;
left: 75px;
top: 40px;
left: 40px;
right: 2px;
bottom: 53px;
background-color: #E8E8E8;
border: 2px solid #808080;
bottom: 100px;
background-color: #A0A0A0;
border: 1px solid #808080;
overflow: auto;
}
@ -87,40 +80,30 @@ body {
float: left;
}
#svg_editor .tools_panel {
/* background: #E8E8E8;*/
/* border: 1px solid #808080;*/
}
#svg_editor #context_tools {
#svg_editor #tools_top {
position: absolute;
left: 19px;
left: 38px;
right: 2px;
top: 2px;
height: 68px;
height: 36px;
border-bottom: none;
}
#svg_editor #context_tools div {
#svg_editor #tools_top div {
float: left;
}
#svg_editor #tools_container {
#svg_editor #tools_left {
position: absolute;
left: 2px;
top: 70px;
bottom: 22px;
}
#svg_editor #tools {
border-right: none;
width: 70px;
text-align: center;
width: 36px;
top: 38px;
left: 2px;
}
/* TODO: fix this */
div.color_block {
display:inline-block;
display: inline-block;
}
#svg_editor #selected_panel {
@ -204,8 +187,6 @@ div.color_block {
position: absolute;
display: none;
background: #E8E8E8;
/* border: 1px solid #808080;
padding: 5px;*/
}
#svg_editor .tools_flyout {
@ -259,21 +240,29 @@ div.color_block {
background-color: #B0B0B0;
}
#svg_editor #footer {
#svg_editor #tools_bottom {
position: absolute;
left: 75px;
left: 40px;
right: 2px;
bottom: 2px;
height: 20px;
border-top: none;
height: 100px;
}
#svg_editor #footer_left {
#svg_editor #tools_bottom_1 {
width: 100px;
height: 100px;
float: left;
position: absolute;
top: -2px;
}
#svg_editor #footer_right {
float: right;
#svg_editor #tools_bottom_2 {
width: 250px;
height: 100px;
float: left;
}
#svg_editor #tools_bottom_3 {
}
#svg_editor #copyright {
text-align: right;
}

View File

@ -15,14 +15,11 @@
<div id="svg_editor">
<div id="workarea">
<style id="styleoverrides" type="text/css"></style>
<div id="svgcanvas">
<div id="svgcanvas"></div>
</div>
</div>
<div id="context_tools" class="tools_panel">
<div id="tools_top" class="tools_panel">
<!-- File-like buttons: New, Save -->
<div>
<img class="tool_button" id="tool_clear" src="images/clear.png" title="New Image [N]" alt="Clear" />
@ -78,7 +75,7 @@
<label class="circle_tool">r:</label>
<input id="circle_r" class="circle_tool attr_changer" title="Change circle's radius" alt="r" size="3"/>
</div>
<div id="ellipse_panel">
<img class="tool_sep" src="images/sep.png" alt="|"/>
<label class="ellipse_tool">cx:</label>
@ -90,7 +87,7 @@
<label class="ellipse_tool">ry:</label>
<input id="ellipse_ry" class="ellipse_tool attr_changer" title="Change ellipse's y radius" alt="ry" size="3"/>
</div>
<div id="line_panel">
<img class="tool_sep" src="images/sep.png" alt="|"/>
<label class="line_tool">x1:</label>
@ -131,14 +128,20 @@
</select>
<input id="text" class="text_tool" type="text" title="Change text contents" size="35"/>
</div>
</div>
</div> <!-- tools_top -->
<div id="palette_holder">
<div id="palette" title="Click to change fill color, shift-click to change stroke color"></div>
</div>
<div id="tools_left" class="tools_panel">
<img class="tool_button_current" id="tool_select" src="images/select.png" title="Select Tool [1]" alt="Select"/><br/>
<img class="tool_button" id="tool_path" src="images/path.png" title="Pencil Tool [2]" alt="Pencil"/><br/>
<img class="tool_button" id="tool_line" src="images/line.png" title="Line Tool [3]" alt="Line"/><br/>
<img class="tool_button" id="tools_rect_show" src="images/square.png" title="Square/Rect Tool [4/Shift+4]" alt="Square"/><br/>
<img class="tool_button" id="tools_ellipse_show" src="images/circle.png" title="Ellipse/Circle Tool [5/Shift+5]" alt="Circle"/><br/>
<img class="tool_button" id="tool_text" src="images/text.png" title="Text Tool [6]" alt="Text"/>
</div> <!-- tools_left -->
<div id="footer" class="tools_panel">
<div id="footer_left">
<div id="tools_bottom" class="tools_panel">
<div id="tools_bottom_1">
<select id="resolution">
<option selected="selected">640x480</option>
<option>800x600</option>
@ -147,23 +150,14 @@
<option>1600x1200</option>
</select>
</div>
<div id ="footer_right">SVG-edit v2.2-preAlpha @ <a href="http://svg-edit.googlecode.com/">http://svg-edit.googlecode.com/</a>
</div>
</div>
<div id="tools_container">
<div id="tools" class="tools_panel">
<img class="tool_button_current" id="tool_select" src="images/select.png" title="Select Tool [1]" alt="Select"/><br/>
<img class="tool_button" id="tool_path" src="images/path.png" title="Pencil Tool [2]" alt="Pencil"/><br/>
<img class="tool_button" id="tool_line" src="images/line.png" title="Line Tool [3]" alt="Line"/><br/>
<img class="tool_button" id="tools_rect_show" src="images/square.png" title="Square/Rect Tool [4/Shift+4]" alt="Square"/><br/>
<img class="tool_button" id="tools_ellipse_show" src="images/circle.png" title="Ellipse/Circle Tool [5/Shift+5]" alt="Circle"/><br/>
<img class="tool_button" id="tool_text" src="images/text.png" title="Text Tool [6]" alt="Text"/>
<hr/>
<div>opacity<br/>
<select id="group_opacity" title="Change group opacity">
<div id="tools_bottom_2">
<table>
<tr>
<td>fill:</td>
<td><div id="fill_color" class="color_block" title="Change fill color"></div></td>
<td>
<select id="fill_opacity" title="Change fill opacity">
<option selected="selected" value="1">100 %</option>
<option value="0.9">90 %</option>
<option value="0.8">80 %</option>
@ -174,14 +168,13 @@
<option value="0.3">30 %</option>
<option value="0.2">20 %</option>
<option value="0.1">10 %</option>
</select>
</div> <!-- opacity -->
<hr/>
<div>fill<br/>
<div id="fill_color" class="color_block" title="Change fill color"></div>
<select id="fill_opacity" title="Change fill opacity">
</select>
</td>
</tr><tr>
<td>stroke:</td>
<td><div id="stroke_color" class="color_block" title="Change stroke color"></div></td>
<td>
<select id="stroke_opacity" title="Change stroke opacity">
<option selected="selected" value="1">100 %</option>
<option value="0.9">90 %</option>
<option value="0.8">80 %</option>
@ -192,28 +185,31 @@
<option value="0.3">30 %</option>
<option value="0.2">20 %</option>
<option value="0.1">10 %</option>
</select>
</div> <!-- fill -->
<hr/>
<div>stroke<br/>
<div id="stroke_color" class="color_block" title="Change stroke color"></div><br/>
<select id="stroke_width" title="Change stroke width">
</select>
</td>
<td>
<select id="stroke_width" title="Change stroke width">
<option selected="selected" value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="5">5</option>
<option value="7">7</option>
</select>
<select id="stroke_style" title="Change stroke dash style">
</select>
</td>
<td>
<select id="stroke_style" title="Change stroke dash style">
<option selected="selected" value="none">---</option>
<option value="2,2">...</option>
<option value="5,5">- -</option>
<option value="5,2,2,2">- .</option>
<option value="5,2,2,2,2,2">- ..</option>
</select>
<select id="stroke_opacity" title="Change stroke opacity">
</td>
</tr><tr>
<td>group:</td>
<td></td>
<td>
<select id="group_opacity" title="Change group opacity">
<option selected="selected" value="1">100 %</option>
<option value="0.9">90 %</option>
<option value="0.8">80 %</option>
@ -224,23 +220,33 @@
<option value="0.3">30 %</option>
<option value="0.2">20 %</option>
<option value="0.1">10 %</option>
</select>
</div> <!-- stroke -->
</div> <!-- tools -->
<div id="color_picker"></div>
<div id="tools_rect" class="tools_flyout">
<div id="tool_square" class="tool_flyout_button" title="Square"></div>
<div id="tool_rect" class="tool_flyout_button" title="Rectangle"></div>
<div id="tool_fhrect" class="tool_flyout_button" title="Free-Hand Rectangle"></div>
</select>
</td>
</tr>
</table>
</div>
<div id="tools_ellipse" class="tools_flyout">
<div id="tool_circle" class="tool_flyout_button" title="Circle"></div>
<div id="tool_ellipse" class="tool_flyout_button" title="Ellipse"></div>
<div id="tool_fhellipse" class="tool_flyout_button" title="Free-Hand Ellipse"></div>
<div id="tools_bottom_3">
<div id="palette_holder"><div id="palette" title="Click to change fill color, shift-click to change stroke color"></div></div>
<div id="copyright">SVG-edit v2.2-preAlpha @ <a href="http://svg-edit.googlecode.com/">http://svg-edit.googlecode.com/</a></div>
</div>
</div>
<!-- hidden divs -->
<div id="color_picker"></div>
<div id="tools_rect" class="tools_flyout">
<div id="tool_square" class="tool_flyout_button" title="Square"></div>
<div id="tool_rect" class="tool_flyout_button" title="Rectangle"></div>
<div id="tool_fhrect" class="tool_flyout_button" title="Free-Hand Rectangle"></div>
</div>
<div id="tools_ellipse" class="tools_flyout">
<div id="tool_circle" class="tool_flyout_button" title="Circle"></div>
<div id="tool_ellipse" class="tool_flyout_button" title="Ellipse"></div>
<div id="tool_fhellipse" class="tool_flyout_button" title="Free-Hand Ellipse"></div>
</div>
</div> <!-- tools_container -->

View File

@ -18,7 +18,7 @@ function svg_edit_setup() {
var textBeingEntered = false;
var selectedElement = null;
// called when we've selected a different element
var selectedChanged = function(window,elem) {
selectedElement = elem;
@ -35,24 +35,24 @@ function svg_edit_setup() {
updateContextPanel(true);
}
// called when any element has changed
// called when any element has changed
var elementChanged = function(window,elem) {
// if the element changed was the svg, then it must be a resolution change
if (elem && elem.tagName == "svg") {
changeResolution(parseInt(elem.getAttribute("width")),
changeResolution(parseInt(elem.getAttribute("width")),
parseInt(elem.getAttribute("height")));
}
// we update the contextual panel with potentially new
// positional/sizing information (we DON'T want to update the
// toolbar here as that creates an infinite loop)
// also this updates the history buttons
// we tell it to skip focusing the text control if the
// we tell it to skip focusing the text control if the
// text element was previously in focus
updateContextPanel(false);
}
// updates the toolbar (colors, opacity, etc) based on the selected element
function updateToolbar() {
if (selectedElement != null) {
@ -78,7 +78,7 @@ function svg_edit_setup() {
$('#stroke_width').val(selectedElement.getAttribute("stroke-width")||1);
$('#stroke_style').val(selectedElement.getAttribute("stroke-dasharray")||"none");
}
updateToolButtonState();
}
@ -136,7 +136,7 @@ function svg_edit_setup() {
break;
}
}
// update history buttons
if (svgCanvas.getUndoStackSize() > 0) {
$('#tool_undo').removeClass( 'tool_button_disabled');
@ -166,9 +166,9 @@ function svg_edit_setup() {
$('#palette').append(str);
var pos = $('#tools_rect_show').position();
$('#tools_rect').css({'left': pos.left+2, 'top': pos.top+2});
$('#tools_rect').css({'left': pos.left+4, 'top': pos.top+40});
pos = $('#tools_ellipse_show').position();
$('#tools_ellipse').css({'left': pos.left+2, 'top': pos.top+2});
$('#tools_ellipse').css({'left': pos.left+4, 'top': pos.top+40});
$('#stroke_width').change(function(){
svgCanvas.setStrokeWidth(this.options[this.selectedIndex].value);
@ -205,7 +205,7 @@ function svg_edit_setup() {
$('#rect_radius').change(function(){
svgCanvas.setRectRadius(this.options[this.selectedIndex].value);
});
$('.attr_changer').change(function() {
svgCanvas.changeSelectedAttribute(this.getAttribute("alt"), this.value);
});
@ -342,7 +342,7 @@ function svg_edit_setup() {
var clickSave = function(){
svgCanvas.save();
}
var clickUndo = function(){
if (svgCanvas.getUndoStackSize() > 0)
svgCanvas.undo();
@ -521,7 +521,7 @@ function svg_edit_setup() {
$('#tools_rect').mouseleave(function() {
$('#tools_rect').fadeOut();
});
$('#tools_ellipse_show').mousedown(function(evt){
$('#tools_ellipse').show();
// this prevents the 'image drag' behavior in Firefox
@ -530,23 +530,19 @@ function svg_edit_setup() {
$('#tools_ellipse').mouseleave(function() {
$('#tools_ellipse').fadeOut();
});
$('.tool_flyout_button').mouseover(function() {
$(this).addClass('tool_flyout_button_current');
}).mouseout(function() {
$(this).removeClass('tool_flyout_button_current');
});
function changeResolution(x,y) {
$('#resolution').val(x+'x'+y);
$('#svgroot').css( { 'width': x, 'height': y } );
$('#svgcanvas').css( { 'width': x, 'height': y } );
$('div#palette_holder').css('width', x);
$('#context_tools').css('width', x + 65);
$('#tools').css('height', y + 24);
$('#footer').css('width', x + 65);
}
$('#resolution').change(function(){
var res = this.value.split('x');
var x = parseInt(res[0]), y = parseInt(res[1]);

View File

@ -16,7 +16,7 @@ function ChangeElementCommand(elem, attrs, text) {
if (attr == "#text") this.newValues[attr] = elem.textContent;
else this.newValues[attr] = elem.getAttribute(attr);
}
this.apply = function() {
for( attr in this.newValues ) {
if (this.newValues[attr]) {
@ -30,7 +30,7 @@ function ChangeElementCommand(elem, attrs, text) {
}
return true;
};
this.unapply = function() {
for( attr in this.oldValues ) {
if (this.oldValues[attr]) {
@ -52,7 +52,7 @@ function InsertElementCommand(elem, text) {
this.parent = elem.parentNode;
this.apply = function() { this.elem = this.parent.insertBefore(this.elem, this.elem.nextSibling); };
this.unapply = function() {
this.parent = this.elem.parentNode;
this.elem = this.elem.parentNode.removeChild(this.elem);
@ -66,7 +66,7 @@ function RemoveElementCommand(elem, parent, text) {
this.apply = function() {
this.parent = this.elem.parentNode;
this.elem = this.parent.removeChild(this.elem);
this.elem = this.parent.removeChild(this.elem);
};
this.unapply = function() { this.elem = this.parent.insertBefore(this.elem, this.elem.nextSibling); };
@ -79,12 +79,12 @@ function MoveElementCommand(elem, oldNextSibling, oldParent, text) {
this.oldParent = oldParent;
this.newNextSibling = elem.nextSibling;
this.newParent = elem.parentNode;
this.apply = function() {
this.apply = function() {
this.elem = this.newParent.insertBefore(this.elem, this.newNextSibling);
};
this.unapply = function() {
this.unapply = function() {
this.elem = this.oldParent.insertBefore(this.elem, this.oldNextSibling);
};
}
@ -322,8 +322,8 @@ function SvgCanvas(c)
var events = {};
var undoStackPointer = 0;
var undoStack = [];
// FIXME: we MUST compress consecutive text changes to the same element
// FIXME: we MUST compress consecutive text changes to the same element
// (right now each keystroke is saved as a separate command that includes the
// entire text contents of the text element)
// TODO: consider limiting the history that we store here (need to do some slicing)
@ -336,7 +336,7 @@ function SvgCanvas(c)
undoStack[undoStack.length] = cmd;
undoStackPointer = undoStack.length;
// console.log("after add command, stackPointer=" + undoStackPointer);
// console.log(undoStack);
// console.log(undoStack);
}
@ -413,8 +413,8 @@ function SvgCanvas(c)
}
}
indent--;
if (!bOneLine) {
out += "\n";
if (!bOneLine) {
out += "\n";
for (i=0; i<indent; i++) out += " ";
}
out += "</" + elem.nodeName + ">";
@ -427,20 +427,20 @@ function SvgCanvas(c)
function recalculateSelectedDimensions() {
var box = selected.getBBox();
// if we have not moved/resized, then immediately leave
if (box.x == selectedBBox.x && box.y == selectedBBox.y &&
if (box.x == selectedBBox.x && box.y == selectedBBox.y &&
box.width == selectedBBox.width && box.height == selectedBBox.height) {
return;
}
// after this point, we have some change
var remapx = function(x) {return ((x-box.x)/box.width)*selectedBBox.width + selectedBBox.x;}
var remapy = function(y) {return ((y-box.y)/box.height)*selectedBBox.height + selectedBBox.y;}
var scalew = function(w) {return w*selectedBBox.width/box.width;}
var scaleh = function(h) {return h*selectedBBox.height/box.height;}
var changes = {};
selected.removeAttribute("transform");
@ -483,7 +483,7 @@ function SvgCanvas(c)
case "circle":
changes["cx"] = selected.cx.baseVal.value;
changes["cy"] = selected.cy.baseVal.value;
changes["r"] = selected.r.baseVal.value;
changes["r"] = selected.r.baseVal.value;
selected.cx.baseVal.value = remapx(selected.cx.baseVal.value);
selected.cy.baseVal.value = remapy(selected.cy.baseVal.value);
// take the minimum of the new selected box's dimensions for the new circle radius
@ -579,7 +579,7 @@ function SvgCanvas(c)
// in mouseDown :
// - when we are in a create mode, the element is added to the canvas
// but the action is not recorded until mouseUp
// - when we are in select mode, select the element, remember the position
// - when we are in select mode, select the element, remember the position
// and do nothing else
var mouseDown = function(evt)
{
@ -736,7 +736,7 @@ function SvgCanvas(c)
}
}
// in mouseMove we do not record any state changes yet (but we do update
// in mouseMove we do not record any state changes yet (but we do update
// any elements that are still being created, moved or resized on the canvas)
var mouseMove = function(evt)
{
@ -855,10 +855,10 @@ function SvgCanvas(c)
break;
}
// TODO: should we fire the change event here? I'm thinking only fire
// this event when the user mouses up. That's when the action (create,
// this event when the user mouses up. That's when the action (create,
// move, resize, draw) has finished
// fire changed event
// call("changed", selected);
// call("changed", selected);
}
// in mouseUp, this is where the command is stored for later undo:
@ -1115,7 +1115,7 @@ function SvgCanvas(c)
this.setFontFamily = function(val) {
current_font_family = val;
this.changeSelectedAttribute("font-family", val);
this.changeSelectedAttribute("font-family", val);
}
this.getFontSize = function() {
@ -1147,7 +1147,7 @@ function SvgCanvas(c)
}
}
}
this.changeSelectedAttribute = function(attr, val) {
if (selected != null) {
var oldval = (attr == "#text" ? selected.textContent : selected.getAttribute(attr));
@ -1208,13 +1208,13 @@ function SvgCanvas(c)
addCommandToHistory(new MoveElementCommand(t, oldNextSibling, oldParent, "bottom"));
}
}
this.moveSelectedElement = function(dx,dy) {
if (selected != null) {
selectedBBox = selected.getBBox();
selectedBBox.x += dx;
selectedBBox.y += dy;
recalculateSelectedDimensions();
recalculateSelectedOutline();
}
@ -1222,16 +1222,16 @@ function SvgCanvas(c)
this.getUndoStackSize = function() { return undoStackPointer; }
this.getRedoStackSize = function() { return undoStack.length - undoStackPointer; }
this.undo = function() {
if (undoStackPointer > 0) {
if (undoStackPointer > 0) {
this.selectNone();
var cmd = undoStack[--undoStackPointer];
cmd.unapply();
call("changed", cmd.elem);
}
// console.log("after undo, stackPointer=" + undoStackPointer);
// console.log(undoStack);
// console.log(undoStack);
}
this.redo = function() {
if (undoStackPointer < undoStack.length && undoStack.length > 0) {
@ -1241,7 +1241,7 @@ function SvgCanvas(c)
call("changed", cmd.elem);
}
// console.log("after redo, stackPointer=" + undoStackPointer);
// console.log(undoStack);
// console.log(undoStack);
}
}