| 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 // TODO(mukai): not clear the focus, but simply close the virtual keyboard. |
| 160 if (from_state != HomeCard::VISIBLE_CENTERED || |
| 161 to_state != HomeCard::VISIBLE_CENTERED) { |
| 162 GetFocusManager()->ClearFocus(); |
| 163 } |
| 159 if (from_state == HomeCard::VISIBLE_CENTERED) | 164 if (from_state == HomeCard::VISIBLE_CENTERED) |
| 160 main_view_->SetLayoutState(1.0f - progress); | 165 main_view_->SetLayoutState(1.0f - progress); |
| 161 else if (to_state == HomeCard::VISIBLE_CENTERED) | 166 else if (to_state == HomeCard::VISIBLE_CENTERED) |
| 162 main_view_->SetLayoutState(progress); | 167 main_view_->SetLayoutState(progress); |
| 163 else | 168 else |
| 164 SetState(to_state); | 169 SetState(to_state); |
| 165 } | 170 } |
| 166 | 171 |
| 167 void SetState(HomeCard::State state) { | 172 void SetState(HomeCard::State state) { |
| 168 if (state == HomeCard::VISIBLE_CENTERED) | 173 if (state == HomeCard::VISIBLE_CENTERED) |
| 169 main_view_->RequestFocusOnSearchBox(); | 174 main_view_->RequestFocusOnSearchBox(); |
| 170 else | 175 else |
| 171 GetWidget()->GetFocusManager()->ClearFocus(); | 176 GetWidget()->GetFocusManager()->ClearFocus(); |
| 172 wm::SetShadowType(GetWidget()->GetNativeView(), | 177 wm::SetShadowType(GetWidget()->GetNativeView(), |
| 173 state == HomeCard::VISIBLE_MINIMIZED ? | 178 state == HomeCard::VISIBLE_MINIMIZED ? |
| 174 wm::SHADOW_TYPE_NONE : | 179 wm::SHADOW_TYPE_NONE : |
| 175 wm::SHADOW_TYPE_RECTANGULAR); | 180 wm::SHADOW_TYPE_RECTANGULAR); |
| 176 main_view_->SetLayoutState( | 181 main_view_->SetLayoutState( |
| 177 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f); | 182 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f); |
| 178 } | 183 } |
| 179 | 184 |
| 180 void SetStateWithAnimation(HomeCard::State state) { | 185 void SetStateWithAnimation(HomeCard::State state) { |
| 186 if (state == HomeCard::VISIBLE_CENTERED) |
| 187 main_view_->RequestFocusOnSearchBox(); |
| 188 else |
| 189 GetWidget()->GetFocusManager()->ClearFocus(); |
| 190 |
| 181 if (state == HomeCard::VISIBLE_MINIMIZED) | 191 if (state == HomeCard::VISIBLE_MINIMIZED) |
| 182 return; | 192 return; |
| 183 | 193 |
| 184 main_view_->SetLayoutStateWithAnimation( | 194 main_view_->SetLayoutStateWithAnimation( |
| 185 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f); | 195 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f); |
| 186 } | 196 } |
| 187 | 197 |
| 188 void ClearGesture() { | 198 void ClearGesture() { |
| 189 gesture_manager_.reset(); | 199 gesture_manager_.reset(); |
| 190 } | 200 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 instance = NULL; | 453 instance = NULL; |
| 444 } | 454 } |
| 445 | 455 |
| 446 // static | 456 // static |
| 447 HomeCard* HomeCard::Get() { | 457 HomeCard* HomeCard::Get() { |
| 448 DCHECK(instance); | 458 DCHECK(instance); |
| 449 return instance; | 459 return instance; |
| 450 } | 460 } |
| 451 | 461 |
| 452 } // namespace athena | 462 } // namespace athena |
| OLD | NEW |