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