ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / ui / app_list / views / contents_animator.h
bloba643afdaec8824c836b544cb4791a01068895065
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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_VIEWS_CONTENTS_ANIMATOR_H_
6 #define UI_APP_LIST_VIEWS_CONTENTS_ANIMATOR_H_
8 #include <string>
10 #include "base/macros.h"
12 namespace gfx {
13 class Rect;
16 namespace app_list {
18 class ContentsView;
20 // Manages an animation between two specific pages of the ContentsView.
21 // Different subclasses implement different animations, so we can have a custom
22 // animation for each pair of pages. Animations are reversible (if A -> B is
23 // implemented, B -> A will implicitly be the inverse animation).
24 class ContentsAnimator {
25 public:
26 explicit ContentsAnimator(ContentsView* contents_view);
28 virtual ~ContentsAnimator();
30 // Gets the name of the animator, for testing.
31 virtual std::string NameForTests() const = 0;
33 // Updates the state of the ContentsView. |progress| is the amount of progress
34 // made on the animation, where 0.0 is the beginning and 1.0 is the end. The
35 // animation should be linear (not eased in or out) so that it can be played
36 // forwards or reversed. Easing will be applied by the PaginationModel.
37 virtual void Update(double progress, int from_page, int to_page) = 0;
39 protected:
40 const ContentsView* contents_view() const { return contents_view_; }
42 // Updates the position of the custom launcher page view (if it exists), in
43 // the default way for start page <-> other page transitions. This places it
44 // into collapsed state on the start page, and hidden on any other page. Any
45 // other behaviour should be implemented with a custom animator. |progress|,
46 // |from_page| and |to_page| are parameters from Update().
47 void UpdateCustomPageForDefaultAnimation(double progress,
48 int from_page,
49 int to_page) const;
51 // Updates the position of the search box view, placing it in the correct
52 // position for the transition from |from_page| to |to_page|.
53 void UpdateSearchBoxForDefaultAnimation(double progress,
54 int from_page,
55 int to_page) const;
57 // Clips the drawing of the search results page to its onscreen bounds.
58 void ClipSearchResultsPageToOnscreenBounds(int page_index,
59 const gfx::Rect& current_bounds,
60 const gfx::Rect& onscreen_bounds);
62 private:
63 ContentsView* contents_view_;
65 DISALLOW_COPY_AND_ASSIGN(ContentsAnimator);
68 // Simple animator that slides pages in and out vertically. Appropriate for any
69 // page pair.
70 class DefaultAnimator : public ContentsAnimator {
71 public:
72 explicit DefaultAnimator(ContentsView* contents_view);
74 ~DefaultAnimator() override {}
76 // ContentsAnimator overrides:
77 std::string NameForTests() const override;
78 void Update(double progress, int from_page, int to_page) override;
80 private:
81 DISALLOW_COPY_AND_ASSIGN(DefaultAnimator);
84 // Animator between the start page and apps grid page.
85 class StartToAppsAnimator : public ContentsAnimator {
86 public:
87 explicit StartToAppsAnimator(ContentsView* contents_view);
89 ~StartToAppsAnimator() override {}
91 // ContentsAnimator overrides:
92 std::string NameForTests() const override;
93 void Update(double progress, int start_page, int apps_page) override;
95 private:
96 DISALLOW_COPY_AND_ASSIGN(StartToAppsAnimator);
99 // Animator from start page to custom page.
100 class StartToCustomAnimator : public ContentsAnimator {
101 public:
102 explicit StartToCustomAnimator(ContentsView* contents_view);
104 std::string NameForTests() const override;
105 void Update(double progress, int start_page, int custom_page) override;
107 private:
108 DISALLOW_COPY_AND_ASSIGN(StartToCustomAnimator);
111 } // namespace app_list
113 #endif // UI_APP_LIST_VIEWS_CONTENTS_ANIMATOR_H_