Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / athena / home / athena_start_page_view.h
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.
4
5 #ifndef ATHENA_HOME_ATHENA_START_PAGE_VIEW_H_
6 #define ATHENA_HOME_ATHENA_START_PAGE_VIEW_H_
7
8 #include "athena/athena_export.h"
9 #include "base/memory/weak_ptr.h"
10 #include "ui/app_list/views/search_box_view_delegate.h"
11 #include "ui/gfx/animation/tween.h"
12 #include "ui/views/view.h"
13
14 namespace app_list {
15 class AppListViewDelegate;
16 class SearchBoxView;
17 class SearchResultListView;
18 }
19
20 namespace athena {
21
22 class ATHENA_EXPORT AthenaStartPageView
23     : public views::View,
24       public app_list::SearchBoxViewDelegate {
25  public:
26   explicit AthenaStartPageView(app_list::AppListViewDelegate* delegate);
27   virtual ~AthenaStartPageView();
28
29   // Requests the focus on the search box in the start page view.
30   void RequestFocusOnSearchBox();
31
32   // Updates the layout state. See the comment of |layout_state_| field.
33   void SetLayoutState(float layout_state);
34
35   // Updates the layout state and move the subviews to the target location with
36   // animation.
37   void SetLayoutStateWithAnimation(float layout_state,
38                                    gfx::Tween::Type tween_type);
39
40  private:
41   friend class AthenaStartPageViewTest;
42
43   static const char kViewClassName[];
44
45   // A struct which bundles the layout data of subviews.
46   struct LayoutData {
47     gfx::Rect search_box;
48     gfx::Rect icons;
49     gfx::Rect controls;
50     float system_info_opacity;
51     float logo_opacity;
52     float background_opacity;
53
54     LayoutData();
55   };
56
57   // Returns the bounds for |VISIBLE_BOTTOM|.
58   LayoutData CreateBottomBounds(int width);
59
60   // Returns the bounds for |VISIBLE_CENTERED|.
61   LayoutData CreateCenteredBounds(int width);
62
63   // Schedules the animation for the layout the search box and the search
64   // results.
65   void LayoutSearchResults(bool should_show_search_results);
66
67   // Called when the animation of search box / search results layout has
68   // completed.
69   void OnSearchResultLayoutAnimationCompleted(bool should_show_search_results);
70
71   // views::View:
72   virtual void Layout() OVERRIDE;
73   virtual bool OnKeyPressed(const ui::KeyEvent& key_event) OVERRIDE;
74
75   // app_list::SearchBoxViewDelegate:
76   virtual void QueryChanged(app_list::SearchBoxView* sender) OVERRIDE;
77
78   // Not owned.
79   app_list::AppListViewDelegate* delegate_;
80
81   // Views are owned through its hierarchy.
82   views::View* system_info_view_;
83   views::View* app_icon_container_;
84   views::View* search_box_container_;
85   views::View* control_icon_container_;
86   views::View* logo_;
87   app_list::SearchBoxView* search_box_view_;
88   app_list::SearchResultListView* search_results_view_;
89
90   // Do not use views::Background but a views::View with ui::Layer for gradient
91   // background opacity update and animation.
92   views::View* background_;
93
94   // The expected height of |search_results_view_|
95   int search_results_height_;
96
97   // The state to specify how each of the subviews should be laid out, in the
98   // range of [0, 1]. 0 means fully BOTTOM state, and 1 is fully CENTERED state.
99   float layout_state_;
100
101   base::WeakPtrFactory<AthenaStartPageView> weak_factory_;
102
103   DISALLOW_COPY_AND_ASSIGN(AthenaStartPageView);
104 };
105
106 }  // namespace athena
107
108 #endif  // ATHENA_HOME_ATHENA_START_PAGE_VIEW_H_