Skip to content
Browse files

Simplified and documented CustomCursorManager and moved embedded cursors

to appropriate locations.

Change-Id: If8f60bf3fe6d621779eed695ed0ba2cbf326a617
  • Loading branch information...
1 parent 5e90786 commit 4d75538c16ec0caf33d2bda9e2bf48ea8dd581fc @adufilie adufilie committed
View
35 WeaveUI/src/weave/ui/DraggablePanel.mxml
@@ -47,8 +47,6 @@ along with Weave. If not, see <http://www.gnu.org/licenses/>.
>
<mx:Script>
<![CDATA[
- import flash.utils.getTimer;
-
import mx.containers.Canvas;
import mx.containers.TitleWindow;
import mx.controls.Alert;
@@ -60,8 +58,6 @@ along with Weave. If not, see <http://www.gnu.org/licenses/>.
import mx.events.CloseEvent;
import mx.events.DragEvent;
import mx.events.ResizeEvent;
- import mx.managers.CursorManager;
- import mx.managers.CursorManagerPriority;
import mx.managers.PopUpManager;
import weave.Weave;
@@ -80,7 +76,6 @@ along with Weave. If not, see <http://www.gnu.org/licenses/>.
import weave.core.LinkableFunction;
import weave.core.LinkableNumber;
import weave.core.LinkableString;
- import weave.primitives.ImageFactory;
import weave.ui.controlBars.VisTaskbar;
import weave.utils.CustomCursorManager;
import weave.utils.EditorManager;
@@ -1104,16 +1099,16 @@ along with Weave. If not, see <http://www.gnu.org/licenses/>.
var resizeCursorName:String = null;
// check to see if the mouse is in the top left (TL) or bottom right (BR) corner
if (status.TL || status.BR)
- resizeCursorName = CustomCursorManager.RESIZE_TOPLEFT_BOTTOMRIGHT;
+ resizeCursorName = CURSOR_RESIZE_TOPLEFT_BOTTOMRIGHT;
// check to see if the mouse is in the top right (TR) or bottom left (BL) corner
else if (status.TR || status.BL)
- resizeCursorName = CustomCursorManager.RESIZE_TOPRIGHT_BOTTOMLEFT;
+ resizeCursorName = CURSOR_RESIZE_TOPRIGHT_BOTTOMLEFT;
// check to see if the mouse is on the left or right side (LR)
else if (status.L || status.R)
- resizeCursorName = CustomCursorManager.RESIZE_LEFT_RIGHT;
+ resizeCursorName = CURSOR_RESIZE_LEFT_RIGHT;
// check to see if the mouse is on the top or bottom side
else if (status.T || status.B)
- resizeCursorName = CustomCursorManager.RESIZE_TOP_BOTTOM;
+ resizeCursorName = CURSOR_RESIZE_TOP_BOTTOM;
CustomCursorManager.removeCursor(draggablePanelCursorID);
if ( resizeCursorName!= null && !event.buttonDown && _enableMoveResize)
@@ -1617,6 +1612,28 @@ along with Weave. If not, see <http://www.gnu.org/licenses/>.
protected const subMenu:SubMenu = new SubMenu(subMenuButton,[MouseEvent.CLICK, MouseEvent.DOUBLE_CLICK]);
+ /**
+ * Embedded cursors
+ */
+ public static const CURSOR_RESIZE_TOP_BOTTOM:String = "resizeTopBottom";
+ [Embed(source="/weave/resources/images/resize_TB.png")]
+ private static var resizeTBCursor:Class;
+ CustomCursorManager.registerEmbeddedCursor(CURSOR_RESIZE_TOP_BOTTOM, resizeTBCursor, NaN, NaN);
+
+ public static const CURSOR_RESIZE_LEFT_RIGHT:String = "resizeLeftRight";
+ [Embed(source="/weave/resources/images/resize_LR.png")]
+ private static var resizeLRCursor:Class;
+ CustomCursorManager.registerEmbeddedCursor(CURSOR_RESIZE_LEFT_RIGHT, resizeLRCursor, NaN, NaN);
+
+ public static const CURSOR_RESIZE_TOPLEFT_BOTTOMRIGHT:String = "resizeTLBR";
+ [Embed(source="/weave/resources/images/resize_TL-BR.png")]
+ private static var resizeTLBRCursor:Class;
+ CustomCursorManager.registerEmbeddedCursor(CURSOR_RESIZE_TOPLEFT_BOTTOMRIGHT, resizeTLBRCursor, NaN, NaN);
+
+ public static const CURSOR_RESIZE_TOPRIGHT_BOTTOMLEFT:String = "resizeTRBL";
+ [Embed(source="/weave/resources/images/resize_TR-BL.png")]
+ private static var resizeTRBLCursor:Class;
+ CustomCursorManager.registerEmbeddedCursor(CURSOR_RESIZE_TOPRIGHT_BOTTOMLEFT, resizeTRBLCursor, NaN, NaN);
// backwards compatibility
[Deprecated(replacement="panelTitle")] public function set toolTitle(value:String):void { panelTitle.value = value; }
View
46 WeaveUI/src/weave/ui/NewUserWizard.mxml
@@ -37,7 +37,7 @@
</ui:HelpComponent>
</mx:HBox>
<mx:HBox>
- <mx:Image click="browseForFiles()" id="uploadImage" source="@Embed(source= '/weave/resources/images/add_file_large.png')"/>
+ <mx:Image click="browseForFiles()" id="uploadImage" buttonMode="true" useHandCursor="true" source="@Embed(source= '/weave/resources/images/add_file_large.png')"/>
<mx:Label color="0xFF0000" id="uploadMessage"/>
</mx:HBox>
<!--<mx:Label text="OR" fontWeight="bold" />
@@ -105,30 +105,30 @@
<!--Images from http://www.webresourcesdepot.com/free-vector-chart-icons/-->
<mx:HBox>
<mx:VBox>
- <mx:Image width="{thumbnailWidth}" height="{thumbnailHeight}" click="createGlobalObject(CompoundBarChartTool)" id="barChartImage" source="@Embed(source= '/weave/resources/images/bar_chart_weave.png')"/>
+ <mx:Image width="{thumbnailWidth}" height="{thumbnailHeight}" click="createGlobalObject(CompoundBarChartTool)" id="barChartImage" buttonMode="true" useHandCursor="true" source="@Embed(source= '/weave/resources/images/bar_chart_weave.png')"/>
<mx:Label text="{lang('Bar Chart')}" fontWeight="bold"/>
</mx:VBox>
<mx:VBox>
- <mx:Image width="{thumbnailWidth}" height="{thumbnailHeight}" click="createGlobalObject(LineChartTool)" id="lineChartImage" source="@Embed(source= '/weave/resources/images/line_chart_weave_new.png')"/>
+ <mx:Image width="{thumbnailWidth}" height="{thumbnailHeight}" click="createGlobalObject(LineChartTool)" id="lineChartImage" buttonMode="true" useHandCursor="true" source="@Embed(source= '/weave/resources/images/line_chart_weave_new.png')"/>
<mx:Label text="{lang('Line Chart')}" fontWeight="bold"/>
</mx:VBox>
<mx:VBox>
- <mx:Image width="{thumbnailWidth}" height="{thumbnailHeight}" click="createGlobalObject(ScatterPlotTool)" id="scatterplotImage" source="@Embed(source= '/weave/resources/images/scatter_plot_weave_new.png')"/>
+ <mx:Image width="{thumbnailWidth}" height="{thumbnailHeight}" click="createGlobalObject(ScatterPlotTool)" id="scatterplotImage" buttonMode="true" useHandCursor="true" source="@Embed(source= '/weave/resources/images/scatter_plot_weave_new.png')"/>
<mx:Label text="{lang('Scatterplot')}" fontWeight="bold"/>
</mx:VBox>
</mx:HBox>
<mx:HBox>
<mx:VBox>
- <mx:Image width="{thumbnailWidth}" height="{thumbnailHeight}" click="createGlobalObject(PieChartTool)" id="pieChartImage" source="@Embed(source= '/weave/resources/images/pie_chart_weave.png')"/>
+ <mx:Image width="{thumbnailWidth}" height="{thumbnailHeight}" click="createGlobalObject(PieChartTool)" id="pieChartImage" buttonMode="true" useHandCursor="true" source="@Embed(source= '/weave/resources/images/pie_chart_weave.png')"/>
<mx:Label text="{lang('Pie Chart')}" fontWeight="bold"/>
</mx:VBox>
<mx:VBox>
- <mx:Image width="{thumbnailWidth}" height="{thumbnailHeight}" click="createGlobalObject(GaugeTool)" id="gaugeImage" source="@Embed(source= '/weave/resources/images/gauge_meter_weave.png')"/>
+ <mx:Image width="{thumbnailWidth}" height="{thumbnailHeight}" click="createGlobalObject(GaugeTool)" id="gaugeImage" buttonMode="true" useHandCursor="true" source="@Embed(source= '/weave/resources/images/gauge_meter_weave.png')"/>
<mx:Label text="{lang('Gauge Meter')}" fontWeight="bold"/>
</mx:VBox>
<mx:VBox>
- <mx:Image width="{thumbnailWidth}" height="{thumbnailHeight}" click="createGlobalObject(HistogramTool)" id="histogramImage" source="@Embed(source= '/weave/resources/images/histogram_weave.png')"/>
+ <mx:Image width="{thumbnailWidth}" height="{thumbnailHeight}" click="createGlobalObject(HistogramTool)" id="histogramImage" buttonMode="true" useHandCursor="true" source="@Embed(source= '/weave/resources/images/histogram_weave.png')"/>
<mx:Label text="{lang('Histogram')}" fontWeight="bold"/>
</mx:VBox>
@@ -154,6 +154,7 @@
import weave.data.DataSources.CSVDataSource;
import weave.utils.CustomCursorManager;
import weave.utils.ProbeTextUtils;
+ import weave.visualization.layers.InteractiveVisualization;
import weave.visualization.tools.CompoundBarChartTool;
import weave.visualization.tools.GaugeTool;
import weave.visualization.tools.HistogramTool;
@@ -171,27 +172,6 @@
private function handleCreationComplete():void
{
- uploadImage.addEventListener(MouseEvent.MOUSE_OVER,handleMouseOverImage);
- uploadImage.addEventListener(MouseEvent.MOUSE_OUT,handleMouseOutImage);
-
- barChartImage.addEventListener(MouseEvent.MOUSE_OVER,handleMouseOverImage);
- barChartImage.addEventListener(MouseEvent.MOUSE_OUT,handleMouseOutImage);
-
- pieChartImage.addEventListener(MouseEvent.MOUSE_OVER,handleMouseOverImage);
- pieChartImage.addEventListener(MouseEvent.MOUSE_OUT,handleMouseOutImage);
-
- lineChartImage.addEventListener(MouseEvent.MOUSE_OVER,handleMouseOverImage);
- lineChartImage.addEventListener(MouseEvent.MOUSE_OUT,handleMouseOutImage);
-
- gaugeImage.addEventListener(MouseEvent.MOUSE_OVER,handleMouseOverImage);
- gaugeImage.addEventListener(MouseEvent.MOUSE_OUT,handleMouseOutImage);
-
- scatterplotImage.addEventListener(MouseEvent.MOUSE_OVER,handleMouseOverImage);
- scatterplotImage.addEventListener(MouseEvent.MOUSE_OUT,handleMouseOutImage);
-
- histogramImage.addEventListener(MouseEvent.MOUSE_OVER,handleMouseOverImage);
- histogramImage.addEventListener(MouseEvent.MOUSE_OUT,handleMouseOutImage);
-
//Creating pre-defined delimiter objects Comma, Tab , Semi Colon and Space.
//The count field helps to quickly identify the object that probably applies to the data entered.
delimiters.comma = new Object();
@@ -298,16 +278,6 @@
}
- private function handleMouseOverImage(event:MouseEvent):void
- {
- CustomCursorManager.showCursor(CustomCursorManager.LINK_CURSOR);
- }
-
- private function handleMouseOutImage(event:MouseEvent):void
- {
- CustomCursorManager.removeCurrentCursor();
- }
-
private var _fileLoader:FileReference = null;
private var csvDataString:String = "";
/**
View
57 WeaveUI/src/weave/ui/PenTool.as
@@ -1,20 +1,20 @@
/*
-Weave (Web-based Analysis and Visualization Environment)
-Copyright (C) 2008-2011 University of Massachusetts Lowell
-
-This file is a part of Weave.
-
-Weave is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License, Version 3,
-as published by the Free Software Foundation.
-
-Weave is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Weave. If not, see <http://www.gnu.org/licenses/>.
+ Weave (Web-based Analysis and Visualization Environment)
+ Copyright (C) 2008-2011 University of Massachusetts Lowell
+
+ This file is a part of Weave.
+
+ Weave is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, Version 3,
+ as published by the Free Software Foundation.
+
+ Weave is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Weave. If not, see <http://www.gnu.org/licenses/>.
*/
package weave.ui
@@ -32,7 +32,6 @@ package weave.ui
import mx.core.mx_internal;
import mx.events.FlexEvent;
import mx.events.ResizeEvent;
- import mx.managers.CursorManagerPriority;
import weave.api.WeaveAPI;
import weave.api.core.IDisposableObject;
@@ -49,7 +48,7 @@ package weave.ui
import weave.utils.CustomCursorManager;
import weave.utils.SpatialIndex;
import weave.visualization.layers.Visualization;
- import weave.visualization.tools.SimpleVisTool;
+ import weave.visualization.tools.SimpleVisTool;
use namespace mx_internal;
@@ -229,9 +228,9 @@ package weave.ui
_drawing = false;
if (value)
- CustomCursorManager.showCursor(CustomCursorManager.PEN_CURSOR);
+ CustomCursorManager.showCursor(PEN_CURSOR);
else
- CustomCursorManager.removeAllCursors();
+ CustomCursorManager.hack_removeAllCursors();
invalidateDisplayList();
}
@@ -427,7 +426,7 @@ package weave.ui
if (!_editMode)
return;
- CustomCursorManager.showCursor(CustomCursorManager.PEN_CURSOR);
+ CustomCursorManager.showCursor(PEN_CURSOR);
}
/**
@@ -439,7 +438,7 @@ package weave.ui
if (!_editMode)
return;
- CustomCursorManager.removeAllCursors();
+ CustomCursorManager.hack_removeAllCursors();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
@@ -669,7 +668,7 @@ package weave.ui
_removeDrawingsMenuItem.enabled = true;
}
- CustomCursorManager.showCursor(CustomCursorManager.PEN_CURSOR);
+ CustomCursorManager.showCursor(PEN_CURSOR);
}
}
@@ -684,7 +683,7 @@ package weave.ui
if (!contextMenu)
return;
- CustomCursorManager.removeCurrentCursor();
+ CustomCursorManager.hack_removeCurrentCursor();
//Reset Context Menu as if no PenMouse Object is there and let following code adjust as necessary.
_penToolMenuItem.caption = ENABLE_PEN;
@@ -736,7 +735,7 @@ package weave.ui
_penToolMenuItem.caption = DISABLE_PEN;
_removeDrawingsMenuItem.enabled = true;
_changeDrawingMode.enabled = true;
- CustomCursorManager.showCursor(CustomCursorManager.PEN_CURSOR);
+ CustomCursorManager.showCursor(PEN_CURSOR);
}
else
{
@@ -808,5 +807,13 @@ package weave.ui
// var penTool:PenTool = linkableContainer.getLinkableChildren().requestObject(PEN_OBJECT_NAME, PenTool, false);
// penTool.selectRecords();
// }
+
+ /**
+ * Embedded cursors
+ */
+ public static const PEN_CURSOR:String = "penCursor";
+ [Embed(source="/weave/resources/images/penpointer.png")]
+ private static var penCursor:Class;
+ CustomCursorManager.registerEmbeddedCursor(PEN_CURSOR, penCursor, 3, 22);
}
}
View
262 WeaveUI/src/weave/utils/CustomCursorManager.as
@@ -24,198 +24,138 @@ package weave.utils
import flash.ui.MouseCursor;
import flash.ui.MouseCursorData;
- import mx.core.BitmapAsset;
- import mx.managers.CursorManager;
-
- import weave.api.reportError;
-
+ import mx.core.BitmapAsset;
+
+ /**
+ * Easy interface for using native cursors.
+ *
+ * @author skolman
+ * @author adufilie
+ */
public class CustomCursorManager
{
- public function CustomCursorManager()
- {
- super();
- }
-
- public static const LINK_CURSOR:String = "linkCursor";
- [Embed(source="/weave/resources/images/axisLinkCursor.png")]
- private static var linkCursor:Class;
-
-
- public static const HAND_CURSOR:String = "handCursor";
- [Embed(source="/weave/resources/images/cursor_hand.png")]
- private static var handCursor:Class;
-
-
- public static const HAND_GRAB_CURSOR:String = "handGrabCursor";
- [Embed(source="/weave/resources/images/cursor_grab.png")]
- private static var handGrabCursor:Class;
-
-
- public static const SELECT_REPLACE_CURSOR:String = "selectReplaceCursor";
- [Embed(source="/weave/resources/images/cursor_select_replace.png")]
- private static var selectReplaceCursor:Class;
-
-
- public static const SELECT_ADD_CURSOR:String = "selectAddCursor";
- [Embed(source="/weave/resources/images/cursor_select_add.png")]
- private static var selectAddCursor:Class;
-
-
- public static const SELECT_SUBTRACT_CURSOR:String = "selectSubtractCursor";
- [Embed(source="/weave/resources/images/cursor_select_subtract.png")]
- private static var selectSubtractCursor:Class;
-
-
- public static const ZOOM_CURSOR:String = "zoomCursor";
- [Embed(source="/weave/resources/images/cursor_zoom.png")]
- private static var zoomCursor:Class;
-
-
- public static const PEN_CURSOR:String = "penCursor";
- [Embed(source="/weave/resources/images/penpointer.png")]
- private static var penCursor:Class;
-
- public static const RESIZE_TOP_BOTTOM:String = "resizeTopBottom";
- [Embed(source="/weave/resources/images/resize_TB.png")]
- private static var _resizeTBCursor:Class;
-
-
-
- public static const RESIZE_LEFT_RIGHT:String = "resizeLeftRight";
- [Embed(source="/weave/resources/images/resize_LR.png")]
- private static var _resizeLRCursor:Class;
-
- public static const RESIZE_TOPLEFT_BOTTOMRIGHT:String = "resizeTLBR";
- [Embed(source="/weave/resources/images/resize_TL-BR.png")]
- private static var _resizeTLBRCursor:Class;
-
- public static const RESIZE_TOPRIGHT_BOTTOMLEFT:String = "resizeTRBL";
- [Embed(source="/weave/resources/images/resize_TR-BL.png")]
- private static var _resizeTRBLCursor:Class;
-
-
- //registering standard cursors
- //Static block start
- zInitiailizeCursors();
- //Static block end
-
/**
- * This function registers all the standard Weave cursors/
- *
- **/
- private static function zInitiailizeCursors():void
+ * This will register an embedded cursor.
+ * To embed a cursor in your own class, follow this example:
+ * <code>
+ * public static const MY_CURSOR:String = "myCursor";
+ * [Embed(source="/weave/resources/images/myCursor.png")]
+ * private static var myCursor:Class;
+ * CustomCursorManager.registerEmbeddedCursor(MY_CURSOR, myCursor, 0, 0);
+ * </code>
+ * @param cursorName A name for the cursor.
+ * @param bitmapAsset The Class containing the embedded cursor image.
+ * @param xHotSpot The X coordinate of the hot spot. Set to NaN to use the center X coordinate.
+ * @param yHotSpot The X coordinate of the hot spot. Set to NaN to use the center Y coordinate.
+ */
+ public static function registerEmbeddedCursor(name:String, bitmapAssetClass:Class, xHotSpot:Number, yHotSpot:Number):void
{
-
- //NOTE: the cursor name should not contain a dot. Mouse class gives errors if you use names like 'CustomCursorManager.PEN_CURSOR'
- var linkCursorBitmap:BitmapAsset = new linkCursor() as BitmapAsset;
- registerCursor(LINK_CURSOR,linkCursorBitmap.bitmapData);
-
- var handCursorBitmap:BitmapAsset = new handCursor() as BitmapAsset;
- registerCursor(HAND_CURSOR,handCursorBitmap.bitmapData);
-
- var handGrabCursorBitmap:BitmapAsset = new handGrabCursor() as BitmapAsset;
- registerCursor(HAND_GRAB_CURSOR,handGrabCursorBitmap.bitmapData);
-
- var selectReplaceCursorBitmap:BitmapAsset = new selectReplaceCursor() as BitmapAsset;
- registerCursor(SELECT_REPLACE_CURSOR,selectReplaceCursorBitmap.bitmapData,2,2);
-
- var selectAddCursorBitmap:BitmapAsset = new selectAddCursor() as BitmapAsset;
- registerCursor(SELECT_ADD_CURSOR,selectAddCursorBitmap.bitmapData,2,2);
-
- var selectSubtractCursorBitmap:BitmapAsset = new selectSubtractCursor() as BitmapAsset;
- registerCursor(SELECT_SUBTRACT_CURSOR,selectSubtractCursorBitmap.bitmapData,2,2);
-
- var zoomCursorBitmap:BitmapAsset = new zoomCursor() as BitmapAsset;
- registerCursor(ZOOM_CURSOR,zoomCursorBitmap.bitmapData);
-
- var penCursorBitmap:BitmapAsset = new penCursor() as BitmapAsset;
- registerCursor(PEN_CURSOR,penCursorBitmap.bitmapData,3,22);
-
- var resizeTBBitmap:BitmapAsset = new _resizeTBCursor() as BitmapAsset;
- registerCursor(RESIZE_TOP_BOTTOM,resizeTBBitmap.bitmapData,resizeTBBitmap.width/2,resizeTBBitmap.height/2);
-
- var resizeLRBitmap:BitmapAsset = new _resizeLRCursor() as BitmapAsset;
- registerCursor(RESIZE_LEFT_RIGHT,resizeLRBitmap.bitmapData,resizeLRBitmap.width/2,resizeLRBitmap.height/2);
-
- var resizeTLBRBitmap:BitmapAsset = new _resizeTLBRCursor() as BitmapAsset;
- registerCursor(RESIZE_TOPLEFT_BOTTOMRIGHT,resizeTLBRBitmap.bitmapData,resizeTLBRBitmap.width/2,resizeTLBRBitmap.height/2);
-
- var resizeTRBLBitmap:BitmapAsset = new _resizeTRBLCursor() as BitmapAsset;
- registerCursor(RESIZE_TOPRIGHT_BOTTOMLEFT,resizeTRBLBitmap.bitmapData,resizeTRBLBitmap.width/2,resizeTRBLBitmap.height/2);
+ var asset:BitmapAsset = new bitmapAssetClass() as BitmapAsset;
+ if (isNaN(xHotSpot))
+ xHotSpot = asset.width / 2;
+ if (isNaN(yHotSpot))
+ yHotSpot = asset.height / 2;
+ registerCursor(name, asset.bitmapData, xHotSpot, yHotSpot);
}
-
- private static function registerCursor(name:String, bitmapData:BitmapData,xOffset:int=0,yOffset:int=0):void
+
+ /**
+ * This will register a BitmapData object as a cursor.
+ * @param cursorName A reasonably unique name for the cursor.
+ * @param bitmapData The cursor image.
+ * @param xHotSpot The X coordinate for the hot spot.
+ * @param yHotSpot The Y coordinate for the hot spot.
+ */
+ public static function registerCursor(cursorName:String, bitmapData:BitmapData, xHotSpot:int = 0, yHotSpot:int = 0):void
{
var cursorData:MouseCursorData = new MouseCursorData();
- var bitmapDataVectors:Vector.<BitmapData> = new Vector.<BitmapData>(1,true);
-
- bitmapDataVectors[0] = bitmapData;
-
- cursorData.data = bitmapDataVectors;
- cursorData.hotSpot = new Point(xOffset,yOffset);
- Mouse.registerCursor(name,cursorData);
- trace("registered " + name);
+ cursorData.data = Vector.<BitmapData>([bitmapData]);
+ cursorData.hotSpot = new Point(xHotSpot, yHotSpot);
+ Mouse.registerCursor(cursorName, cursorData);
}
-
- private static var idCounter:int = 0;
+ private static var idCounter:int = 0; // used to generate unique IDs for cursors
+ private static const cursorStack:Array = []; // keeps track of previously shown cursors
- private static var idCursorMap:Array = new Array();
/**
* This function is to set the cursor to standard cursor types like hand cursor, link cursor, etc.
* Look at the static String constants to get all the types of available cursors.
- * @param type A string name. Use one of the string constants
- * @param xOffset the x-coordinate on the bitmap where you want the click to register. (0,0) is the upper left corner of the bitmap image.
- * @param yOffset the y-coordinate on the bitmap where you want the click to register. (0,0) is the upper left corner of the bitmap image.
- * @return An integer mapped to the cursorname.
+ * @param name The name of a registered cursor.
+ * @return An id mapped to the cursor that can be passed to removeCursor() later.
* */
- public static function showCursor(type:String):int
+ public static function showCursor(name:String):int
{
- Mouse.cursor = type;
- idCounter++;
- idCursorMap.push([idCounter,type]);
- return idCounter;
+ cursorStack.push(new CursorEntry(idCounter, name));
+ updateCursor();
+ return idCounter++; // increment for next time
}
-
+ /**
+ * Removes a cursor previously shown.
+ * @param id The id of the cursor that was returned by a previous call to showCursor().
+ */
public static function removeCursor(id:int):void
{
- for(var i:int; i<idCursorMap.length; i++)
+ for (var i:int; i < cursorStack.length; i++)
{
- if(idCursorMap[i][0] == id)
+ if (CursorEntry(cursorStack[i]).id == id)
{
- idCursorMap.splice(i,1);
- setToLastCursor();
+ cursorStack.splice(i,1);
+ updateCursor();
return;
}
}
-
}
+
+ /**
+ * This function should always be called after modifying the cursor stack.
+ */
+ private static function updateCursor():void
+ {
+ if (cursorStack.length > 0)
+ Mouse.cursor = CursorEntry(cursorStack[cursorStack.length - 1]).name;
+ else
+ Mouse.cursor = MouseCursor.AUTO;
+ }
+
+
+
+ ///////////
+ // hacks //
+ ///////////
- public static function removeCurrentCursor():void
+ /**
+ * @TODO Stop using this function and remove it.
+ */
+ [Exclude]
+ public static function hack_removeCurrentCursor():void
{
- if(idCursorMap.length ==0)
+ if (cursorStack.length == 0)
return;
- var currentCursor:Array = idCursorMap.pop();
-
- setToLastCursor();
-
+ cursorStack.pop();
+ updateCursor();
}
-
- private static function setToLastCursor():void
- {
- //set to last cursor
- if(idCursorMap.length !=0)
- Mouse.cursor = idCursorMap[idCursorMap.length-1][1];
- else
- Mouse.cursor = MouseCursor.AUTO;
- }
- public static function removeAllCursors():void
+ /**
+ * @TODO Stop using this function and remove it.
+ */
+ [Exclude]
+ public static function hack_removeAllCursors():void
{
- idCursorMap = [];
- setToLastCursor();
+ cursorStack.length = 0;
+ updateCursor();
}
}
-}
+}
+
+internal class CursorEntry
+{
+ public function CursorEntry(id:int, name:String)
+ {
+ this.id = id;
+ this.name = name;
+ }
+
+ public var id:Number;
+ public var name:String;
+}
View
54 WeaveUI/src/weave/visualization/layers/InteractiveVisualization.as
@@ -94,7 +94,7 @@ package weave.visualization.layers
}
private function removeCursor(e:Event):void
{
- CustomCursorManager.removeCurrentCursor();
+ CustomCursorManager.hack_removeCurrentCursor();
}
public const enableZoomAndPan:LinkableBoolean = registerLinkableChild(this, new LinkableBoolean(true));
@@ -159,25 +159,25 @@ package weave.visualization.layers
if (_mouseMode == InteractionController.PAN)
{
if (WeaveAPI.StageUtils.mouseButtonDown)
- CustomCursorManager.showCursor(CustomCursorManager.HAND_GRAB_CURSOR);
+ CustomCursorManager.showCursor(CURSOR_HAND_GRAB);
else
- CustomCursorManager.showCursor(CustomCursorManager.HAND_CURSOR);
+ CustomCursorManager.showCursor(CURSOR_HAND);
}
else if (_mouseMode == InteractionController.SELECT_ADD)
{
- CustomCursorManager.showCursor(CustomCursorManager.SELECT_ADD_CURSOR);
+ CustomCursorManager.showCursor(CURSOR_SELECT_ADD);
}
else if (_mouseMode == InteractionController.SELECT || _mouseMode == InteractionController.PROBE)
{
- CustomCursorManager.showCursor(CustomCursorManager.SELECT_REPLACE_CURSOR);
+ CustomCursorManager.showCursor(CURSOR_SELECT_REPLACE);
}
else if (_mouseMode == InteractionController.SELECT_REMOVE)
{
- CustomCursorManager.showCursor(CustomCursorManager.SELECT_SUBTRACT_CURSOR);
+ CustomCursorManager.showCursor(CURSOR_SELECT_SUBTRACT);
}
else if (_mouseMode == InteractionController.ZOOM)
{
- CustomCursorManager.showCursor(CustomCursorManager.ZOOM_CURSOR);
+ CustomCursorManager.showCursor(CURSOR_ZOOM);
}
}
}
@@ -251,7 +251,7 @@ package weave.visualization.layers
{
if (mouseIsRolledOver)
{
- CustomCursorManager.removeAllCursors();
+ CustomCursorManager.hack_removeAllCursors();
mouseIsRolledOver = false;
// when rolled over goes from true to false, clear the probe
@@ -953,5 +953,43 @@ package weave.visualization.layers
return tempPoint;
}
+
+ /**
+ * Embedded cursors
+ */
+ public static const CURSOR_LINK:String = "linkCursor";
+ [Embed(source="/weave/resources/images/axisLinkCursor.png")]
+ private static var linkCursor:Class;
+ CustomCursorManager.registerEmbeddedCursor(CURSOR_LINK, linkCursor, 0, 0);
+
+ public static const CURSOR_HAND:String = "handCursor";
+ [Embed(source="/weave/resources/images/cursor_hand.png")]
+ public static var handCursor:Class;
+ CustomCursorManager.registerEmbeddedCursor(CURSOR_HAND, handCursor, 1, 2);
+
+ public static const CURSOR_HAND_GRAB:String = "handGrabCursor";
+ [Embed(source="/weave/resources/images/cursor_grab.png")]
+ private static var handGrabCursor:Class;
+ CustomCursorManager.registerEmbeddedCursor(CURSOR_HAND_GRAB, handGrabCursor, 1, 2);
+
+ public static const CURSOR_SELECT_REPLACE:String = "selectReplaceCursor";
+ [Embed(source="/weave/resources/images/cursor_select_replace.png")]
+ private static var selectReplaceCursor:Class;
+ CustomCursorManager.registerEmbeddedCursor(CURSOR_SELECT_REPLACE, selectReplaceCursor, 1, 2);
+
+ public static const CURSOR_SELECT_ADD:String = "selectAddCursor";
+ [Embed(source="/weave/resources/images/cursor_select_add.png")]
+ private static var selectAddCursor:Class;
+ CustomCursorManager.registerEmbeddedCursor(CURSOR_SELECT_ADD, selectAddCursor, 1, 2);
+
+ public static const CURSOR_SELECT_SUBTRACT:String = "selectSubtractCursor";
+ [Embed(source="/weave/resources/images/cursor_select_subtract.png")]
+ private static var selectSubtractCursor:Class;
+ CustomCursorManager.registerEmbeddedCursor(CURSOR_SELECT_SUBTRACT, selectSubtractCursor, 1, 2);
+
+ public static const CURSOR_ZOOM:String = "zoomCursor";
+ [Embed(source="/weave/resources/images/cursor_zoom.png")]
+ private static var zoomCursor:Class;
+ CustomCursorManager.registerEmbeddedCursor(CURSOR_ZOOM, zoomCursor, 0, 0);
}
}
View
2 WeaveUI/src/weave/visualization/layers/SimpleInteractiveVisualization.as
@@ -387,7 +387,7 @@ package weave.visualization.layers
var stageHeight:int = stage.stageHeight; //stage.height returns incorrect values
if (theMargin && Weave.properties.enableToolControls.value)
- CustomCursorManager.showCursor(CustomCursorManager.LINK_CURSOR);
+ CustomCursorManager.showCursor(CURSOR_LINK);
// if we should be creating a tooltip
if (axisColumn && Weave.properties.enableAxisToolTips.value)
{
View
4 WeaveUI/src/weave/visualization/tools/GaugeTool.mxml
@@ -36,6 +36,8 @@
import weave.utils.ColumnUtils;
import weave.utils.CustomCursorManager;
import weave.utils.LinkableTextFormat;
+ import weave.visualization.layers.InteractiveVisualization;
+ import weave.visualization.layers.SimpleInteractiveVisualization;
import weave.visualization.plotters.GaugePlotter;
WeaveAPI.registerImplementation(IVisTool, GaugeTool, lang("Gauge Tool"));
@@ -106,7 +108,7 @@
private function showLinkCursor():void
{
if (Weave.properties.enableToolControls.value)
- CustomCursorManager.showCursor(CustomCursorManager.LINK_CURSOR);
+ CustomCursorManager.showCursor(InteractiveVisualization.CURSOR_LINK);
}
private function updateMarginLabel():void
View
5 WeaveUI/src/weave/visualization/tools/SizeBinLegendTool.mxml
@@ -36,6 +36,7 @@
import weave.utils.ColumnUtils;
import weave.utils.CustomCursorManager;
import weave.utils.LinkableTextFormat;
+ import weave.visualization.layers.InteractiveVisualization;
import weave.visualization.layers.LayerSettings;
import weave.visualization.layers.SimpleInteractiveVisualization;
import weave.visualization.plotters.ColorBinLegendPlotter;
@@ -163,9 +164,9 @@
fontWeight="bold" click="handleMarginLabelClick()"
x="0" y="0" paddingLeft="5" paddingTop="5" paddingRight="5"
text="{marginLabelText}" width="100%"
- mouseOver="CustomCursorManager.showCursor(CustomCursorManager.LINK_CURSOR)"
+ mouseOver="CustomCursorManager.showCursor(InteractiveVisualization.CURSOR_LINK)"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
- mouseOut="CustomCursorManager.removeCurrentCursor()"
+ mouseOut="CustomCursorManager.hack_removeCurrentCursor()"
wordWrap="true" selectable="false" editable="false"
borderThickness="0" backgroundAlpha="0"
toolTip="{lang('{0}\r\tClick here to select the attribute used for {1}.', marginLabelText, marginLabelMode)}"/>

0 comments on commit 4d75538

Please sign in to comment.
Something went wrong with that request. Please try again.