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::GetInstance()->ToggleOverview(); | 200 athena::WindowManager::Get()->ToggleOverview(); |
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 14 matching lines...) Expand all Loading... |
225 HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder) | 225 HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder) |
226 : model_builder_(model_builder), | 226 : model_builder_(model_builder), |
227 state_(HIDDEN), | 227 state_(HIDDEN), |
228 original_state_(VISIBLE_MINIMIZED), | 228 original_state_(VISIBLE_MINIMIZED), |
229 home_card_widget_(NULL), | 229 home_card_widget_(NULL), |
230 home_card_view_(NULL), | 230 home_card_view_(NULL), |
231 layout_manager_(NULL), | 231 layout_manager_(NULL), |
232 activation_client_(NULL) { | 232 activation_client_(NULL) { |
233 DCHECK(!instance); | 233 DCHECK(!instance); |
234 instance = this; | 234 instance = this; |
235 WindowManager::GetInstance()->AddObserver(this); | 235 WindowManager::Get()->AddObserver(this); |
236 } | 236 } |
237 | 237 |
238 HomeCardImpl::~HomeCardImpl() { | 238 HomeCardImpl::~HomeCardImpl() { |
239 DCHECK(instance); | 239 DCHECK(instance); |
240 WindowManager::GetInstance()->RemoveObserver(this); | 240 WindowManager::Get()->RemoveObserver(this); |
241 if (activation_client_) | 241 if (activation_client_) |
242 activation_client_->RemoveObserver(this); | 242 activation_client_->RemoveObserver(this); |
243 home_card_widget_->CloseNow(); | 243 home_card_widget_->CloseNow(); |
244 | 244 |
245 // Reset the view delegate first as it access search provider during | 245 // Reset the view delegate first as it access search provider during |
246 // shutdown. | 246 // shutdown. |
247 view_delegate_.reset(); | 247 view_delegate_.reset(); |
248 search_provider_.reset(); | 248 search_provider_.reset(); |
249 instance = NULL; | 249 instance = NULL; |
250 } | 250 } |
(...skipping 121 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::GetInstance()->ToggleOverview(); | 382 WindowManager::Get()->ToggleOverview(); |
383 } else { | 383 } else { |
384 state_ = final_state; | 384 state_ = final_state; |
385 // When the animation happens after a fling, EASE_IN_OUT would cause weird | 385 // 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 | 386 // slow-down right after the finger release because of slow-in. Therefore |
387 // EASE_OUT is better. | 387 // EASE_OUT is better. |
388 gfx::Tween::Type tween_type = | 388 gfx::Tween::Type tween_type = |
389 is_fling ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN_OUT; | 389 is_fling ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN_OUT; |
390 home_card_view_->SetStateWithAnimation(state_, tween_type); | 390 home_card_view_->SetStateWithAnimation(state_, tween_type); |
391 layout_manager_->Layout(true, tween_type); | 391 layout_manager_->Layout(true, tween_type); |
392 } | 392 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 instance = NULL; | 450 instance = NULL; |
451 } | 451 } |
452 | 452 |
453 // static | 453 // static |
454 HomeCard* HomeCard::Get() { | 454 HomeCard* HomeCard::Get() { |
455 DCHECK(instance); | 455 DCHECK(instance); |
456 return instance; | 456 return instance; |
457 } | 457 } |
458 | 458 |
459 } // namespace athena | 459 } // namespace athena |
OLD | NEW |