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

Side by Side Diff: chrome/browser/chromeos/panels/panel_scroller.cc

Issue 1961001: Refactors animation to allow for cleaner subclassing. I'm doing this (Closed)
Patch Set: Incorporated review feedback Created 10 years, 7 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "chrome/browser/chromeos/panels/panel_scroller.h" 5 #include "chrome/browser/chromeos/panels/panel_scroller.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "gfx/canvas.h" 11 #include "gfx/canvas.h"
12 #include "chrome/browser/chromeos/panels/panel_scroller_container.h" 12 #include "chrome/browser/chromeos/panels/panel_scroller_container.h"
13 #include "chrome/browser/chromeos/panels/panel_scroller_header.h" 13 #include "chrome/browser/chromeos/panels/panel_scroller_header.h"
14 #include "views/widget/widget_gtk.h" 14 #include "views/widget/widget_gtk.h"
15 15
16 struct PanelScroller::Panel { 16 struct PanelScroller::Panel {
17 PanelScrollerHeader* header; 17 PanelScrollerHeader* header;
18 PanelScrollerContainer* container; 18 PanelScrollerContainer* container;
19 }; 19 };
20 20
21 PanelScroller::PanelScroller() 21 PanelScroller::PanelScroller()
22 : views::View(), 22 : views::View(),
23 divider_height_(18), 23 divider_height_(18),
24 needs_layout_(true), 24 needs_layout_(true),
25 scroll_pos_(0), 25 scroll_pos_(0),
26 ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)), 26 ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)),
27 animated_scroll_begin_(0), 27 animated_scroll_begin_(0),
28 animated_scroll_end_(0) { 28 animated_scroll_end_(0) {
29 animation_.SetTweenType(SlideAnimation::EASE_IN_OUT); 29 animation_.SetTweenType(Tween::EASE_IN_OUT);
30 animation_.SetSlideDuration(300); 30 animation_.SetSlideDuration(300);
31 31
32 Panel* panel = new Panel; 32 Panel* panel = new Panel;
33 panel->header = new PanelScrollerHeader(this); 33 panel->header = new PanelScrollerHeader(this);
34 panel->header->set_title(ASCIIToUTF16("Email")); 34 panel->header->set_title(ASCIIToUTF16("Email"));
35 panel->container = new PanelScrollerContainer(this, new views::View()); 35 panel->container = new PanelScrollerContainer(this, new views::View());
36 panels_.push_back(panel); 36 panels_.push_back(panel);
37 37
38 panel = new Panel; 38 panel = new Panel;
39 panel->header = new PanelScrollerHeader(this); 39 panel->header = new PanelScrollerHeader(this);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 230
231 animated_scroll_begin_ = scroll_pos_; 231 animated_scroll_begin_ = scroll_pos_;
232 if (animated_scroll_begin_ == animated_scroll_end_) 232 if (animated_scroll_begin_ == animated_scroll_end_)
233 return; // Nothing to animate. 233 return; // Nothing to animate.
234 234
235 // Start animating to the destination. 235 // Start animating to the destination.
236 animation_.Reset(); 236 animation_.Reset();
237 animation_.Show(); 237 animation_.Show();
238 } 238 }
239 239
240 void PanelScroller::AnimationEnded(const Animation* animation) {
241 }
242
243 void PanelScroller::AnimationProgressed(const Animation* animation) { 240 void PanelScroller::AnimationProgressed(const Animation* animation) {
244 scroll_pos_ = static_cast<int>( 241 scroll_pos_ = static_cast<int>(
245 static_cast<double>(animated_scroll_end_ - animated_scroll_begin_) * 242 static_cast<double>(animated_scroll_end_ - animated_scroll_begin_) *
246 animation_.GetCurrentValue()) + animated_scroll_begin_; 243 animation_.GetCurrentValue()) + animated_scroll_begin_;
247 244
248 Layout(); 245 Layout();
249 SchedulePaint(); 246 SchedulePaint();
250 } 247 }
251
252 void PanelScroller::AnimationCanceled(const Animation* animation) {
253 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/panels/panel_scroller.h ('k') | chrome/browser/chromeos/status/network_menu_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698