From d4b4eeed7de825a1dce084a156f69bbfce367870 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Thu, 9 Jul 2020 14:01:03 -0700 Subject: [PATCH] Add all system cursors (framework) (#60931) --- .../lib/src/rendering/mouse_cursor.dart | 419 +++++++++++++++++- 1 file changed, 401 insertions(+), 18 deletions(-) diff --git a/packages/flutter/lib/src/rendering/mouse_cursor.dart b/packages/flutter/lib/src/rendering/mouse_cursor.dart index bbde2641f40..472bbe3ad5c 100644 --- a/packages/flutter/lib/src/rendering/mouse_cursor.dart +++ b/packages/flutter/lib/src/rendering/mouse_cursor.dart @@ -400,7 +400,7 @@ class SystemMouseCursor extends MouseCursor { /// /// [SystemMouseCursors] is a superset of the system cursors of every platform /// that Flutter supports, therefore some of these objects might map to the same -/// result, or fallback to the basic arrow. This mapping is defined by the +/// result, or fallback to the [basic] arrow. This mapping is defined by the /// Flutter engine. /// /// The cursor names are chosen to reflect the cursors' use cases instead of @@ -416,45 +416,428 @@ class SystemMouseCursors { /// Any cursor other than [none] or [uncontrolled] unhides the cursor. static const SystemMouseCursor none = SystemMouseCursor._(kind: 'none'); + + //// STATUS //// + /// The platform-dependent basic cursor. /// /// Typically the shape of an arrow. + /// + /// Corresponds to: + /// + /// * Android: TYPE_DEFAULT, TYPE_ARROW + /// * Web: default + /// * macOS: arrowCursor static const SystemMouseCursor basic = SystemMouseCursor._(kind: 'basic'); - /// A cursor that indicates a user interface element that is clickable, such as a hyperlink. + /// A cursor that emphasizes an element being clickable, such as a hyperlink. /// /// Typically the shape of a pointing hand. + /// + /// Corresponds to: + /// + /// * Android: TYPE_HAND + /// * Web: pointer + /// * macOS: pointingHandCursor static const SystemMouseCursor click = SystemMouseCursor._(kind: 'click'); - /// A cursor that indicates selectable text. + /// A cursor indicating an operation that will not be carried out. /// - /// Typically the shape of a capital I. - static const SystemMouseCursor text = SystemMouseCursor._(kind: 'text'); - - /// A cursor that indicates a forbidden action. + /// Typically the shape of a circle with a diagonal line. May fall back to + /// [noDrop]. /// - /// Typically the shape of a circle with a diagonal line. + /// Corresponds to: + /// + /// * Android: TYPE_NO_DROP + /// * Web: not-allowed + /// * macOS: operationNotAllowedCursor + /// + /// See also: + /// + /// * [noDrop], which indicates somewhere that the current item may not be + /// dropped. static const SystemMouseCursor forbidden = SystemMouseCursor._(kind: 'forbidden'); - /// A cursor that indicates something that can be dragged. + /// A cursor indicating the status that the program is busy and therefore + /// can not be interacted with. + /// + /// Typically the shape of an hourglass or a watch. + /// + /// This cursor is not available as a system cursor on macOS. Although macOS + /// displays a "spinning ball" cursor when busy, it's handled by the OS and not + /// exposed for applications to choose. + /// + /// Corresponds to: + /// + /// * Android: TYPE_WAIT + /// * Web: wait + /// + /// See also: + /// + /// * [progress], which is similar to [wait] but the program can still be + /// interacted with. + static const SystemMouseCursor wait = SystemMouseCursor._(kind: 'wait'); + + /// A cursor indicating the status that the program is busy but can still be + /// interacted with. + /// + /// Typically the shape of an arrow with an hourglass or a watch at the corner. + /// Does *not* fall back to [wait] if unavailable. + /// + /// Corresponds to: + /// + /// * Web: progress + /// + /// See also: + /// + /// * [wait], which is similar to [progress] but the program can not be + /// interacted with. + static const SystemMouseCursor progress = SystemMouseCursor._(kind: 'progress'); + + /// A cursor indicating somewhere the user can trigger a context menu. + /// + /// Typically the shape of an arrow with a small menu at the corner. + /// + /// Corresponds to: + /// + /// * Android: TYPE_CONTEXT_MENU + /// * Web: context-menu + /// * macOS: contextualMenuCursor + static const SystemMouseCursor contextMenu = SystemMouseCursor._(kind: 'contextMenu'); + + /// A cursor indicating help information. + /// + /// Typically the shape of a question mark, or an arrow therewith. + /// + /// Corresponds to: + /// + /// * Android: TYPE_HELP + /// * Web: help + static const SystemMouseCursor help = SystemMouseCursor._(kind: 'help'); + + + //// SELECTION //// + + /// A cursor indicating selectable text. + /// + /// Typically the shape of a capital I. + /// + /// Corresponds to: + /// + /// * Android: TYPE_TEXT + /// * Web: text + /// * macOS: IBeamCursor + static const SystemMouseCursor text = SystemMouseCursor._(kind: 'text'); + + /// A cursor indicating selectable vertical text. + /// + /// Typically the shape of a capital I rotated to be horizontal. May fall back + /// to [text]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_VERTICAL_TEXT + /// * Web: vertical-text + /// * macOS: IBeamCursorForVerticalLayout + static const SystemMouseCursor verticalText = SystemMouseCursor._(kind: 'verticalText'); + + /// A cursor indicating selectable table cells. + /// + /// Typically the shape of a hollow plus sign. + /// + /// Corresponds to: + /// + /// * Android: TYPE_CELL + /// * Web: cell + static const SystemMouseCursor cell = SystemMouseCursor._(kind: 'cell'); + + /// A cursor indicating precise selection, such as selecting a pixel in a + /// bitmap. + /// + /// Typically the shape of a crosshair. + /// + /// Corresponds to: + /// + /// * Android: TYPE_CROSSHAIR + /// * Web: crosshair + /// * macOS: crosshairCursor + static const SystemMouseCursor precise = SystemMouseCursor._(kind: 'precise'); + + + //// DRAG-AND-DROP //// + + /// A cursor indicating moving something. + /// + /// Typically the shape of four-way arrow. May fall back to [allScroll]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_ALL_SCROLL + /// * Web: move + static const SystemMouseCursor move = SystemMouseCursor._(kind: 'move'); + + /// A cursor indicating something that can be dragged. /// /// Typically the shape of an open hand. + /// + /// Corresponds to: + /// + /// * Android: TYPE_GRAB + /// * Web: grab + /// * macOS: openHandCursor static const SystemMouseCursor grab = SystemMouseCursor._(kind: 'grab'); - /// A cursor that indicates something that is being dragged. + /// A cursor indicating something that is being dragged. /// /// Typically the shape of a closed hand. + /// + /// Corresponds to: + /// + /// * Android: TYPE_GRABBING + /// * Web: grabbing + /// * macOS: closedHandCursor static const SystemMouseCursor grabbing = SystemMouseCursor._(kind: 'grabbing'); - /// A cursor in the shape of a horizontal double-arrow. + /// A cursor indicating somewhere that the current item may not be dropped. /// - /// This cursor is typically used when moving or resizing an object, and the - /// object can be moved left or right. - static const SystemMouseCursor horizontalDoubleArrow = SystemMouseCursor._(kind: 'horizontalDoubleArrow'); + /// Typically the shape of a hand with a [forbidden] sign at the corner. May + /// fall back to [forbidden]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_NO_DROP + /// * Web: no-drop + /// * macOS: operationNotAllowedCursor + /// + /// See also: + /// + /// * [forbidden], which indicates an action that will not be carried out. + static const SystemMouseCursor noDrop = SystemMouseCursor._(kind: 'noDrop'); - /// A cursor in the shape of a vertical double-arrow. + /// A cursor indicating that the current operation will create an alias of, or + /// a shortcut of the item. /// - /// This cursor is typically used when moving or resizing an object, and the - /// object can be moved up or down. - static const SystemMouseCursor verticalDoubleArrow = SystemMouseCursor._(kind: 'verticalDoubleArrow'); + /// Typically the shape of an arrow with a shortcut icon at the corner. + /// + /// Corresponds to: + /// + /// * Android: TYPE_ALIAS + /// * Web: alias + /// * macOS: dragLinkCursor + static const SystemMouseCursor alias = SystemMouseCursor._(kind: 'alias'); + + /// A cursor indicating that the current operation will copy the item. + /// + /// Typically the shape of an arrow with a boxed plus sign at the corner. + /// + /// Corresponds to: + /// + /// * Android: TYPE_COPY + /// * Web: copy + /// * macOS: dragCopyCursor + static const SystemMouseCursor copy = SystemMouseCursor._(kind: 'copy'); + + /// A cursor indicating that the current operation will result in the + /// disappearance of the item. + /// + /// Typically the shape of an arrow with a cloud of smoke at the corner. + /// + /// Corresponds to: + /// + /// * macOS: disappearingItemCursor + static const SystemMouseCursor disappearing = SystemMouseCursor._(kind: 'disappearing'); + + + //// RESIZING AND SCROLLING //// + + /// A cursor indicating scrolling in any direction. + /// + /// Typically the shape of a dot surrounded by 4 arrows. + /// + /// Corresponds to: + /// + /// * Android: TYPE_ALL_SCROLL + /// * Web: all-scroll + /// + /// See also: + /// + /// * [move], which indicates moving in any direction. + static const SystemMouseCursor allScroll = SystemMouseCursor._(kind: 'allScroll'); + + /// A cursor indicating resizing an object bidirectionally from its left or + /// right edge. + /// + /// Typically the shape of a bidirectional arrow pointing left and right. + /// + /// Corresponds to: + /// + /// * Android: TYPE_HORIZONTAL_DOUBLE_ARROW + /// * Web: ew-resize + /// * macOS: resizeLeftRightCursor + static const SystemMouseCursor resizeLeftRight = SystemMouseCursor._(kind: 'resizeLeftRight'); + + /// A cursor indicating resizing an object bidirectionally from its top or + /// bottom edge. + /// + /// Typically the shape of a bidirectional arrow pointing up and down. + /// + /// Corresponds to: + /// + /// * Android: TYPE_VERTICAL_DOUBLE_ARROW + /// * Web: ns-resize + /// * macOS: resizeUpDownCursor + static const SystemMouseCursor resizeUpDown = SystemMouseCursor._(kind: 'resizeUpDown'); + + /// A cursor indicating resizing an object bidirectionally from its top left or + /// bottom right corner. + /// + /// Typically the shape of a bidirectional arrow pointing upper left and lower right. + /// + /// Corresponds to: + /// + /// * Android: TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW + /// * Web: nwse-resize + static const SystemMouseCursor resizeUpLeftDownRight = SystemMouseCursor._(kind: 'resizeUpLeftDownRight'); + + /// A cursor indicating resizing an object bidirectionally from its top right or + /// bottom left corner. + /// + /// Typically the shape of a bidirectional arrow pointing upper right and lower left. + /// + /// Corresponds to: + /// + /// * Android: TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW + /// * Web: nesw-resize + static const SystemMouseCursor resizeUpRightDownLeft = SystemMouseCursor._(kind: 'resizeUpRightDownLeft'); + + /// A cursor indicating resizing an object from its top edge. + /// + /// Typically the shape of an arrow pointing up. May fallback to [resizeUpDown]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_VERTICAL_DOUBLE_ARROW + /// * Web: n-resize + /// * macOS: resizeUpCursor + static const SystemMouseCursor resizeUp = SystemMouseCursor._(kind: 'resizeUp'); + + /// A cursor indicating resizing an object from its bottom edge. + /// + /// Typically the shape of an arrow pointing down. May fallback to [resizeUpDown]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_VERTICAL_DOUBLE_ARROW + /// * Web: s-resize + /// * macOS: resizeDownCursor + static const SystemMouseCursor resizeDown = SystemMouseCursor._(kind: 'resizeDown'); + + /// A cursor indicating resizing an object from its left edge. + /// + /// Typically the shape of an arrow pointing left. May fallback to [resizeLeftRight]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_HORIZONTAL_DOUBLE_ARROW + /// * Web: w-resize + /// * macOS: resizeLeftCursor + static const SystemMouseCursor resizeLeft = SystemMouseCursor._(kind: 'resizeLeft'); + + /// A cursor indicating resizing an object from its right edge. + /// + /// Typically the shape of an arrow pointing right. May fallback to [resizeLeftRight]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_HORIZONTAL_DOUBLE_ARROW + /// * Web: e-resize + /// * macOS: resizeRightCursor + static const SystemMouseCursor resizeRight = SystemMouseCursor._(kind: 'resizeRight'); + + /// A cursor indicating resizing an object from its top-left corner. + /// + /// Typically the shape of an arrow pointing upper left. May fallback to [resizeUpLeftDownRight]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW + /// * Web: nw-resize + static const SystemMouseCursor resizeUpLeft = SystemMouseCursor._(kind: 'resizeUpLeft'); + + /// A cursor indicating resizing an object from its top-right corner. + /// + /// Typically the shape of an arrow pointing upper right. May fallback to [resizeUpRightDownLeft]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW + /// * Web: ne-resize + static const SystemMouseCursor resizeUpRight = SystemMouseCursor._(kind: 'resizeUpRight'); + + /// A cursor indicating resizing an object from its bottom-left corner. + /// + /// Typically the shape of an arrow pointing lower left. May fallback to [resizeUpRightDownLeft]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW + /// * Web: sw-resize + static const SystemMouseCursor resizeDownLeft = SystemMouseCursor._(kind: 'resizeDownLeft'); + + /// A cursor indicating resizing an object from its bottom-right corner. + /// + /// Typically the shape of an arrow pointing lower right. May fallback to [resizeUpLeftDownRight]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW + /// * Web: se-resize + static const SystemMouseCursor resizeDownRight = SystemMouseCursor._(kind: 'resizeDownRight'); + + /// A cursor indicating resizing a column, or an item horizontally. + /// + /// Typically the shape of arrows pointing left and right with a vertical bar + /// separating them. May fallback to [resizeLeftRight]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_HORIZONTAL_DOUBLE_ARROW + /// * Web: col-resize + /// * macOS: resizeLeftRightCursor + static const SystemMouseCursor resizeColumn = SystemMouseCursor._(kind: 'resizeColumn'); + + /// A cursor indicating resizing a row, or an item vertically. + /// + /// Typically the shape of arrows pointing up and down with a horizontal bar + /// separating them. May fallback to [resizeUpDown]. + /// + /// Corresponds to: + /// + /// * Android: TYPE_VERTICAL_DOUBLE_ARROW + /// * Web: row-resize + /// * macOS: resizeUpDownCursor + static const SystemMouseCursor resizeRow = SystemMouseCursor._(kind: 'resizeRow'); + + + //// OTHER OPERATIONS //// + + /// A cursor indicating zooming in. + /// + /// Typically a magnifying glass with a plus sign. + /// + /// Corresponds to: + /// + /// * Android: TYPE_ZOOM_IN + /// * Web: zoom-in + static const SystemMouseCursor zoomIn = SystemMouseCursor._(kind: 'zoomIn'); + + /// A cursor indicating zooming out. + /// + /// Typically a magnifying glass with a minus sign. + /// + /// Corresponds to: + /// + /// * Android: TYPE_ZOOM_OUT + /// * Web: zoom-out + static const SystemMouseCursor zoomOut = SystemMouseCursor._(kind: 'zoomOut'); }