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

Unified Diff: ash/common/system/tray/tray_popup_utils.cc

Issue 2675893002: Remove some pre-md code from TrayPopupUtils and UserView. (Closed)
Patch Set: Created 3 years, 10 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: ash/common/system/tray/tray_popup_utils.cc
diff --git a/ash/common/system/tray/tray_popup_utils.cc b/ash/common/system/tray/tray_popup_utils.cc
index 3c2a607f9a3792ad6150212f674692f7697a4910..b6ac1bf53ae4c2251741fe1fb766b6992a3fd816 100644
--- a/ash/common/system/tray/tray_popup_utils.cc
+++ b/ash/common/system/tray/tray_popup_utils.cc
@@ -112,37 +112,24 @@ class BorderlessLabelButton : public views::LabelButton {
BorderlessLabelButton(views::ButtonListener* listener,
const base::string16& text)
: LabelButton(listener, text) {
- if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
- SetInkDropMode(views::InkDropHostView::InkDropMode::ON);
- set_has_ink_drop_action_on_click(true);
- set_ink_drop_base_color(kTrayPopupInkDropBaseColor);
- set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity);
- const int kHorizontalPadding = 20;
- SetBorder(views::CreateEmptyBorder(gfx::Insets(0, kHorizontalPadding)));
- TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::BUTTON);
- style.SetupLabel(label());
- SetFocusPainter(TrayPopupUtils::CreateFocusPainter());
- } else {
- SetBorder(std::unique_ptr<views::Border>(new TrayPopupLabelButtonBorder));
- SetFocusPainter(views::Painter::CreateSolidFocusPainter(
- kFocusBorderColor, gfx::Insets(1, 1, 2, 2)));
- set_animate_on_state_change(false);
- }
+ const int kHorizontalPadding = 20;
+ SetBorder(views::CreateEmptyBorder(gfx::Insets(0, kHorizontalPadding)));
+ TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::BUTTON);
+ style.SetupLabel(label());
SetHorizontalAlignment(gfx::ALIGN_CENTER);
- SetFocusForPlatform();
+ SetFocusPainter(TrayPopupUtils::CreateFocusPainter());
+
+ TrayPopupUtils::ConfigureTrayPopupButton(this);
}
~BorderlessLabelButton() override {}
// views::LabelButton:
- int GetHeightForWidth(int width) const override {
- if (MaterialDesignController::IsSystemTrayMenuMaterial())
- return kMenuButtonSize;
-
- return LabelButton::GetHeightForWidth(width);
- }
+ int GetHeightForWidth(int width) const override { return kMenuButtonSize; }
private:
+ // TODO(estade,bruthig): there's a lot in common here with ActionableView.
+ // Find a way to share. See related TODO on InkDropHostView::SetInkDropMode().
std::unique_ptr<views::InkDrop> CreateInkDrop() override {
return TrayPopupUtils::CreateInkDrop(TrayPopupInkDropStyle::INSET_BOUNDS,
this);
@@ -280,6 +267,19 @@ std::unique_ptr<views::Painter> TrayPopupUtils::CreateFocusPainter() {
kFocusBorderColor, kFocusBorderThickness, gfx::InsetsF());
}
+void TrayPopupUtils::ConfigureTrayPopupButton(views::CustomButton* button) {
+ // All buttons that call into here want this focus painter, but
+ // SetFocusPainter is defined separately on derived classes and isn't part of
+ // CustomButton. TODO(estade): Address this.
+ // button->SetFocusPainter(TrayPopupUtils::CreateFocusPainter());
+ button->SetFocusForPlatform();
+
+ button->SetInkDropMode(views::InkDropHostView::InkDropMode::ON);
+ button->set_has_ink_drop_action_on_click(true);
+ button->set_ink_drop_base_color(kTrayPopupInkDropBaseColor);
+ button->set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity);
+}
+
void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) {
view->set_id(VIEW_ID_STICKY_HEADER);
view->set_background(
@@ -320,9 +320,6 @@ views::LabelButton* TrayPopupUtils::CreateTrayPopupBorderlessButton(
views::LabelButton* TrayPopupUtils::CreateTrayPopupButton(
views::ButtonListener* listener,
const base::string16& text) {
- if (!MaterialDesignController::IsSystemTrayMenuMaterial())
- return CreateTrayPopupBorderlessButton(listener, text);
-
auto* button = views::MdTextButton::Create(listener, text);
button->SetProminent(true);
return button;

Powered by Google App Engine
This is Rietveld 408576698