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

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

Issue 2234823003: Make the mute button in the Ash system menu keyboard focusable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « ash/ash_strings.grd ('k') | 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/audio/volume_view.h" 5 #include "ash/common/system/audio/volume_view.h"
6 6
7 #include "ash/common/ash_constants.h" 7 #include "ash/common/ash_constants.h"
8 #include "ash/common/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/metrics/user_metrics_action.h" 9 #include "ash/common/metrics/user_metrics_action.h"
10 #include "ash/common/system/audio/tray_audio.h" 10 #include "ash/common/system/audio/tray_audio.h"
11 #include "ash/common/system/audio/tray_audio_delegate.h" 11 #include "ash/common/system/audio/tray_audio_delegate.h"
12 #include "ash/common/system/tray/system_tray_item.h" 12 #include "ash/common/system/tray/system_tray_item.h"
13 #include "ash/common/system/tray/tray_constants.h" 13 #include "ash/common/system/tray/tray_constants.h"
14 #include "ash/common/system/tray/tray_popup_item_container.h" 14 #include "ash/common/system/tray/tray_popup_item_container.h"
15 #include "ash/common/wm_shell.h" 15 #include "ash/common/wm_shell.h"
16 #include "grit/ash_resources.h" 16 #include "grit/ash_resources.h"
17 #include "grit/ash_strings.h" 17 #include "grit/ash_strings.h"
18 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/image/image_skia_operations.h" 20 #include "ui/gfx/image/image_skia_operations.h"
21 #include "ui/gfx/paint_vector_icon.h" 21 #include "ui/gfx/paint_vector_icon.h"
22 #include "ui/gfx/vector_icons_public.h" 22 #include "ui/gfx/vector_icons_public.h"
23 #include "ui/views/background.h" 23 #include "ui/views/background.h"
24 #include "ui/views/border.h" 24 #include "ui/views/border.h"
25 #include "ui/views/controls/button/image_button.h" 25 #include "ui/views/controls/button/image_button.h"
26 #include "ui/views/controls/image_view.h" 26 #include "ui/views/controls/image_view.h"
27 #include "ui/views/controls/separator.h" 27 #include "ui/views/controls/separator.h"
28 #include "ui/views/layout/box_layout.h" 28 #include "ui/views/layout/box_layout.h"
29 #include "ui/views/painter.h"
29 30
30 namespace { 31 namespace {
31 const int kVolumeImageWidth = 25; 32 const int kVolumeImageWidth = 25;
32 const int kVolumeImageHeight = 25; 33 const int kVolumeImageHeight = 25;
33 const int kSeparatorSize = 3; 34 const int kSeparatorSize = 3;
34 const int kSeparatorVerticalInset = 8; 35 const int kSeparatorVerticalInset = 8;
35 const int kSliderRightPaddingToVolumeViewEdge = 17; 36 const int kSliderRightPaddingToVolumeViewEdge = 17;
36 const int kExtraPaddingBetweenBarAndMore = 10; 37 const int kExtraPaddingBetweenBarAndMore = 10;
37 const int kExtraPaddingBetweenIconAndSlider = 8; 38 const int kExtraPaddingBetweenIconAndSlider = 8;
38 const int kBoxLayoutPadding = 2; 39 const int kBoxLayoutPadding = 2;
39 40
40 // IDR_AURA_UBER_TRAY_VOLUME_LEVELS contains 5 images, 41 // IDR_AURA_UBER_TRAY_VOLUME_LEVELS contains 5 images,
41 // The one for mute is at the 0 index and the other 42 // The one for mute is at the 0 index and the other
42 // four are used for ascending volume levels. 43 // four are used for ascending volume levels.
43 const int kVolumeLevels = 4; 44 const int kVolumeLevels = 4;
44 45
45 } // namespace 46 } // namespace
46 47
47 namespace ash { 48 namespace ash {
48 namespace tray { 49 namespace tray {
49 50
50 class VolumeButton : public views::ToggleImageButton { 51 class VolumeButton : public views::ToggleImageButton {
51 public: 52 public:
52 VolumeButton(views::ButtonListener* listener, 53 VolumeButton(views::ButtonListener* listener,
53 system::TrayAudioDelegate* audio_delegate) 54 system::TrayAudioDelegate* audio_delegate)
54 : views::ToggleImageButton(listener), 55 : views::ToggleImageButton(listener),
55 audio_delegate_(audio_delegate), 56 audio_delegate_(audio_delegate),
56 image_index_(-1) { 57 image_index_(-1) {
58 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
59
60 SetFocusBehavior(FocusBehavior::ALWAYS);
61 SetFocusPainter(views::Painter::CreateSolidFocusPainter(
62 kFocusBorderColor, gfx::Insets(1, 1, 1, 1)));
63 SetAccessibleName(
David Tseng 2016/08/10 15:41:02 Could you override View::GetAccessibleState(AXView
tdanderson 2016/08/10 20:24:33 If I'm understanding the code correctly, it looks
64 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_VOLUME_MUTE));
65
57 SetImageAlignment(ALIGN_CENTER, ALIGN_MIDDLE); 66 SetImageAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
58 image_ = ui::ResourceBundle::GetSharedInstance().GetImageNamed( 67 image_ = bundle.GetImageNamed(IDR_AURA_UBER_TRAY_VOLUME_LEVELS);
59 IDR_AURA_UBER_TRAY_VOLUME_LEVELS); 68
60 Update(); 69 Update();
61 } 70 }
62 71
63 ~VolumeButton() override {} 72 ~VolumeButton() override {}
64 73
65 void Update() { 74 void Update() {
66 float level = 75 float level =
67 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f; 76 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f;
68 int image_index = 77 int image_index =
69 audio_delegate_->IsOutputAudioMuted() 78 audio_delegate_->IsOutputAudioMuted()
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height())); 299 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height()));
291 } 300 }
292 301
293 void VolumeView::GetAccessibleState(ui::AXViewState* state) { 302 void VolumeView::GetAccessibleState(ui::AXViewState* state) {
294 // Intentionally overrides ActionableView, leaving |state| unset. A slider 303 // Intentionally overrides ActionableView, leaving |state| unset. A slider
295 // childview exposes accessibility data. 304 // childview exposes accessibility data.
296 } 305 }
297 306
298 } // namespace tray 307 } // namespace tray
299 } // namespace ash 308 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ash_strings.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698