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

Unified Diff: ui/views/controls/button/vector_icon_button.cc

Issue 2305933002: Update dialog close buttons to use vector icons and ripples. (Closed)
Patch Set: 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
Index: ui/views/controls/button/vector_icon_button.cc
diff --git a/chrome/browser/ui/views/bar_control_button.cc b/ui/views/controls/button/vector_icon_button.cc
similarity index 76%
rename from chrome/browser/ui/views/bar_control_button.cc
rename to ui/views/controls/button/vector_icon_button.cc
index 74eba4ea5bae55f0c63a65382717e3cb20cd16bd..3190e4a68cd86fd9a3c163b8d51d50f681dcb46c 100644
--- a/chrome/browser/ui/views/bar_control_button.cc
+++ b/ui/views/controls/button/vector_icon_button.cc
@@ -2,15 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/views/bar_control_button.h"
+#include "ui/views/controls/button/vector_icon_button.h"
#include "ui/base/material_design/material_design_controller.h"
+#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/views/border.h"
#include "ui/views/painter.h"
+namespace views {
+
namespace {
// Extra space around the buttons to increase their event target size.
@@ -18,7 +21,7 @@ const int kButtonExtraTouchSize = 4;
} // namespace
-BarControlButton::BarControlButton(views::ButtonListener* listener)
+VectorIconButton::VectorIconButton(views::ButtonListener* listener)
: views::ImageButton(listener), id_(gfx::VectorIconId::VECTOR_ICON_NONE) {
if (ui::MaterialDesignController::IsModeMaterial())
SetInkDropMode(InkDropMode::ON);
@@ -28,9 +31,9 @@ BarControlButton::BarControlButton(views::ButtonListener* listener)
SetFocusPainter(nullptr);
}
-BarControlButton::~BarControlButton() {}
+VectorIconButton::~VectorIconButton() {}
-void BarControlButton::SetIcon(
+void VectorIconButton::SetIcon(
gfx::VectorIconId id,
const base::Callback<SkColor(void)>& get_text_color_callback) {
id_ = id;
@@ -43,8 +46,13 @@ void BarControlButton::SetIcon(
}
}
-void BarControlButton::OnThemeChanged() {
+void VectorIconButton::OnEnabledChanged() {
+ OnThemeChanged();
+}
+
+void VectorIconButton::OnThemeChanged() {
SkColor icon_color =
+ get_text_color_callback_.is_null() ? gfx::kChromeIconGrey :
color_utils::DeriveDefaultIconColor(get_text_color_callback_.Run());
gfx::ImageSkia image = gfx::CreateVectorIcon(id_, icon_color);
SetImage(views::CustomButton::STATE_NORMAL, &image);
@@ -53,6 +61,8 @@ void BarControlButton::OnThemeChanged() {
set_ink_drop_base_color(icon_color);
}
-void BarControlButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
+void VectorIconButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
OnThemeChanged();
}
+
+} // namespace views

Powered by Google App Engine
This is Rietveld 408576698