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

Side by Side Diff: ui/touch_selection/touch_handle.cc

Issue 701823002: Separate out Touch Selection Orientation enum (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes done with new design Created 5 years, 9 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
« no previous file with comments | « ui/touch_selection/touch_handle.h ('k') | ui/touch_selection/touch_handle_orientation.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "ui/touch_selection/touch_handle.h" 5 #include "ui/touch_selection/touch_handle.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 namespace ui { 9 namespace ui {
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 } // namespace 45 } // namespace
46 46
47 // Responsible for rendering a selection or insertion handle for text editing. 47 // Responsible for rendering a selection or insertion handle for text editing.
48 TouchHandle::TouchHandle(TouchHandleClient* client, 48 TouchHandle::TouchHandle(TouchHandleClient* client,
49 TouchHandleOrientation orientation) 49 TouchHandleOrientation orientation)
50 : drawable_(client->CreateDrawable()), 50 : drawable_(client->CreateDrawable()),
51 client_(client), 51 client_(client),
52 orientation_(orientation), 52 orientation_(orientation),
53 deferred_orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED), 53 deferred_orientation_(TouchHandleOrientation::UNDEFINED),
54 alpha_(0.f), 54 alpha_(0.f),
55 animate_deferred_fade_(false), 55 animate_deferred_fade_(false),
56 enabled_(true), 56 enabled_(true),
57 is_visible_(false), 57 is_visible_(false),
58 is_dragging_(false), 58 is_dragging_(false),
59 is_drag_within_tap_region_(false) { 59 is_drag_within_tap_region_(false) {
60 DCHECK_NE(orientation, TOUCH_HANDLE_ORIENTATION_UNDEFINED); 60 DCHECK_NE(static_cast<int>(orientation),
61 static_cast<int>(TouchHandleOrientation::UNDEFINED));
61 drawable_->SetEnabled(enabled_); 62 drawable_->SetEnabled(enabled_);
62 drawable_->SetOrientation(orientation_); 63 drawable_->SetOrientation(orientation_);
63 drawable_->SetAlpha(alpha_); 64 drawable_->SetAlpha(alpha_);
64 drawable_->SetFocus(position_); 65 drawable_->SetFocus(position_);
65 } 66 }
66 67
67 TouchHandle::~TouchHandle() { 68 TouchHandle::~TouchHandle() {
68 } 69 }
69 70
70 void TouchHandle::SetEnabled(bool enabled) { 71 void TouchHandle::SetEnabled(bool enabled) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 position_ = position; 109 position_ = position;
109 // Suppress repositioning a handle while invisible or fading out to prevent it 110 // Suppress repositioning a handle while invisible or fading out to prevent it
110 // from "ghosting" outside the visible bounds. The position will be pushed to 111 // from "ghosting" outside the visible bounds. The position will be pushed to
111 // the drawable when the handle regains visibility (see |SetVisible()|). 112 // the drawable when the handle regains visibility (see |SetVisible()|).
112 if (is_visible_) 113 if (is_visible_)
113 drawable_->SetFocus(position_); 114 drawable_->SetFocus(position_);
114 } 115 }
115 116
116 void TouchHandle::SetOrientation(TouchHandleOrientation orientation) { 117 void TouchHandle::SetOrientation(TouchHandleOrientation orientation) {
117 DCHECK(enabled_); 118 DCHECK(enabled_);
118 DCHECK_NE(orientation, TOUCH_HANDLE_ORIENTATION_UNDEFINED); 119 DCHECK_NE(static_cast<int>(orientation),
jdduke (slow) 2015/02/25 17:36:48 Dang, I didn't realize our DCHECK code doesn't pla
AviD 2015/02/26 06:28:08 If we define this in anonymous namespace, it gives
120 static_cast<int>(TouchHandleOrientation::UNDEFINED));
119 if (is_dragging_) { 121 if (is_dragging_) {
120 deferred_orientation_ = orientation; 122 deferred_orientation_ = orientation;
121 return; 123 return;
122 } 124 }
123 DCHECK_EQ(deferred_orientation_, TOUCH_HANDLE_ORIENTATION_UNDEFINED); 125 DCHECK_EQ(static_cast<int>(deferred_orientation_),
126 static_cast<int>(TouchHandleOrientation::UNDEFINED));
124 if (orientation_ == orientation) 127 if (orientation_ == orientation)
125 return; 128 return;
126 129
127 orientation_ = orientation; 130 orientation_ = orientation;
128 drawable_->SetOrientation(orientation); 131 drawable_->SetOrientation(orientation);
129 } 132 }
130 133
131 bool TouchHandle::WillHandleTouchEvent(const MotionEvent& event) { 134 bool TouchHandle::WillHandleTouchEvent(const MotionEvent& event) {
132 if (!enabled_) 135 if (!enabled_)
133 return false; 136 return false;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 226
224 void TouchHandle::EndDrag() { 227 void TouchHandle::EndDrag() {
225 DCHECK(enabled_); 228 DCHECK(enabled_);
226 if (!is_dragging_) 229 if (!is_dragging_)
227 return; 230 return;
228 231
229 is_dragging_ = false; 232 is_dragging_ = false;
230 is_drag_within_tap_region_ = false; 233 is_drag_within_tap_region_ = false;
231 client_->OnHandleDragEnd(*this); 234 client_->OnHandleDragEnd(*this);
232 235
233 if (deferred_orientation_ != TOUCH_HANDLE_ORIENTATION_UNDEFINED) { 236 if (deferred_orientation_ != TouchHandleOrientation::UNDEFINED) {
234 TouchHandleOrientation deferred_orientation = deferred_orientation_; 237 TouchHandleOrientation deferred_orientation = deferred_orientation_;
235 deferred_orientation_ = TOUCH_HANDLE_ORIENTATION_UNDEFINED; 238 deferred_orientation_ = TouchHandleOrientation::UNDEFINED;
236 SetOrientation(deferred_orientation); 239 SetOrientation(deferred_orientation);
237 } 240 }
238 241
239 if (animate_deferred_fade_) { 242 if (animate_deferred_fade_) {
240 BeginFade(); 243 BeginFade();
241 } else { 244 } else {
242 // As drawable visibility assignment is deferred while dragging, push the 245 // As drawable visibility assignment is deferred while dragging, push the
243 // change by forcing fade completion. 246 // change by forcing fade completion.
244 EndFade(); 247 EndFade();
245 } 248 }
(...skipping 25 matching lines...) Expand all
271 274
272 void TouchHandle::SetAlpha(float alpha) { 275 void TouchHandle::SetAlpha(float alpha) {
273 alpha = std::max(0.f, std::min(1.f, alpha)); 276 alpha = std::max(0.f, std::min(1.f, alpha));
274 if (alpha_ == alpha) 277 if (alpha_ == alpha)
275 return; 278 return;
276 alpha_ = alpha; 279 alpha_ = alpha;
277 drawable_->SetAlpha(alpha); 280 drawable_->SetAlpha(alpha);
278 } 281 }
279 282
280 } // namespace ui 283 } // namespace ui
OLDNEW
« no previous file with comments | « ui/touch_selection/touch_handle.h ('k') | ui/touch_selection/touch_handle_orientation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698