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

Unified Diff: ash/common/system/tray/system_menu_button.cc

Issue 2456783005: [ash-md] Changed the style of ink drop applied to system menu icon buttons. (Closed)
Patch Set: Addressed review comments. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/tray/system_menu_button.h ('k') | ash/common/system/tray/tray_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/tray/system_menu_button.cc
diff --git a/ash/common/system/tray/system_menu_button.cc b/ash/common/system/tray/system_menu_button.cc
index 091441920a39416251d0b0b576246d3372959d50..5931b24ecf99bf9a96afd8bb4b431b79d91e120a 100644
--- a/ash/common/system/tray/system_menu_button.cc
+++ b/ash/common/system/tray/system_menu_button.cc
@@ -11,15 +11,17 @@
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/animation/flood_fill_ink_drop_ripple.h"
#include "ui/views/animation/ink_drop_highlight.h"
+#include "ui/views/animation/square_ink_drop_ripple.h"
#include "ui/views/border.h"
#include "ui/views/painter.h"
namespace ash {
SystemMenuButton::SystemMenuButton(views::ButtonListener* listener,
+ InkDropStyle ink_drop_style,
const gfx::VectorIcon& icon,
int accessible_name_id)
- : views::ImageButton(listener) {
+ : views::ImageButton(listener), ink_drop_style_(ink_drop_style) {
gfx::ImageSkia image = gfx::CreateVectorIcon(icon, kMenuIconColor);
SetImage(views::Button::STATE_NORMAL, &image);
gfx::ImageSkia disabled_image =
@@ -40,27 +42,68 @@ SystemMenuButton::SystemMenuButton(views::ButtonListener* listener,
SetFocusPainter(views::Painter::CreateSolidFocusPainter(
kFocusBorderColor, gfx::Insets(1, 1, 1, 1)));
- SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER);
+ SetInkDropMode(InkDropMode::ON);
set_has_ink_drop_action_on_click(true);
- set_ink_drop_base_color(SK_ColorBLACK);
+ set_ink_drop_base_color(kTrayPopupInkDropBaseColor);
+ set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity);
}
SystemMenuButton::~SystemMenuButton() {}
std::unique_ptr<views::InkDropRipple> SystemMenuButton::CreateInkDropRipple()
const {
- return base::MakeUnique<views::FloodFillInkDropRipple>(
- GetLocalBounds(), GetInkDropCenterBasedOnLastEvent(),
- GetInkDropBaseColor(), ink_drop_visible_opacity());
+ const gfx::Size size = GetInkDropSize();
+ switch (ink_drop_style_) {
+ case InkDropStyle::SQUARE:
+ return base::MakeUnique<views::SquareInkDropRipple>(
+ size, size.width() / 2, size, size.width() / 2,
+ GetInkDropCenterBasedOnLastEvent(), GetLocalBounds().CenterPoint(),
+ GetInkDropBaseColor(), ink_drop_visible_opacity());
+ case InkDropStyle::FLOOD_FILL:
+ gfx::Rect bounds = GetLocalBounds();
+ bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset);
+ return base::MakeUnique<views::FloodFillInkDropRipple>(
+ bounds, GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(),
+ ink_drop_visible_opacity());
+ }
+ // Required for some compilers.
+ NOTREACHED();
+ return nullptr;
}
std::unique_ptr<views::InkDropHighlight>
SystemMenuButton::CreateInkDropHighlight() const {
- return nullptr;
+ // TODO(bruthig): Show the highlight when the ink drop is active. (See
+ // crbug.com/649734)
+ if (!ShouldShowInkDropHighlight())
+ return nullptr;
+
+ int highlight_radius = 0;
+ switch (ink_drop_style_) {
+ case InkDropStyle::SQUARE:
+ highlight_radius = GetInkDropSize().width() / 2;
+ break;
+ case InkDropStyle::FLOOD_FILL:
+ highlight_radius = 0;
+ break;
+ }
+
+ std::unique_ptr<views::InkDropHighlight> highlight(
+ new views::InkDropHighlight(GetInkDropSize(), highlight_radius,
+ gfx::RectF(GetLocalBounds()).CenterPoint(),
+ GetInkDropBaseColor()));
+ highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity);
+ return highlight;
}
-bool SystemMenuButton::ShouldShowInkDropForFocus() const {
+bool SystemMenuButton::ShouldShowInkDropHighlight() const {
return false;
}
+gfx::Size SystemMenuButton::GetInkDropSize() const {
+ gfx::Rect bounds = GetLocalBounds();
+ bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset);
+ return bounds.size();
+}
+
} // namespace ash
« no previous file with comments | « ash/common/system/tray/system_menu_button.h ('k') | ash/common/system/tray/tray_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698