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

Side by Side Diff: ui/views/animation/ink_drop_host_view.cc

Issue 2897533003: Change default ink drop center points to center of contents bounds (Closed)
Patch Set: fix compile 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
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_button.cc ('k') | ui/views/view.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/views/animation/ink_drop_host_view.h" 5 #include "ui/views/animation/ink_drop_host_view.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "ui/events/event.h" 8 #include "ui/events/event.h"
9 #include "ui/events/scoped_target_handler.h" 9 #include "ui/events/scoped_target_handler.h"
10 #include "ui/gfx/color_palette.h" 10 #include "ui/gfx/color_palette.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 ink_drop_mask_.reset(); 150 ink_drop_mask_.reset();
151 if (!old_paint_to_layer_) 151 if (!old_paint_to_layer_)
152 DestroyLayer(); 152 DestroyLayer();
153 } 153 }
154 154
155 std::unique_ptr<InkDrop> InkDropHostView::CreateInkDrop() { 155 std::unique_ptr<InkDrop> InkDropHostView::CreateInkDrop() {
156 return CreateDefaultInkDropImpl(); 156 return CreateDefaultInkDropImpl();
157 } 157 }
158 158
159 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const { 159 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const {
160 return CreateDefaultInkDropRipple(GetLocalBounds().CenterPoint()); 160 return CreateDefaultInkDropRipple(
161 GetMirroredRect(GetContentsBounds()).CenterPoint());
161 } 162 }
162 163
163 std::unique_ptr<InkDropHighlight> InkDropHostView::CreateInkDropHighlight() 164 std::unique_ptr<InkDropHighlight> InkDropHostView::CreateInkDropHighlight()
164 const { 165 const {
165 return CreateDefaultInkDropHighlight( 166 return CreateDefaultInkDropHighlight(
166 gfx::RectF(GetLocalBounds()).CenterPoint()); 167 gfx::RectF(GetMirroredRect(GetContentsBounds())).CenterPoint());
167 } 168 }
168 169
169 std::unique_ptr<InkDropRipple> InkDropHostView::CreateDefaultInkDropRipple( 170 std::unique_ptr<InkDropRipple> InkDropHostView::CreateDefaultInkDropRipple(
170 const gfx::Point& center_point, 171 const gfx::Point& center_point,
171 const gfx::Size& size) const { 172 const gfx::Size& size) const {
172 std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple( 173 std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple(
173 CalculateLargeInkDropSize(size), kInkDropLargeCornerRadius, size, 174 CalculateLargeInkDropSize(size), kInkDropLargeCornerRadius, size,
174 kInkDropSmallCornerRadius, center_point, GetInkDropBaseColor(), 175 kInkDropSmallCornerRadius, center_point, GetInkDropBaseColor(),
175 ink_drop_visible_opacity())); 176 ink_drop_visible_opacity()));
176 return ripple; 177 return ripple;
(...skipping 14 matching lines...) Expand all
191 192
192 if (ink_drop_mode_ != InkDropMode::ON) 193 if (ink_drop_mode_ != InkDropMode::ON)
193 gesture_handler_ = nullptr; 194 gesture_handler_ = nullptr;
194 else if (!gesture_handler_) 195 else if (!gesture_handler_)
195 gesture_handler_ = base::MakeUnique<InkDropGestureHandler>(this); 196 gesture_handler_ = base::MakeUnique<InkDropGestureHandler>(this);
196 } 197 }
197 198
198 gfx::Point InkDropHostView::GetInkDropCenterBasedOnLastEvent() const { 199 gfx::Point InkDropHostView::GetInkDropCenterBasedOnLastEvent() const {
199 return last_ripple_triggering_event_ 200 return last_ripple_triggering_event_
200 ? last_ripple_triggering_event_->location() 201 ? last_ripple_triggering_event_->location()
201 : GetLocalBounds().CenterPoint(); 202 : GetMirroredRect(GetContentsBounds()).CenterPoint();
202 } 203 }
203 204
204 void InkDropHostView::AnimateInkDrop(InkDropState state, 205 void InkDropHostView::AnimateInkDrop(InkDropState state,
205 const ui::LocatedEvent* event) { 206 const ui::LocatedEvent* event) {
206 #if defined(OS_WIN) 207 #if defined(OS_WIN)
207 // On Windows, don't initiate ink-drops for touch/gesture events. 208 // On Windows, don't initiate ink-drops for touch/gesture events.
208 // Additionally, certain event states should dismiss existing ink-drop 209 // Additionally, certain event states should dismiss existing ink-drop
209 // animations. If the state is already other than HIDDEN, presumably from 210 // animations. If the state is already other than HIDDEN, presumably from
210 // a mouse or keyboard event, then the state should be allowed. Conversely, 211 // a mouse or keyboard event, then the state should be allowed. Conversely,
211 // if the requested state is ACTIVATED, then it should always be allowed. 212 // if the requested state is ACTIVATED, then it should always be allowed.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 std::unique_ptr<InkDropImpl> 305 std::unique_ptr<InkDropImpl>
305 InkDropHostView::CreateDefaultFloodFillInkDropImpl() { 306 InkDropHostView::CreateDefaultFloodFillInkDropImpl() {
306 std::unique_ptr<views::InkDropImpl> ink_drop = 307 std::unique_ptr<views::InkDropImpl> ink_drop =
307 InkDropHostView::CreateDefaultInkDropImpl(); 308 InkDropHostView::CreateDefaultInkDropImpl();
308 ink_drop->SetAutoHighlightMode( 309 ink_drop->SetAutoHighlightMode(
309 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE); 310 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE);
310 return ink_drop; 311 return ink_drop;
311 } 312 }
312 313
313 } // namespace views 314 } // namespace views
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_button.cc ('k') | ui/views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698