Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
crayon_mockup.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
07afba1
)
resize controlls are little arrows
author
Jason Woofenden
<jason@jasonwoof.com>
Sat, 17 Oct 2015 20:12:04 +0000
(16:12 -0400)
committer
Jason Woofenden
<jason@jasonwoof.com>
Sat, 17 Oct 2015 20:12:04 +0000
(16:12 -0400)
main.coffee
patch
|
blob
|
history
diff --git
a/main.coffee
b/main.coffee
index
1f4edfc
..
48c001b
100644
(file)
--- a/
main.coffee
+++ b/
main.coffee
@@
-97,24
+97,24
@@
class Control extends Visible
dy = xy.y - @y
return dx * dx + dy * dy
dy = xy.y - @y
return dx * dx + dy * dy
-class ControlPoint extends Control
+class ControlNWSE extends Control
constructor: (args) ->
super args
@css_class = 'control_point'
constructor: (args) ->
super args
@css_class = 'control_point'
- @el = json_to_svg circle:
- cx: @x + 1
- cy: @y + 1
- r: 6
+ @el = json_to_svg path:
+ d: @make_path()
class: 'control_point normal'
@svg.appendChild @el
class: 'control_point normal'
@svg.appendChild @el
+ make_path: ->
+ # / return "M#{@x + 5} #{@y - 5}v6l-2-2-4 4 2 2h-6v-6l2 2 4-4-2-2z"
+ return "M#{@x - 5} #{@y - 5}h6l-2 2 4 4 2 -2v6h-6l2-2-4-4-2 2z"
destruct: ->
super()
if @el?
@svg.removeChild @el
move: (args) ->
super args
destruct: ->
super()
if @el?
@svg.removeChild @el
move: (args) ->
super args
- @el.setAttribute 'cx', @x
- @el.setAttribute 'cy', @y
+ @el.setAttribute 'd', @make_path()
class Widget extends Visible
#sub-classes are expected to implement all of these:
class Widget extends Visible
#sub-classes are expected to implement all of these:
@@
-198,12
+198,14
@@
class RectWidget extends Widget
prox = PROX_MAX - 1
return prox
resize: (wh) ->
prox = PROX_MAX - 1
return prox
resize: (wh) ->
+ dw = wh.w - @width
+ dh = wh.h - @height
@width = wh.w
@width = wh.w
- @el.setAttribute 'width', @width
+ @el.setAttribute 'width', @width - 2
@height = wh.h
@height = wh.h
- @el.setAttribute 'height', @height
+ @el.setAttribute 'height', @height - 2
if @controls.length > 1
if @controls.length > 1
- @controls[1].move x: @x + @width, y: @y + @height
+ @controls[1].move x: @controls[1].x + dw, y: @controls[1].y + dh
make_controls: (args) -> # create controls, return them
console.log 'make_controls'
if @controls.length > 0
make_controls: (args) -> # create controls, return them
console.log 'make_controls'
if @controls.length > 0
@@
-211,10
+213,10
@@
class RectWidget extends Widget
@kill_controls()
w = @
@controls = [
@kill_controls()
w = @
@controls = [
- new ControlPoint svg: @svg, x: @x, y: @y, done: args.done, drag: (dxy) ->
+ new ControlNWSE svg: @svg, x: @x - 7, y: @y - 7, done: args.done, drag: (dxy) ->
w.resize w: w.width - dxy.x, h: w.height - dxy.y
w.move x: w.x + dxy.x, y: w.y + dxy.y
w.resize w: w.width - dxy.x, h: w.height - dxy.y
w.move x: w.x + dxy.x, y: w.y + dxy.y
- new ControlPoint svg: @svg, x: @x + @width, y: @y + @height, done: args.done, drag: (dxy) ->
+ new ControlNWSE svg: @svg, x: @x + @width + 7, y: @y + @height + 7, done: args.done, drag: (dxy) ->
w.resize w: w.width + dxy.x, h: w.height + dxy.y
]
return @controls
w.resize w: w.width + dxy.x, h: w.height + dxy.y
]
return @controls