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/common/container_priorities.h" | 10 #include "athena/common/container_priorities.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 // as its child view, so that custom pages and apps grid are available in | 149 // as its child view, so that custom pages and apps grid are available in |
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 if (from_state != HomeCard::VISIBLE_CENTERED || | |
oshima
2014/08/28 19:33:12
We probably don't want to clear focus when a user
Jun Mukai
2014/08/28 21:26:25
Done.
| |
160 to_state != HomeCard::VISIBLE_CENTERED) { | |
161 GetFocusManager()->ClearFocus(); | |
162 } | |
159 if (from_state == HomeCard::VISIBLE_CENTERED) | 163 if (from_state == HomeCard::VISIBLE_CENTERED) |
160 main_view_->SetLayoutState(1.0f - progress); | 164 main_view_->SetLayoutState(1.0f - progress); |
161 else if (to_state == HomeCard::VISIBLE_CENTERED) | 165 else if (to_state == HomeCard::VISIBLE_CENTERED) |
162 main_view_->SetLayoutState(progress); | 166 main_view_->SetLayoutState(progress); |
163 else | 167 else |
164 SetState(to_state); | 168 SetState(to_state); |
165 } | 169 } |
166 | 170 |
167 void SetState(HomeCard::State state) { | 171 void SetState(HomeCard::State state) { |
168 if (state == HomeCard::VISIBLE_CENTERED) | 172 if (state == HomeCard::VISIBLE_CENTERED) |
169 main_view_->RequestFocusOnSearchBox(); | 173 main_view_->RequestFocusOnSearchBox(); |
170 else | 174 else |
171 GetWidget()->GetFocusManager()->ClearFocus(); | 175 GetWidget()->GetFocusManager()->ClearFocus(); |
172 wm::SetShadowType(GetWidget()->GetNativeView(), | 176 wm::SetShadowType(GetWidget()->GetNativeView(), |
173 state == HomeCard::VISIBLE_MINIMIZED ? | 177 state == HomeCard::VISIBLE_MINIMIZED ? |
174 wm::SHADOW_TYPE_NONE : | 178 wm::SHADOW_TYPE_NONE : |
175 wm::SHADOW_TYPE_RECTANGULAR); | 179 wm::SHADOW_TYPE_RECTANGULAR); |
176 main_view_->SetLayoutState( | 180 main_view_->SetLayoutState( |
177 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f); | 181 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f); |
178 } | 182 } |
179 | 183 |
180 void SetStateWithAnimation(HomeCard::State state) { | 184 void SetStateWithAnimation(HomeCard::State state) { |
185 if (state == HomeCard::VISIBLE_CENTERED) | |
186 main_view_->RequestFocusOnSearchBox(); | |
187 else | |
188 GetWidget()->GetFocusManager()->ClearFocus(); | |
189 | |
181 if (state == HomeCard::VISIBLE_MINIMIZED) | 190 if (state == HomeCard::VISIBLE_MINIMIZED) |
182 return; | 191 return; |
183 | 192 |
184 main_view_->SetLayoutStateWithAnimation( | 193 main_view_->SetLayoutStateWithAnimation( |
185 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f); | 194 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f); |
186 } | 195 } |
187 | 196 |
188 void ClearGesture() { | 197 void ClearGesture() { |
189 gesture_manager_.reset(); | 198 gesture_manager_.reset(); |
190 } | 199 } |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 instance = NULL; | 452 instance = NULL; |
444 } | 453 } |
445 | 454 |
446 // static | 455 // static |
447 HomeCard* HomeCard::Get() { | 456 HomeCard* HomeCard::Get() { |
448 DCHECK(instance); | 457 DCHECK(instance); |
449 return instance; | 458 return instance; |
450 } | 459 } |
451 | 460 |
452 } // namespace athena | 461 } // namespace athena |
OLD | NEW |