Chromium Code Reviews| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 scoped_ptr<HomeCardGestureManager> gesture_manager_; | 219 scoped_ptr<HomeCardGestureManager> gesture_manager_; |
| 220 HomeCardGestureManager::Delegate* gesture_delegate_; | 220 HomeCardGestureManager::Delegate* gesture_delegate_; |
| 221 | 221 |
| 222 DISALLOW_COPY_AND_ASSIGN(HomeCardView); | 222 DISALLOW_COPY_AND_ASSIGN(HomeCardView); |
| 223 }; | 223 }; |
| 224 | 224 |
| 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 overview_state_(VISIBLE_BOTTOM), | |
| 229 home_card_widget_(NULL), | 230 home_card_widget_(NULL), |
| 230 home_card_view_(NULL), | 231 home_card_view_(NULL), |
| 231 layout_manager_(NULL), | 232 layout_manager_(NULL), |
| 232 activation_client_(NULL) { | 233 activation_client_(NULL) { |
| 233 DCHECK(!instance); | 234 DCHECK(!instance); |
| 234 instance = this; | 235 instance = this; |
| 235 WindowManager::GetInstance()->AddObserver(this); | 236 WindowManager::GetInstance()->AddObserver(this); |
| 236 } | 237 } |
| 237 | 238 |
| 238 HomeCardImpl::~HomeCardImpl() { | 239 HomeCardImpl::~HomeCardImpl() { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 | 296 |
| 296 void HomeCardImpl::InstallAccelerators() { | 297 void HomeCardImpl::InstallAccelerators() { |
| 297 const AcceleratorData accelerator_data[] = { | 298 const AcceleratorData accelerator_data[] = { |
| 298 {TRIGGER_ON_PRESS, ui::VKEY_L, ui::EF_CONTROL_DOWN, | 299 {TRIGGER_ON_PRESS, ui::VKEY_L, ui::EF_CONTROL_DOWN, |
| 299 COMMAND_SHOW_HOME_CARD, AF_NONE}, | 300 COMMAND_SHOW_HOME_CARD, AF_NONE}, |
| 300 }; | 301 }; |
| 301 AcceleratorManager::Get()->RegisterAccelerators( | 302 AcceleratorManager::Get()->RegisterAccelerators( |
| 302 accelerator_data, arraysize(accelerator_data), this); | 303 accelerator_data, arraysize(accelerator_data), this); |
| 303 } | 304 } |
| 304 | 305 |
| 306 // Use when switching internally between "shown" and "not shown" so that | |
| 307 // we enter and exit overview mode appropriately | |
| 308 void HomeCardImpl::SetStateAndOverview(HomeCard::State state) { | |
|
Jun Mukai
2014/09/25 21:53:41
This method name is unclear. SetStateAndToggleOve
Greg Levin
2014/10/02 21:56:09
Done (mostly... see below)
| |
| 309 if (state_ == state) | |
| 310 return; | |
| 311 | |
| 312 bool show = (state == VISIBLE_BOTTOM || state == VISIBLE_CENTERED); | |
| 313 if (show == WindowManager::GetInstance()->IsOverviewModeActive()) { | |
| 314 SetState(state); // overview mode already matches state | |
| 315 } else { | |
| 316 overview_state_ = state; | |
| 317 WindowManager::GetInstance()->ToggleOverview(); | |
| 318 } | |
| 319 } | |
| 320 | |
| 305 void HomeCardImpl::SetState(HomeCard::State state) { | 321 void HomeCardImpl::SetState(HomeCard::State state) { |
| 306 if (state_ == state) | 322 if (state_ == state) |
| 307 return; | 323 return; |
| 308 | 324 |
| 309 // Update |state_| before changing the visibility of the widgets, so that | 325 // Update |state_| before changing the visibility of the widgets, so that |
| 310 // LayoutManager callbacks get the correct state. | 326 // LayoutManager callbacks get the correct state. |
| 311 HomeCard::State old_state = state_; | 327 HomeCard::State old_state = state_; |
| 312 state_ = state; | 328 state_ = state; |
| 313 original_state_ = state; | 329 original_state_ = state; |
| 314 | 330 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 | 377 |
| 362 bool HomeCardImpl::IsCommandEnabled(int command_id) const { | 378 bool HomeCardImpl::IsCommandEnabled(int command_id) const { |
| 363 return true; | 379 return true; |
| 364 } | 380 } |
| 365 | 381 |
| 366 bool HomeCardImpl::OnAcceleratorFired(int command_id, | 382 bool HomeCardImpl::OnAcceleratorFired(int command_id, |
| 367 const ui::Accelerator& accelerator) { | 383 const ui::Accelerator& accelerator) { |
| 368 DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id); | 384 DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id); |
| 369 | 385 |
| 370 if (state_ == VISIBLE_CENTERED && original_state_ != VISIBLE_BOTTOM) | 386 if (state_ == VISIBLE_CENTERED && original_state_ != VISIBLE_BOTTOM) |
| 371 SetState(VISIBLE_MINIMIZED); | 387 SetStateAndOverview(VISIBLE_MINIMIZED); |
| 372 else if (state_ == VISIBLE_MINIMIZED) | 388 else if (state_ == VISIBLE_MINIMIZED) |
| 373 SetState(VISIBLE_CENTERED); | 389 SetStateAndOverview(VISIBLE_CENTERED); |
| 374 return true; | 390 return true; |
| 375 } | 391 } |
| 376 | 392 |
| 377 void HomeCardImpl::OnGestureEnded(State final_state, bool is_fling) { | 393 void HomeCardImpl::OnGestureEnded(State final_state, bool is_fling) { |
| 378 home_card_view_->ClearGesture(); | 394 home_card_view_->ClearGesture(); |
| 379 if (state_ != final_state && | 395 if (state_ != final_state && |
| 380 (state_ == VISIBLE_MINIMIZED || final_state == VISIBLE_MINIMIZED)) { | 396 (state_ == VISIBLE_MINIMIZED || final_state == VISIBLE_MINIMIZED)) { |
| 381 SetState(final_state); | 397 SetState(final_state); |
| 382 WindowManager::GetInstance()->ToggleOverview(); | 398 WindowManager::GetInstance()->ToggleOverview(); |
| 383 } else { | 399 } else { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 408 GetBoundsForState(screen_bounds, to_state))); | 424 GetBoundsForState(screen_bounds, to_state))); |
| 409 | 425 |
| 410 home_card_view_->SetStateProgress(from_state, to_state, progress); | 426 home_card_view_->SetStateProgress(from_state, to_state, progress); |
| 411 | 427 |
| 412 // TODO(mukai): signals the update to the window manager so that it shows the | 428 // TODO(mukai): signals the update to the window manager so that it shows the |
| 413 // intermediate visual state of overview mode. | 429 // intermediate visual state of overview mode. |
| 414 } | 430 } |
| 415 | 431 |
| 416 void HomeCardImpl::OnOverviewModeEnter() { | 432 void HomeCardImpl::OnOverviewModeEnter() { |
| 417 if (state_ == HIDDEN || state_ == VISIBLE_MINIMIZED) | 433 if (state_ == HIDDEN || state_ == VISIBLE_MINIMIZED) |
| 418 SetState(VISIBLE_BOTTOM); | 434 SetState(overview_state_); |
|
Jun Mukai
2014/09/25 21:53:41
I am not sure why overview_state_ is necessary. I
Greg Levin
2014/10/02 21:56:09
ToggleOverview() was a little imprecise for use he
| |
| 419 } | 435 } |
| 420 | 436 |
| 421 void HomeCardImpl::OnOverviewModeExit() { | 437 void HomeCardImpl::OnOverviewModeExit() { |
| 422 SetState(VISIBLE_MINIMIZED); | 438 SetState(VISIBLE_MINIMIZED); |
| 439 overview_state_ = VISIBLE_BOTTOM; | |
| 423 } | 440 } |
| 424 | 441 |
| 425 void HomeCardImpl::OnSplitViewModeEnter() { | 442 void HomeCardImpl::OnSplitViewModeEnter() { |
| 426 } | 443 } |
| 427 | 444 |
| 428 void HomeCardImpl::OnSplitViewModeExit() { | 445 void HomeCardImpl::OnSplitViewModeExit() { |
| 429 } | 446 } |
| 430 | 447 |
| 431 void HomeCardImpl::OnWindowActivated(aura::Window* gained_active, | 448 void HomeCardImpl::OnWindowActivated(aura::Window* gained_active, |
| 432 aura::Window* lost_active) { | 449 aura::Window* lost_active) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 450 instance = NULL; | 467 instance = NULL; |
| 451 } | 468 } |
| 452 | 469 |
| 453 // static | 470 // static |
| 454 HomeCard* HomeCard::Get() { | 471 HomeCard* HomeCard::Get() { |
| 455 DCHECK(instance); | 472 DCHECK(instance); |
| 456 return instance; | 473 return instance; |
| 457 } | 474 } |
| 458 | 475 |
| 459 } // namespace athena | 476 } // namespace athena |
| OLD | NEW |