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

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

Issue 2218323002: Better CrOS logout button for vertical trays. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reviews Created 4 years, 4 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 | « ui/views/controls/button/md_text_button.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/md_text_button.cc
diff --git a/ui/views/controls/button/md_text_button.cc b/ui/views/controls/button/md_text_button.cc
index 77eb8e436e73a403cfa8f865ac008ae030c1d97e..38748f783fbead54dfe8443be0486e459ada2098 100644
--- a/ui/views/controls/button/md_text_button.cc
+++ b/ui/views/controls/button/md_text_button.cc
@@ -9,6 +9,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h"
+#include "ui/views/animation/flood_fill_ink_drop_ripple.h"
#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/animation/ink_drop_painted_layer_delegates.h"
#include "ui/views/background.h"
@@ -172,6 +173,14 @@ SkColor MdTextButton::GetInkDropBaseColor() const {
return color_utils::DeriveDefaultIconColor(label()->enabled_color());
}
+std::unique_ptr<views::InkDropRipple> MdTextButton::CreateInkDropRipple()
+ const {
+ return std::unique_ptr<views::InkDropRipple>(
+ new views::FloodFillInkDropRipple(
+ GetLocalBounds(), GetInkDropCenterBasedOnLastEvent(),
+ GetInkDropBaseColor(), ink_drop_visible_opacity()));
+}
+
std::unique_ptr<views::InkDropHighlight> MdTextButton::CreateInkDropHighlight()
const {
if (!ShouldShowInkDropHighlight())
@@ -206,6 +215,11 @@ void MdTextButton::SetEnabledTextColors(SkColor color) {
UpdateColors();
}
+void MdTextButton::SetText(const base::string16& text) {
+ LabelButton::SetText(text);
+ UpdatePaddingForFont();
+}
+
void MdTextButton::AdjustFontSize(int size_delta) {
LabelButton::AdjustFontSize(size_delta);
UpdatePaddingForFont();
@@ -235,12 +249,17 @@ MdTextButton::MdTextButton(ButtonListener* listener)
focus_ring_->SetVisible(false);
set_request_focus_on_press(false);
LabelButton::SetFontList(GetMdFontList());
- UpdatePaddingForFont();
}
MdTextButton::~MdTextButton() {}
void MdTextButton::UpdatePaddingForFont() {
+ // Don't use font-based padding when there's no text visible.
+ if (GetText().empty()) {
+ SetBorder(Border::NullBorder());
+ return;
+ }
+
// Top and bottom padding depend on the font. Example: if font cap height is
// 9dp, use 8dp bottom padding and 7dp top padding to total 24dp.
const gfx::FontList& font = label()->font_list();
« no previous file with comments | « ui/views/controls/button/md_text_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698