Namespace Papercube.canvasController
| Extends: | SC.Object |
| Defined in: | clients/papercube/controllers/canvas.js |
| Version: | 1.0 |
| Author: | Peter Bergstrom |
| Copyright: | 2008-2009 Peter Bergström. |
Overview
This controls the canvas, the canvas is a viewport that allows views to be resolution independent. This is done by keeping track of various zooming parameters and communicating this to the zoomView (preview pane) and the core view that is being used.
Property Summary
-
- (Integer) _scrollCoolDown [R/W]The scroll zoom cool off. -
- (Integer) _scrollCoolDownAmount [R/W]The amount to wait between scroll zoom events. -
- (DOM Element) fanDiv [R/W]Fan menu div container. -
- (Object) fans [R/W]Fan menu properties. -
- (DOM Element) fanSVG [R/W]Fan menu SVG. -
- (DOM Element) fanSVGRoot [R/W]Fan menu SVG root. -
- (Boolean) leftViewShowing [R/W]Set to YES when the left view is visible. -
- (Boolean) shouldShowCanvas [R/W]boolean signifying that the app should be showing the canvas.
Method Summary
-
- (Array) _createSVGElement(type, attributes, events, The)Create a new SVG element. -
- (Array) _getSVGParams(evt)Get the fan slice details based on the event object passed in. -
- (void) _highlightFan(evt, The)Set a fan's highlight or hide the fan. -
- (void) circleMouseUp(evt)Mouse up event on the center circle of the fan. -
- (void) createFan(name, fanType)Based on the name and the fan type, look for the registered fan and create it. -
- (void) fanForNodeGraph(view)For NodeGraphs, register using this generic function. -
- (void) getWindowProperties()Get window properties and set the portal dimensions then reposition the canvas. -
- (void) hideFan()Hide the currently visible fan. -
- (void) init()Initalization function. -
- (Boolean) panToCoordinates(xDiff, yDiff, updateZoomPreview)Zoom to a set of coordinates. -
- (void) registerFans(name, fans)Registed the fans for a view. -
- (void) repositionCanvasDidChange()Reposition the canvas inside the portal if needed, This is triggered if the percentages or the zoom value changes. -
- (Boolean) setZoomToPointerLocation(xPos, yPos, zoomIn)Zoom in or out to center around where the pointer location. -
- (Boolean) showFan(x, y, name, fanType)Show a fan menu. -
- (void) svgMouseDown(evt)SVG mouse down. -
- (void) svgMouseOut(evt)SVG mouse over. -
- (void) svgMouseOver(evt)SVG mouse over. -
- (void) svgMouseUp(evt)SVG mouse up. -
- (Boolean) zoomToLocation(pctX, pctY, zoomValue)Zoom in or out to center around a desired x and y percentage.
Property Details
_scrollCoolDown [R/W]
The scroll zoom cool off.
- Integer _scrollCoolDown
Discussion
Record scroll time to compare with the _scrollCoolDownAmount.
_scrollCoolDownAmount [R/W]
The amount to wait between scroll zoom events.
- Integer _scrollCoolDownAmount
Default Value: 200 milliseconds
leftViewShowing [R/W]
Set to YES when the left view is visible.
- Boolean leftViewShowing
Default Value: NO
shouldShowCanvas [R/W]
boolean signifying that the app should be showing the canvas.
- Boolean shouldShowCanvas
Default Value: NO
Method Detail
_createSVGElement()
Create a new SVG element.
- (Array) _createSVGElement (type, attributes, events, The)
Parameters
type {string} The node type.
attributes {Object} The attributes hash.
events {Object} The events hash.
(DOM Element)The parentNode to attach to.
Returns
(Array) {DOM Element} The SVG element that was created.
_getSVGParams()
Get the fan slice details based on the event object passed in.
- (Array) _getSVGParams (evt)
Parameters
(DOM Event)evt The mouse event.
Returns
(Array) {object} Returns the SVG params.
_highlightFan()
Set a fan's highlight or hide the fan.
- (void) _highlightFan (evt, The)
Parameters
(DOM Event)evt The mouse event.
The {string} desired hex fill color of the fan.
circleMouseUp()
Mouse up event on the center circle of the fan.
- (void) circleMouseUp (evt)
Parameters
(DOM Event)evt The mouseUp event.
Discussion
Then, just hide the fan.
createFan()
Based on the name and the fan type, look for the registered fan and create it.
- (void) createFan (name, fanType)
Parameters
name {string} The view's name.
fanType {string} The type of fan.
Discussion
Fans are lazily created only when they are requested.
fanForNodeGraph()
For NodeGraphs, register using this generic function.
- (void) fanForNodeGraph (view)
Parameters
view {NodeGraph.NodeGraphView}
getWindowProperties()
Get window properties and set the portal dimensions then reposition the canvas.
- (void) getWindowProperties ()
panToCoordinates()
Zoom to a set of coordinates.
- (Boolean) panToCoordinates (xDiff, yDiff, updateZoomPreview)
Parameters
xDiff {Integer} The x position of the mouse pointer.
yDiff {Integer} The y position of the mouse pointer.
updateZoomPreview {Boolean} If YES, update the zoom preview pane.
Returns
(Boolean) Returns NO if there is an error.
registerFans()
Registed the fans for a view.
- (void) registerFans (name, fans)
Parameters
name {string} The view's name.
fans {string} The fan's options.
repositionCanvasDidChange()
Reposition the canvas inside the portal if needed, This is triggered if the percentages or the zoom value changes.
- (void) repositionCanvasDidChange ()
Observes
percentageX
percentageY
zoomValue
setZoomToPointerLocation()
Zoom in or out to center around where the pointer location.
- (Boolean) setZoomToPointerLocation (xPos, yPos, zoomIn)
Parameters
xPos {Integer} The x position of the mouse pointer.
yPos {Integer} The y position of the mouse pointer.
zoomIn {boolean} If YES, zoom in, otherwise, zoom out.
Returns
(Boolean) Returns NO if there is an error.
showFan()
Show a fan menu.
- (Boolean) showFan (x, y, name, fanType)
Parameters
x {Integer} The x position.
y {Integer} The y position.
name {string} The view's name.
fanType {string} The type of fan.
Returns
(Boolean) Returns the NO if the fan name is not registered.
svgMouseDown()
SVG mouse down.
- (void) svgMouseDown (evt)
Parameters
(DOM Event)evt The mouseDown event.
Discussion
If the event contains a wedge or fan DOM element, remove its highlight, otherwise hide the fan.
svgMouseOut()
SVG mouse over.
- (void) svgMouseOut (evt)
Parameters
(DOM Event)evt The mouseOut event.
Discussion
If the event contains a wedge or fan DOM element, remove its highlight, otherwise hide the fan.
svgMouseOver()
SVG mouse over.
- (void) svgMouseOver (evt)
Parameters
(DOM Event)evt The mouseOver event.
Discussion
If the event contains a wedge or fan DOM element, highlight it, otherwise hide the fan.
svgMouseUp()
SVG mouse up.
- (void) svgMouseUp (evt)
Parameters
(DOM Event)evt The mouseUp event.
Discussion
Call back to the parent view.
zoomToLocation()
Zoom in or out to center around a desired x and y percentage.
- (Boolean) zoomToLocation (pctX, pctY, zoomValue)
Parameters
pctX {Integer} The x position percentage.
pctY {Integer} The y position percentage.
zoomValue {Integer} The desired zoomValue.
Returns
(Boolean) Returns NO if there is an error.