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

Side by Side Diff: ash/common/system/chromeos/audio/volume_view.cc

Issue 2671593003: Re-layout Chrome OS audio row when headphone connected (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/system/chromeos/audio/volume_view.h" 5 #include "ash/common/system/chromeos/audio/volume_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/metrics/user_metrics_action.h" 10 #include "ash/common/metrics/user_metrics_action.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 Update(); 249 Update();
250 slider_->set_enable_accessibility_events(true); 250 slider_->set_enable_accessibility_events(true);
251 } 251 }
252 252
253 void VolumeView::UpdateDeviceTypeAndMore() { 253 void VolumeView::UpdateDeviceTypeAndMore() {
254 bool show_more = is_default_view_ && audio_delegate_->HasAlternativeSources(); 254 bool show_more = is_default_view_ && audio_delegate_->HasAlternativeSources();
255 255
256 if (!show_more) 256 if (!show_more)
257 return; 257 return;
258 258
259 bool was_visible = device_type_->visible();
260
259 // Show output device icon if necessary. 261 // Show output device icon if necessary.
260 device_type_->SetVisible(false); 262 device_type_->SetVisible(false);
261 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 263 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
262 const gfx::VectorIcon& device_icon = 264 const gfx::VectorIcon& device_icon =
263 audio_delegate_->GetActiveOutputDeviceVectorIcon(); 265 audio_delegate_->GetActiveOutputDeviceVectorIcon();
264 if (!device_icon.is_empty()) { 266 if (!device_icon.is_empty()) {
265 device_type_->SetImage( 267 device_type_->SetImage(
266 gfx::CreateVectorIcon(device_icon, kMenuIconColor)); 268 gfx::CreateVectorIcon(device_icon, kMenuIconColor));
267 device_type_->SetVisible(true); 269 device_type_->SetVisible(true);
268 } 270 }
269 } else { 271 } else {
270 int device_icon = audio_delegate_->GetActiveOutputDeviceIconId(); 272 int device_icon = audio_delegate_->GetActiveOutputDeviceIconId();
271 if (device_icon != system::TrayAudioDelegate::kNoAudioDeviceIcon) { 273 if (device_icon != system::TrayAudioDelegate::kNoAudioDeviceIcon) {
272 device_type_->SetImage(ui::ResourceBundle::GetSharedInstance() 274 device_type_->SetImage(ui::ResourceBundle::GetSharedInstance()
273 .GetImageNamed(device_icon) 275 .GetImageNamed(device_icon)
274 .ToImageSkia()); 276 .ToImageSkia());
275 device_type_->SetVisible(true); 277 device_type_->SetVisible(true);
276 } 278 }
277 } 279 }
280 if (device_type_->visible() != was_visible)
281 device_type_->InvalidateLayout();
sadrul 2017/02/02 21:25:34 Setting the visibility can trigger a repaint. For
mohsen 2017/02/02 21:35:31 Sure. That makes a lot of sense. Done.
278 } 282 }
279 283
280 void VolumeView::HandleVolumeUp(int level) { 284 void VolumeView::HandleVolumeUp(int level) {
281 audio_delegate_->SetOutputVolumeLevel(level); 285 audio_delegate_->SetOutputVolumeLevel(level);
282 if (audio_delegate_->IsOutputAudioMuted() && 286 if (audio_delegate_->IsOutputAudioMuted() &&
283 level > audio_delegate_->GetOutputDefaultVolumeMuteLevel()) { 287 level > audio_delegate_->GetOutputDefaultVolumeMuteLevel()) {
284 audio_delegate_->SetOutputAudioIsMuted(false); 288 audio_delegate_->SetOutputAudioIsMuted(false);
285 } 289 }
286 } 290 }
287 291
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 void VolumeView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 347 void VolumeView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
344 // Separator's prefered size is based on set bounds. When an empty bounds is 348 // Separator's prefered size is based on set bounds. When an empty bounds is
345 // set on first layout this causes BoxLayout to ignore the separator. Reset 349 // set on first layout this causes BoxLayout to ignore the separator. Reset
346 // its height on each bounds change so that it is laid out properly. 350 // its height on each bounds change so that it is laid out properly.
347 if (separator_) 351 if (separator_)
348 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height())); 352 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height()));
349 } 353 }
350 354
351 } // namespace tray 355 } // namespace tray
352 } // namespace ash 356 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698