Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: athena/home/home_card_impl.cc

Issue 529813002: Simplify HomeCardGestureManager::UpdateScrollState() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « athena/home/home_card_gesture_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/container_priorities.h" 10 #include "athena/common/container_priorities.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // the home card. 150 // the home card.
151 // TODO(mukai): make it so after the detailed UI has been fixed. 151 // TODO(mukai): make it so after the detailed UI has been fixed.
152 main_view_ = new AthenaStartPageView(view_delegate); 152 main_view_ = new AthenaStartPageView(view_delegate);
153 AddChildView(main_view_); 153 AddChildView(main_view_);
154 } 154 }
155 155
156 void SetStateProgress(HomeCard::State from_state, 156 void SetStateProgress(HomeCard::State from_state,
157 HomeCard::State to_state, 157 HomeCard::State to_state,
158 float progress) { 158 float progress) {
159 // TODO(mukai): not clear the focus, but simply close the virtual keyboard. 159 // TODO(mukai): not clear the focus, but simply close the virtual keyboard.
160 if (from_state != HomeCard::VISIBLE_CENTERED || 160 GetFocusManager()->ClearFocus();
161 to_state != HomeCard::VISIBLE_CENTERED) { 161
162 GetFocusManager()->ClearFocus();
163 }
164 if (from_state == HomeCard::VISIBLE_CENTERED) 162 if (from_state == HomeCard::VISIBLE_CENTERED)
165 main_view_->SetLayoutState(1.0f - progress); 163 main_view_->SetLayoutState(1.0f - progress);
166 else if (to_state == HomeCard::VISIBLE_CENTERED) 164 else if (to_state == HomeCard::VISIBLE_CENTERED)
167 main_view_->SetLayoutState(progress); 165 main_view_->SetLayoutState(progress);
168 UpdateShadow(true); 166 UpdateShadow(true);
169 } 167 }
170 168
171 void SetStateWithAnimation(HomeCard::State state) { 169 void SetStateWithAnimation(HomeCard::State state) {
172 UpdateShadow(state != HomeCard::VISIBLE_MINIMIZED); 170 UpdateShadow(state != HomeCard::VISIBLE_MINIMIZED);
173 if (state == HomeCard::VISIBLE_CENTERED) 171 if (state == HomeCard::VISIBLE_CENTERED)
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 home_card_view_->SetStateWithAnimation(state_); 387 home_card_view_->SetStateWithAnimation(state_);
390 layout_manager_->Layout(true); 388 layout_manager_->Layout(true);
391 } 389 }
392 } 390 }
393 391
394 void HomeCardImpl::OnGestureProgressed( 392 void HomeCardImpl::OnGestureProgressed(
395 State from_state, State to_state, float progress) { 393 State from_state, State to_state, float progress) {
396 if (from_state == VISIBLE_MINIMIZED || to_state == VISIBLE_MINIMIZED) { 394 if (from_state == VISIBLE_MINIMIZED || to_state == VISIBLE_MINIMIZED) {
397 minimized_home_->layer()->SetVisible(true); 395 minimized_home_->layer()->SetVisible(true);
398 float opacity = 396 float opacity =
399 (from_state == VISIBLE_MINIMIZED) ? 1.0f - progress : progress; 397 (from_state == VISIBLE_MINIMIZED) ? 1.0f - progress : progress;
Jun Mukai 2014/09/02 08:22:42 Instead this could be rewritten as: opacity = (to_
400 minimized_home_->layer()->SetOpacity(opacity); 398 minimized_home_->layer()->SetOpacity(opacity);
401 } 399 }
402 gfx::Rect screen_bounds = 400 gfx::Rect screen_bounds =
403 home_card_widget_->GetNativeWindow()->GetRootWindow()->bounds(); 401 home_card_widget_->GetNativeWindow()->GetRootWindow()->bounds();
404 home_card_widget_->SetBounds(gfx::Tween::RectValueBetween( 402 home_card_widget_->SetBounds(gfx::Tween::RectValueBetween(
405 progress, 403 progress,
406 GetBoundsForState(screen_bounds, from_state), 404 GetBoundsForState(screen_bounds, from_state),
407 GetBoundsForState(screen_bounds, to_state))); 405 GetBoundsForState(screen_bounds, to_state)));
408 406
409 home_card_view_->SetStateProgress(from_state, to_state, progress); 407 home_card_view_->SetStateProgress(from_state, to_state, progress);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 instance = NULL; 444 instance = NULL;
447 } 445 }
448 446
449 // static 447 // static
450 HomeCard* HomeCard::Get() { 448 HomeCard* HomeCard::Get() {
451 DCHECK(instance); 449 DCHECK(instance);
452 return instance; 450 return instance;
453 } 451 }
454 452
455 } // namespace athena 453 } // namespace athena
OLDNEW
« no previous file with comments | « athena/home/home_card_gesture_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698