OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shelf/shelf_widget.h" | 5 #include "ash/shelf/shelf_widget.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/focus_cycler.h" | 8 #include "ash/focus_cycler.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/session/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 bool disable_dimming_animations_for_test); | 60 bool disable_dimming_animations_for_test); |
61 virtual ~DimmerView(); | 61 virtual ~DimmerView(); |
62 | 62 |
63 // Called by |DimmerEventFilter| when the mouse |hovered| state changes. | 63 // Called by |DimmerEventFilter| when the mouse |hovered| state changes. |
64 void SetHovered(bool hovered); | 64 void SetHovered(bool hovered); |
65 | 65 |
66 // Force the dimmer to be undimmed. | 66 // Force the dimmer to be undimmed. |
67 void ForceUndimming(bool force); | 67 void ForceUndimming(bool force); |
68 | 68 |
69 // views::WidgetDelegate overrides: | 69 // views::WidgetDelegate overrides: |
70 virtual views::Widget* GetWidget() OVERRIDE { | 70 virtual views::Widget* GetWidget() override { |
71 return View::GetWidget(); | 71 return View::GetWidget(); |
72 } | 72 } |
73 virtual const views::Widget* GetWidget() const OVERRIDE { | 73 virtual const views::Widget* GetWidget() const override { |
74 return View::GetWidget(); | 74 return View::GetWidget(); |
75 } | 75 } |
76 | 76 |
77 // ash::BackgroundAnimatorDelegate overrides: | 77 // ash::BackgroundAnimatorDelegate overrides: |
78 virtual void UpdateBackground(int alpha) OVERRIDE { | 78 virtual void UpdateBackground(int alpha) override { |
79 alpha_ = alpha; | 79 alpha_ = alpha; |
80 SchedulePaint(); | 80 SchedulePaint(); |
81 } | 81 } |
82 | 82 |
83 // views::View overrides: | 83 // views::View overrides: |
84 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; | 84 virtual void OnPaintBackground(gfx::Canvas* canvas) override; |
85 | 85 |
86 // A function to test the current alpha used. | 86 // A function to test the current alpha used. |
87 int get_dimming_alpha_for_test() { return alpha_; } | 87 int get_dimming_alpha_for_test() { return alpha_; } |
88 | 88 |
89 private: | 89 private: |
90 // This class monitors mouse events to see if it is on top of the shelf. | 90 // This class monitors mouse events to see if it is on top of the shelf. |
91 class DimmerEventFilter : public ui::EventHandler { | 91 class DimmerEventFilter : public ui::EventHandler { |
92 public: | 92 public: |
93 explicit DimmerEventFilter(DimmerView* owner); | 93 explicit DimmerEventFilter(DimmerView* owner); |
94 virtual ~DimmerEventFilter(); | 94 virtual ~DimmerEventFilter(); |
95 | 95 |
96 // Overridden from ui::EventHandler: | 96 // Overridden from ui::EventHandler: |
97 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 97 virtual void OnMouseEvent(ui::MouseEvent* event) override; |
98 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | 98 virtual void OnTouchEvent(ui::TouchEvent* event) override; |
99 | 99 |
100 private: | 100 private: |
101 // The owning class. | 101 // The owning class. |
102 DimmerView* owner_; | 102 DimmerView* owner_; |
103 | 103 |
104 // TRUE if the mouse is inside the shelf. | 104 // TRUE if the mouse is inside the shelf. |
105 bool mouse_inside_; | 105 bool mouse_inside_; |
106 | 106 |
107 // TRUE if a touch event is inside the shelf. | 107 // TRUE if a touch event is inside the shelf. |
108 bool touch_inside_; | 108 bool touch_inside_; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 case ash::SHELF_ALIGNMENT_RIGHT: | 267 case ash::SHELF_ALIGNMENT_RIGHT: |
268 return gfx::Insets(0, distance, 0, 0); | 268 return gfx::Insets(0, distance, 0, 0); |
269 case ash::SHELF_ALIGNMENT_TOP: | 269 case ash::SHELF_ALIGNMENT_TOP: |
270 return gfx::Insets(0, 0, distance, 0); | 270 return gfx::Insets(0, 0, distance, 0); |
271 } | 271 } |
272 NOTREACHED(); | 272 NOTREACHED(); |
273 return gfx::Insets(); | 273 return gfx::Insets(); |
274 } | 274 } |
275 | 275 |
276 // ash::ShelfLayoutManagerObserver: | 276 // ash::ShelfLayoutManagerObserver: |
277 virtual void WillDeleteShelf() OVERRIDE { | 277 virtual void WillDeleteShelf() override { |
278 shelf_ = NULL; | 278 shelf_ = NULL; |
279 } | 279 } |
280 | 280 |
281 virtual void WillChangeVisibilityState( | 281 virtual void WillChangeVisibilityState( |
282 ash::ShelfVisibilityState new_state) OVERRIDE { | 282 ash::ShelfVisibilityState new_state) override { |
283 gfx::Insets mouse_insets; | 283 gfx::Insets mouse_insets; |
284 gfx::Insets touch_insets; | 284 gfx::Insets touch_insets; |
285 if (new_state == ash::SHELF_VISIBLE) { | 285 if (new_state == ash::SHELF_VISIBLE) { |
286 // Let clicks at the very top of the shelf through so windows can be | 286 // Let clicks at the very top of the shelf through so windows can be |
287 // resized with the bottom-right corner and bottom edge. | 287 // resized with the bottom-right corner and bottom edge. |
288 mouse_insets = GetInsetsForAlignment( | 288 mouse_insets = GetInsetsForAlignment( |
289 ShelfLayoutManager::kWorkspaceAreaVisibleInset, | 289 ShelfLayoutManager::kWorkspaceAreaVisibleInset, |
290 shelf_->GetAlignment()); | 290 shelf_->GetAlignment()); |
291 } else if (new_state == ash::SHELF_AUTO_HIDE) { | 291 } else if (new_state == ash::SHELF_AUTO_HIDE) { |
292 // Extend the touch hit target out a bit to allow users to drag shelf out | 292 // Extend the touch hit target out a bit to allow users to drag shelf out |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 ui::Layer* opaque_background() { return &opaque_background_; } | 327 ui::Layer* opaque_background() { return &opaque_background_; } |
328 ui::Layer* opaque_foreground() { return &opaque_foreground_; } | 328 ui::Layer* opaque_foreground() { return &opaque_foreground_; } |
329 | 329 |
330 // Set if the shelf area is dimmed (eg when a window is maximized). | 330 // Set if the shelf area is dimmed (eg when a window is maximized). |
331 void SetDimmed(bool dimmed); | 331 void SetDimmed(bool dimmed); |
332 bool GetDimmed() const; | 332 bool GetDimmed() const; |
333 | 333 |
334 void SetParentLayer(ui::Layer* layer); | 334 void SetParentLayer(ui::Layer* layer); |
335 | 335 |
336 // views::View overrides: | 336 // views::View overrides: |
337 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; | 337 virtual void OnPaintBackground(gfx::Canvas* canvas) override; |
338 | 338 |
339 // views::WidgetDelegateView overrides: | 339 // views::WidgetDelegateView overrides: |
340 virtual views::Widget* GetWidget() OVERRIDE { | 340 virtual views::Widget* GetWidget() override { |
341 return View::GetWidget(); | 341 return View::GetWidget(); |
342 } | 342 } |
343 virtual const views::Widget* GetWidget() const OVERRIDE { | 343 virtual const views::Widget* GetWidget() const override { |
344 return View::GetWidget(); | 344 return View::GetWidget(); |
345 } | 345 } |
346 | 346 |
347 virtual bool CanActivate() const OVERRIDE; | 347 virtual bool CanActivate() const override; |
348 virtual void Layout() OVERRIDE; | 348 virtual void Layout() override; |
349 virtual void ReorderChildLayers(ui::Layer* parent_layer) OVERRIDE; | 349 virtual void ReorderChildLayers(ui::Layer* parent_layer) override; |
350 // This will be called when the parent local bounds change. | 350 // This will be called when the parent local bounds change. |
351 virtual void OnBoundsChanged(const gfx::Rect& old_bounds) OVERRIDE; | 351 virtual void OnBoundsChanged(const gfx::Rect& old_bounds) override; |
352 | 352 |
353 // aura::WindowObserver overrides: | 353 // aura::WindowObserver overrides: |
354 // This will be called when the shelf itself changes its absolute position. | 354 // This will be called when the shelf itself changes its absolute position. |
355 // Since the |dimmer_| panel needs to be placed in screen coordinates it needs | 355 // Since the |dimmer_| panel needs to be placed in screen coordinates it needs |
356 // to be repositioned. The difference to the OnBoundsChanged call above is | 356 // to be repositioned. The difference to the OnBoundsChanged call above is |
357 // that this gets also triggered when the shelf only moves. | 357 // that this gets also triggered when the shelf only moves. |
358 virtual void OnWindowBoundsChanged(aura::Window* window, | 358 virtual void OnWindowBoundsChanged(aura::Window* window, |
359 const gfx::Rect& old_bounds, | 359 const gfx::Rect& old_bounds, |
360 const gfx::Rect& new_bounds) OVERRIDE; | 360 const gfx::Rect& new_bounds) override; |
361 | 361 |
362 // BackgroundAnimatorDelegate overrides: | 362 // BackgroundAnimatorDelegate overrides: |
363 virtual void UpdateBackground(int alpha) OVERRIDE; | 363 virtual void UpdateBackground(int alpha) override; |
364 | 364 |
365 // Force the shelf to be presented in an undimmed state. | 365 // Force the shelf to be presented in an undimmed state. |
366 void ForceUndimming(bool force); | 366 void ForceUndimming(bool force); |
367 | 367 |
368 // A function to test the current alpha used by the dimming bar. If there is | 368 // A function to test the current alpha used by the dimming bar. If there is |
369 // no dimmer active, the function will return -1. | 369 // no dimmer active, the function will return -1. |
370 int GetDimmingAlphaForTest(); | 370 int GetDimmingAlphaForTest(); |
371 | 371 |
372 // A function to test the bounds of the dimming bar. Returns gfx::Rect() if | 372 // A function to test the bounds of the dimming bar. Returns gfx::Rect() if |
373 // the dimmer is inactive. | 373 // the dimmer is inactive. |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 DCHECK(delegate_view_); | 839 DCHECK(delegate_view_); |
840 return delegate_view_->disable_dimming_animations_for_test(); | 840 return delegate_view_->disable_dimming_animations_for_test(); |
841 } | 841 } |
842 | 842 |
843 void ShelfWidget::WillDeleteShelf() { | 843 void ShelfWidget::WillDeleteShelf() { |
844 shelf_layout_manager_->RemoveObserver(this); | 844 shelf_layout_manager_->RemoveObserver(this); |
845 shelf_layout_manager_ = NULL; | 845 shelf_layout_manager_ = NULL; |
846 } | 846 } |
847 | 847 |
848 } // namespace ash | 848 } // namespace ash |
OLD | NEW |