Commit c52ab914 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Show settings button in volume slider bubble.

Previously, settings button for volume slider was hidden when volume
slider was shown as a single row bubble, not in a main bubble.

This CL changes the settings button to be always shown. When the button
is clicked in the slider bubble, it will open the main bubble.

TEST=manual
BUG=870473

Change-Id: Icc5b3d528414ee49ce6f0ffb4f4d47c0ce69c9ec
Reviewed-on: https://chromium-review.googlesource.com/1170667
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582486}
parent 22fde54f
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "ash/metrics/user_metrics_recorder.h" #include "ash/metrics/user_metrics_recorder.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/audio/unified_volume_view.h" #include "ash/system/audio/unified_volume_view.h"
#include "ash/system/unified/unified_system_tray_controller.h"
#include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h" #include "base/metrics/user_metrics_action.h"
...@@ -17,14 +16,16 @@ using chromeos::CrasAudioHandler; ...@@ -17,14 +16,16 @@ using chromeos::CrasAudioHandler;
namespace ash { namespace ash {
UnifiedVolumeSliderController::UnifiedVolumeSliderController( UnifiedVolumeSliderController::UnifiedVolumeSliderController(
UnifiedSystemTrayController* tray_controller) UnifiedVolumeSliderController::Delegate* delegate)
: tray_controller_(tray_controller) {} : delegate_(delegate) {
DCHECK(delegate);
}
UnifiedVolumeSliderController::~UnifiedVolumeSliderController() = default; UnifiedVolumeSliderController::~UnifiedVolumeSliderController() = default;
views::View* UnifiedVolumeSliderController::CreateView() { views::View* UnifiedVolumeSliderController::CreateView() {
DCHECK(!slider_); DCHECK(!slider_);
slider_ = new UnifiedVolumeView(this, !!tray_controller_); slider_ = new UnifiedVolumeView(this);
return slider_; return slider_;
} }
...@@ -38,7 +39,7 @@ void UnifiedVolumeSliderController::ButtonPressed(views::Button* sender, ...@@ -38,7 +39,7 @@ void UnifiedVolumeSliderController::ButtonPressed(views::Button* sender,
base::RecordAction(base::UserMetricsAction("StatusArea_Audio_Unmuted")); base::RecordAction(base::UserMetricsAction("StatusArea_Audio_Unmuted"));
CrasAudioHandler::Get()->SetOutputMute(mute_on); CrasAudioHandler::Get()->SetOutputMute(mute_on);
} else if (sender == slider_->more_button()) { } else if (sender == slider_->more_button()) {
tray_controller_->ShowAudioDetailedView(); delegate_->OnAudioSettingsButtonClicked();
} }
} }
......
...@@ -9,16 +9,18 @@ ...@@ -9,16 +9,18 @@
namespace ash { namespace ash {
class UnifiedSystemTrayController;
class UnifiedVolumeView; 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:
// |tray_controller| may be null if the volume slider is in slider bubble, not class Delegate {
// main bubble. public:
explicit UnifiedVolumeSliderController( virtual ~Delegate() = default;
UnifiedSystemTrayController* tray_controller); virtual void OnAudioSettingsButtonClicked() = 0;
};
explicit UnifiedVolumeSliderController(Delegate* delegate);
~UnifiedVolumeSliderController() override; ~UnifiedVolumeSliderController() override;
// UnifiedSliderListener: // UnifiedSliderListener:
...@@ -30,7 +32,7 @@ class UnifiedVolumeSliderController : public UnifiedSliderListener { ...@@ -30,7 +32,7 @@ class UnifiedVolumeSliderController : public UnifiedSliderListener {
views::SliderChangeReason reason) override; views::SliderChangeReason reason) override;
private: private:
UnifiedSystemTrayController* const tray_controller_; Delegate* const delegate_;
UnifiedVolumeView* slider_ = nullptr; UnifiedVolumeView* slider_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(UnifiedVolumeSliderController); DISALLOW_COPY_AND_ASSIGN(UnifiedVolumeSliderController);
......
...@@ -120,13 +120,11 @@ class MoreButton : public views::Button { ...@@ -120,13 +120,11 @@ class MoreButton : public views::Button {
} // namespace } // namespace
UnifiedVolumeView::UnifiedVolumeView(UnifiedVolumeSliderController* controller, UnifiedVolumeView::UnifiedVolumeView(UnifiedVolumeSliderController* controller)
bool is_main_view)
: UnifiedSliderView(controller, : UnifiedSliderView(controller,
kSystemMenuVolumeHighIcon, kSystemMenuVolumeHighIcon,
IDS_ASH_STATUS_TRAY_VOLUME), IDS_ASH_STATUS_TRAY_VOLUME),
more_button_(new MoreButton(controller)), more_button_(new MoreButton(controller)) {
is_main_view_(is_main_view) {
DCHECK(CrasAudioHandler::IsInitialized()); DCHECK(CrasAudioHandler::IsInitialized());
CrasAudioHandler::Get()->AddAudioObserver(this); CrasAudioHandler::Get()->AddAudioObserver(this);
AddChildView(more_button_); AddChildView(more_button_);
...@@ -148,9 +146,8 @@ void UnifiedVolumeView::Update(bool by_user) { ...@@ -148,9 +146,8 @@ void UnifiedVolumeView::Update(bool by_user) {
button()->SetToggled(!is_muted); button()->SetToggled(!is_muted);
button()->SetVectorIcon(GetVolumeIconForLevel(is_muted ? 0.f : level)); button()->SetVectorIcon(GetVolumeIconForLevel(is_muted ? 0.f : level));
more_button_->SetVisible(is_main_view_ && more_button_->SetVisible(CrasAudioHandler::Get()->has_alternative_input() ||
(CrasAudioHandler::Get()->has_alternative_input() || CrasAudioHandler::Get()->has_alternative_output());
CrasAudioHandler::Get()->has_alternative_output()));
// Slider's value is in finer granularity than audio volume level(0.01), // Slider's value is in finer granularity than audio volume level(0.01),
// there will be a small discrepancy between slider's value and volume level // there will be a small discrepancy between slider's value and volume level
......
...@@ -16,8 +16,7 @@ class UnifiedVolumeSliderController; ...@@ -16,8 +16,7 @@ class UnifiedVolumeSliderController;
class UnifiedVolumeView : public UnifiedSliderView, class UnifiedVolumeView : public UnifiedSliderView,
public chromeos::CrasAudioHandler::AudioObserver { public chromeos::CrasAudioHandler::AudioObserver {
public: public:
UnifiedVolumeView(UnifiedVolumeSliderController* controller, explicit UnifiedVolumeView(UnifiedVolumeSliderController* controller);
bool is_main_view);
~UnifiedVolumeView() override; ~UnifiedVolumeView() override;
views::Button* more_button() { return more_button_; } views::Button* more_button() { return more_button_; }
...@@ -36,7 +35,6 @@ class UnifiedVolumeView : public UnifiedSliderView, ...@@ -36,7 +35,6 @@ class UnifiedVolumeView : public UnifiedSliderView,
void ChildVisibilityChanged(views::View* child) override; void ChildVisibilityChanged(views::View* child) override;
views::Button* const more_button_; views::Button* const more_button_;
const bool is_main_view_;
DISALLOW_COPY_AND_ASSIGN(UnifiedVolumeView); DISALLOW_COPY_AND_ASSIGN(UnifiedVolumeView);
}; };
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "ash/public/cpp/app_list/app_list_features.h" #include "ash/public/cpp/app_list/app_list_features.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/audio/unified_volume_slider_controller.h"
#include "ash/system/brightness/unified_brightness_slider_controller.h" #include "ash/system/brightness/unified_brightness_slider_controller.h"
#include "ash/system/keyboard_brightness/unified_keyboard_brightness_slider_controller.h" #include "ash/system/keyboard_brightness/unified_keyboard_brightness_slider_controller.h"
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
...@@ -109,6 +108,10 @@ void UnifiedSliderBubbleController::OnKeyboardBrightnessChanged(bool by_user) { ...@@ -109,6 +108,10 @@ void UnifiedSliderBubbleController::OnKeyboardBrightnessChanged(bool by_user) {
ShowBubble(SLIDER_TYPE_KEYBOARD_BRIGHTNESS); ShowBubble(SLIDER_TYPE_KEYBOARD_BRIGHTNESS);
} }
void UnifiedSliderBubbleController::OnAudioSettingsButtonClicked() {
tray_->ShowAudioDetailedViewBubble();
}
void UnifiedSliderBubbleController::ShowBubble(SliderType slider_type) { void UnifiedSliderBubbleController::ShowBubble(SliderType slider_type) {
if (IsAnyMainBubbleShown()) { if (IsAnyMainBubbleShown()) {
tray_->EnsureBubbleExpanded(); tray_->EnsureBubbleExpanded();
...@@ -195,7 +198,7 @@ void UnifiedSliderBubbleController::CreateSliderController() { ...@@ -195,7 +198,7 @@ void UnifiedSliderBubbleController::CreateSliderController() {
switch (slider_type_) { switch (slider_type_) {
case SLIDER_TYPE_VOLUME: case SLIDER_TYPE_VOLUME:
slider_controller_ = slider_controller_ =
std::make_unique<UnifiedVolumeSliderController>(nullptr); std::make_unique<UnifiedVolumeSliderController>(this);
return; return;
case SLIDER_TYPE_DISPLAY_BRIGHTNESS: case SLIDER_TYPE_DISPLAY_BRIGHTNESS:
slider_controller_ = slider_controller_ =
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define ASH_SYSTEM_UNIFIED_UNIFIED_SLIDER_BUBBLE_CONTROLLER_H_ #define ASH_SYSTEM_UNIFIED_UNIFIED_SLIDER_BUBBLE_CONTROLLER_H_
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/system/audio/unified_volume_slider_controller.h"
#include "ash/system/unified/unified_system_tray_model.h" #include "ash/system/unified/unified_system_tray_model.h"
#include "chromeos/audio/cras_audio_handler.h" #include "chromeos/audio/cras_audio_handler.h"
#include "ui/views/bubble/tray_bubble_view.h" #include "ui/views/bubble/tray_bubble_view.h"
...@@ -20,7 +21,8 @@ class UnifiedSliderListener; ...@@ -20,7 +21,8 @@ class UnifiedSliderListener;
class ASH_EXPORT UnifiedSliderBubbleController class ASH_EXPORT UnifiedSliderBubbleController
: public views::TrayBubbleView::Delegate, : public views::TrayBubbleView::Delegate,
public chromeos::CrasAudioHandler::AudioObserver, public chromeos::CrasAudioHandler::AudioObserver,
public UnifiedSystemTrayModel::Observer { public UnifiedSystemTrayModel::Observer,
public UnifiedVolumeSliderController::Delegate {
public: public:
enum SliderType { enum SliderType {
SLIDER_TYPE_VOLUME = 0, SLIDER_TYPE_VOLUME = 0,
...@@ -53,6 +55,9 @@ class ASH_EXPORT UnifiedSliderBubbleController ...@@ -53,6 +55,9 @@ class ASH_EXPORT UnifiedSliderBubbleController
void OnDisplayBrightnessChanged(bool by_user) override; void OnDisplayBrightnessChanged(bool by_user) override;
void OnKeyboardBrightnessChanged(bool by_user) override; void OnKeyboardBrightnessChanged(bool by_user) override;
// UnifiedVolumeSliderController::Delegate:
void OnAudioSettingsButtonClicked() override;
private: private:
friend class UnifiedSystemTrayTest; friend class UnifiedSystemTrayTest;
......
...@@ -206,6 +206,11 @@ void UnifiedSystemTray::ShowVolumeSliderBubble() { ...@@ -206,6 +206,11 @@ void UnifiedSystemTray::ShowVolumeSliderBubble() {
UnifiedSliderBubbleController::SLIDER_TYPE_VOLUME); UnifiedSliderBubbleController::SLIDER_TYPE_VOLUME);
} }
void UnifiedSystemTray::ShowAudioDetailedViewBubble() {
ShowBubble(false /* show_by_click */);
bubble_->ShowAudioDetailedView();
}
void UnifiedSystemTray::SetTrayBubbleHeight(int height) { void UnifiedSystemTray::SetTrayBubbleHeight(int height) {
ui_delegate_->SetTrayBubbleHeight(height); ui_delegate_->SetTrayBubbleHeight(height);
} }
......
...@@ -60,6 +60,9 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView { ...@@ -60,6 +60,9 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView {
// is same as one shown when volume buttons on keyboard are pressed. // is same as one shown when volume buttons on keyboard are pressed.
void ShowVolumeSliderBubble(); void ShowVolumeSliderBubble();
// Shows main bubble with audio settings detailed view.
void ShowAudioDetailedViewBubble();
// Return the bounds of the bubble in the screen. // Return the bounds of the bubble in the screen.
gfx::Rect GetBubbleBoundsInScreen() const; gfx::Rect GetBubbleBoundsInScreen() const;
......
...@@ -162,6 +162,15 @@ void UnifiedSystemTrayBubble::EnsureExpanded() { ...@@ -162,6 +162,15 @@ void UnifiedSystemTrayBubble::EnsureExpanded() {
controller_->EnsureExpanded(); controller_->EnsureExpanded();
} }
void UnifiedSystemTrayBubble::ShowAudioDetailedView() {
if (!bubble_widget_)
return;
DCHECK(unified_view_);
DCHECK(controller_);
controller_->ShowAudioDetailedView();
}
void UnifiedSystemTrayBubble::UpdateBubble() { void UnifiedSystemTrayBubble::UpdateBubble() {
if (!bubble_widget_) if (!bubble_widget_)
return; return;
......
...@@ -60,6 +60,9 @@ class UnifiedSystemTrayBubble : public TrayBubbleBase, ...@@ -60,6 +60,9 @@ class UnifiedSystemTrayBubble : public TrayBubbleBase,
// Ensure the bubble is expanded. // Ensure the bubble is expanded.
void EnsureExpanded(); void EnsureExpanded();
// Show audio settings detailed view.
void ShowAudioDetailedView();
// Update bubble bounds and focus if necessary. // Update bubble bounds and focus if necessary.
void UpdateBubble(); void UpdateBubble();
......
...@@ -331,6 +331,10 @@ void UnifiedSystemTrayController::AnimationCanceled( ...@@ -331,6 +331,10 @@ void UnifiedSystemTrayController::AnimationCanceled(
UpdateExpandedAmount(); UpdateExpandedAmount();
} }
void UnifiedSystemTrayController::OnAudioSettingsButtonClicked() {
ShowAudioDetailedView();
}
void UnifiedSystemTrayController::InitFeaturePods() { void UnifiedSystemTrayController::InitFeaturePods() {
AddFeaturePodItem(std::make_unique<NetworkFeaturePodController>(this)); AddFeaturePodItem(std::make_unique<NetworkFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<BluetoothFeaturePodController>(this)); AddFeaturePodItem(std::make_unique<BluetoothFeaturePodController>(this));
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <vector> #include <vector>
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/system/audio/unified_volume_slider_controller.h"
#include "ash/system/unified/unified_system_tray_model.h" #include "ash/system/unified/unified_system_tray_model.h"
#include "base/macros.h" #include "base/macros.h"
#include "ui/gfx/animation/animation_delegate.h" #include "ui/gfx/animation/animation_delegate.h"
...@@ -29,7 +30,9 @@ class UnifiedSystemTrayModel; ...@@ -29,7 +30,9 @@ class UnifiedSystemTrayModel;
class UnifiedSystemTrayView; class UnifiedSystemTrayView;
// Controller class of UnifiedSystemTrayView. Handles events of the view. // Controller class of UnifiedSystemTrayView. Handles events of the view.
class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate { class ASH_EXPORT UnifiedSystemTrayController
: public gfx::AnimationDelegate,
public UnifiedVolumeSliderController::Delegate {
public: public:
UnifiedSystemTrayController(UnifiedSystemTrayModel* model, UnifiedSystemTrayController(UnifiedSystemTrayModel* model,
UnifiedSystemTrayBubble* bubble = nullptr); UnifiedSystemTrayBubble* bubble = nullptr);
...@@ -114,6 +117,9 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate { ...@@ -114,6 +117,9 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate {
void AnimationProgressed(const gfx::Animation* animation) override; void AnimationProgressed(const gfx::Animation* animation) override;
void AnimationCanceled(const gfx::Animation* animation) override; void AnimationCanceled(const gfx::Animation* animation) override;
// UnifiedVolumeSliderController::Delegate:
void OnAudioSettingsButtonClicked() override;
UnifiedSystemTrayModel* model() { return model_; } UnifiedSystemTrayModel* model() { return model_; }
private: private:
......
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