| 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" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 device_type_(NULL), | 151 device_type_(NULL), |
| 152 more_(NULL), | 152 more_(NULL), |
| 153 is_default_view_(is_default_view) { | 153 is_default_view_(is_default_view) { |
| 154 SetFocusBehavior(FocusBehavior::NEVER); | 154 SetFocusBehavior(FocusBehavior::NEVER); |
| 155 views::BoxLayout* box_layout = new views::BoxLayout( | 155 views::BoxLayout* box_layout = new views::BoxLayout( |
| 156 views::BoxLayout::kHorizontal, 0, 0, kBoxLayoutPadding); | 156 views::BoxLayout::kHorizontal, 0, 0, kBoxLayoutPadding); |
| 157 box_layout->SetDefaultFlex(0); | 157 box_layout->SetDefaultFlex(0); |
| 158 SetLayoutManager(box_layout); | 158 SetLayoutManager(box_layout); |
| 159 | 159 |
| 160 icon_ = new VolumeButton(this, audio_delegate_); | 160 icon_ = new VolumeButton(this, audio_delegate_); |
| 161 icon_->SetBorder(views::Border::CreateEmptyBorder( | 161 icon_->SetBorder(views::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 0, |
| 162 0, kTrayPopupPaddingHorizontal, 0, kExtraPaddingBetweenIconAndSlider)); | 162 kExtraPaddingBetweenIconAndSlider)); |
| 163 AddChildView(icon_); | 163 AddChildView(icon_); |
| 164 slider_ = views::Slider::CreateSlider( | 164 slider_ = views::Slider::CreateSlider( |
| 165 ash::MaterialDesignController::IsSystemTrayMenuMaterial(), this); | 165 ash::MaterialDesignController::IsSystemTrayMenuMaterial(), this); |
| 166 | 166 |
| 167 if (ash::MaterialDesignController::IsSystemTrayMenuMaterial()) { | 167 if (ash::MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 168 slider_->SetBorder(views::Border::CreateEmptyBorder( | 168 slider_->SetBorder(views::CreateEmptyBorder( |
| 169 gfx::Insets(0, kTrayPopupSliderPaddingMD) + slider_->GetInsets())); | 169 gfx::Insets(0, kTrayPopupSliderPaddingMD) + slider_->GetInsets())); |
| 170 } else { | 170 } else { |
| 171 slider_->SetBorder(views::Border::CreateEmptyBorder( | 171 slider_->SetBorder( |
| 172 0, 0, 0, kTrayPopupPaddingBetweenItems)); | 172 views::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems)); |
| 173 } | 173 } |
| 174 | 174 |
| 175 slider_->set_focus_border_color(kFocusBorderColor); | 175 slider_->set_focus_border_color(kFocusBorderColor); |
| 176 slider_->SetValue( | 176 slider_->SetValue( |
| 177 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f); | 177 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f); |
| 178 slider_->SetAccessibleName( | 178 slider_->SetAccessibleName( |
| 179 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( | 179 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( |
| 180 IDS_ASH_STATUS_TRAY_VOLUME)); | 180 IDS_ASH_STATUS_TRAY_VOLUME)); |
| 181 AddChildView(slider_); | 181 AddChildView(slider_); |
| 182 box_layout->SetFlexForView(slider_, 1); | 182 box_layout->SetFlexForView(slider_, 1); |
| 183 | 183 |
| 184 separator_ = new views::Separator(views::Separator::VERTICAL); | 184 separator_ = new views::Separator(views::Separator::VERTICAL); |
| 185 separator_->SetColor(kButtonStrokeColor); | 185 separator_->SetColor(kButtonStrokeColor); |
| 186 separator_->SetPreferredSize(kSeparatorSize); | 186 separator_->SetPreferredSize(kSeparatorSize); |
| 187 separator_->SetBorder(views::Border::CreateEmptyBorder( | 187 separator_->SetBorder(views::CreateEmptyBorder( |
| 188 kSeparatorVerticalInset, 0, kSeparatorVerticalInset, kBoxLayoutPadding)); | 188 kSeparatorVerticalInset, 0, kSeparatorVerticalInset, kBoxLayoutPadding)); |
| 189 | 189 |
| 190 more_region_ = new TrayPopupItemContainer(separator_, true); | 190 more_region_ = new TrayPopupItemContainer(separator_, true); |
| 191 more_region_->SetBorder( | 191 more_region_->SetBorder( |
| 192 views::Border::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems)); | 192 views::CreateEmptyBorder(0, 0, 0, kTrayPopupPaddingBetweenItems)); |
| 193 AddChildView(more_region_); | 193 AddChildView(more_region_); |
| 194 | 194 |
| 195 device_type_ = new views::ImageView; | 195 device_type_ = new views::ImageView; |
| 196 more_region_->AddChildView(device_type_); | 196 more_region_->AddChildView(device_type_); |
| 197 | 197 |
| 198 more_ = new views::ImageView; | 198 more_ = new views::ImageView; |
| 199 more_->EnableCanvasFlippingForRTLUI(true); | 199 more_->EnableCanvasFlippingForRTLUI(true); |
| 200 | 200 |
| 201 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 201 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 202 more_->SetImage( | 202 more_->SetImage( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // did not change. In that case, setting the value of the slider won't | 235 // did not change. In that case, setting the value of the slider won't |
| 236 // trigger an update. So explicitly trigger an update. | 236 // trigger an update. So explicitly trigger an update. |
| 237 Update(); | 237 Update(); |
| 238 slider_->set_enable_accessibility_events(true); | 238 slider_->set_enable_accessibility_events(true); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void VolumeView::UpdateDeviceTypeAndMore() { | 241 void VolumeView::UpdateDeviceTypeAndMore() { |
| 242 bool show_more = is_default_view_ && TrayAudio::ShowAudioDeviceMenu() && | 242 bool show_more = is_default_view_ && TrayAudio::ShowAudioDeviceMenu() && |
| 243 audio_delegate_->HasAlternativeSources(); | 243 audio_delegate_->HasAlternativeSources(); |
| 244 if (!ash::MaterialDesignController::IsSystemTrayMenuMaterial()) { | 244 if (!ash::MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 245 slider_->SetBorder(views::Border::CreateEmptyBorder( | 245 slider_->SetBorder(views::CreateEmptyBorder( |
| 246 0, 0, 0, show_more ? kTrayPopupPaddingBetweenItems | 246 0, 0, 0, show_more ? kTrayPopupPaddingBetweenItems |
| 247 : kSliderRightPaddingToVolumeViewEdge)); | 247 : kSliderRightPaddingToVolumeViewEdge)); |
| 248 } | 248 } |
| 249 if (!show_more) { | 249 if (!show_more) { |
| 250 more_region_->SetVisible(false); | 250 more_region_->SetVisible(false); |
| 251 return; | 251 return; |
| 252 } | 252 } |
| 253 | 253 |
| 254 // Show output device icon if necessary. | 254 // Show output device icon if necessary. |
| 255 device_type_->SetVisible(false); | 255 device_type_->SetVisible(false); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height())); | 346 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height())); |
| 347 } | 347 } |
| 348 | 348 |
| 349 void VolumeView::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 349 void VolumeView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 350 // Intentionally overrides ActionableView, leaving |state| unset. A slider | 350 // Intentionally overrides ActionableView, leaving |state| unset. A slider |
| 351 // childview exposes accessibility data. | 351 // childview exposes accessibility data. |
| 352 } | 352 } |
| 353 | 353 |
| 354 } // namespace tray | 354 } // namespace tray |
| 355 } // namespace ash | 355 } // namespace ash |
| OLD | NEW |