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

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

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: wip: address high-level comments 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
index 9d731b93f10e6104a5ecfde2d5580f3aa357a180..a9a5d66745ad05e1d38c50ba484ba50bd91f7748 100644
--- a/ui/views/controls/button/vector_icon_button.cc
+++ b/ui/views/controls/button/vector_icon_button.cc
@@ -7,32 +7,26 @@
#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"
+#include "ui/views/views_delegate.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);
+ SetPadding(ViewsDelegate::GetInstance()->GetButtonMargins());
}
VectorIconButton::~VectorIconButton() {}
void VectorIconButton::SetIcon(const gfx::VectorIcon& icon) {
icon_ = &icon;
- OnSetIcon();
+ UpdateImagesAndColors();
}
void VectorIconButton::OnThemeChanged() {
@@ -43,14 +37,10 @@ void VectorIconButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
UpdateImagesAndColors();
}
-void VectorIconButton::OnSetIcon() {
- if (!border())
- SetBorder(CreateEmptyBorder(gfx::Insets(kButtonExtraTouchSize)));
-
- UpdateImagesAndColors();
-}
-
void VectorIconButton::UpdateImagesAndColors() {
+ if (!icon_)
+ return;
+
SkColor icon_color =
color_utils::DeriveDefaultIconColor(delegate_->GetVectorIconBaseColor());
SkColor disabled_color = SkColorSetA(icon_color, 0xff / 2);

Powered by Google App Engine
This is Rietveld 408576698