OLD | NEW |
1 // Copyright (c) 2010 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 "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.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 "gfx/canvas.h" | 14 #include "gfx/canvas.h" |
15 #include "views/widget/widget_gtk.h" | 15 #include "views/widget/widget_gtk.h" |
16 | 16 |
17 struct PanelScroller::Panel { | 17 struct PanelScroller::Panel { |
18 PanelScrollerHeader* header; | 18 PanelScrollerHeader* header; |
19 PanelScrollerContainer* container; | 19 PanelScrollerContainer* container; |
20 }; | 20 }; |
21 | 21 |
22 PanelScroller::PanelScroller() | 22 PanelScroller::PanelScroller() |
23 : views::View(), | 23 : views::View(), |
24 divider_height_(18), | 24 divider_height_(18), |
25 needs_layout_(true), | 25 needs_layout_(true), |
26 scroll_pos_(0), | 26 scroll_pos_(0), |
27 ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)), | 27 ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)), |
28 animated_scroll_begin_(0), | 28 animated_scroll_begin_(0), |
29 animated_scroll_end_(0) { | 29 animated_scroll_end_(0) { |
30 animation_.SetTweenType(Tween::EASE_IN_OUT); | 30 animation_.SetTweenType(ui::Tween::EASE_IN_OUT); |
31 animation_.SetSlideDuration(300); | 31 animation_.SetSlideDuration(300); |
32 | 32 |
33 Panel* panel = new Panel; | 33 Panel* panel = new Panel; |
34 panel->header = new PanelScrollerHeader(this); | 34 panel->header = new PanelScrollerHeader(this); |
35 panel->header->set_title(ASCIIToUTF16("Email")); | 35 panel->header->set_title(ASCIIToUTF16("Email")); |
36 panel->container = new PanelScrollerContainer(this, new views::View()); | 36 panel->container = new PanelScrollerContainer(this, new views::View()); |
37 panels_.push_back(panel); | 37 panels_.push_back(panel); |
38 | 38 |
39 panel = new Panel; | 39 panel = new Panel; |
40 panel->header = new PanelScrollerHeader(this); | 40 panel->header = new PanelScrollerHeader(this); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 animated_scroll_begin_ = scroll_pos_; | 232 animated_scroll_begin_ = scroll_pos_; |
233 if (animated_scroll_begin_ == animated_scroll_end_) | 233 if (animated_scroll_begin_ == animated_scroll_end_) |
234 return; // Nothing to animate. | 234 return; // Nothing to animate. |
235 | 235 |
236 // Start animating to the destination. | 236 // Start animating to the destination. |
237 animation_.Reset(); | 237 animation_.Reset(); |
238 animation_.Show(); | 238 animation_.Show(); |
239 } | 239 } |
240 | 240 |
241 void PanelScroller::AnimationProgressed(const Animation* animation) { | 241 void PanelScroller::AnimationProgressed(const ui::Animation* animation) { |
242 scroll_pos_ = static_cast<int>( | 242 scroll_pos_ = static_cast<int>( |
243 static_cast<double>(animated_scroll_end_ - animated_scroll_begin_) * | 243 static_cast<double>(animated_scroll_end_ - animated_scroll_begin_) * |
244 animation_.GetCurrentValue()) + animated_scroll_begin_; | 244 animation_.GetCurrentValue()) + animated_scroll_begin_; |
245 | 245 |
246 Layout(); | 246 Layout(); |
247 SchedulePaint(); | 247 SchedulePaint(); |
248 } | 248 } |
OLD | NEW |