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

Unified Diff: ash/system/audio/volume_view.cc

Issue 2812223005: Display current output device icon in the floating volume row when switching output devices (Closed)
Patch Set: Address nits. Created 3 years, 8 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
« no previous file with comments | « no previous file | ash/system/brightness/tray_brightness.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/audio/volume_view.cc
diff --git a/ash/system/audio/volume_view.cc b/ash/system/audio/volume_view.cc
index 7fdf5711016736597436a6cb70f733c2be3d2804..efbdd2f7ac7be59724f3245afff01cb4701813b7 100644
--- a/ash/system/audio/volume_view.cc
+++ b/ash/system/audio/volume_view.cc
@@ -131,29 +131,6 @@ VolumeView::VolumeView(SystemTrayItem* owner,
tri_view_->AddView(TriView::Container::CENTER, slider_);
set_background(views::Background::CreateSolidBackground(kBackgroundColor));
-
- if (!is_default_view_) {
- tri_view_->SetContainerVisible(TriView::Container::END, false);
- Update();
- return;
- }
-
- more_button_ = new ButtonListenerActionableView(
- owner_, TrayPopupInkDropStyle::INSET_BOUNDS, this);
- TrayPopupUtils::ConfigureContainer(TriView::Container::END, more_button_);
-
- more_button_->SetInkDropMode(views::InkDropHostView::InkDropMode::ON);
- more_button_->SetBorder(views::CreateEmptyBorder(gfx::Insets(
- 0, kTrayPopupButtonEndMargin)));
- tri_view_->AddView(TriView::Container::END, more_button_);
-
- device_type_ = TrayPopupUtils::CreateMoreImageView();
- device_type_->SetVisible(false);
- more_button_->AddChildView(device_type_);
-
- more_button_->AddChildView(TrayPopupUtils::CreateMoreImageView());
- more_button_->SetAccessibleName(
- l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_AUDIO));
Update();
}
@@ -186,19 +163,59 @@ void VolumeView::SetVolumeLevel(float percent) {
void VolumeView::UpdateDeviceTypeAndMore() {
CrasAudioHandler* audio_handler = CrasAudioHandler::Get();
- bool show_more =
- is_default_view_ && (audio_handler->has_alternative_output() ||
- audio_handler->has_alternative_input());
-
- if (!show_more)
+ // There is no point in letting the user open the audio detailed submenu if
+ // there are no alternative output or input devices present, so do not show
+ // the 'more' button in the default audio row.
+ if (is_default_view_ && !audio_handler->has_alternative_output() &&
+ !audio_handler->has_alternative_input()) {
+ tri_view_->SetContainerVisible(TriView::Container::END, false);
+ // TODO(tdanderson): TriView itself should trigger a relayout when the
+ // visibility of one of its containers is changed.
+ tri_view_->InvalidateLayout();
return;
+ }
const gfx::VectorIcon& device_icon = GetActiveOutputDeviceVectorIcon();
- const bool target_visibility = !device_icon.is_empty();
- if (target_visibility)
+ const bool device_icon_visibility = !device_icon.is_empty();
+
+ if (is_default_view_) {
+ if (!more_button_) {
+ more_button_ = new ButtonListenerActionableView(
+ owner_, TrayPopupInkDropStyle::INSET_BOUNDS, this);
+ TrayPopupUtils::ConfigureContainer(TriView::Container::END, more_button_);
+
+ more_button_->SetInkDropMode(views::InkDropHostView::InkDropMode::ON);
+ more_button_->SetBorder(
+ views::CreateEmptyBorder(gfx::Insets(0, kTrayPopupButtonEndMargin)));
+ tri_view_->AddView(TriView::Container::END, more_button_);
+
+ device_type_ = TrayPopupUtils::CreateMoreImageView();
+ device_type_->SetVisible(false);
+ more_button_->AddChildView(device_type_);
+
+ more_button_->AddChildView(TrayPopupUtils::CreateMoreImageView());
+ more_button_->SetAccessibleName(
+ l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_AUDIO));
+ }
+ } else {
+ if (!device_icon_visibility) {
+ tri_view_->SetContainerVisible(TriView::Container::END, false);
+ tri_view_->InvalidateLayout();
+ return;
+ }
+ if (!device_type_) {
+ device_type_ = TrayPopupUtils::CreateMoreImageView();
+ device_type_->SetVisible(false);
+ tri_view_->AddView(TriView::Container::END, device_type_);
+ }
+ }
+
+ tri_view_->SetContainerVisible(TriView::Container::END, true);
+ tri_view_->InvalidateLayout();
+ if (device_icon_visibility)
device_type_->SetImage(gfx::CreateVectorIcon(device_icon, kMenuIconColor));
- if (device_type_->visible() != target_visibility) {
- device_type_->SetVisible(target_visibility);
+ if (device_type_->visible() != device_icon_visibility) {
+ device_type_->SetVisible(device_icon_visibility);
device_type_->InvalidateLayout();
}
}
« no previous file with comments | « no previous file | ash/system/brightness/tray_brightness.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698