From 5d25c9f93fbbf647221bdeda87bba3e8803ed59f Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Tue, 30 Jun 2020 17:56:54 -0700 Subject: [PATCH 01/11] Add Android cursors --- lib/web_ui/lib/src/engine/mouse_cursor.dart | 25 +++++++++++++++--- .../plugin/mouse/MouseCursorPlugin.java | 26 ++++++++++++++++--- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/lib/web_ui/lib/src/engine/mouse_cursor.dart b/lib/web_ui/lib/src/engine/mouse_cursor.dart index 2ee68977e42cd..7f675460e0bc8 100644 --- a/lib/web_ui/lib/src/engine/mouse_cursor.dart +++ b/lib/web_ui/lib/src/engine/mouse_cursor.dart @@ -20,18 +20,35 @@ class MouseCursor { MouseCursor._() {} - // The kind values must be kept in sync with flutter's - // rendering/mouse_cursor.dart + // Map from Flutter's kind values to CSS's cursor values. + // + // This map must be kept in sync with flutter's rendering/mouse_cursor.dart. static const Map _kindToCssValueMap = { - 'none': 'none', + 'alias': 'alias', + 'allScroll': 'all-scroll', 'basic': 'default', + 'cell': 'cell', 'click': 'pointer', - 'text': 'text', + 'contextMenu': 'context-menu', + 'copy': 'copy', 'forbidden': 'not-allowed', 'grab': 'grab', 'grabbing': 'grabbing', + 'help': 'help', 'horizontalDoubleArrow': 'ew-resize', + 'move': 'move', + 'none': 'none', + 'noDrop': 'no-drop', + 'precise': 'crosshair', + 'progress': 'progress', + 'text': 'text', + 'upLeftDoubleArrow': 'nwse-resize', + 'upRightDoubleArrow': 'nesw-resize', 'verticalDoubleArrow': 'ns-resize', + 'verticalText': 'vertical-text', + 'wait': 'wait', + 'zoomIn': 'zoom-in', + 'zoomOut': 'zoom-out', }; static String _mapKindToCssValue(String? kind) { return _kindToCssValueMap[kind] ?? 'default'; diff --git a/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java b/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java index a4a3966a27e62..f0d8276f55050 100644 --- a/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java +++ b/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java @@ -47,17 +47,35 @@ private PointerIcon resolveSystemCursor(@NonNull String kind) { private static final long serialVersionUID = 1L; { - put("none", Integer.valueOf(PointerIcon.TYPE_NULL)); - // "basic": default + put("alias", Integer.valueOf(PointerIcon.TYPE_ALIAS)); + put("allScroll", Integer.valueOf(PointerIcon.TYPE_ALL_SCROLL)); + put("cell", Integer.valueOf(PointerIcon.TYPE_CELL)); put("click", Integer.valueOf(PointerIcon.TYPE_HAND)); - put("text", Integer.valueOf(PointerIcon.TYPE_TEXT)); - // "forbidden": default + put("contextMenu", Integer.valueOf(PointerIcon.TYPE_CONTEXT_MENU)); + put("copy", Integer.valueOf(PointerIcon.TYPE_COPY)); + put("forbidden", Integer.valueOf(PointerIcon.TYPE_NO_DROP)); put("grab", Integer.valueOf(PointerIcon.TYPE_GRAB)); put("grabbing", Integer.valueOf(PointerIcon.TYPE_GRABBING)); + put("help", Integer.valueOf(PointerIcon.TYPE_HELP)); put( "horizontalDoubleArrow", Integer.valueOf(PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW)); + put("move", Integer.valueOf(PointerIcon.TYPE_ALL_SCROLL)); + put("none", Integer.valueOf(PointerIcon.TYPE_NULL)); + put("noDrop", Integer.valueOf(PointerIcon.TYPE_NO_DROP)); + put("precise", Integer.valueOf(PointerIcon.TYPE_CROSSHAIR)); + put("text", Integer.valueOf(PointerIcon.TYPE_TEXT)); + put( + "upLeftDoubleArrow", + Integer.valueOf(PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW)); + put( + "upRightDoubleArrow", + Integer.valueOf(PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW)); put("verticalDoubleArrow", Integer.valueOf(PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW)); + put("verticalText", Integer.valueOf(PointerIcon.TYPE_VERTICAL_TEXT)); + put("wait", Integer.valueOf(PointerIcon.TYPE_WAIT)); + put("zoomIn", Integer.valueOf(PointerIcon.TYPE_ZOOM_IN)); + put("zoomOut", Integer.valueOf(PointerIcon.TYPE_ZOOM_OUT)); } }; } From 11ec6c563f439a01b81987e857899c271baa5872 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Mon, 6 Jul 2020 14:36:16 -0700 Subject: [PATCH 02/11] Add all css cursors --- lib/web_ui/lib/src/engine/mouse_cursor.dart | 18 ++++-- .../plugin/mouse/MouseCursorPlugin.java | 62 ++++++++++--------- 2 files changed, 47 insertions(+), 33 deletions(-) diff --git a/lib/web_ui/lib/src/engine/mouse_cursor.dart b/lib/web_ui/lib/src/engine/mouse_cursor.dart index 7f675460e0bc8..7df96e0bf2828 100644 --- a/lib/web_ui/lib/src/engine/mouse_cursor.dart +++ b/lib/web_ui/lib/src/engine/mouse_cursor.dart @@ -35,16 +35,26 @@ class MouseCursor { 'grab': 'grab', 'grabbing': 'grabbing', 'help': 'help', - 'horizontalDoubleArrow': 'ew-resize', 'move': 'move', 'none': 'none', 'noDrop': 'no-drop', 'precise': 'crosshair', 'progress': 'progress', 'text': 'text', - 'upLeftDoubleArrow': 'nwse-resize', - 'upRightDoubleArrow': 'nesw-resize', - 'verticalDoubleArrow': 'ns-resize', + 'resizeColumn': 'col-resize', + 'resizeDown': 's-resize', + 'resizeDownLeft': 'sw-resize', + 'resizeDownRight': 'se-resize', + 'resizeLeft': 'w-resize', + 'resizeLeftRight': 'ew-resize', + 'resizeRight': 'e-resize', + 'resizeRow': 'row-resize', + 'resizeUp': 'n-resize', + 'resizeUpDown': 'ns-resize', + 'resizeUpLeft': 'nw-resize', + 'resizeUpRight': 'ne-resize', + 'resizeUpLeftDownRight': 'nwse-resize', + 'resizeUpRightDownLeft': 'nesw-resize', 'verticalText': 'vertical-text', 'wait': 'wait', 'zoomIn': 'zoom-in', diff --git a/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java b/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java index f0d8276f55050..38bfff572c493 100644 --- a/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java +++ b/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java @@ -47,35 +47,39 @@ private PointerIcon resolveSystemCursor(@NonNull String kind) { private static final long serialVersionUID = 1L; { - put("alias", Integer.valueOf(PointerIcon.TYPE_ALIAS)); - put("allScroll", Integer.valueOf(PointerIcon.TYPE_ALL_SCROLL)); - put("cell", Integer.valueOf(PointerIcon.TYPE_CELL)); - put("click", Integer.valueOf(PointerIcon.TYPE_HAND)); - put("contextMenu", Integer.valueOf(PointerIcon.TYPE_CONTEXT_MENU)); - put("copy", Integer.valueOf(PointerIcon.TYPE_COPY)); - put("forbidden", Integer.valueOf(PointerIcon.TYPE_NO_DROP)); - put("grab", Integer.valueOf(PointerIcon.TYPE_GRAB)); - put("grabbing", Integer.valueOf(PointerIcon.TYPE_GRABBING)); - put("help", Integer.valueOf(PointerIcon.TYPE_HELP)); - put( - "horizontalDoubleArrow", - Integer.valueOf(PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW)); - put("move", Integer.valueOf(PointerIcon.TYPE_ALL_SCROLL)); - put("none", Integer.valueOf(PointerIcon.TYPE_NULL)); - put("noDrop", Integer.valueOf(PointerIcon.TYPE_NO_DROP)); - put("precise", Integer.valueOf(PointerIcon.TYPE_CROSSHAIR)); - put("text", Integer.valueOf(PointerIcon.TYPE_TEXT)); - put( - "upLeftDoubleArrow", - Integer.valueOf(PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW)); - put( - "upRightDoubleArrow", - Integer.valueOf(PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW)); - put("verticalDoubleArrow", Integer.valueOf(PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW)); - put("verticalText", Integer.valueOf(PointerIcon.TYPE_VERTICAL_TEXT)); - put("wait", Integer.valueOf(PointerIcon.TYPE_WAIT)); - put("zoomIn", Integer.valueOf(PointerIcon.TYPE_ZOOM_IN)); - put("zoomOut", Integer.valueOf(PointerIcon.TYPE_ZOOM_OUT)); + put("alias", PointerIcon.TYPE_ALIAS); + put("allScroll", PointerIcon.TYPE_ALL_SCROLL); + put("cell", PointerIcon.TYPE_CELL); + put("click", PointerIcon.TYPE_HAND); + put("contextMenu", PointerIcon.TYPE_CONTEXT_MENU); + put("copy", PointerIcon.TYPE_COPY); + put("forbidden", PointerIcon.TYPE_NO_DROP); + put("grab", PointerIcon.TYPE_GRAB); + put("grabbing", PointerIcon.TYPE_GRABBING); + put("help", PointerIcon.TYPE_HELP); + put("move", PointerIcon.TYPE_ALL_SCROLL); + put("none", PointerIcon.TYPE_NULL); + put("noDrop", PointerIcon.TYPE_NO_DROP); + put("precise", PointerIcon.TYPE_CROSSHAIR); + put("text", PointerIcon.TYPE_TEXT); + put("resizeColumn", PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW); + put("resizeDown", PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW); + put("resizeUpLeft", PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW); + put("resizeDownRight", PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW); + put("resizeLeft", PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW); + put("resizeLeftRight", PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW); + put("resizeRight", PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW); + put("resizeRow", PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW); + put("resizeUp", PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW); + put("resizeUpDown", PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW); + put("resizeUpLeft", PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW); + put("resizeUpRight", PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW); + put("resizeUpLeftDownRight", PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW); + put("resizeUpRightDownLeft", PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW); + put("verticalText", PointerIcon.TYPE_VERTICAL_TEXT); + put("wait", PointerIcon.TYPE_WAIT); + put("zoomIn", PointerIcon.TYPE_ZOOM_IN); + put("zoomOut",PointerIcon.TYPE_ZOOM_OUT); } }; } From aedccbf99d7ba13bea5d20565f4a9d3471a59745 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Mon, 6 Jul 2020 17:06:19 -0700 Subject: [PATCH 03/11] Add macOS --- .../Source/FlutterMouseCursorPlugin.mm | 47 ++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm b/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm index 376701956a0f3..a323d574814b4 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm @@ -14,6 +14,8 @@ static NSString* const kKindValueNone = @"none"; +static NSDictionary* systemCursors; + /** * Maps a Flutter's constant to a platform's cursor object. * @@ -22,24 +24,35 @@ static NSCursor* GetCursorForKind(NSString* kind) { // The following mapping must be kept in sync with Flutter framework's // mouse_cursor.dart - if ([kind isEqualToString:@"basic"]) - return [NSCursor arrowCursor]; - else if ([kind isEqualToString:@"click"]) - return [NSCursor pointingHandCursor]; - else if ([kind isEqualToString:@"text"]) - return [NSCursor IBeamCursor]; - else if ([kind isEqualToString:@"forbidden"]) - return [NSCursor operationNotAllowedCursor]; - else if ([kind isEqualToString:@"grab"]) - return [NSCursor openHandCursor]; - else if ([kind isEqualToString:@"grabbing"]) - return [NSCursor closedHandCursor]; - else if ([kind isEqualToString:@"horizontalDoubleArrow"]) - return [NSCursor resizeLeftRightCursor]; - else if ([kind isEqualToString:@"verticalDoubleArrow"]) - return [NSCursor resizeUpDownCursor]; - else + + if (systemCursors == nil) { + systemCursors = @{ + @"alias": [NSCursor dragLinkCursor], + @"click": [NSCursor pointingHandCursor], + @"contextMenu": [NSCursor contextualMenuCursor], + @"copy": [NSCursor dragCopyCursor], + @"disappearing": [NSCursor disappearingItemCursor], + @"forbidden": [NSCursor operationNotAllowedCursor], + @"grab": [NSCursor openHandCursor], + @"grabbing": [NSCursor closedHandCursor], + @"noDrop": [NSCursor operationNotAllowedCursor], + @"precise": [NSCursor crosshairCursor], + @"text": [NSCursor IBeamCursor], + @"resizeColumn": [NSCursor resizeLeftRightCursor], + @"resizeDown": [NSCursor resizeDownCursor], + @"resizeLeft": [NSCursor resizeLeftCursor], + @"resizeLeftRight": [NSCursor resizeLeftRightCursor], + @"resizeRight": [NSCursor resizeRightCursor], + @"resizeRow": [NSCursor resizeUpDownCursor], + @"resizeUp": [NSCursor resizeUpCursor], + @"resizeUpDown": [NSCursor resizeUpDownCursor], + @"verticalText": [NSCursor IBeamCursorForVerticalLayout], + }; + } + NSCursor* result = [systemCursors objectForKey:kind]; + if (result == nil) // Including @"basic" return [NSCursor arrowCursor]; + return result; } @interface FlutterMouseCursorPlugin () From 57fe73fbdae0d0f99117625ef05af9ed668c8bdb Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Thu, 9 Jul 2020 17:13:57 -0700 Subject: [PATCH 04/11] Add basic cursor back --- .../android/io/flutter/plugin/mouse/MouseCursorPlugin.java | 1 + .../darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java b/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java index 38bfff572c493..4c7787e0e3fec 100644 --- a/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java +++ b/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java @@ -49,6 +49,7 @@ private PointerIcon resolveSystemCursor(@NonNull String kind) { { put("alias", PointerIcon.TYPE_ALIAS); put("allScroll", PointerIcon.TYPE_ALL_SCROLL); + put("basic", PointerIcon.TYPE_ARROW); put("cell", PointerIcon.TYPE_CELL); put("click", PointerIcon.TYPE_HAND); put("contextMenu", PointerIcon.TYPE_CONTEXT_MENU); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm b/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm index a323d574814b4..70e4d731101a3 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm @@ -28,6 +28,7 @@ if (systemCursors == nil) { systemCursors = @{ @"alias": [NSCursor dragLinkCursor], + @"basic": [NSCursor arrowCursor], @"click": [NSCursor pointingHandCursor], @"contextMenu": [NSCursor contextualMenuCursor], @"copy": [NSCursor dragCopyCursor], @@ -50,7 +51,7 @@ }; } NSCursor* result = [systemCursors objectForKey:kind]; - if (result == nil) // Including @"basic" + if (result == nil) return [NSCursor arrowCursor]; return result; } From 3e99abe8f3752792043dcfb5c9c3ec119e8663f4 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Thu, 9 Jul 2020 17:17:40 -0700 Subject: [PATCH 05/11] Fix space --- .../android/io/flutter/plugin/mouse/MouseCursorPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java b/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java index 4c7787e0e3fec..b00ffd1898e22 100644 --- a/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java +++ b/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java @@ -80,7 +80,7 @@ private PointerIcon resolveSystemCursor(@NonNull String kind) { put("verticalText", PointerIcon.TYPE_VERTICAL_TEXT); put("wait", PointerIcon.TYPE_WAIT); put("zoomIn", PointerIcon.TYPE_ZOOM_IN); - put("zoomOut",PointerIcon.TYPE_ZOOM_OUT); + put("zoomOut", PointerIcon.TYPE_ZOOM_OUT); } }; } From e0df03faa0556f21642f49ceee76f2aaa2f076cb Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Mon, 13 Jul 2020 15:47:59 -0700 Subject: [PATCH 06/11] Add linux cursors --- .../Source/FlutterMouseCursorPlugin.mm | 42 +++++++++---------- .../platform/linux/fl_mouse_cursor_plugin.cc | 34 +++++++++++++-- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm b/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm index 70e4d731101a3..e73331db17140 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm @@ -27,27 +27,27 @@ if (systemCursors == nil) { systemCursors = @{ - @"alias": [NSCursor dragLinkCursor], - @"basic": [NSCursor arrowCursor], - @"click": [NSCursor pointingHandCursor], - @"contextMenu": [NSCursor contextualMenuCursor], - @"copy": [NSCursor dragCopyCursor], - @"disappearing": [NSCursor disappearingItemCursor], - @"forbidden": [NSCursor operationNotAllowedCursor], - @"grab": [NSCursor openHandCursor], - @"grabbing": [NSCursor closedHandCursor], - @"noDrop": [NSCursor operationNotAllowedCursor], - @"precise": [NSCursor crosshairCursor], - @"text": [NSCursor IBeamCursor], - @"resizeColumn": [NSCursor resizeLeftRightCursor], - @"resizeDown": [NSCursor resizeDownCursor], - @"resizeLeft": [NSCursor resizeLeftCursor], - @"resizeLeftRight": [NSCursor resizeLeftRightCursor], - @"resizeRight": [NSCursor resizeRightCursor], - @"resizeRow": [NSCursor resizeUpDownCursor], - @"resizeUp": [NSCursor resizeUpCursor], - @"resizeUpDown": [NSCursor resizeUpDownCursor], - @"verticalText": [NSCursor IBeamCursorForVerticalLayout], + @"alias" : [NSCursor dragLinkCursor], + @"basic" : [NSCursor arrowCursor], + @"click" : [NSCursor pointingHandCursor], + @"contextMenu" : [NSCursor contextualMenuCursor], + @"copy" : [NSCursor dragCopyCursor], + @"disappearing" : [NSCursor disappearingItemCursor], + @"forbidden" : [NSCursor operationNotAllowedCursor], + @"grab" : [NSCursor openHandCursor], + @"grabbing" : [NSCursor closedHandCursor], + @"noDrop" : [NSCursor operationNotAllowedCursor], + @"precise" : [NSCursor crosshairCursor], + @"text" : [NSCursor IBeamCursor], + @"resizeColumn" : [NSCursor resizeLeftRightCursor], + @"resizeDown" : [NSCursor resizeDownCursor], + @"resizeLeft" : [NSCursor resizeLeftCursor], + @"resizeLeftRight" : [NSCursor resizeLeftRightCursor], + @"resizeRight" : [NSCursor resizeRightCursor], + @"resizeRow" : [NSCursor resizeUpDownCursor], + @"resizeUp" : [NSCursor resizeUpCursor], + @"resizeUpDown" : [NSCursor resizeUpDownCursor], + @"verticalText" : [NSCursor IBeamCursorForVerticalLayout], }; } NSCursor* result = [systemCursors objectForKey:kind]; diff --git a/shell/platform/linux/fl_mouse_cursor_plugin.cc b/shell/platform/linux/fl_mouse_cursor_plugin.cc index e0669505a9712..67337dcda9593 100644 --- a/shell/platform/linux/fl_mouse_cursor_plugin.cc +++ b/shell/platform/linux/fl_mouse_cursor_plugin.cc @@ -46,13 +46,41 @@ static bool define_system_cursor(GHashTable* table, static void populate_system_cursor_table(GHashTable* table) { // The following mapping must be kept in sync with Flutter framework's // mouse_cursor.dart. - define_system_cursor(table, "none", "none"); + define_system_cursor(table, "alias", "alias"); + define_system_cursor(table, "allScroll", "all-scroll"); + define_system_cursor(table, "basic", "default"); + define_system_cursor(table, "cell", "cell"); define_system_cursor(table, "click", "pointer"); - define_system_cursor(table, "text", "text"); + define_system_cursor(table, "contextMenu", "context-menu"); + define_system_cursor(table, "copy", "copy"); define_system_cursor(table, "forbidden", "not-allowed"); - define_system_cursor(table, "grab", "grabbing"); + define_system_cursor(table, "grab", "grab"); + define_system_cursor(table, "grabbing", "grabbing"); + define_system_cursor(table, "help", "help"); + define_system_cursor(table, "move", "move"); + define_system_cursor(table, "none", "none"); + define_system_cursor(table, "noDrop", "no-drop"); + define_system_cursor(table, "precise", "crosshair"); + define_system_cursor(table, "progress", "progress"); + define_system_cursor(table, "text", "text"); + define_system_cursor(table, "resizeColumn", "col-resize"); + define_system_cursor(table, "resizeDown", "s-resize"); + define_system_cursor(table, "resizeDownLeft", "sw-resize"); + define_system_cursor(table, "resizeDownRight", "se-resize"); + define_system_cursor(table, "resizeLeft", "w-resize"); define_system_cursor(table, "resizeLeftRight", "ew-resize"); + define_system_cursor(table, "resizeRight", "e-resize"); + define_system_cursor(table, "resizeRow", "row-resize"); + define_system_cursor(table, "resizeUp", "n-resize"); define_system_cursor(table, "resizeUpDown", "ns-resize"); + define_system_cursor(table, "resizeUpLeft", "nw-resize"); + define_system_cursor(table, "resizeUpRight", "ne-resize"); + define_system_cursor(table, "resizeUpLeftDownRight", "nwse-resize"); + define_system_cursor(table, "resizeUpRightDownLeft", "nesw-resize"); + define_system_cursor(table, "verticalText", "vertical-text"); + define_system_cursor(table, "wait", "wait"); + define_system_cursor(table, "zoomIn", "zoom-in"); + define_system_cursor(table, "zoomOut", "zoom-out"); } // Sets the mouse cursor. From e6cda8787748c289f1ca126745fa0c06f900f9ac Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Mon, 13 Jul 2020 16:28:05 -0700 Subject: [PATCH 07/11] Add windows cursors --- .../platform/windows/win32_flutter_window.cc | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/shell/platform/windows/win32_flutter_window.cc b/shell/platform/windows/win32_flutter_window.cc index 6fea467183870..c629ee4f4d643 100644 --- a/shell/platform/windows/win32_flutter_window.cc +++ b/shell/platform/windows/win32_flutter_window.cc @@ -20,13 +20,32 @@ constexpr int kScrollOffsetMultiplier = 20; // Returns the arrow cursor for unknown constants. static HCURSOR GetCursorByName(const std::string& cursor_name) { static auto* cursors = new std::map{ - {"none", nullptr}, - {"basic", IDC_ARROW}, - {"click", IDC_HAND}, - {"text", IDC_IBEAM}, - {"forbidden", IDC_NO}, - {"horizontalDoubleArrow", IDC_SIZEWE}, - {"verticalDoubleArrow", IDC_SIZENS}, + {'allScroll': IDC_SIZEALL}, + {'basic': IDC_ARROW}, + {'click': IDC_HAND}, + {'forbidden': IDC_NO}, + {'help': IDC_HELP}, + {'move': IDC_SIZEALL}, + {'none': nullptr}, + {'noDrop': IDC_NO}, + {'precise': IDC_CROSS}, + {'progress': IDC_APPSTARTING}, + {'text': IDC_IBEAM}, + {'resizeColumn': IDC_SIZEWE}, + {'resizeDown': IDC_SIZENS}, + {'resizeDownLeft': IDC_SIZENESW}, + {'resizeDownRight': IDC_SIZENWSE}, + {'resizeLeft': IDC_SIZEWE}, + {'resizeLeftRight': IDC_SIZEWE}, + {'resizeRight': IDC_SIZEWE}, + {'resizeRow': IDC_SIZENS}, + {'resizeUp': IDC_SIZENS}, + {'resizeUpDown': IDC_SIZENS}, + {'resizeUpLeft': IDC_SIZENWSE}, + {'resizeUpRight': IDC_SIZENESW}, + {'resizeUpLeftDownRight': IDC_SIZENWSE}, + {'resizeUpRightDownLeft': IDC_SIZENESW}, + {'wait': IDC_WAIT}, }; const wchar_t* idc_name = IDC_ARROW; auto it = cursors->find(cursor_name); From c0c5522372089a7abf3de7915c83e8d5bcd9fe27 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Mon, 13 Jul 2020 17:04:21 -0700 Subject: [PATCH 08/11] Lint. Doc --- lib/web_ui/lib/src/engine/mouse_cursor.dart | 3 +- .../platform/windows/win32_flutter_window.cc | 55 ++++++++++--------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/lib/web_ui/lib/src/engine/mouse_cursor.dart b/lib/web_ui/lib/src/engine/mouse_cursor.dart index 7df96e0bf2828..fb06bb565521e 100644 --- a/lib/web_ui/lib/src/engine/mouse_cursor.dart +++ b/lib/web_ui/lib/src/engine/mouse_cursor.dart @@ -22,7 +22,8 @@ class MouseCursor { // Map from Flutter's kind values to CSS's cursor values. // - // This map must be kept in sync with flutter's rendering/mouse_cursor.dart. + // This map must be kept in sync with Flutter framework's + // rendering/mouse_cursor.dart. static const Map _kindToCssValueMap = { 'alias': 'alias', 'allScroll': 'all-scroll', diff --git a/shell/platform/windows/win32_flutter_window.cc b/shell/platform/windows/win32_flutter_window.cc index c629ee4f4d643..24264e0d79916 100644 --- a/shell/platform/windows/win32_flutter_window.cc +++ b/shell/platform/windows/win32_flutter_window.cc @@ -18,34 +18,37 @@ constexpr int kScrollOffsetMultiplier = 20; // Maps a Flutter cursor name to an HCURSOR. // // Returns the arrow cursor for unknown constants. +// +// This map must be kept in sync with Flutter framework's +// rendering/mouse_cursor.dart. static HCURSOR GetCursorByName(const std::string& cursor_name) { static auto* cursors = new std::map{ - {'allScroll': IDC_SIZEALL}, - {'basic': IDC_ARROW}, - {'click': IDC_HAND}, - {'forbidden': IDC_NO}, - {'help': IDC_HELP}, - {'move': IDC_SIZEALL}, - {'none': nullptr}, - {'noDrop': IDC_NO}, - {'precise': IDC_CROSS}, - {'progress': IDC_APPSTARTING}, - {'text': IDC_IBEAM}, - {'resizeColumn': IDC_SIZEWE}, - {'resizeDown': IDC_SIZENS}, - {'resizeDownLeft': IDC_SIZENESW}, - {'resizeDownRight': IDC_SIZENWSE}, - {'resizeLeft': IDC_SIZEWE}, - {'resizeLeftRight': IDC_SIZEWE}, - {'resizeRight': IDC_SIZEWE}, - {'resizeRow': IDC_SIZENS}, - {'resizeUp': IDC_SIZENS}, - {'resizeUpDown': IDC_SIZENS}, - {'resizeUpLeft': IDC_SIZENWSE}, - {'resizeUpRight': IDC_SIZENESW}, - {'resizeUpLeftDownRight': IDC_SIZENWSE}, - {'resizeUpRightDownLeft': IDC_SIZENESW}, - {'wait': IDC_WAIT}, + {'allScroll' : IDC_SIZEALL}, + {'basic' : IDC_ARROW}, + {'click' : IDC_HAND}, + {'forbidden' : IDC_NO}, + {'help' : IDC_HELP}, + {'move' : IDC_SIZEALL}, + {'none' : nullptr}, + {'noDrop' : IDC_NO}, + {'precise' : IDC_CROSS}, + {'progress' : IDC_APPSTARTING}, + {'text' : IDC_IBEAM}, + {'resizeColumn' : IDC_SIZEWE}, + {'resizeDown' : IDC_SIZENS}, + {'resizeDownLeft' : IDC_SIZENESW}, + {'resizeDownRight' : IDC_SIZENWSE}, + {'resizeLeft' : IDC_SIZEWE}, + {'resizeLeftRight' : IDC_SIZEWE}, + {'resizeRight' : IDC_SIZEWE}, + {'resizeRow' : IDC_SIZENS}, + {'resizeUp' : IDC_SIZENS}, + {'resizeUpDown' : IDC_SIZENS}, + {'resizeUpLeft' : IDC_SIZENWSE}, + {'resizeUpRight' : IDC_SIZENESW}, + {'resizeUpLeftDownRight' : IDC_SIZENWSE}, + {'resizeUpRightDownLeft' : IDC_SIZENESW}, + {'wait' : IDC_WAIT}, }; const wchar_t* idc_name = IDC_ARROW; auto it = cursors->find(cursor_name); From f0dde18c04ffb849a7ea5379eb632e4acf594cc1 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Tue, 14 Jul 2020 14:42:47 -0700 Subject: [PATCH 09/11] fix quotes --- .../platform/windows/win32_flutter_window.cc | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/shell/platform/windows/win32_flutter_window.cc b/shell/platform/windows/win32_flutter_window.cc index 24264e0d79916..0a577b3707aaf 100644 --- a/shell/platform/windows/win32_flutter_window.cc +++ b/shell/platform/windows/win32_flutter_window.cc @@ -23,32 +23,32 @@ constexpr int kScrollOffsetMultiplier = 20; // rendering/mouse_cursor.dart. static HCURSOR GetCursorByName(const std::string& cursor_name) { static auto* cursors = new std::map{ - {'allScroll' : IDC_SIZEALL}, - {'basic' : IDC_ARROW}, - {'click' : IDC_HAND}, - {'forbidden' : IDC_NO}, - {'help' : IDC_HELP}, - {'move' : IDC_SIZEALL}, - {'none' : nullptr}, - {'noDrop' : IDC_NO}, - {'precise' : IDC_CROSS}, - {'progress' : IDC_APPSTARTING}, - {'text' : IDC_IBEAM}, - {'resizeColumn' : IDC_SIZEWE}, - {'resizeDown' : IDC_SIZENS}, - {'resizeDownLeft' : IDC_SIZENESW}, - {'resizeDownRight' : IDC_SIZENWSE}, - {'resizeLeft' : IDC_SIZEWE}, - {'resizeLeftRight' : IDC_SIZEWE}, - {'resizeRight' : IDC_SIZEWE}, - {'resizeRow' : IDC_SIZENS}, - {'resizeUp' : IDC_SIZENS}, - {'resizeUpDown' : IDC_SIZENS}, - {'resizeUpLeft' : IDC_SIZENWSE}, - {'resizeUpRight' : IDC_SIZENESW}, - {'resizeUpLeftDownRight' : IDC_SIZENWSE}, - {'resizeUpRightDownLeft' : IDC_SIZENESW}, - {'wait' : IDC_WAIT}, + {"allScroll" : IDC_SIZEALL}, + {"basic" : IDC_ARROW}, + {"click" : IDC_HAND}, + {"forbidden" : IDC_NO}, + {"help" : IDC_HELP}, + {"move" : IDC_SIZEALL}, + {"none" : nullptr}, + {"noDrop" : IDC_NO}, + {"precise" : IDC_CROSS}, + {"progress" : IDC_APPSTARTING}, + {"text" : IDC_IBEAM}, + {"resizeColumn" : IDC_SIZEWE}, + {"resizeDown" : IDC_SIZENS}, + {"resizeDownLeft" : IDC_SIZENESW}, + {"resizeDownRight" : IDC_SIZENWSE}, + {"resizeLeft" : IDC_SIZEWE}, + {"resizeLeftRight" : IDC_SIZEWE}, + {"resizeRight" : IDC_SIZEWE}, + {"resizeRow" : IDC_SIZENS}, + {"resizeUp" : IDC_SIZENS}, + {"resizeUpDown" : IDC_SIZENS}, + {"resizeUpLeft" : IDC_SIZENWSE}, + {"resizeUpRight" : IDC_SIZENESW}, + {"resizeUpLeftDownRight" : IDC_SIZENWSE}, + {"resizeUpRightDownLeft" : IDC_SIZENESW}, + {"wait" : IDC_WAIT}, }; const wchar_t* idc_name = IDC_ARROW; auto it = cursors->find(cursor_name); From d2faebdeccc83373541fd3062fbf1b23d353140b Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Tue, 14 Jul 2020 15:32:51 -0700 Subject: [PATCH 10/11] Fix syntax --- .../platform/windows/win32_flutter_window.cc | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/shell/platform/windows/win32_flutter_window.cc b/shell/platform/windows/win32_flutter_window.cc index 0a577b3707aaf..c48ebb1a8e2cb 100644 --- a/shell/platform/windows/win32_flutter_window.cc +++ b/shell/platform/windows/win32_flutter_window.cc @@ -23,32 +23,32 @@ constexpr int kScrollOffsetMultiplier = 20; // rendering/mouse_cursor.dart. static HCURSOR GetCursorByName(const std::string& cursor_name) { static auto* cursors = new std::map{ - {"allScroll" : IDC_SIZEALL}, - {"basic" : IDC_ARROW}, - {"click" : IDC_HAND}, - {"forbidden" : IDC_NO}, - {"help" : IDC_HELP}, - {"move" : IDC_SIZEALL}, - {"none" : nullptr}, - {"noDrop" : IDC_NO}, - {"precise" : IDC_CROSS}, - {"progress" : IDC_APPSTARTING}, - {"text" : IDC_IBEAM}, - {"resizeColumn" : IDC_SIZEWE}, - {"resizeDown" : IDC_SIZENS}, - {"resizeDownLeft" : IDC_SIZENESW}, - {"resizeDownRight" : IDC_SIZENWSE}, - {"resizeLeft" : IDC_SIZEWE}, - {"resizeLeftRight" : IDC_SIZEWE}, - {"resizeRight" : IDC_SIZEWE}, - {"resizeRow" : IDC_SIZENS}, - {"resizeUp" : IDC_SIZENS}, - {"resizeUpDown" : IDC_SIZENS}, - {"resizeUpLeft" : IDC_SIZENWSE}, - {"resizeUpRight" : IDC_SIZENESW}, - {"resizeUpLeftDownRight" : IDC_SIZENWSE}, - {"resizeUpRightDownLeft" : IDC_SIZENESW}, - {"wait" : IDC_WAIT}, + {"allScroll", IDC_SIZEALL}, + {"basic", IDC_ARROW}, + {"click", IDC_HAND}, + {"forbidden", IDC_NO}, + {"help", IDC_HELP}, + {"move", IDC_SIZEALL}, + {"none", nullptr}, + {"noDrop", IDC_NO}, + {"precise", IDC_CROSS}, + {"progress", IDC_APPSTARTING}, + {"text", IDC_IBEAM}, + {"resizeColumn", IDC_SIZEWE}, + {"resizeDown", IDC_SIZENS}, + {"resizeDownLeft", IDC_SIZENESW}, + {"resizeDownRight", IDC_SIZENWSE}, + {"resizeLeft", IDC_SIZEWE}, + {"resizeLeftRight", IDC_SIZEWE}, + {"resizeRight", IDC_SIZEWE}, + {"resizeRow", IDC_SIZENS}, + {"resizeUp", IDC_SIZENS}, + {"resizeUpDown", IDC_SIZENS}, + {"resizeUpLeft", IDC_SIZENWSE}, + {"resizeUpRight", IDC_SIZENESW}, + {"resizeUpLeftDownRight", IDC_SIZENWSE}, + {"resizeUpRightDownLeft", IDC_SIZENESW}, + {"wait", IDC_WAIT}, }; const wchar_t* idc_name = IDC_ARROW; auto it = cursors->find(cursor_name); @@ -61,7 +61,7 @@ static HCURSOR GetCursorByName(const std::string& cursor_name) { } // namespace Win32FlutterWindow::Win32FlutterWindow(int width, int height) - : binding_handler_delegate_(nullptr) { + , binding_handler_delegate_(nullptr) { Win32Window::InitializeChild("FLUTTERVIEW", width, height); current_cursor_ = ::LoadCursor(nullptr, IDC_ARROW); } From 8581c9e07f1336031c7d98fcebccfdef981d29e9 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Tue, 14 Jul 2020 16:31:01 -0700 Subject: [PATCH 11/11] Update win32_flutter_window.cc --- shell/platform/windows/win32_flutter_window.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/windows/win32_flutter_window.cc b/shell/platform/windows/win32_flutter_window.cc index c48ebb1a8e2cb..42915f2535bab 100644 --- a/shell/platform/windows/win32_flutter_window.cc +++ b/shell/platform/windows/win32_flutter_window.cc @@ -61,7 +61,7 @@ static HCURSOR GetCursorByName(const std::string& cursor_name) { } // namespace Win32FlutterWindow::Win32FlutterWindow(int width, int height) - , binding_handler_delegate_(nullptr) { + : binding_handler_delegate_(nullptr) { Win32Window::InitializeChild("FLUTTERVIEW", width, height); current_cursor_ = ::LoadCursor(nullptr, IDC_ARROW); }