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

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

Issue 521493002: Cleanup home card shadow code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 | « no previous file | athena/home/home_card_unittest.cc » ('j') | 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (from_state != HomeCard::VISIBLE_CENTERED ||
161 to_state != HomeCard::VISIBLE_CENTERED) { 161 to_state != HomeCard::VISIBLE_CENTERED) {
162 GetFocusManager()->ClearFocus(); 162 GetFocusManager()->ClearFocus();
163 } 163 }
164 if (from_state == HomeCard::VISIBLE_CENTERED) 164 if (from_state == HomeCard::VISIBLE_CENTERED)
165 main_view_->SetLayoutState(1.0f - progress); 165 main_view_->SetLayoutState(1.0f - progress);
166 else if (to_state == HomeCard::VISIBLE_CENTERED) 166 else if (to_state == HomeCard::VISIBLE_CENTERED)
167 main_view_->SetLayoutState(progress); 167 main_view_->SetLayoutState(progress);
168 else 168 UpdateShadow(true);
169 SetState(to_state);
170 } 169 }
171 170
172 void SetState(HomeCard::State state) { 171 void SetStateWithAnimation(HomeCard::State state) {
172 UpdateShadow(state != HomeCard::VISIBLE_MINIMIZED);
173 if (state == HomeCard::VISIBLE_CENTERED) 173 if (state == HomeCard::VISIBLE_CENTERED)
174 main_view_->RequestFocusOnSearchBox(); 174 main_view_->RequestFocusOnSearchBox();
175 else 175 else
176 GetWidget()->GetFocusManager()->ClearFocus();
177 wm::SetShadowType(GetWidget()->GetNativeView(),
178 state == HomeCard::VISIBLE_MINIMIZED ?
179 wm::SHADOW_TYPE_NONE :
180 wm::SHADOW_TYPE_RECTANGULAR);
181 main_view_->SetLayoutState(
182 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f);
183 }
184
185 void SetStateWithAnimation(HomeCard::State state) {
186 if (state == HomeCard::VISIBLE_CENTERED)
187 main_view_->RequestFocusOnSearchBox();
188 else
189 GetWidget()->GetFocusManager()->ClearFocus(); 176 GetWidget()->GetFocusManager()->ClearFocus();
190 177
191 if (state == HomeCard::VISIBLE_MINIMIZED) 178 if (state == HomeCard::VISIBLE_MINIMIZED)
192 return; 179 return;
193 180
194 main_view_->SetLayoutStateWithAnimation( 181 main_view_->SetLayoutStateWithAnimation(
195 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f); 182 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f);
196 } 183 }
197 184
198 void ClearGesture() { 185 void ClearGesture() {
(...skipping 15 matching lines...) Expand all
214 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { 201 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE {
215 if (HomeCard::Get()->GetState() == HomeCard::VISIBLE_MINIMIZED && 202 if (HomeCard::Get()->GetState() == HomeCard::VISIBLE_MINIMIZED &&
216 event.IsLeftMouseButton() && event.GetClickCount() == 1) { 203 event.IsLeftMouseButton() && event.GetClickCount() == 1) {
217 athena::WindowManager::GetInstance()->ToggleOverview(); 204 athena::WindowManager::GetInstance()->ToggleOverview();
218 return true; 205 return true;
219 } 206 }
220 return false; 207 return false;
221 } 208 }
222 209
223 private: 210 private:
211 void UpdateShadow(bool should_show) {
212 wm::SetShadowType(
213 GetWidget()->GetNativeWindow(),
214 should_show ? wm::SHADOW_TYPE_RECTANGULAR : wm::SHADOW_TYPE_NONE);
215 }
216
224 // views::WidgetDelegate: 217 // views::WidgetDelegate:
225 virtual views::View* GetContentsView() OVERRIDE { 218 virtual views::View* GetContentsView() OVERRIDE {
226 return this; 219 return this;
227 } 220 }
228 221
229 AthenaStartPageView* main_view_; 222 AthenaStartPageView* main_view_;
230 scoped_ptr<HomeCardGestureManager> gesture_manager_; 223 scoped_ptr<HomeCardGestureManager> gesture_manager_;
231 HomeCardGestureManager::Delegate* gesture_delegate_; 224 HomeCardGestureManager::Delegate* gesture_delegate_;
232 225
233 DISALLOW_COPY_AND_ASSIGN(HomeCardView); 226 DISALLOW_COPY_AND_ASSIGN(HomeCardView);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 instance = NULL; 446 instance = NULL;
454 } 447 }
455 448
456 // static 449 // static
457 HomeCard* HomeCard::Get() { 450 HomeCard* HomeCard::Get() {
458 DCHECK(instance); 451 DCHECK(instance);
459 return instance; 452 return instance;
460 } 453 }
461 454
462 } // namespace athena 455 } // namespace athena
OLDNEW
« no previous file with comments | « no previous file | athena/home/home_card_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698