Commit 44bfbfa7 authored by ellyjones's avatar ellyjones Committed by Commit bot

Harmony: disable ripples on Mac

The Mac IxD doesn't use them. Instead, buttons have a separate pressed state which is defined in the Harmony spec.

BUG=640032

Review-Url: https://codereview.chromium.org/2270933002
Cr-Commit-Position: refs/heads/master@{#414825}
parent 9ea42589
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "ui/views/controls/button/label_button_border.h" #include "ui/views/controls/button/label_button_border.h"
#include "ui/views/painter.h" #include "ui/views/painter.h"
#include "ui/views/resources/grit/views_resources.h" #include "ui/views/resources/grit/views_resources.h"
#include "ui/views/style/platform_style.h"
namespace views { namespace views {
...@@ -35,7 +36,8 @@ Checkbox::Checkbox(const base::string16& label) ...@@ -35,7 +36,8 @@ Checkbox::Checkbox(const base::string16& label)
if (UseMd()) { if (UseMd()) {
set_request_focus_on_press(false); set_request_focus_on_press(false);
SetInkDropMode(InkDropMode::ON); SetInkDropMode(PlatformStyle::kUseRipples ? InkDropMode::ON
: InkDropMode::OFF);
set_has_ink_drop_action_on_click(true); set_has_ink_drop_action_on_click(true);
// The "small" size is 21dp, the large size is 1.33 * 21dp = 28dp. // The "small" size is 21dp, the large size is 1.33 * 21dp = 28dp.
set_ink_drop_size(gfx::Size(21, 21)); set_ink_drop_size(gfx::Size(21, 21));
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/button/blue_button.h" #include "ui/views/controls/button/blue_button.h"
#include "ui/views/painter.h" #include "ui/views/painter.h"
#include "ui/views/style/platform_style.h"
namespace views { namespace views {
...@@ -178,6 +179,11 @@ std::unique_ptr<views::InkDropRipple> MdTextButton::CreateInkDropRipple() ...@@ -178,6 +179,11 @@ std::unique_ptr<views::InkDropRipple> MdTextButton::CreateInkDropRipple()
GetInkDropBaseColor(), ink_drop_visible_opacity())); GetInkDropBaseColor(), ink_drop_visible_opacity()));
} }
void MdTextButton::StateChanged() {
LabelButton::StateChanged();
UpdateColors();
}
std::unique_ptr<views::InkDropHighlight> MdTextButton::CreateInkDropHighlight() std::unique_ptr<views::InkDropHighlight> MdTextButton::CreateInkDropHighlight()
const { const {
if (!ShouldShowInkDropHighlight()) if (!ShouldShowInkDropHighlight())
...@@ -235,7 +241,8 @@ MdTextButton::MdTextButton(ButtonListener* listener) ...@@ -235,7 +241,8 @@ MdTextButton::MdTextButton(ButtonListener* listener)
: LabelButton(listener, base::string16()), : LabelButton(listener, base::string16()),
focus_ring_(new internal::MdFocusRing()), focus_ring_(new internal::MdFocusRing()),
is_cta_(false) { is_cta_(false) {
SetInkDropMode(InkDropMode::ON); SetInkDropMode(PlatformStyle::kUseRipples ? InkDropMode::ON
: InkDropMode::OFF);
set_has_ink_drop_action_on_click(true); set_has_ink_drop_action_on_click(true);
SetHorizontalAlignment(gfx::ALIGN_CENTER); SetHorizontalAlignment(gfx::ALIGN_CENTER);
SetFocusForPlatform(); SetFocusForPlatform();
...@@ -306,6 +313,8 @@ void MdTextButton::UpdateColors() { ...@@ -306,6 +313,8 @@ void MdTextButton::UpdateColors() {
? color_utils::BlendTowardOppositeLuma(text_color, 0xD8) ? color_utils::BlendTowardOppositeLuma(text_color, 0xD8)
: SK_ColorTRANSPARENT; : SK_ColorTRANSPARENT;
bg_color = PlatformStyle::BackgroundColorForMdButton(bg_color, state());
const SkAlpha kStrokeOpacity = 0x1A; const SkAlpha kStrokeOpacity = 0x1A;
SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color)) SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color))
? SkColorSetA(SK_ColorBLACK, kStrokeOpacity) ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity)
......
...@@ -56,6 +56,7 @@ class VIEWS_EXPORT MdTextButton : public LabelButton { ...@@ -56,6 +56,7 @@ class VIEWS_EXPORT MdTextButton : public LabelButton {
void SetText(const base::string16& text) override; void SetText(const base::string16& text) override;
void AdjustFontSize(int size_delta) override; void AdjustFontSize(int size_delta) override;
void UpdateStyleToIndicateDefaultStatus() override; void UpdateStyleToIndicateDefaultStatus() override;
void StateChanged() override;
protected: protected:
// LabelButton: // LabelButton:
......
...@@ -43,6 +43,7 @@ const bool PlatformStyle::kTextfieldDragVerticallyDragsToEnd = false; ...@@ -43,6 +43,7 @@ const bool PlatformStyle::kTextfieldDragVerticallyDragsToEnd = false;
const CustomButton::NotifyAction PlatformStyle::kMenuNotifyActivationAction = const CustomButton::NotifyAction PlatformStyle::kMenuNotifyActivationAction =
CustomButton::NOTIFY_ON_RELEASE; CustomButton::NOTIFY_ON_RELEASE;
const bool PlatformStyle::kTreeViewSelectionPaintsEntireRow = false; const bool PlatformStyle::kTreeViewSelectionPaintsEntireRow = false;
const bool PlatformStyle::kUseRipples = true;
// static // static
gfx::ImageSkia PlatformStyle::CreateComboboxArrow(bool is_enabled, gfx::ImageSkia PlatformStyle::CreateComboboxArrow(bool is_enabled,
...@@ -88,6 +89,12 @@ SkColor PlatformStyle::TextColorForButton( ...@@ -88,6 +89,12 @@ SkColor PlatformStyle::TextColorForButton(
return color_by_state[button.state()]; return color_by_state[button.state()];
} }
SkColor PlatformStyle::BackgroundColorForMdButton(
SkColor color,
Button::ButtonState state) {
return color;
}
#endif // OS_MACOSX #endif // OS_MACOSX
#if !defined(DESKTOP_LINUX) && !defined(OS_MACOSX) #if !defined(DESKTOP_LINUX) && !defined(OS_MACOSX)
......
...@@ -53,6 +53,9 @@ class VIEWS_EXPORT PlatformStyle { ...@@ -53,6 +53,9 @@ class VIEWS_EXPORT PlatformStyle {
// label for that row. // label for that row.
static const bool kTreeViewSelectionPaintsEntireRow; static const bool kTreeViewSelectionPaintsEntireRow;
// Whether ripples should be used for visual feedback on control activation.
static const bool kUseRipples;
// Creates an ImageSkia containing the image to use for the combobox arrow. // Creates an ImageSkia containing the image to use for the combobox arrow.
// The |is_enabled| argument is true if the control the arrow is for is // The |is_enabled| argument is true if the control the arrow is for is
// enabled, and false if the control is disabled. The |style| argument is the // enabled, and false if the control is disabled. The |style| argument is the
...@@ -85,6 +88,11 @@ class VIEWS_EXPORT PlatformStyle { ...@@ -85,6 +88,11 @@ class VIEWS_EXPORT PlatformStyle {
static void ApplyLabelButtonTextStyle(Label* label, static void ApplyLabelButtonTextStyle(Label* label,
ButtonColorByState* color_by_state); ButtonColorByState* color_by_state);
// Returns the background color that should be used for an MdTextButton or
// other MD controls when in the given state.
static SkColor BackgroundColorForMdButton(SkColor color,
Button::ButtonState state);
// Applies the current system theme to the default border created by |button|. // Applies the current system theme to the default border created by |button|.
static std::unique_ptr<Border> CreateThemedLabelButtonBorder( static std::unique_ptr<Border> CreateThemedLabelButtonBorder(
LabelButton* button); LabelButton* button);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icons.h" #include "ui/gfx/vector_icons.h"
#include "ui/resources/grit/ui_resources.h" #include "ui/resources/grit/ui_resources.h"
...@@ -25,6 +26,7 @@ const bool PlatformStyle::kDefaultLabelButtonHasBoldFont = false; ...@@ -25,6 +26,7 @@ const bool PlatformStyle::kDefaultLabelButtonHasBoldFont = false;
const bool PlatformStyle::kDialogDefaultButtonCanBeCancel = false; const bool PlatformStyle::kDialogDefaultButtonCanBeCancel = false;
const bool PlatformStyle::kTextfieldDragVerticallyDragsToEnd = true; const bool PlatformStyle::kTextfieldDragVerticallyDragsToEnd = true;
const bool PlatformStyle::kTreeViewSelectionPaintsEntireRow = true; const bool PlatformStyle::kTreeViewSelectionPaintsEntireRow = true;
const bool PlatformStyle::kUseRipples = false;
const CustomButton::NotifyAction PlatformStyle::kMenuNotifyActivationAction = const CustomButton::NotifyAction PlatformStyle::kMenuNotifyActivationAction =
CustomButton::NOTIFY_ON_PRESS; CustomButton::NOTIFY_ON_PRESS;
...@@ -94,4 +96,14 @@ void PlatformStyle::ApplyLabelButtonTextStyle( ...@@ -94,4 +96,14 @@ void PlatformStyle::ApplyLabelButtonTextStyle(
theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHighlightColor); theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHighlightColor);
} }
// static
SkColor PlatformStyle::BackgroundColorForMdButton(
SkColor color,
Button::ButtonState state) {
// Per Harmony specs: Pressed state on Mac is + #000 at 0.05 alpha.
if (state == Button::STATE_PRESSED)
return color_utils::AlphaBlend(SK_ColorBLACK, color, 0x08);
return color;
}
} // namespace views } // namespace views
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment