Commit 1056ad8f authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Change ButtonPressed overrides to callbacks: ash/system/

Bug: 772945
Change-Id: I6623910c2a85b4b662e9bef1951f3c9f811eb0ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2515100
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824033}
parent 5b15bf9f
...@@ -41,20 +41,6 @@ views::View* MicGainSliderController::CreateView() { ...@@ -41,20 +41,6 @@ views::View* MicGainSliderController::CreateView() {
return nullptr; return nullptr;
} }
void MicGainSliderController::ButtonPressed(views::Button* sender,
const ui::Event& event) {
bool is_muted = !CrasAudioHandler::Get()->IsInputMuted();
if (is_muted) {
base::RecordAction(base::UserMetricsAction("StatusArea_Mic_Muted"));
} else {
base::RecordAction(base::UserMetricsAction("StatusArea_Mic_Unmuted"));
}
CrasAudioHandler::Get()->SetMuteForDevice(
CrasAudioHandler::Get()->GetPrimaryActiveInputNode(), is_muted);
}
void MicGainSliderController::SliderValueChanged( void MicGainSliderController::SliderValueChanged(
views::Slider* sender, views::Slider* sender,
float value, float value,
...@@ -74,4 +60,15 @@ void MicGainSliderController::SliderValueChanged( ...@@ -74,4 +60,15 @@ void MicGainSliderController::SliderValueChanged(
CrasAudioHandler::Get()->SetInputGainPercent(value * 100); CrasAudioHandler::Get()->SetInputGainPercent(value * 100);
} }
void MicGainSliderController::SliderButtonPressed() {
auto* const audio_handler = CrasAudioHandler::Get();
const bool mute = !audio_handler->IsInputMuted();
if (mute)
base::RecordAction(base::UserMetricsAction("StatusArea_Mic_Muted"));
else
base::RecordAction(base::UserMetricsAction("StatusArea_Mic_Unmuted"));
audio_handler->SetMuteForDevice(audio_handler->GetPrimaryActiveInputNode(),
mute);
}
} // namespace ash } // namespace ash
...@@ -31,11 +31,12 @@ class ASH_EXPORT MicGainSliderController : public UnifiedSliderListener { ...@@ -31,11 +31,12 @@ class ASH_EXPORT MicGainSliderController : public UnifiedSliderListener {
// UnifiedSliderListener: // UnifiedSliderListener:
views::View* CreateView() override; views::View* CreateView() override;
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
void SliderValueChanged(views::Slider* sender, void SliderValueChanged(views::Slider* sender,
float value, float value,
float old_value, float old_value,
views::SliderChangeReason reason) override; views::SliderChangeReason reason) override;
void SliderButtonPressed();
}; };
} // namespace ash } // namespace ash
......
...@@ -20,9 +20,12 @@ namespace ash { ...@@ -20,9 +20,12 @@ namespace ash {
MicGainSliderView::MicGainSliderView(MicGainSliderController* controller, MicGainSliderView::MicGainSliderView(MicGainSliderController* controller,
uint64_t device_id, uint64_t device_id,
bool internal) bool internal)
: UnifiedSliderView(controller, : UnifiedSliderView(
kImeMenuMicrophoneIcon, base::BindRepeating(&MicGainSliderController::SliderButtonPressed,
IDS_ASH_STATUS_TRAY_VOLUME_SLIDER_LABEL), base::Unretained(controller)),
controller,
kImeMenuMicrophoneIcon,
IDS_ASH_STATUS_TRAY_VOLUME_SLIDER_LABEL),
device_id_(device_id), device_id_(device_id),
internal_(internal) { internal_(internal) {
CrasAudioHandler::Get()->AddAudioObserver(this); CrasAudioHandler::Get()->AddAudioObserver(this);
......
...@@ -25,24 +25,7 @@ UnifiedVolumeSliderController::UnifiedVolumeSliderController( ...@@ -25,24 +25,7 @@ UnifiedVolumeSliderController::UnifiedVolumeSliderController(
UnifiedVolumeSliderController::~UnifiedVolumeSliderController() = default; UnifiedVolumeSliderController::~UnifiedVolumeSliderController() = default;
views::View* UnifiedVolumeSliderController::CreateView() { views::View* UnifiedVolumeSliderController::CreateView() {
DCHECK(!slider_); return new UnifiedVolumeView(this, delegate_);
slider_ = new UnifiedVolumeView(this);
return slider_;
}
void UnifiedVolumeSliderController::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender == slider_->button()) {
bool mute_on = !CrasAudioHandler::Get()->IsOutputMuted();
if (mute_on) {
base::RecordAction(base::UserMetricsAction("StatusArea_Audio_Muted"));
} else {
base::RecordAction(base::UserMetricsAction("StatusArea_Audio_Unmuted"));
}
CrasAudioHandler::Get()->SetOutputMute(mute_on);
} else if (sender == slider_->more_button()) {
delegate_->OnAudioSettingsButtonClicked();
}
} }
void UnifiedVolumeSliderController::SliderValueChanged( void UnifiedVolumeSliderController::SliderValueChanged(
...@@ -69,4 +52,14 @@ void UnifiedVolumeSliderController::SliderValueChanged( ...@@ -69,4 +52,14 @@ void UnifiedVolumeSliderController::SliderValueChanged(
} }
} }
void UnifiedVolumeSliderController::SliderButtonPressed() {
auto* const audio_handler = CrasAudioHandler::Get();
const bool mute = !audio_handler->IsOutputMuted();
if (mute)
base::RecordAction(base::UserMetricsAction("StatusArea_Audio_Muted"));
else
base::RecordAction(base::UserMetricsAction("StatusArea_Audio_Unmuted"));
audio_handler->SetOutputMute(mute);
}
} // namespace ash } // namespace ash
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
namespace ash { namespace ash {
class UnifiedVolumeView;
// Controller of a slider that can change audio volume. // Controller of a slider that can change audio volume.
class UnifiedVolumeSliderController : public UnifiedSliderListener { class UnifiedVolumeSliderController : public UnifiedSliderListener {
public: public:
...@@ -25,15 +23,15 @@ class UnifiedVolumeSliderController : public UnifiedSliderListener { ...@@ -25,15 +23,15 @@ class UnifiedVolumeSliderController : public UnifiedSliderListener {
// UnifiedSliderListener: // UnifiedSliderListener:
views::View* CreateView() override; views::View* CreateView() override;
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
void SliderValueChanged(views::Slider* sender, void SliderValueChanged(views::Slider* sender,
float value, float value,
float old_value, float old_value,
views::SliderChangeReason reason) override; views::SliderChangeReason reason) override;
void SliderButtonPressed();
private: private:
Delegate* const delegate_; Delegate* const delegate_;
UnifiedVolumeView* slider_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(UnifiedVolumeSliderController); DISALLOW_COPY_AND_ASSIGN(UnifiedVolumeSliderController);
}; };
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h" #include "ash/style/ash_color_provider.h"
#include "ash/system/audio/unified_volume_slider_controller.h"
#include "ash/system/tray/tray_popup_utils.h" #include "ash/system/tray/tray_popup_utils.h"
#include "base/i18n/rtl.h" #include "base/i18n/rtl.h"
#include "base/stl_util.h" #include "base/stl_util.h"
...@@ -61,8 +60,8 @@ SkColor GetBackgroundColorOfMoreButton() { ...@@ -61,8 +60,8 @@ SkColor GetBackgroundColorOfMoreButton() {
class MoreButton : public views::Button { class MoreButton : public views::Button {
public: public:
explicit MoreButton(views::ButtonListener* listener) explicit MoreButton(PressedCallback callback)
: views::Button(listener) { : views::Button(std::move(callback)) {
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, views::BoxLayout::Orientation::kHorizontal,
gfx::Insets((kTrayItemSize - gfx::Insets((kTrayItemSize -
...@@ -133,11 +132,19 @@ class MoreButton : public views::Button { ...@@ -133,11 +132,19 @@ class MoreButton : public views::Button {
} // namespace } // namespace
UnifiedVolumeView::UnifiedVolumeView(UnifiedVolumeSliderController* controller) UnifiedVolumeView::UnifiedVolumeView(
: UnifiedSliderView(controller, UnifiedVolumeSliderController* controller,
UnifiedVolumeSliderController::Delegate* delegate)
: UnifiedSliderView(base::BindRepeating(
&UnifiedVolumeSliderController::SliderButtonPressed,
base::Unretained(controller)),
controller,
kSystemMenuVolumeHighIcon, kSystemMenuVolumeHighIcon,
IDS_ASH_STATUS_TRAY_VOLUME_SLIDER_LABEL), IDS_ASH_STATUS_TRAY_VOLUME_SLIDER_LABEL),
more_button_(new MoreButton(controller)) { more_button_(new MoreButton(
base::BindRepeating(&UnifiedVolumeSliderController::Delegate::
OnAudioSettingsButtonClicked,
base::Unretained(delegate)))) {
CrasAudioHandler::Get()->AddAudioObserver(this); CrasAudioHandler::Get()->AddAudioObserver(this);
AddChildView(more_button_); AddChildView(more_button_);
Update(false /* by_user */); Update(false /* by_user */);
......
...@@ -5,22 +5,20 @@ ...@@ -5,22 +5,20 @@
#ifndef ASH_SYSTEM_AUDIO_UNIFIED_VOLUME_VIEW_H_ #ifndef ASH_SYSTEM_AUDIO_UNIFIED_VOLUME_VIEW_H_
#define ASH_SYSTEM_AUDIO_UNIFIED_VOLUME_VIEW_H_ #define ASH_SYSTEM_AUDIO_UNIFIED_VOLUME_VIEW_H_
#include "ash/system/audio/unified_volume_slider_controller.h"
#include "ash/system/unified/unified_slider_view.h" #include "ash/system/unified/unified_slider_view.h"
#include "chromeos/audio/cras_audio_handler.h" #include "chromeos/audio/cras_audio_handler.h"
namespace ash { namespace ash {
class UnifiedVolumeSliderController;
// View of a slider that can change audio volume. // View of a slider that can change audio volume.
class UnifiedVolumeView : public UnifiedSliderView, class UnifiedVolumeView : public UnifiedSliderView,
public chromeos::CrasAudioHandler::AudioObserver { public chromeos::CrasAudioHandler::AudioObserver {
public: public:
explicit UnifiedVolumeView(UnifiedVolumeSliderController* controller); UnifiedVolumeView(UnifiedVolumeSliderController* controller,
UnifiedVolumeSliderController::Delegate* delegate);
~UnifiedVolumeView() override; ~UnifiedVolumeView() override;
views::Button* more_button() { return more_button_; }
// views::View: // views::View:
const char* GetClassName() const override; const char* GetClassName() const override;
......
...@@ -33,11 +33,6 @@ views::View* UnifiedBrightnessSliderController::CreateView() { ...@@ -33,11 +33,6 @@ views::View* UnifiedBrightnessSliderController::CreateView() {
return slider_; return slider_;
} }
void UnifiedBrightnessSliderController::ButtonPressed(views::Button* sender,
const ui::Event& event) {
// The button in is UnifiedBrightnessView is no-op.
}
void UnifiedBrightnessSliderController::SliderValueChanged( void UnifiedBrightnessSliderController::SliderValueChanged(
views::Slider* sender, views::Slider* sender,
float value, float value,
......
...@@ -19,7 +19,6 @@ class UnifiedBrightnessSliderController : public UnifiedSliderListener { ...@@ -19,7 +19,6 @@ class UnifiedBrightnessSliderController : public UnifiedSliderListener {
// UnifiedSliderListener: // UnifiedSliderListener:
views::View* CreateView() override; views::View* CreateView() override;
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
void SliderValueChanged(views::Slider* sender, void SliderValueChanged(views::Slider* sender,
float value, float value,
float old_value, float old_value,
......
...@@ -14,7 +14,8 @@ namespace ash { ...@@ -14,7 +14,8 @@ namespace ash {
UnifiedBrightnessView::UnifiedBrightnessView( UnifiedBrightnessView::UnifiedBrightnessView(
UnifiedBrightnessSliderController* controller, UnifiedBrightnessSliderController* controller,
UnifiedSystemTrayModel* model) UnifiedSystemTrayModel* model)
: UnifiedSliderView(controller, : UnifiedSliderView(views::Button::PressedCallback(),
controller,
kUnifiedMenuBrightnessIcon, kUnifiedMenuBrightnessIcon,
IDS_ASH_STATUS_TRAY_BRIGHTNESS), IDS_ASH_STATUS_TRAY_BRIGHTNESS),
model_(model) { model_(model) {
......
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/range/range.h" #include "ui/gfx/range/range.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/controls/scroll_view.h" #include "ui/views/controls/scroll_view.h"
...@@ -66,12 +65,6 @@ gfx::Range GetImeListViewRange() { ...@@ -66,12 +65,6 @@ gfx::Range GetImeListViewRange() {
return gfx::Range(tray_item_height * min_items, tray_item_height * max_items); return gfx::Range(tray_item_height * min_items, tray_item_height * max_items);
} }
// Shows language and input settings page.
void ShowIMESettings() {
base::RecordAction(base::UserMetricsAction("StatusArea_IME_Detailed"));
Shell::Get()->system_tray_model()->client()->ShowIMESettings();
}
// Returns true if the current screen is login or lock screen. // Returns true if the current screen is login or lock screen.
bool IsInLoginOrLockScreen() { bool IsInLoginOrLockScreen() {
using session_manager::SessionState; using session_manager::SessionState;
...@@ -120,15 +113,8 @@ class ImeMenuImageView : public views::ImageView { ...@@ -120,15 +113,8 @@ class ImeMenuImageView : public views::ImageView {
DISALLOW_COPY_AND_ASSIGN(ImeMenuImageView); DISALLOW_COPY_AND_ASSIGN(ImeMenuImageView);
}; };
SystemMenuButton* CreateImeMenuButton(views::ButtonListener* listener,
const gfx::VectorIcon& icon,
int accessible_name_id,
int right_border) {
return new SystemMenuButton(listener, icon, accessible_name_id);
}
// The view that contains IME menu title. // The view that contains IME menu title.
class ImeTitleView : public views::View, public views::ButtonListener { class ImeTitleView : public views::View {
public: public:
explicit ImeTitleView() { explicit ImeTitleView() {
SetBorder(views::CreatePaddedBorder( SetBorder(views::CreatePaddedBorder(
...@@ -153,16 +139,15 @@ class ImeTitleView : public views::View, public views::ButtonListener { ...@@ -153,16 +139,15 @@ class ImeTitleView : public views::View, public views::ButtonListener {
layout_ptr->SetFlexForView(title_label, 1); layout_ptr->SetFlexForView(title_label, 1);
settings_button_ = AddChildView(std::make_unique<TopShortcutButton>( settings_button_ = AddChildView(std::make_unique<TopShortcutButton>(
this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS)); base::BindRepeating([]() {
base::RecordAction(
base::UserMetricsAction("StatusArea_IME_Detailed"));
Shell::Get()->system_tray_model()->client()->ShowIMESettings();
}),
kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS));
settings_button_->SetEnabled(TrayPopupUtils::CanOpenWebUISettings()); settings_button_->SetEnabled(TrayPopupUtils::CanOpenWebUISettings());
} }
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override {
DCHECK_EQ(sender, settings_button_);
ShowIMESettings();
}
~ImeTitleView() override = default; ~ImeTitleView() override = default;
// views::View: // views::View:
...@@ -175,7 +160,7 @@ class ImeTitleView : public views::View, public views::ButtonListener { ...@@ -175,7 +160,7 @@ class ImeTitleView : public views::View, public views::ButtonListener {
}; };
// The view that contains buttons shown on the bottom of IME menu. // The view that contains buttons shown on the bottom of IME menu.
class ImeButtonsView : public views::View, public views::ButtonListener { class ImeButtonsView : public views::View {
public: public:
ImeButtonsView(ImeMenuTray* ime_menu_tray, ImeButtonsView(ImeMenuTray* ime_menu_tray,
bool show_emoji, bool show_emoji,
...@@ -189,28 +174,16 @@ class ImeButtonsView : public views::View, public views::ButtonListener { ...@@ -189,28 +174,16 @@ class ImeButtonsView : public views::View, public views::ButtonListener {
~ImeButtonsView() override = default; ~ImeButtonsView() override = default;
// views::ButtonListener: void KeysetButtonPressed(chromeos::input_method::ImeKeyset keyset) {
void ButtonPressed(views::Button* sender, const ui::Event& event) override {
// The |keyset| will be used for drawing input view keyset in IME
// extensions. ImeMenuTray::ShowKeyboardWithKeyset() will deal with
// the |keyset| string to generate the right input view url.
chromeos::input_method::ImeKeyset keyset =
chromeos::input_method::ImeKeyset::kNone;
if (sender == emoji_button_)
keyset = chromeos::input_method::ImeKeyset::kEmoji;
else if (sender == voice_button_)
keyset = chromeos::input_method::ImeKeyset::kVoice;
else if (sender == handwriting_button_)
keyset = chromeos::input_method::ImeKeyset::kHandwriting;
else
NOTREACHED();
// TODO(dcheng): When https://crbug.com/742517 is fixed, Mojo will generate // TODO(dcheng): When https://crbug.com/742517 is fixed, Mojo will generate
// a constant for the number of values in the enum. For now, we just define // a constant for the number of values in the enum. For now, we just define
// it here and keep it in sync with the enum. // it here and keep it in sync with the enum.
const int kImeKeysetUmaBoundary = 4; const int kImeKeysetUmaBoundary = 4;
UMA_HISTOGRAM_ENUMERATION("InputMethod.ImeMenu.EmojiHandwritingVoiceButton", UMA_HISTOGRAM_ENUMERATION("InputMethod.ImeMenu.EmojiHandwritingVoiceButton",
keyset, kImeKeysetUmaBoundary); keyset, kImeKeysetUmaBoundary);
// The |keyset| will be used for drawing input view keyset in IME
// extensions. ImeMenuTray::ShowKeyboardWithKeyset() will deal with
// the |keyset| string to generate the right input view url.
ime_menu_tray_->ShowKeyboardWithKeyset(keyset); ime_menu_tray_->ShowKeyboardWithKeyset(keyset);
} }
...@@ -231,26 +204,31 @@ class ImeButtonsView : public views::View, public views::ButtonListener { ...@@ -231,26 +204,31 @@ class ImeButtonsView : public views::View, public views::ButtonListener {
gfx::Insets(kMenuSeparatorVerticalPadding - kMenuSeparatorWidth, gfx::Insets(kMenuSeparatorVerticalPadding - kMenuSeparatorWidth,
kMenuExtraMarginFromLeftEdge))); kMenuExtraMarginFromLeftEdge)));
const int right_border = 1;
if (show_emoji) { if (show_emoji) {
emoji_button_ = emoji_button_ = new SystemMenuButton(
CreateImeMenuButton(this, kImeMenuEmoticonIcon, base::BindRepeating(&ImeButtonsView::KeysetButtonPressed,
IDS_ASH_STATUS_TRAY_IME_EMOJI, right_border); base::Unretained(this),
chromeos::input_method::ImeKeyset::kEmoji),
kImeMenuEmoticonIcon, IDS_ASH_STATUS_TRAY_IME_EMOJI);
emoji_button_->SetID(kEmojiButtonId); emoji_button_->SetID(kEmojiButtonId);
AddChildView(emoji_button_); AddChildView(emoji_button_);
} }
if (show_handwriting) { if (show_handwriting) {
handwriting_button_ = CreateImeMenuButton( handwriting_button_ = new SystemMenuButton(
this, kImeMenuWriteIcon, IDS_ASH_STATUS_TRAY_IME_HANDWRITING, base::BindRepeating(&ImeButtonsView::KeysetButtonPressed,
right_border); base::Unretained(this),
chromeos::input_method::ImeKeyset::kHandwriting),
kImeMenuWriteIcon, IDS_ASH_STATUS_TRAY_IME_HANDWRITING);
AddChildView(handwriting_button_); AddChildView(handwriting_button_);
} }
if (show_voice) { if (show_voice) {
voice_button_ = voice_button_ = new SystemMenuButton(
CreateImeMenuButton(this, kImeMenuMicrophoneIcon, base::BindRepeating(&ImeButtonsView::KeysetButtonPressed,
IDS_ASH_STATUS_TRAY_IME_VOICE, right_border); base::Unretained(this),
chromeos::input_method::ImeKeyset::kVoice),
kImeMenuMicrophoneIcon, IDS_ASH_STATUS_TRAY_IME_VOICE);
AddChildView(voice_button_); AddChildView(voice_button_);
} }
} }
......
...@@ -18,7 +18,8 @@ class UnifiedKeyboardBrightnessView : public UnifiedSliderView, ...@@ -18,7 +18,8 @@ class UnifiedKeyboardBrightnessView : public UnifiedSliderView,
UnifiedKeyboardBrightnessView( UnifiedKeyboardBrightnessView(
UnifiedKeyboardBrightnessSliderController* controller, UnifiedKeyboardBrightnessSliderController* controller,
UnifiedSystemTrayModel* model) UnifiedSystemTrayModel* model)
: UnifiedSliderView(controller, : UnifiedSliderView(views::Button::PressedCallback(),
controller,
kUnifiedMenuKeyboardBrightnessIcon, kUnifiedMenuKeyboardBrightnessIcon,
IDS_ASH_STATUS_TRAY_BRIGHTNESS, IDS_ASH_STATUS_TRAY_BRIGHTNESS,
true /* readonly*/), true /* readonly*/),
...@@ -55,12 +56,6 @@ views::View* UnifiedKeyboardBrightnessSliderController::CreateView() { ...@@ -55,12 +56,6 @@ views::View* UnifiedKeyboardBrightnessSliderController::CreateView() {
return slider_; return slider_;
} }
void UnifiedKeyboardBrightnessSliderController::ButtonPressed(
views::Button* sender,
const ui::Event& event) {
// This slider is read-only.
}
void UnifiedKeyboardBrightnessSliderController::SliderValueChanged( void UnifiedKeyboardBrightnessSliderController::SliderValueChanged(
views::Slider* sender, views::Slider* sender,
float value, float value,
......
...@@ -20,7 +20,6 @@ class UnifiedKeyboardBrightnessSliderController : public UnifiedSliderListener { ...@@ -20,7 +20,6 @@ class UnifiedKeyboardBrightnessSliderController : public UnifiedSliderListener {
// UnifiedSliderListener: // UnifiedSliderListener:
views::View* CreateView() override; views::View* CreateView() override;
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
void SliderValueChanged(views::Slider* sender, void SliderValueChanged(views::Slider* sender,
float value, float value,
float old_value, float old_value,
......
...@@ -40,10 +40,10 @@ SystemMenuButton::SystemMenuButton(PressedCallback callback, ...@@ -40,10 +40,10 @@ SystemMenuButton::SystemMenuButton(PressedCallback callback,
AshColorProvider::ControlsLayerType::kFocusRingColor)); AshColorProvider::ControlsLayerType::kFocusRingColor));
} }
SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, SystemMenuButton::SystemMenuButton(PressedCallback callback,
const gfx::VectorIcon& icon, const gfx::VectorIcon& icon,
int accessible_name_id) int accessible_name_id)
: SystemMenuButton(PressedCallback(listener, this), : SystemMenuButton(std::move(callback),
gfx::ImageSkia(), gfx::ImageSkia(),
gfx::ImageSkia(), gfx::ImageSkia(),
accessible_name_id) { accessible_name_id) {
......
...@@ -30,7 +30,7 @@ class SystemMenuButton : public views::ImageButton { ...@@ -30,7 +30,7 @@ class SystemMenuButton : public views::ImageButton {
// Similar to the above constructor. Just gets a single vector icon and // Similar to the above constructor. Just gets a single vector icon and
// creates the normal and disabled icons based on that using default menu icon // creates the normal and disabled icons based on that using default menu icon
// colors. // colors.
SystemMenuButton(views::ButtonListener* listener, SystemMenuButton(PressedCallback callback,
const gfx::VectorIcon& icon, const gfx::VectorIcon& icon,
int accessible_name_id); int accessible_name_id);
~SystemMenuButton() override; ~SystemMenuButton() override;
......
...@@ -83,10 +83,10 @@ std::unique_ptr<views::Slider> CreateSlider(UnifiedSliderListener* listener, ...@@ -83,10 +83,10 @@ std::unique_ptr<views::Slider> CreateSlider(UnifiedSliderListener* listener,
} // namespace } // namespace
UnifiedSliderButton::UnifiedSliderButton(views::ButtonListener* listener, UnifiedSliderButton::UnifiedSliderButton(PressedCallback callback,
const gfx::VectorIcon& icon, const gfx::VectorIcon& icon,
int accessible_name_id) int accessible_name_id)
: views::ImageButton(listener) { : views::ImageButton(std::move(callback)) {
SetImageHorizontalAlignment(ALIGN_CENTER); SetImageHorizontalAlignment(ALIGN_CENTER);
SetImageVerticalAlignment(ALIGN_MIDDLE); SetImageVerticalAlignment(ALIGN_MIDDLE);
if (accessible_name_id) if (accessible_name_id)
...@@ -182,12 +182,13 @@ void UnifiedSliderButton::UpdateVectorIcon() { ...@@ -182,12 +182,13 @@ void UnifiedSliderButton::UpdateVectorIcon() {
this, *icon_, toggled_, GetDefaultSizeOfVectorIcon(*icon_)); this, *icon_, toggled_, GetDefaultSizeOfVectorIcon(*icon_));
} }
UnifiedSliderView::UnifiedSliderView(UnifiedSliderListener* listener, UnifiedSliderView::UnifiedSliderView(views::Button::PressedCallback callback,
UnifiedSliderListener* listener,
const gfx::VectorIcon& icon, const gfx::VectorIcon& icon,
int accessible_name_id, int accessible_name_id,
bool readonly) bool readonly)
: button_(AddChildView( : button_(AddChildView(
std::make_unique<UnifiedSliderButton>(listener, std::make_unique<UnifiedSliderButton>(std::move(callback),
icon, icon,
accessible_name_id))), accessible_name_id))),
slider_(AddChildView(CreateSlider(listener, readonly))) { slider_(AddChildView(CreateSlider(listener, readonly))) {
......
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
namespace ash { namespace ash {
class UnifiedSliderListener : public views::ButtonListener, class UnifiedSliderListener : public views::SliderListener {
public views::SliderListener {
public: public:
// Instantiates UnifiedSliderView. The view will be onwed by views hierarchy. // Instantiates UnifiedSliderView. The view will be onwed by views hierarchy.
// The view should be always deleted after the controller is destructed. // The view should be always deleted after the controller is destructed.
...@@ -26,7 +25,7 @@ class UnifiedSliderListener : public views::ButtonListener, ...@@ -26,7 +25,7 @@ class UnifiedSliderListener : public views::ButtonListener,
// A button used in a slider row of UnifiedSystemTray. The button is togglable. // A button used in a slider row of UnifiedSystemTray. The button is togglable.
class UnifiedSliderButton : public views::ImageButton { class UnifiedSliderButton : public views::ImageButton {
public: public:
UnifiedSliderButton(views::ButtonListener* listener, UnifiedSliderButton(PressedCallback callback,
const gfx::VectorIcon& icon, const gfx::VectorIcon& icon,
int accessible_name_id); int accessible_name_id);
~UnifiedSliderButton() override; ~UnifiedSliderButton() override;
...@@ -64,7 +63,8 @@ class UnifiedSliderButton : public views::ImageButton { ...@@ -64,7 +63,8 @@ class UnifiedSliderButton : public views::ImageButton {
class UnifiedSliderView : public views::View { class UnifiedSliderView : public views::View {
public: public:
// If |readonly| is set, the slider will not accept any user events. // If |readonly| is set, the slider will not accept any user events.
UnifiedSliderView(UnifiedSliderListener* listener, UnifiedSliderView(views::Button::PressedCallback callback,
UnifiedSliderListener* listener,
const gfx::VectorIcon& icon, const gfx::VectorIcon& icon,
int accessible_name_id, int accessible_name_id,
bool readonly = false); bool readonly = false);
......
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