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

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

Issue 9463003: aura-x11: Add custom web cursor support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/aura.gyp ('k') | ui/aura/cursor_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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_AURA_CURSOR_H_ 5 #ifndef UI_AURA_CURSOR_H_
6 #define UI_AURA_CURSOR_H_ 6 #define UI_AURA_CURSOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include "build/build_config.h"
10 #include "ui/aura/aura_export.h"
11
12 namespace gfx {
13 class Point;
14 class Size;
15 }
16
17 #if defined(OS_WIN)
18 typedef struct HINSTANCE__* HINSTANCE;
19 typedef struct HICON__* HICON;
20 typedef HICON HCURSOR;
21 #endif
22
9 namespace aura { 23 namespace aura {
10 24
25 #if defined(OS_WIN)
26 typedef ::HCURSOR PlatformCursor;
27 #elif defined(USE_X11)
28 typedef unsigned long PlatformCursor;
29 #else
30 typedef void* PlatformCursor;
31 #endif
32
11 // TODO(jamescook): Once we're on C++0x we could change these constants 33 // TODO(jamescook): Once we're on C++0x we could change these constants
12 // to an enum and forward declare it in native_widget_types.h. 34 // to an enum and forward declare it in native_widget_types.h.
13 35
14 // Equivalent to a NULL HCURSOR on Windows. 36 // Equivalent to a NULL HCURSOR on Windows.
15 const int kCursorNull = 0; 37 const int kCursorNull = 0;
16 38
17 // Aura cursors mirror WebKit cursors from WebCursorInfo, but are replicated 39 // Aura cursors mirror WebKit cursors from WebCursorInfo, but are replicated
18 // here so we don't introduce a WebKit dependency. 40 // here so we don't introduce a WebKit dependency.
19 const int kCursorPointer = 1; 41 const int kCursorPointer = 1;
20 const int kCursorCross = 2; 42 const int kCursorCross = 2;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 const int kCursorNoDrop = 36; 76 const int kCursorNoDrop = 36;
55 const int kCursorCopy = 37; 77 const int kCursorCopy = 37;
56 const int kCursorNone = 38; 78 const int kCursorNone = 38;
57 const int kCursorNotAllowed = 39; 79 const int kCursorNotAllowed = 39;
58 const int kCursorZoomIn = 40; 80 const int kCursorZoomIn = 40;
59 const int kCursorZoomOut = 41; 81 const int kCursorZoomOut = 41;
60 const int kCursorGrab = 42; 82 const int kCursorGrab = 42;
61 const int kCursorGrabbing = 43; 83 const int kCursorGrabbing = 43;
62 const int kCursorCustom = 44; 84 const int kCursorCustom = 44;
63 85
86 // Ref-counted cursor that supports both default and custom cursors.
87 class AURA_EXPORT Cursor {
88 public:
89 Cursor()
90 : native_type_(0),
91 platform_(0) {
92 }
93
94 // Implicit constructor.
95 Cursor(int type)
96 : native_type_(type),
97 platform_(0) {
98 }
99
100 // Allow copy.
101 Cursor(const Cursor& cursor)
102 : native_type_(cursor.native_type_),
103 platform_(cursor.platform_) {
104 if (native_type_ == kCursorCustom)
105 RefCustomCursor();
106 }
107
108 ~Cursor() {
109 if (native_type_ == kCursorCustom)
110 UnrefCustomCursor();
111 }
112
113 void SetPlatformCursor(const PlatformCursor& platform) {
114 if (platform_)
115 UnrefCustomCursor();
116 native_type_ = kCursorCustom;
117 platform_ = platform;
118 RefCustomCursor();
119 }
120
121 void RefCustomCursor();
122 void UnrefCustomCursor();
123
124 int native_type() const { return native_type_; }
125 PlatformCursor platform() const { return platform_; }
126
127 bool operator==(int type) const { return native_type_ == type; }
Daniel Erat 2012/02/27 17:53:55 This feels a bit weird to me. I think that it'd b
128 bool operator==(const Cursor& cursor) const {
129 return native_type_ == cursor.native_type_ &&
130 platform_ == cursor.platform_;
131 }
132 bool operator!=(int type) const { return native_type_ != type; }
133 bool operator!=(const Cursor& cursor) const {
134 return native_type_ != cursor.native_type_ ||
135 platform_ != cursor.platform_;
136 }
137
138 private:
139 // See definitions above.
140 int native_type_;
141
142 PlatformCursor platform_;
Daniel Erat 2012/02/27 17:53:55 nit: rename to platform_cursor_
143 };
144
64 } // namespace aura 145 } // namespace aura
65 146
66 #endif // UI_AURA_CURSOR_H_ 147 #endif // UI_AURA_CURSOR_H_
OLDNEW
« no previous file with comments | « ui/aura/aura.gyp ('k') | ui/aura/cursor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698