| OLD | NEW |
| 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 "ash/resources/vector_icons/vector_icons.h" | 16 #include "ash/resources/vector_icons/vector_icons.h" |
| 17 #include "grit/ash_resources.h" | 17 #include "grit/ash_resources.h" |
| 18 #include "grit/ash_strings.h" | 18 #include "grit/ash_strings.h" |
| 19 #include "ui/accessibility/ax_view_state.h" | 19 #include "ui/accessibility/ax_node_data.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
| 22 #include "ui/gfx/image/image_skia_operations.h" | 22 #include "ui/gfx/image/image_skia_operations.h" |
| 23 #include "ui/gfx/paint_vector_icon.h" | 23 #include "ui/gfx/paint_vector_icon.h" |
| 24 #include "ui/gfx/vector_icon_types.h" | 24 #include "ui/gfx/vector_icon_types.h" |
| 25 #include "ui/views/background.h" | 25 #include "ui/views/background.h" |
| 26 #include "ui/views/border.h" | 26 #include "ui/views/border.h" |
| 27 #include "ui/views/controls/button/image_button.h" | 27 #include "ui/views/controls/button/image_button.h" |
| 28 #include "ui/views/controls/image_view.h" | 28 #include "ui/views/controls/image_view.h" |
| 29 #include "ui/views/controls/separator.h" | 29 #include "ui/views/controls/separator.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 108 } |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 // views::View: | 111 // views::View: |
| 112 gfx::Size GetPreferredSize() const override { | 112 gfx::Size GetPreferredSize() const override { |
| 113 gfx::Size size = views::ToggleImageButton::GetPreferredSize(); | 113 gfx::Size size = views::ToggleImageButton::GetPreferredSize(); |
| 114 size.set_height(GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); | 114 size.set_height(GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); |
| 115 return size; | 115 return size; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void GetAccessibleState(ui::AXViewState* state) override { | 118 void GetAccessibleNodeData(ui::AXNodeData* node_data) override { |
| 119 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 119 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 120 state->name = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_VOLUME_MUTE); | 120 node_data->SetName( |
| 121 state->role = ui::AX_ROLE_TOGGLE_BUTTON; | 121 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_VOLUME_MUTE)); |
| 122 node_data->role = ui::AX_ROLE_TOGGLE_BUTTON; |
| 122 if (audio_delegate_->IsOutputAudioMuted()) | 123 if (audio_delegate_->IsOutputAudioMuted()) |
| 123 state->AddStateFlag(ui::AX_STATE_PRESSED); | 124 node_data->AddStateFlag(ui::AX_STATE_PRESSED); |
| 124 } | 125 } |
| 125 | 126 |
| 126 // views::CustomButton: | 127 // views::CustomButton: |
| 127 void StateChanged() override { | 128 void StateChanged() override { |
| 128 if (state() == STATE_HOVERED || state() == STATE_PRESSED) { | 129 if (state() == STATE_HOVERED || state() == STATE_PRESSED) { |
| 129 set_background( | 130 set_background( |
| 130 views::Background::CreateSolidBackground(kHoverBackgroundColor)); | 131 views::Background::CreateSolidBackground(kHoverBackgroundColor)); |
| 131 } else { | 132 } else { |
| 132 set_background(nullptr); | 133 set_background(nullptr); |
| 133 } | 134 } |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 return true; | 339 return true; |
| 339 } | 340 } |
| 340 | 341 |
| 341 void VolumeView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 342 void VolumeView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 342 // Separator's prefered size is based on set bounds. When an empty bounds is | 343 // Separator's prefered size is based on set bounds. When an empty bounds is |
| 343 // set on first layout this causes BoxLayout to ignore the separator. Reset | 344 // set on first layout this causes BoxLayout to ignore the separator. Reset |
| 344 // its height on each bounds change so that it is laid out properly. | 345 // its height on each bounds change so that it is laid out properly. |
| 345 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height())); | 346 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height())); |
| 346 } | 347 } |
| 347 | 348 |
| 348 void VolumeView::GetAccessibleState(ui::AXViewState* state) { | 349 void VolumeView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 349 // Intentionally overrides ActionableView, leaving |state| unset. A slider | 350 // Intentionally overrides ActionableView, leaving |state| unset. A slider |
| 350 // childview exposes accessibility data. | 351 // childview exposes accessibility data. |
| 351 } | 352 } |
| 352 | 353 |
| 353 } // namespace tray | 354 } // namespace tray |
| 354 } // namespace ash | 355 } // namespace ash |
| OLD | NEW |