Workaround for xkbcommon dead keys.
[chromium-blink-merge.git] / ui / app_list / views / contents_animator.h
blobcd559901a64d91fa8008edb012b50003c4ac41e4
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 // Gets the on-screen page bounds for a given launcher page with index
43 // |page_index|.
44 gfx::Rect GetOnscreenPageBounds(int page_index) const;
46 // Gets the origin (the off-screen resting place) for a given launcher page
47 // with index |page_index|.
48 gfx::Rect GetOffscreenPageBounds(int page_index) const;
50 // Updates the position of the custom launcher page view (if it exists), in
51 // the default way for start page <-> other page transitions. This places it
52 // into collapsed state on the start page, and hidden on any other page. Any
53 // other behaviour should be implemented with a custom animator. |progress|,
54 // |from_page| and |to_page| are parameters from Update().
55 void UpdateCustomPageForDefaultAnimation(double progress,
56 int from_page,
57 int to_page) const;
59 // Updates the position of the search box view, placing it in the correct
60 // position for the transition from |from_page| to |to_page|.
61 void UpdateSearchBoxForDefaultAnimation(double progress,
62 int from_page,
63 int to_page) const;
65 // Clips the drawing of the search results page to its onscreen bounds.
66 void ClipSearchResultsPageToOnscreenBounds(int page_index,
67 const gfx::Rect& current_bounds,
68 const gfx::Rect& onscreen_bounds);
70 private:
71 ContentsView* contents_view_;
73 DISALLOW_COPY_AND_ASSIGN(ContentsAnimator);
76 // Simple animator that slides pages in and out vertically. Appropriate for any
77 // page pair.
78 class DefaultAnimator : public ContentsAnimator {
79 public:
80 explicit DefaultAnimator(ContentsView* contents_view);
82 ~DefaultAnimator() override {}
84 // ContentsAnimator overrides:
85 std::string NameForTests() const override;
86 void Update(double progress, int from_page, int to_page) override;
88 private:
89 DISALLOW_COPY_AND_ASSIGN(DefaultAnimator);
92 // Animator between the start page and apps grid page.
93 class StartToAppsAnimator : public ContentsAnimator {
94 public:
95 explicit StartToAppsAnimator(ContentsView* contents_view);
97 ~StartToAppsAnimator() override {}
99 // ContentsAnimator overrides:
100 std::string NameForTests() const override;
101 void Update(double progress, int start_page, int apps_page) override;
103 private:
104 DISALLOW_COPY_AND_ASSIGN(StartToAppsAnimator);
107 // Animator from start page to custom page.
108 class StartToCustomAnimator : public ContentsAnimator {
109 public:
110 explicit StartToCustomAnimator(ContentsView* contents_view);
112 std::string NameForTests() const override;
113 void Update(double progress, int start_page, int custom_page) override;
115 private:
116 DISALLOW_COPY_AND_ASSIGN(StartToCustomAnimator);
119 } // namespace app_list
121 #endif // UI_APP_LIST_VIEWS_CONTENTS_ANIMATOR_H_