Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: ui/base/cursor/cursor.h

Issue 2833163002: Change ui cursor identifiers to an enum class. (Closed)
Patch Set: Remove extranious ::ui:: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_BASE_CURSOR_CURSOR_H_ 5 #ifndef UI_BASE_CURSOR_CURSOR_H_
6 #define UI_BASE_CURSOR_CURSOR_H_ 6 #define UI_BASE_CURSOR_CURSOR_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "ui/base/ui_base_export.h" 9 #include "ui/base/ui_base_export.h"
10 10
11 #if defined(OS_WIN) 11 #if defined(OS_WIN)
12 typedef struct HINSTANCE__* HINSTANCE; 12 typedef struct HINSTANCE__* HINSTANCE;
13 typedef struct HICON__* HICON; 13 typedef struct HICON__* HICON;
14 typedef HICON HCURSOR; 14 typedef HICON HCURSOR;
15 #endif 15 #endif
16 16
17 namespace ui { 17 namespace ui {
18 18
19 #if defined(OS_WIN) 19 #if defined(OS_WIN)
20 typedef ::HCURSOR PlatformCursor; 20 typedef ::HCURSOR PlatformCursor;
21 #elif defined(USE_X11) 21 #elif defined(USE_X11)
22 typedef unsigned long PlatformCursor; 22 typedef unsigned long PlatformCursor;
23 #else 23 #else
24 typedef void* PlatformCursor; 24 typedef void* PlatformCursor;
25 #endif 25 #endif
26 26
27 // TODO(jamescook): Once we're on C++0x we could change these constants 27 enum class CursorType {
28 // to an enum and forward declare it in native_widget_types.h. 28 // Equivalent to a NULL HCURSOR on Windows.
29 CURSOR_NULL = 0,
sky 2017/04/24 20:12:43 Sorry to mention this here, but the new style is k
Elliot Glaysher 2017/04/25 17:16:45 Done.
29 30
30 // Equivalent to a NULL HCURSOR on Windows. 31 // These cursors mirror WebKit cursors from WebCursorInfo, but are replicated
31 const int kCursorNull = 0; 32 // here so we don't introduce a WebKit dependency.
33 POINTER = 1,
34 CROSS = 2,
35 HAND = 3,
36 IBEAM = 4,
37 WAIT = 5,
38 HELP = 6,
39 EAST_RESIZE = 7,
40 NORTH_RESIZE = 8,
41 NORTH_EAST_RESIZE = 9,
42 NORTH_WEST_RESIZE = 10,
43 SOUTH_RESIZE = 11,
44 SOUTH_EAST_RESIZE = 12,
45 SOUTH_WEST_RESIZE = 13,
46 WEST_RESIZE = 14,
47 NORTH_SOUTH_RESIZE = 15,
48 EAST_WEST_RESIZE = 16,
49 NORTH_EAST_SOUTH_WEST_RESIZE = 17,
50 NORTH_WEST_SOUTH_EAST_RESIZE = 18,
51 COLUMN_RESIZE = 19,
52 ROW_RESIZE = 20,
53 MIDDLE_PANNING = 21,
54 EAST_PANNING = 22,
55 NORTH_PANNING = 23,
56 NORTH_EAST_PANNING = 24,
57 NORTH_WEST_PANNING = 25,
58 SOUTH_PANNING = 26,
59 SOUTH_EAST_PANNING = 27,
60 SOUTH_WEST_PANNING = 28,
61 WEST_PANNING = 29,
62 MOVE = 30,
63 VERTICAL_TEXT = 31,
64 CELL = 32,
65 CONTEXT_MENU = 33,
66 ALIAS = 34,
67 PROGRESS = 35,
68 NO_DROP = 36,
69 COPY = 37,
70 NONE = 38,
71 NOT_ALLOWED = 39,
72 ZOOM_IN = 40,
73 ZOOM_OUT = 41,
74 GRAB = 42,
75 GRABBING = 43,
76 CUSTOM = 44,
32 77
33 // These cursors mirror WebKit cursors from WebCursorInfo, but are replicated 78 // These additional drag and drop cursors are not listed in WebCursorInfo.
34 // here so we don't introduce a WebKit dependency. 79 DND_NONE = 45,
35 const int kCursorPointer = 1; 80 DND_MOVE = 46,
36 const int kCursorCross = 2; 81 DND_COPY = 47,
37 const int kCursorHand = 3; 82 DND_LINK = 48,
38 const int kCursorIBeam = 4; 83 };
39 const int kCursorWait = 5;
40 const int kCursorHelp = 6;
41 const int kCursorEastResize = 7;
42 const int kCursorNorthResize = 8;
43 const int kCursorNorthEastResize = 9;
44 const int kCursorNorthWestResize = 10;
45 const int kCursorSouthResize = 11;
46 const int kCursorSouthEastResize = 12;
47 const int kCursorSouthWestResize = 13;
48 const int kCursorWestResize = 14;
49 const int kCursorNorthSouthResize = 15;
50 const int kCursorEastWestResize = 16;
51 const int kCursorNorthEastSouthWestResize = 17;
52 const int kCursorNorthWestSouthEastResize = 18;
53 const int kCursorColumnResize = 19;
54 const int kCursorRowResize = 20;
55 const int kCursorMiddlePanning = 21;
56 const int kCursorEastPanning = 22;
57 const int kCursorNorthPanning = 23;
58 const int kCursorNorthEastPanning = 24;
59 const int kCursorNorthWestPanning = 25;
60 const int kCursorSouthPanning = 26;
61 const int kCursorSouthEastPanning = 27;
62 const int kCursorSouthWestPanning = 28;
63 const int kCursorWestPanning = 29;
64 const int kCursorMove = 30;
65 const int kCursorVerticalText = 31;
66 const int kCursorCell = 32;
67 const int kCursorContextMenu = 33;
68 const int kCursorAlias = 34;
69 const int kCursorProgress = 35;
70 const int kCursorNoDrop = 36;
71 const int kCursorCopy = 37;
72 const int kCursorNone = 38;
73 const int kCursorNotAllowed = 39;
74 const int kCursorZoomIn = 40;
75 const int kCursorZoomOut = 41;
76 const int kCursorGrab = 42;
77 const int kCursorGrabbing = 43;
78 const int kCursorCustom = 44;
79 const int kCursorDndNone = 45;
80 const int kCursorDndMove = 46;
81 const int kCursorDndCopy = 47;
82 const int kCursorDndLink = 48;
83 84
84 enum CursorSetType { 85 enum CursorSetType {
85 CURSOR_SET_NORMAL, 86 CURSOR_SET_NORMAL,
86 CURSOR_SET_LARGE 87 CURSOR_SET_LARGE
87 }; 88 };
88 89
89 // Ref-counted cursor that supports both default and custom cursors. 90 // Ref-counted cursor that supports both default and custom cursors.
90 class UI_BASE_EXPORT Cursor { 91 class UI_BASE_EXPORT Cursor {
91 public: 92 public:
92 Cursor(); 93 Cursor();
93 94
94 // Implicit constructor. 95 // Implicit constructor.
95 Cursor(int type); 96 Cursor(CursorType type);
sky 2017/04/24 20:12:43 explicit (I'm not sure why it wasn't explicit befo
Elliot Glaysher 2017/04/25 17:16:45 This can't be explicit. gfx::NativeCursor is the
96 97
97 // Allow copy. 98 // Allow copy.
98 Cursor(const Cursor& cursor); 99 Cursor(const Cursor& cursor);
99 100
100 ~Cursor(); 101 ~Cursor();
101 102
102 void SetPlatformCursor(const PlatformCursor& platform); 103 void SetPlatformCursor(const PlatformCursor& platform);
103 104
104 void RefCustomCursor(); 105 void RefCustomCursor();
105 void UnrefCustomCursor(); 106 void UnrefCustomCursor();
106 107
107 int native_type() const { return native_type_; } 108 CursorType native_type() const { return native_type_; }
108 PlatformCursor platform() const { return platform_cursor_; } 109 PlatformCursor platform() const { return platform_cursor_; }
109 float device_scale_factor() const { 110 float device_scale_factor() const {
110 return device_scale_factor_; 111 return device_scale_factor_;
111 } 112 }
112 void set_device_scale_factor(float device_scale_factor) { 113 void set_device_scale_factor(float device_scale_factor) {
113 device_scale_factor_ = device_scale_factor; 114 device_scale_factor_ = device_scale_factor;
114 } 115 }
115 116
116 bool operator==(int type) const { return native_type_ == type; } 117 bool operator==(CursorType type) const { return native_type_ == type; }
117 bool operator==(const Cursor& cursor) const { 118 bool operator==(const Cursor& cursor) const {
118 return native_type_ == cursor.native_type_ && 119 return native_type_ == cursor.native_type_ &&
119 platform_cursor_ == cursor.platform_cursor_ && 120 platform_cursor_ == cursor.platform_cursor_ &&
120 device_scale_factor_ == cursor.device_scale_factor_; 121 device_scale_factor_ == cursor.device_scale_factor_;
121 } 122 }
122 bool operator!=(int type) const { return native_type_ != type; } 123 bool operator!=(CursorType type) const { return native_type_ != type; }
123 bool operator!=(const Cursor& cursor) const { 124 bool operator!=(const Cursor& cursor) const {
124 return native_type_ != cursor.native_type_ || 125 return native_type_ != cursor.native_type_ ||
125 platform_cursor_ != cursor.platform_cursor_ || 126 platform_cursor_ != cursor.platform_cursor_ ||
126 device_scale_factor_ != cursor.device_scale_factor_; 127 device_scale_factor_ != cursor.device_scale_factor_;
127 } 128 }
128 129
129 void operator=(const Cursor& cursor) { 130 void operator=(const Cursor& cursor) {
130 Assign(cursor); 131 Assign(cursor);
131 } 132 }
132 133
133 private: 134 private:
134 void Assign(const Cursor& cursor); 135 void Assign(const Cursor& cursor);
135 136
136 // See definitions above. 137 // See definitions above.
137 int native_type_; 138 CursorType native_type_;
138 139
139 PlatformCursor platform_cursor_; 140 PlatformCursor platform_cursor_;
140 141
141 // The device scale factor for the cursor. 142 // The device scale factor for the cursor.
142 float device_scale_factor_; 143 float device_scale_factor_;
143 }; 144 };
144 145
145 } // namespace ui 146 } // namespace ui
146 147
147 #endif // UI_BASE_CURSOR_CURSOR_H_ 148 #endif // UI_BASE_CURSOR_CURSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698