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

Side by Side Diff: ui/views/controls/button/label_button.cc

Issue 1761443003: [MD] simplify and unify some ink drop center calculations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 #include "ui/views/controls/button/label_button.h" 5 #include "ui/views/controls/button/label_button.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 413 }
414 414
415 void LabelButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { 415 void LabelButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
416 image()->SetPaintToLayer(false); 416 image()->SetPaintToLayer(false);
417 ink_drop_container_->layer()->Remove(ink_drop_layer); 417 ink_drop_container_->layer()->Remove(ink_drop_layer);
418 ink_drop_container_->SetVisible(false); 418 ink_drop_container_->SetVisible(false);
419 } 419 }
420 420
421 scoped_ptr<views::InkDropAnimation> LabelButton::CreateInkDropAnimation() 421 scoped_ptr<views::InkDropAnimation> LabelButton::CreateInkDropAnimation()
422 const { 422 const {
423 // TODO(bruthig): Make the flood fill ink drops centered on the LocatedEvent
424 // that triggered them.
425 return GetText().empty() 423 return GetText().empty()
426 ? CustomButton::CreateInkDropAnimation() 424 ? CustomButton::CreateInkDropAnimation()
427 : make_scoped_ptr(new views::FloodFillInkDropAnimation( 425 : make_scoped_ptr(new views::FloodFillInkDropAnimation(
428 size(), GetInkDropCenter(), GetInkDropBaseColor())); 426 size(), GetInkDropCenter(), GetInkDropBaseColor()));
429 } 427 }
430 428
431 scoped_ptr<views::InkDropHover> LabelButton::CreateInkDropHover() const { 429 scoped_ptr<views::InkDropHover> LabelButton::CreateInkDropHover() const {
432 if (!ShouldShowInkDropHover()) 430 if (!ShouldShowInkDropHover())
433 return nullptr; 431 return nullptr;
434 return GetText().empty() 432 return GetText().empty()
435 ? CustomButton::CreateInkDropHover() 433 ? CustomButton::CreateInkDropHover()
436 : make_scoped_ptr(new views::InkDropHover( 434 : make_scoped_ptr(new views::InkDropHover(
437 size(), 0, GetInkDropCenter(), GetInkDropBaseColor())); 435 size(), 0, GetInkDropCenter(), GetInkDropBaseColor()));
438 } 436 }
439 437
438 gfx::Point LabelButton::GetInkDropCenter() const {
439 // TODO(bruthig): Make the flood fill ink drops centered on the LocatedEvent
440 // that triggered them.
441 return GetText().empty() ? image()->bounds().CenterPoint()
varkha 2016/03/03 05:51:47 I think you need to do something like this: gfx:
442 : CustomButton::GetInkDropCenter();
443 }
444
440 void LabelButton::StateChanged() { 445 void LabelButton::StateChanged() {
441 const gfx::Size previous_image_size(image_->GetPreferredSize()); 446 const gfx::Size previous_image_size(image_->GetPreferredSize());
442 UpdateImage(); 447 UpdateImage();
443 const SkColor color = button_state_colors_[state()]; 448 const SkColor color = button_state_colors_[state()];
444 if (state() != STATE_DISABLED && label_->enabled_color() != color) 449 if (state() != STATE_DISABLED && label_->enabled_color() != color)
445 label_->SetEnabledColor(color); 450 label_->SetEnabledColor(color);
446 label_->SetEnabled(state() != STATE_DISABLED); 451 label_->SetEnabled(state() != STATE_DISABLED);
447 if (image_->GetPreferredSize() != previous_image_size) 452 if (image_->GetPreferredSize() != previous_image_size)
448 Layout(); 453 Layout();
449 } 454 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 GetExtraParams(params); 567 GetExtraParams(params);
563 return ui::NativeTheme::kHovered; 568 return ui::NativeTheme::kHovered;
564 } 569 }
565 570
566 void LabelButton::ResetCachedPreferredSize() { 571 void LabelButton::ResetCachedPreferredSize() {
567 cached_preferred_size_valid_ = false; 572 cached_preferred_size_valid_ = false;
568 cached_preferred_size_ = gfx::Size(); 573 cached_preferred_size_ = gfx::Size();
569 } 574 }
570 575
571 } // namespace views 576 } // namespace views
OLDNEW
« chrome/browser/ui/views/toolbar/app_menu_button.cc ('K') | « ui/views/controls/button/label_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698