• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_CHROMEOS_PANELS_PANEL_SCROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_PANELS_PANEL_SCROLLER_H_
7 #pragma once
8 
9 #include <vector>
10 
11 #include "base/basictypes.h"
12 #include "ui/base/animation/animation_delegate.h"
13 #include "ui/base/animation/slide_animation.h"
14 #include "views/view.h"
15 
16 class PanelScrollerHeader;
17 
18 class PanelScroller : public views::View, public ui::AnimationDelegate {
19  public:
20   PanelScroller();
21   ~PanelScroller();
22 
23   static PanelScroller* CreateWindow();
24 
25   // Overridden from View:
26   virtual void ViewHierarchyChanged(bool is_add,
27                                     views::View* parent,
28                                     views::View* child) OVERRIDE;
29   virtual gfx::Size GetPreferredSize() OVERRIDE;
30   virtual void Layout() OVERRIDE;
31   virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
32   virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
33 
34   // Called when a panel header is clicked with the affected container. This
35   // function will make sure the panel is fully visible.
36   void HeaderClicked(PanelScrollerHeader* source);
37 
38  private:
39   struct Panel;
40 
41   // ui::AnimationDelegate overrides.
42   virtual void AnimationProgressed(const ui::Animation* animation);
43 
44   // Scrolls to the panel at the given index. It will be moved to the top.
45   void ScrollToPanel(int index);
46 
47   // All panels in this scroller.
48   std::vector<Panel*> panels_;
49 
50   // Height in pixels of the headers above each panel.
51   int divider_height_;
52 
53   bool needs_layout_;
54 
55   // The current scroll position.
56   int scroll_pos_;
57 
58   ui::SlideAnimation animation_;
59 
60   // When animating a scroll, these indicate the beginning and ending of the
61   // scroll. The scroll_pos_ always indicates the current one.
62   int animated_scroll_begin_;
63   int animated_scroll_end_;
64 
65   DISALLOW_COPY_AND_ASSIGN(PanelScroller);
66 };
67 
68 #endif  // CHROME_BROWSER_CHROMEOS_PANELS_PANEL_SCROLLER_H_
69 
70