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/wm/shelf_layout_manager.h" | 5 #include "ash/wm/shelf_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // Notifies ShelfLayoutManager any time the mouse moves. | 67 // Notifies ShelfLayoutManager any time the mouse moves. |
68 class ShelfLayoutManager::AutoHideEventFilter : public ui::EventHandler { | 68 class ShelfLayoutManager::AutoHideEventFilter : public ui::EventHandler { |
69 public: | 69 public: |
70 explicit AutoHideEventFilter(ShelfLayoutManager* shelf); | 70 explicit AutoHideEventFilter(ShelfLayoutManager* shelf); |
71 virtual ~AutoHideEventFilter(); | 71 virtual ~AutoHideEventFilter(); |
72 | 72 |
73 // Returns true if the last mouse event was a mouse drag. | 73 // Returns true if the last mouse event was a mouse drag. |
74 bool in_mouse_drag() const { return in_mouse_drag_; } | 74 bool in_mouse_drag() const { return in_mouse_drag_; } |
75 | 75 |
76 // Overridden from ui::EventHandler: | 76 // Overridden from ui::EventHandler: |
77 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 77 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
78 | 78 |
79 private: | 79 private: |
80 ShelfLayoutManager* shelf_; | 80 ShelfLayoutManager* shelf_; |
81 bool in_mouse_drag_; | 81 bool in_mouse_drag_; |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(AutoHideEventFilter); | 83 DISALLOW_COPY_AND_ASSIGN(AutoHideEventFilter); |
84 }; | 84 }; |
85 | 85 |
86 ShelfLayoutManager::AutoHideEventFilter::AutoHideEventFilter( | 86 ShelfLayoutManager::AutoHideEventFilter::AutoHideEventFilter( |
87 ShelfLayoutManager* shelf) | 87 ShelfLayoutManager* shelf) |
88 : shelf_(shelf), | 88 : shelf_(shelf), |
89 in_mouse_drag_(false) { | 89 in_mouse_drag_(false) { |
90 Shell::GetInstance()->AddPreTargetHandler(this); | 90 Shell::GetInstance()->AddPreTargetHandler(this); |
91 } | 91 } |
92 | 92 |
93 ShelfLayoutManager::AutoHideEventFilter::~AutoHideEventFilter() { | 93 ShelfLayoutManager::AutoHideEventFilter::~AutoHideEventFilter() { |
94 Shell::GetInstance()->RemovePreTargetHandler(this); | 94 Shell::GetInstance()->RemovePreTargetHandler(this); |
95 } | 95 } |
96 | 96 |
97 ui::EventResult ShelfLayoutManager::AutoHideEventFilter::OnMouseEvent( | 97 void ShelfLayoutManager::AutoHideEventFilter::OnMouseEvent( |
98 ui::MouseEvent* event) { | 98 ui::MouseEvent* event) { |
99 // This also checks IsShelfWindow() to make sure we don't attempt to hide the | 99 // This also checks IsShelfWindow() to make sure we don't attempt to hide the |
100 // shelf if the mouse down occurs on the shelf. | 100 // shelf if the mouse down occurs on the shelf. |
101 in_mouse_drag_ = (event->type() == ui::ET_MOUSE_DRAGGED || | 101 in_mouse_drag_ = (event->type() == ui::ET_MOUSE_DRAGGED || |
102 (in_mouse_drag_ && event->type() != ui::ET_MOUSE_RELEASED && | 102 (in_mouse_drag_ && event->type() != ui::ET_MOUSE_RELEASED && |
103 event->type() != ui::ET_MOUSE_CAPTURE_CHANGED)) && | 103 event->type() != ui::ET_MOUSE_CAPTURE_CHANGED)) && |
104 !shelf_->IsShelfWindow(static_cast<aura::Window*>(event->target())); | 104 !shelf_->IsShelfWindow(static_cast<aura::Window*>(event->target())); |
105 if (event->type() == ui::ET_MOUSE_MOVED) | 105 if (event->type() == ui::ET_MOUSE_MOVED) |
106 shelf_->UpdateAutoHideState(); | 106 shelf_->UpdateAutoHideState(); |
107 return ui::ER_UNHANDLED; | 107 return; |
108 } | 108 } |
109 | 109 |
110 // ShelfLayoutManager:UpdateShelfObserver -------------------------------------- | 110 // ShelfLayoutManager:UpdateShelfObserver -------------------------------------- |
111 | 111 |
112 // UpdateShelfObserver is used to delay updating the background until the | 112 // UpdateShelfObserver is used to delay updating the background until the |
113 // animation completes. | 113 // animation completes. |
114 class ShelfLayoutManager::UpdateShelfObserver | 114 class ShelfLayoutManager::UpdateShelfObserver |
115 : public ui::ImplicitAnimationObserver { | 115 : public ui::ImplicitAnimationObserver { |
116 public: | 116 public: |
117 explicit UpdateShelfObserver(ShelfLayoutManager* shelf) : shelf_(shelf) { | 117 explicit UpdateShelfObserver(ShelfLayoutManager* shelf) : shelf_(shelf) { |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 893 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
894 if (state.visibility_state == SHELF_VISIBLE) | 894 if (state.visibility_state == SHELF_VISIBLE) |
895 return size; | 895 return size; |
896 if (state.visibility_state == SHELF_AUTO_HIDE) | 896 if (state.visibility_state == SHELF_AUTO_HIDE) |
897 return kAutoHideSize; | 897 return kAutoHideSize; |
898 return 0; | 898 return 0; |
899 } | 899 } |
900 | 900 |
901 } // namespace internal | 901 } // namespace internal |
902 } // namespace ash | 902 } // namespace ash |
OLD | NEW |