Skip to content

Commit

Permalink
auto and fixed size for text. Fix few bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
maccman committed May 7, 2012
1 parent 4e10b80 commit 8ce049c
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 36 deletions.
17 changes: 1 addition & 16 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ Phase 3:


Nice to have: Nice to have:


* HTML import
* ✓ Keyboard shortcuts * ✓ Keyboard shortcuts
* Versioning * Versioning
* Exporting HTML?
* ✓ Exporting CSS * ✓ Exporting CSS
* Share (dropbox/email?) * Share (dropbox/email?)
* Clone HTML components
* WebFonts * WebFonts
* Layers? * Layers?
* ✓ Context menu * ✓ Context menu
Expand Down Expand Up @@ -78,20 +77,6 @@ Nice to have:


------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------


##Rulers & Snap

When moving element - cycle through all the other elements, compare the sides - inject rulers if necessary. Also show rulers for center of page. Need to think about how multiple selected items works.

Two types of snapping:

* Line snapping to:
* Center of page (x/y) axis
* Bottom/left/right side of pages?
* Sides of elements?
* Middle of elements
* Width snapping:
* Detect distance between elements - snap when two distances are the same.

#Save to png #Save to png


https://github.com/paulhammond/webkit2png/blob/master/webkit2png https://github.com/paulhammond/webkit2png/blob/master/webkit2png
Expand Down
12 changes: 10 additions & 2 deletions assets/javascripts/app/controllers/elements/text.module.coffee
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,18 +16,26 @@ class Text extends Rectangle


$.extend({}, super, result) $.extend({}, super, result)


startEditing: ->
return if @editing
super

@autoSize()

stopEditing: -> stopEditing: ->
return unless @editing return unless @editing
super super


if @text() if @text()
@fitToText() @fixSize()
else else
# Remove the element if empty # Remove the element if empty
@remove() @remove()


fitToText: -> autoSize: ->
@el.css(width: 'auto', height: 'auto') @el.css(width: 'auto', height: 'auto')

fixSize: ->
@set( @set(
width: @el.outerWidth(), width: @el.outerWidth(),
height: @el.outerHeight() height: @el.outerHeight()
Expand Down
3 changes: 3 additions & 0 deletions assets/javascripts/app/models/properties/shadow.module.coffee
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ class Shadow extends Property


toValue: -> toValue: ->
value = value =
inset: @inset
x: @x x: @x
y: @y y: @y
blur: @blur
spread: @spread
color: @color color: @color


module.exports = Shadow module.exports = Shadow
16 changes: 10 additions & 6 deletions assets/stylesheets/app/inspector.css.styl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@
border-bottom: 1px solid rgba(0, 0, 0, 0.2) border-bottom: 1px solid rgba(0, 0, 0, 0.2)
ellipsis() ellipsis()


.preview {
margin: 0 3px 0 0
width: 8px
height: 8px
display: inline-block
border: 1px solid rgba(0, 0, 0, 0.1)
}

&:last-child { &:last-child {
border-bottom: none border-bottom: none
} }
Expand All @@ -190,12 +198,8 @@
vbg-gradient(#BCC6DE, #9BA8C7) vbg-gradient(#BCC6DE, #9BA8C7)
} }


.preview { &.selected .preview {
margin: 0 3px 0 0 border: none
width: 8px
height: 8px
display: inline-block
border: 1px solid rgba(0, 0, 0, 0.1)
} }
} }


Expand Down
17 changes: 14 additions & 3 deletions public/assets/app/controllers/elements/text.module.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -95,23 +95,34 @@ this.require.define({"app/controllers/elements/text":function(exports, require,
return $.extend({}, Text.__super__.defaults.apply(this, arguments), result); return $.extend({}, Text.__super__.defaults.apply(this, arguments), result);
}; };


Text.prototype.startEditing = function() {
if (this.editing) {
return;
}
Text.__super__.startEditing.apply(this, arguments);
return this.autoSize();
};

Text.prototype.stopEditing = function() { Text.prototype.stopEditing = function() {
if (!this.editing) { if (!this.editing) {
return; return;
} }
Text.__super__.stopEditing.apply(this, arguments); Text.__super__.stopEditing.apply(this, arguments);
if (this.text()) { if (this.text()) {
return this.fitToText(); return this.fixSize();
} else { } else {
return this.remove(); return this.remove();
} }
}; };


Text.prototype.fitToText = function() { Text.prototype.autoSize = function() {
this.el.css({ return this.el.css({
width: 'auto', width: 'auto',
height: 'auto' height: 'auto'
}); });
};

Text.prototype.fixSize = function() {
return this.set({ return this.set({
width: this.el.outerWidth(), width: this.el.outerWidth(),
height: this.el.outerHeight() height: this.el.outerHeight()
Expand Down
3 changes: 3 additions & 0 deletions public/assets/app/models/properties/shadow.module.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ this.require.define({"app/models/properties/shadow":function(exports, require, m
Shadow.prototype.toValue = function() { Shadow.prototype.toValue = function() {
var value; var value;
return value = { return value = {
inset: this.inset,
x: this.x, x: this.x,
y: this.y, y: this.y,
blur: this.blur,
spread: this.spread,
color: this.color color: this.color
}; };
}; };
Expand Down
15 changes: 9 additions & 6 deletions public/assets/application.css
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -498,6 +498,13 @@ body {
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;
} }
#app .inspector .list .item .preview {
margin: 0 3px 0 0;
width: 8px;
height: 8px;
display: inline-block;
border: 1px solid rgba(0,0,0,0.10);
}
#app .inspector .list .item:last-child { #app .inspector .list .item:last-child {
border-bottom: none; border-bottom: none;
} }
Expand All @@ -510,12 +517,8 @@ body {
background: -moz-linear-gradient(top, #bcc6de, #9ba8c7); background: -moz-linear-gradient(top, #bcc6de, #9ba8c7);
background: linear-gradient(top, #bcc6de, #9ba8c7); background: linear-gradient(top, #bcc6de, #9ba8c7);
} }
#app .inspector .list .item .preview { #app .inspector .list .item.selected .preview {
margin: 0 3px 0 0; border: none;
width: 8px;
height: 8px;
display: inline-block;
border: 1px solid rgba(0,0,0,0.10);
} }
#app .inspector .list footer { #app .inspector .list footer {
border-top: 1px solid rgba(0,0,0,0.15); border-top: 1px solid rgba(0,0,0,0.15);
Expand Down
20 changes: 17 additions & 3 deletions public/assets/application.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13207,23 +13207,34 @@ this.require.define({"app/controllers/elements/text":function(exports, require,
return $.extend({}, Text.__super__.defaults.apply(this, arguments), result); return $.extend({}, Text.__super__.defaults.apply(this, arguments), result);
}; };


Text.prototype.startEditing = function() {
if (this.editing) {
return;
}
Text.__super__.startEditing.apply(this, arguments);
return this.autoSize();
};

Text.prototype.stopEditing = function() { Text.prototype.stopEditing = function() {
if (!this.editing) { if (!this.editing) {
return; return;
} }
Text.__super__.stopEditing.apply(this, arguments); Text.__super__.stopEditing.apply(this, arguments);
if (this.text()) { if (this.text()) {
return this.fitToText(); return this.fixSize();
} else { } else {
return this.remove(); return this.remove();
} }
}; };


Text.prototype.fitToText = function() { Text.prototype.autoSize = function() {
this.el.css({ return this.el.css({
width: 'auto', width: 'auto',
height: 'auto' height: 'auto'
}); });
};

Text.prototype.fixSize = function() {
return this.set({ return this.set({
width: this.el.outerWidth(), width: this.el.outerWidth(),
height: this.el.outerHeight() height: this.el.outerHeight()
Expand Down Expand Up @@ -17316,8 +17327,11 @@ this.require.define({"app/models/properties/shadow":function(exports, require, m
Shadow.prototype.toValue = function() { Shadow.prototype.toValue = function() {
var value; var value;
return value = { return value = {
inset: this.inset,
x: this.x, x: this.x,
y: this.y, y: this.y,
blur: this.blur,
spread: this.spread,
color: this.color color: this.color
}; };
}; };
Expand Down

0 comments on commit 8ce049c

Please sign in to comment.