Chromium Code Reviews| 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..dd4d12ef21e6aeb442460601f864d1b837519090 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,15 +163,50 @@ 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) |
| + // None output device is connected |
|
tdanderson
2017/04/13 16:15:52
I really appreciate that you are including comment
|
| + if (is_default_view_ && !audio_handler->has_alternative_output()) { |
|
tdanderson
2017/04/13 16:15:52
I'm not sure I understand why you aren't also chec
minch1
2017/04/13 17:47:39
If I check !audio_handler->has_alternative_input()
tdanderson
2017/04/13 20:54:56
Ah, now I understand. I think what you're suggesti
|
| + tri_view_->SetContainerVisible(TriView::Container::END, false); |
| + if (more_button_) |
| + more_button_->InvalidateLayout(); |
|
tdanderson
2017/04/13 16:15:52
What happens if you don't invalidate the layout he
minch1
2017/04/13 17:47:39
Open the ash system menu,
1. No alternative output
tdanderson
2017/04/13 20:54:56
Thanks for the detailed explanation. Can you try c
minch1
2017/04/13 23:16:01
Yes, tri_view_->InvalidateLayout() has the same ef
|
| return; |
| + } |
| const gfx::VectorIcon& device_icon = GetActiveOutputDeviceVectorIcon(); |
| const bool target_visibility = !device_icon.is_empty(); |
| + |
| + if (!is_default_view_) { |
|
tdanderson
2017/04/13 16:15:52
minor nit: it is usually preferred from a style an
|
| + // Floating audio menu with Speaker(internal) output |
| + if (!target_visibility) { |
|
tdanderson
2017/04/13 16:15:52
I find this variable to be a bit awkwardly-named a
minch1
2017/04/13 17:47:39
Yeap, I think so. I moved this from the constructo
minch1
2017/04/13 23:16:01
I forgot |target_visibility| will be used in line
|
| + tri_view_->SetContainerVisible(TriView::Container::END, false); |
| + return; |
| + } |
| + device_type_ = TrayPopupUtils::CreateMoreImageView(); |
| + device_type_->SetVisible(false); |
|
tdanderson
2017/04/13 16:15:52
I'm not sure why you're setting visibility to fals
minch1
2017/04/13 17:47:39
Actually I think to initialize device_type_ as Cre
tdanderson
2017/04/13 20:54:56
Ah yes, you're right. I missed the fact that Creat
|
| + tri_view_->AddView(TriView::Container::END, device_type_); |
|
tdanderson
2017/04/13 16:15:52
It might be a good idea to call tri_view_->SetCont
minch1
2017/04/13 17:47:39
For the floating audio row. I think It will create
tdanderson
2017/04/13 20:54:56
The only time I could see there being a potential
minch1
2017/04/13 23:16:01
Yes, you are right. I forgot to plug or unplug the
|
| + } else { |
| + 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)); |
| + } |
| + |
| + tri_view_->SetContainerVisible(TriView::Container::END, true); |
| + more_button_->InvalidateLayout(); |
| + } |
| + |
| if (target_visibility) |
| device_type_->SetImage(gfx::CreateVectorIcon(device_icon, kMenuIconColor)); |
| if (device_type_->visible() != target_visibility) { |