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

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

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: check details Created 3 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/button/vector_icon_button.cc
diff --git a/ui/views/controls/button/vector_icon_button.cc b/ui/views/controls/button/vector_icon_button.cc
deleted file mode 100644
index 9d731b93f10e6104a5ecfde2d5580f3aa357a180..0000000000000000000000000000000000000000
--- a/ui/views/controls/button/vector_icon_button.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2015 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 "ui/views/controls/button/vector_icon_button.h"
-
-#include "ui/gfx/color_palette.h"
-#include "ui/gfx/color_utils.h"
-#include "ui/gfx/paint_vector_icon.h"
-#include "ui/views/border.h"
-#include "ui/views/controls/button/vector_icon_button_delegate.h"
-#include "ui/views/painter.h"
-
-namespace views {
-
-namespace {
-
-// Extra space around the buttons to increase their event target size.
-const int kButtonExtraTouchSize = 4;
-
-} // namespace
-
-VectorIconButton::VectorIconButton(VectorIconButtonDelegate* delegate)
- : ImageButton(delegate), delegate_(delegate), icon_(&gfx::kNoneIcon) {
- SetInkDropMode(InkDropMode::ON);
- set_has_ink_drop_action_on_click(true);
- SetImageAlignment(ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE);
- SetFocusPainter(nullptr);
-}
-
-VectorIconButton::~VectorIconButton() {}
-
-void VectorIconButton::SetIcon(const gfx::VectorIcon& icon) {
- icon_ = &icon;
- OnSetIcon();
-}
-
-void VectorIconButton::OnThemeChanged() {
- UpdateImagesAndColors();
-}
-
-void VectorIconButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
- UpdateImagesAndColors();
-}
-
-void VectorIconButton::OnSetIcon() {
- if (!border())
- SetBorder(CreateEmptyBorder(gfx::Insets(kButtonExtraTouchSize)));
-
- UpdateImagesAndColors();
-}
-
-void VectorIconButton::UpdateImagesAndColors() {
- SkColor icon_color =
- color_utils::DeriveDefaultIconColor(delegate_->GetVectorIconBaseColor());
- SkColor disabled_color = SkColorSetA(icon_color, 0xff / 2);
- SetImage(CustomButton::STATE_NORMAL,
- gfx::CreateVectorIcon(*icon_, icon_color));
- SetImage(CustomButton::STATE_DISABLED,
- gfx::CreateVectorIcon(*icon_, disabled_color));
- set_ink_drop_base_color(icon_color);
-}
-
-} // namespace views
« no previous file with comments | « ui/views/controls/button/vector_icon_button.h ('k') | ui/views/controls/button/vector_icon_button_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698