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