| 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()->ActivateOverview(false); |
| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 360 } |
| 361 | 361 |
| 362 bool HomeCardImpl::IsCommandEnabled(int command_id) const { | 362 bool HomeCardImpl::IsCommandEnabled(int command_id) const { |
| 363 return true; | 363 return true; |
| 364 } | 364 } |
| 365 | 365 |
| 366 bool HomeCardImpl::OnAcceleratorFired(int command_id, | 366 bool HomeCardImpl::OnAcceleratorFired(int command_id, |
| 367 const ui::Accelerator& accelerator) { | 367 const ui::Accelerator& accelerator) { |
| 368 DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id); | 368 DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id); |
| 369 | 369 |
| 370 if (state_ == VISIBLE_CENTERED && original_state_ != VISIBLE_BOTTOM) | 370 if (state_ == VISIBLE_CENTERED && original_state_ != VISIBLE_BOTTOM) { |
| 371 SetState(VISIBLE_MINIMIZED); | 371 SetState(VISIBLE_MINIMIZED); |
| 372 else if (state_ == VISIBLE_MINIMIZED) | 372 WindowManager::Get()->ActivateOverview(false); |
| 373 } else if (state_ == VISIBLE_MINIMIZED) { |
| 373 SetState(VISIBLE_CENTERED); | 374 SetState(VISIBLE_CENTERED); |
| 375 WindowManager::Get()->ActivateOverview(true); |
| 376 } |
| 374 return true; | 377 return true; |
| 375 } | 378 } |
| 376 | 379 |
| 377 void HomeCardImpl::OnGestureEnded(State final_state, bool is_fling) { | 380 void HomeCardImpl::OnGestureEnded(State final_state, bool is_fling) { |
| 378 home_card_view_->ClearGesture(); | 381 home_card_view_->ClearGesture(); |
| 379 if (state_ != final_state && | 382 if (state_ != final_state && |
| 380 (state_ == VISIBLE_MINIMIZED || final_state == VISIBLE_MINIMIZED)) { | 383 (state_ == VISIBLE_MINIMIZED || final_state == VISIBLE_MINIMIZED)) { |
| 381 SetState(final_state); | 384 SetState(final_state); |
| 382 WindowManager::Get()->ToggleOverview(); | 385 WindowManager::Get()->ActivateOverview( |
| 386 !WindowManager::Get()->IsOverviewModeActive()); |
| 383 } else { | 387 } else { |
| 384 state_ = final_state; | 388 state_ = final_state; |
| 385 // When the animation happens after a fling, EASE_IN_OUT would cause weird | 389 // 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 | 390 // slow-down right after the finger release because of slow-in. Therefore |
| 387 // EASE_OUT is better. | 391 // EASE_OUT is better. |
| 388 gfx::Tween::Type tween_type = | 392 gfx::Tween::Type tween_type = |
| 389 is_fling ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN_OUT; | 393 is_fling ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN_OUT; |
| 390 home_card_view_->SetStateWithAnimation(state_, tween_type); | 394 home_card_view_->SetStateWithAnimation(state_, tween_type); |
| 391 layout_manager_->Layout(true, tween_type); | 395 layout_manager_->Layout(true, tween_type); |
| 392 } | 396 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 instance = NULL; | 454 instance = NULL; |
| 451 } | 455 } |
| 452 | 456 |
| 453 // static | 457 // static |
| 454 HomeCard* HomeCard::Get() { | 458 HomeCard* HomeCard::Get() { |
| 455 DCHECK(instance); | 459 DCHECK(instance); |
| 456 return instance; | 460 return instance; |
| 457 } | 461 } |
| 458 | 462 |
| 459 } // namespace athena | 463 } // namespace athena |
| OLD | NEW |