| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/system/palette/palette_tray.h" | 5 #include "ash/system/palette/palette_tray.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_controller.h" |
| 8 #include "ash/accessibility_delegate.h" |
| 7 #include "ash/resources/vector_icons/vector_icons.h" | 9 #include "ash/resources/vector_icons/vector_icons.h" |
| 8 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| 9 #include "ash/session/session_controller.h" | 11 #include "ash/session/session_controller.h" |
| 10 #include "ash/shelf/shelf.h" | 12 #include "ash/shelf/shelf.h" |
| 11 #include "ash/shelf/shelf_constants.h" | 13 #include "ash/shelf/shelf_constants.h" |
| 12 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 13 #include "ash/strings/grit/ash_strings.h" | 15 #include "ash/strings/grit/ash_strings.h" |
| 14 #include "ash/system/palette/palette_tool_manager.h" | 16 #include "ash/system/palette/palette_tool_manager.h" |
| 15 #include "ash/system/palette/palette_utils.h" | 17 #include "ash/system/palette/palette_utils.h" |
| 16 #include "ash/system/tray/system_menu_button.h" | 18 #include "ash/system/tray/system_menu_button.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 150 |
| 149 tray_container()->SetMargin(kTrayIconMainAxisInset, kTrayIconCrossAxisInset); | 151 tray_container()->SetMargin(kTrayIconMainAxisInset, kTrayIconCrossAxisInset); |
| 150 tray_container()->AddChildView(icon_); | 152 tray_container()->AddChildView(icon_); |
| 151 | 153 |
| 152 Shell::Get()->AddShellObserver(this); | 154 Shell::Get()->AddShellObserver(this); |
| 153 ui::InputDeviceManager::GetInstance()->AddObserver(this); | 155 ui::InputDeviceManager::GetInstance()->AddObserver(this); |
| 154 } | 156 } |
| 155 | 157 |
| 156 PaletteTray::~PaletteTray() { | 158 PaletteTray::~PaletteTray() { |
| 157 if (bubble_) | 159 if (bubble_) |
| 158 bubble_->bubble_view()->reset_delegate(); | 160 bubble_->bubble_view()->ResetDelegate(); |
| 159 | 161 |
| 160 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); | 162 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); |
| 161 Shell::Get()->RemoveShellObserver(this); | 163 Shell::Get()->RemoveShellObserver(this); |
| 162 } | 164 } |
| 163 | 165 |
| 164 bool PaletteTray::PerformAction(const ui::Event& event) { | 166 bool PaletteTray::PerformAction(const ui::Event& event) { |
| 165 if (bubble_) { | 167 if (bubble_) { |
| 166 if (num_actions_in_bubble_ == 0) | 168 if (num_actions_in_bubble_ == 0) |
| 167 RecordPaletteOptionsUsage(PaletteTrayOptions::PALETTE_CLOSED_NO_ACTION); | 169 RecordPaletteOptionsUsage(PaletteTrayOptions::PALETTE_CLOSED_NO_ACTION); |
| 168 HidePalette(); | 170 HidePalette(); |
| 169 return true; | 171 return true; |
| 170 } | 172 } |
| 171 | 173 |
| 172 return ShowPalette(); | 174 return ShowPalette(); |
| 173 } | 175 } |
| 174 | 176 |
| 175 bool PaletteTray::ShowPalette() { | 177 bool PaletteTray::ShowPalette() { |
| 176 if (bubble_) | 178 if (bubble_) |
| 177 return false; | 179 return false; |
| 178 | 180 |
| 179 DCHECK(tray_container()); | 181 DCHECK(tray_container()); |
| 180 | 182 |
| 181 views::TrayBubbleView::InitParams init_params; | 183 views::TrayBubbleView::InitParams init_params; |
| 182 init_params.delegate = this; | 184 init_params.delegate = this; |
| 183 init_params.parent_window = GetBubbleWindowContainer(); | 185 init_params.parent_window = GetBubbleWindowContainer(); |
| 184 init_params.anchor_view = GetBubbleAnchor(); | 186 init_params.anchor_view = GetBubbleAnchor(); |
| 185 init_params.anchor_alignment = GetAnchorAlignment(); | 187 init_params.anchor_alignment = GetAnchorAlignment(); |
| 186 init_params.min_width = kPaletteWidth; | 188 init_params.min_width = kPaletteWidth; |
| 187 init_params.max_width = kPaletteWidth; | 189 init_params.max_width = kPaletteWidth; |
| 188 init_params.can_activate = true; | |
| 189 init_params.close_on_deactivate = true; | 190 init_params.close_on_deactivate = true; |
| 190 | 191 |
| 191 // TODO(tdanderson): Refactor into common row layout code. | 192 // TODO(tdanderson): Refactor into common row layout code. |
| 192 // TODO(tdanderson|jdufault): Add material design ripple effects to the menu | 193 // TODO(tdanderson|jdufault): Add material design ripple effects to the menu |
| 193 // rows. | 194 // rows. |
| 194 | 195 |
| 195 // Create and customize bubble view. | 196 // Create and customize bubble view. |
| 196 views::TrayBubbleView* bubble_view = new views::TrayBubbleView(init_params); | 197 views::TrayBubbleView* bubble_view = new views::TrayBubbleView(init_params); |
| 197 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); | 198 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); |
| 198 bubble_view->set_margins( | 199 bubble_view->set_margins( |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 293 |
| 293 void PaletteTray::BubbleViewDestroyed() { | 294 void PaletteTray::BubbleViewDestroyed() { |
| 294 palette_tool_manager_->NotifyViewsDestroyed(); | 295 palette_tool_manager_->NotifyViewsDestroyed(); |
| 295 SetIsActive(false); | 296 SetIsActive(false); |
| 296 } | 297 } |
| 297 | 298 |
| 298 void PaletteTray::OnMouseEnteredView() {} | 299 void PaletteTray::OnMouseEnteredView() {} |
| 299 | 300 |
| 300 void PaletteTray::OnMouseExitedView() {} | 301 void PaletteTray::OnMouseExitedView() {} |
| 301 | 302 |
| 303 void PaletteTray::RegisterAccelerators( |
| 304 const std::vector<ui::Accelerator>& accelerators, |
| 305 views::TrayBubbleView* tray_bubble_view) { |
| 306 Shell::Get()->accelerator_controller()->Register(accelerators, |
| 307 tray_bubble_view); |
| 308 } |
| 309 |
| 310 void PaletteTray::UnregisterAllAccelerators( |
| 311 views::TrayBubbleView* tray_bubble_view) { |
| 312 Shell::Get()->accelerator_controller()->UnregisterAll(tray_bubble_view); |
| 313 } |
| 314 |
| 302 base::string16 PaletteTray::GetAccessibleNameForBubble() { | 315 base::string16 PaletteTray::GetAccessibleNameForBubble() { |
| 303 return GetAccessibleNameForTray(); | 316 return GetAccessibleNameForTray(); |
| 304 } | 317 } |
| 305 | 318 |
| 319 bool PaletteTray::ShouldEnableExtraKeyboardAccessibility() { |
| 320 return Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); |
| 321 } |
| 322 |
| 306 void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) { | 323 void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
| 307 HideBubbleWithView(bubble_view); | 324 HideBubbleWithView(bubble_view); |
| 308 } | 325 } |
| 309 | 326 |
| 310 void PaletteTray::HidePalette() { | 327 void PaletteTray::HidePalette() { |
| 311 is_bubble_auto_opened_ = false; | 328 is_bubble_auto_opened_ = false; |
| 312 num_actions_in_bubble_ = 0; | 329 num_actions_in_bubble_ = 0; |
| 313 bubble_.reset(); | 330 bubble_.reset(); |
| 314 | 331 |
| 315 shelf()->UpdateAutoHideState(); | 332 shelf()->UpdateAutoHideState(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 UpdateIconVisibility(); | 402 UpdateIconVisibility(); |
| 386 } | 403 } |
| 387 } | 404 } |
| 388 | 405 |
| 389 void PaletteTray::UpdateIconVisibility() { | 406 void PaletteTray::UpdateIconVisibility() { |
| 390 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && | 407 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && |
| 391 ShouldShowOnDisplay(this) && IsInUserSession()); | 408 ShouldShowOnDisplay(this) && IsInUserSession()); |
| 392 } | 409 } |
| 393 | 410 |
| 394 } // namespace ash | 411 } // namespace ash |
| OLD | NEW |