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

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

Issue 2367903002: Introduce SystemMenuButton for Ash material design (Closed)
Patch Set: comments Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/tray/system_menu_button.h ('k') | no next file » | 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
new file mode 100644
index 0000000000000000000000000000000000000000..5586d965de6d87b3fb6065fa48d6bf2cecc7cc44
--- /dev/null
+++ b/ash/common/system/tray/system_menu_button.cc
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/common/system/tray/system_menu_button.h"
+
+#include "ash/common/ash_constants.h"
+#include "ash/common/system/tray/system_tray.h"
+#include "ash/common/system/tray/tray_constants.h"
+#include "ui/base/resource/resource_bundle.h"
+#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/border.h"
+#include "ui/views/painter.h"
+
+namespace ash {
+
+SystemMenuButton::SystemMenuButton(views::ButtonListener* listener,
+ const gfx::VectorIcon& icon,
+ int accessible_name_id)
+ : views::ImageButton(listener) {
+ gfx::ImageSkia image = gfx::CreateVectorIcon(icon, kMenuIconColor);
+ SetImage(views::Button::STATE_NORMAL, &image);
+ const int horizontal_padding = (kMenuButtonSize - image.width()) / 2;
+ const int vertical_padding = (kMenuButtonSize - image.height()) / 2;
+ SetBorder(
+ views::Border::CreateEmptyBorder(vertical_padding, horizontal_padding,
+ vertical_padding, horizontal_padding));
+
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ SetTooltipText(bundle.GetLocalizedString(accessible_name_id));
+
+ // TODO(tdanderson): Update the focus rect color, border thickness, and
+ // location for material design.
+ SetFocusForPlatform();
+ SetFocusPainter(views::Painter::CreateSolidFocusPainter(
+ kFocusBorderColor, gfx::Insets(1, 1, 1, 1)));
+
+ SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER);
+ set_has_ink_drop_action_on_click(true);
+ set_ink_drop_base_color(kMenuIconColor);
+}
+
+SystemMenuButton::~SystemMenuButton() {}
+
+std::unique_ptr<views::InkDropRipple> SystemMenuButton::CreateInkDropRipple()
+ const {
+ return base::MakeUnique<views::FloodFillInkDropRipple>(
+ GetLocalBounds(), GetInkDropCenterBasedOnLastEvent(),
+ GetInkDropBaseColor(), ink_drop_visible_opacity());
+}
+
+std::unique_ptr<views::InkDropHighlight>
+SystemMenuButton::CreateInkDropHighlight() const {
+ gfx::Size size = GetLocalBounds().size();
+ return base::MakeUnique<views::InkDropHighlight>(
+ size, kInkDropSmallCornerRadius,
+ gfx::RectF(gfx::SizeF(size)).CenterPoint(), kMenuIconColor);
+}
+
+bool SystemMenuButton::ShouldShowInkDropForFocus() const {
+ return false;
+}
+
+} // namespace ash
« no previous file with comments | « ash/common/system/tray/system_menu_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698