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

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

Issue 1926943002: Introduce new flag to control usage of MD in secondary (not top-chrome) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: improve docs Created 4 years, 7 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/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 bfee2c9fcaae4b4d5db91a57c614a8103cfdde40..c23705db15aacd838aeff975c4522b2b3b77dee0 100644
--- a/ui/views/controls/button/md_text_button.cc
+++ b/ui/views/controls/button/md_text_button.cc
@@ -23,19 +23,34 @@ const int kVerticalPadding = 6;
// Minimum size to reserve for the button contents.
const int kMinWidth = 48;
+LabelButton* CreateButton(ButtonListener* listener,
+ const base::string16& text,
+ bool md) {
+ if (md)
+ return MdTextButton::CreateMdButton(listener, text);
+
+ LabelButton* button = new LabelButton(listener, text);
+ button->SetStyle(CustomButton::STYLE_BUTTON);
+ return button;
+}
+
} // namespace
// static
LabelButton* MdTextButton::CreateStandardButton(ButtonListener* listener,
const base::string16& text) {
- if (ui::MaterialDesignController::IsModeMaterial())
- return CreateMdButton(listener, text);
+ return CreateButton(listener, text,
+ ui::MaterialDesignController::IsModeMaterial());
+}
- LabelButton* button = new LabelButton(listener, text);
- button->SetStyle(STYLE_BUTTON);
- return button;
+// static
+LabelButton* MdTextButton::CreateSecondaryUiButton(ButtonListener* listener,
+ const base::string16& text) {
+ return CreateButton(listener, text,
+ ui::MaterialDesignController::IsSecondaryUiMaterial());
}
+// static
MdTextButton* MdTextButton::CreateMdButton(ButtonListener* listener,
const base::string16& text) {
MdTextButton* button = new MdTextButton(listener);
@@ -69,6 +84,15 @@ void MdTextButton::SetText(const base::string16& text) {
LabelButton::SetText(base::i18n::ToUpper(text));
}
+void MdTextButton::UpdateStyleForDefaultness() {
+ // Update the call to action state to reflect defaultness. Don't change strong
+ // call to action to weak.
+ if (!is_default())
+ SetCallToAction(NO_CALL_TO_ACTION);
+ else if (cta_ == NO_CALL_TO_ACTION)
+ SetCallToAction(WEAK_CALL_TO_ACTION);
+}
+
MdTextButton::MdTextButton(ButtonListener* listener)
: LabelButton(listener, base::string16()),
ink_drop_delegate_(this, this),

Powered by Google App Engine
This is Rietveld 408576698