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

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

Issue 481683003: Support for Adaptive Handle Orientation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added corresponding methods in Aura Created 5 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_drawable_aura.h" 5 #include "ui/touch_selection/touch_handle_drawable_aura.h"
6 6
7 #include "ui/aura/window.h" 7 #include "ui/aura/window.h"
8 #include "ui/aura/window_targeter.h" 8 #include "ui/aura/window_targeter.h"
9 #include "ui/aura_extra/image_window_delegate.h" 9 #include "ui/aura_extra/image_window_delegate.h"
10 #include "ui/base/cursor/cursor.h" 10 #include "ui/base/cursor/cursor.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 if (enabled == enabled_) 89 if (enabled == enabled_)
90 return; 90 return;
91 91
92 enabled_ = enabled; 92 enabled_ = enabled;
93 if (IsVisible()) 93 if (IsVisible())
94 window_->Show(); 94 window_->Show();
95 else 95 else
96 window_->Hide(); 96 window_->Hide();
97 } 97 }
98 98
99 void TouchHandleDrawableAura::SetOrientation( 99 void TouchHandleDrawableAura::SetOrientation(TouchHandleOrientation orientation,
100 TouchHandleOrientation orientation) { 100 bool mirror_vertical,
101 bool mirror_horizontal) {
101 if (orientation_ == orientation) 102 if (orientation_ == orientation)
jdduke (slow) 2015/09/14 18:38:41 Since it's unsupported, can you add DCHECK(!mirro
AviD 2015/09/21 15:40:16 Acknowledged.
102 return; 103 return;
103 orientation_ = orientation; 104 orientation_ = orientation;
104 gfx::Image* image = GetHandleImage(orientation); 105 gfx::Image* image = GetHandleImage(orientation);
105 window_delegate_->SetImage(*image); 106 window_delegate_->SetImage(*image);
106 107
107 // Calculate the relative bounds. 108 // Calculate the relative bounds.
108 gfx::Size image_size = image->Size(); 109 gfx::Size image_size = image->Size();
109 int window_width = image_size.width() + 2 * kSelectionHandlePadding; 110 int window_width = image_size.width() + 2 * kSelectionHandlePadding;
110 int window_height = image_size.height() + 2 * kSelectionHandlePadding; 111 int window_height = image_size.height() + 2 * kSelectionHandlePadding;
111 // Due to the shape of the handle images, the window is aligned differently to 112 // Due to the shape of the handle images, the window is aligned differently to
(...skipping 14 matching lines...) Expand all
126 break; 127 break;
127 }; 128 };
128 relative_bounds_ = gfx::RectF( 129 relative_bounds_ = gfx::RectF(
129 window_left, 130 window_left,
130 kSelectionHandleVerticalVisualOffset - kSelectionHandlePadding, 131 kSelectionHandleVerticalVisualOffset - kSelectionHandlePadding,
131 window_width, 132 window_width,
132 window_height); 133 window_height);
133 UpdateBounds(); 134 UpdateBounds();
134 } 135 }
135 136
137 void TouchHandleDrawableAura::SetOrigin(const gfx::PointF& position) {
138 focal_position_ = position;
jdduke (slow) 2015/09/14 18:38:41 Are you sure this is correct?
mohsen 2015/09/14 21:52:41 Now that we set origin instead of focus point, we
AviD 2015/09/21 15:40:16 @mohsen: I have changed SetOrientation to : void
mohsen 2015/09/21 20:24:22 Yeah, that seems fine to me. These handles are en
139 UpdateBounds();
140 }
141
136 void TouchHandleDrawableAura::SetAlpha(float alpha) { 142 void TouchHandleDrawableAura::SetAlpha(float alpha) {
137 if (alpha == alpha_) 143 if (alpha == alpha_)
138 return; 144 return;
139 145
140 alpha_ = alpha; 146 alpha_ = alpha;
141 window_->layer()->SetOpacity(alpha_); 147 window_->layer()->SetOpacity(alpha_);
142 if (IsVisible()) 148 if (IsVisible())
143 window_->Show(); 149 window_->Show();
144 else 150 else
145 window_->Hide(); 151 window_->Hide();
146 } 152 }
147 153
148 void TouchHandleDrawableAura::SetFocus(const gfx::PointF& position) {
149 focal_position_ = position;
150 UpdateBounds();
151 }
152
153 gfx::RectF TouchHandleDrawableAura::GetVisibleBounds() const { 154 gfx::RectF TouchHandleDrawableAura::GetVisibleBounds() const {
154 gfx::RectF bounds(window_->bounds()); 155 gfx::RectF bounds(window_->bounds());
155 bounds.Inset(kSelectionHandlePadding, 156 bounds.Inset(kSelectionHandlePadding,
156 kSelectionHandlePadding + kSelectionHandleVerticalVisualOffset, 157 kSelectionHandlePadding + kSelectionHandleVerticalVisualOffset,
157 kSelectionHandlePadding, 158 kSelectionHandlePadding,
158 kSelectionHandlePadding); 159 kSelectionHandlePadding);
159 return bounds; 160 return bounds;
160 } 161 }
161 162
163 const float TouchHandleDrawableAura::GetDrawableHorizontalPaddingRatio() const {
164 // Aura does not have any transparent padding for its handle drawable.
165 return 0.0f;
jdduke (slow) 2015/09/14 18:38:41 Is that true?
mohsen 2015/09/14 21:52:41 Yes, there is no padding around handles in aura re
166 }
167
162 } // namespace ui 168 } // namespace ui
OLDNEW
« no previous file with comments | « ui/touch_selection/touch_handle_drawable_aura.h ('k') | ui/touch_selection/touch_handle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698