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 "athena/home/home_card_impl.h" | 5 #include "athena/home/home_card_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "athena/env/public/athena_env.h" | 10 #include "athena/env/public/athena_env.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 gesture_delegate_, | 190 gesture_delegate_, |
191 GetWidget()->GetNativeWindow()->GetRootWindow()->bounds())); | 191 GetWidget()->GetNativeWindow()->GetRootWindow()->bounds())); |
192 } | 192 } |
193 | 193 |
194 if (gesture_manager_) | 194 if (gesture_manager_) |
195 gesture_manager_->ProcessGestureEvent(event); | 195 gesture_manager_->ProcessGestureEvent(event); |
196 } | 196 } |
197 virtual bool OnMousePressed(const ui::MouseEvent& event) override { | 197 virtual bool OnMousePressed(const ui::MouseEvent& event) override { |
198 if (HomeCard::Get()->GetState() == HomeCard::VISIBLE_MINIMIZED && | 198 if (HomeCard::Get()->GetState() == HomeCard::VISIBLE_MINIMIZED && |
199 event.IsLeftMouseButton() && event.GetClickCount() == 1) { | 199 event.IsLeftMouseButton() && event.GetClickCount() == 1) { |
200 athena::WindowManager::Get()->ToggleOverview(); | 200 athena::WindowManager::Get()->EnterOverview(); |
201 return true; | 201 return true; |
202 } | 202 } |
203 return false; | 203 return false; |
204 } | 204 } |
205 | 205 |
206 private: | 206 private: |
207 void UpdateShadow(bool should_show) { | 207 void UpdateShadow(bool should_show) { |
208 wm::SetShadowType( | 208 wm::SetShadowType( |
209 GetWidget()->GetNativeWindow(), | 209 GetWidget()->GetNativeWindow(), |
210 should_show ? wm::SHADOW_TYPE_RECTANGULAR : wm::SHADOW_TYPE_NONE); | 210 should_show ? wm::SHADOW_TYPE_RECTANGULAR : wm::SHADOW_TYPE_NONE); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 else if (state_ == VISIBLE_MINIMIZED) | 372 else if (state_ == VISIBLE_MINIMIZED) |
373 SetState(VISIBLE_CENTERED); | 373 SetState(VISIBLE_CENTERED); |
374 return true; | 374 return true; |
375 } | 375 } |
376 | 376 |
377 void HomeCardImpl::OnGestureEnded(State final_state, bool is_fling) { | 377 void HomeCardImpl::OnGestureEnded(State final_state, bool is_fling) { |
378 home_card_view_->ClearGesture(); | 378 home_card_view_->ClearGesture(); |
379 if (state_ != final_state && | 379 if (state_ != final_state && |
380 (state_ == VISIBLE_MINIMIZED || final_state == VISIBLE_MINIMIZED)) { | 380 (state_ == VISIBLE_MINIMIZED || final_state == VISIBLE_MINIMIZED)) { |
381 SetState(final_state); | 381 SetState(final_state); |
382 WindowManager::Get()->ToggleOverview(); | 382 if (WindowManager::Get()->IsOverviewModeActive()) |
| 383 WindowManager::Get()->ExitOverview(); |
| 384 else |
| 385 WindowManager::Get()->EnterOverview(); |
383 } else { | 386 } else { |
384 state_ = final_state; | 387 state_ = final_state; |
385 // When the animation happens after a fling, EASE_IN_OUT would cause weird | 388 // When the animation happens after a fling, EASE_IN_OUT would cause weird |
386 // slow-down right after the finger release because of slow-in. Therefore | 389 // slow-down right after the finger release because of slow-in. Therefore |
387 // EASE_OUT is better. | 390 // EASE_OUT is better. |
388 gfx::Tween::Type tween_type = | 391 gfx::Tween::Type tween_type = |
389 is_fling ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN_OUT; | 392 is_fling ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN_OUT; |
390 home_card_view_->SetStateWithAnimation(state_, tween_type); | 393 home_card_view_->SetStateWithAnimation(state_, tween_type); |
391 layout_manager_->Layout(true, tween_type); | 394 layout_manager_->Layout(true, tween_type); |
392 } | 395 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 instance = NULL; | 453 instance = NULL; |
451 } | 454 } |
452 | 455 |
453 // static | 456 // static |
454 HomeCard* HomeCard::Get() { | 457 HomeCard* HomeCard::Get() { |
455 DCHECK(instance); | 458 DCHECK(instance); |
456 return instance; | 459 return instance; |
457 } | 460 } |
458 | 461 |
459 } // namespace athena | 462 } // namespace athena |
OLD | NEW |