1 // Copyright (c) 2012 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_SEARCH_RESULT_LIST_VIEW_H_
6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_
8 #include "base/basictypes.h"
9 #include "base/memory/weak_ptr.h"
10 #include "ui/app_list/views/search_result_container_view.h"
11 #include "ui/gfx/animation/animation_delegate.h"
12 #include "ui/views/view.h"
15 class LinearAnimation;
20 class SearchResultListViewTest;
23 class AppListViewDelegate;
24 class SearchResultListViewDelegate;
25 class SearchResultView;
27 // SearchResultListView displays SearchResultList with a list of
29 class APP_LIST_EXPORT SearchResultListView : public gfx::AnimationDelegate,
30 public SearchResultContainerView {
32 SearchResultListView(SearchResultListViewDelegate* delegate,
33 AppListViewDelegate* view_delegate);
34 ~SearchResultListView() override;
36 void SetSelectedIndex(int selected_index);
38 void UpdateAutoLaunchState();
40 bool IsResultViewSelected(const SearchResultView* result_view) const;
42 void SearchResultActivated(SearchResultView* view, int event_flags);
44 void SearchResultActionActivated(SearchResultView* view,
48 void OnSearchResultInstalled(SearchResultView* view);
50 void OnSearchResultUninstalled(SearchResultView* view);
52 // Overridden from views::View:
53 bool OnKeyPressed(const ui::KeyEvent& event) override;
54 gfx::Size GetPreferredSize() const override;
56 // Overridden from ui::ListModelObserver:
57 void ListItemsRemoved(size_t start, size_t count) override;
59 // Overridden from SearchResultContainerView:
60 void Update() override;
63 friend class test::SearchResultListViewTest;
65 // Updates the auto launch states.
66 void SetAutoLaunchTimeout(const base::TimeDelta& timeout);
67 void CancelAutoLaunchTimeout();
69 // Helper function to get SearchResultView at given |index|.
70 SearchResultView* GetResultViewAt(int index);
72 // Forcibly auto-launch for test if it is in auto-launching state.
73 void ForceAutoLaunchForTest();
75 // Overridden from views::View:
76 void Layout() override;
77 int GetHeightForWidth(int w) const override;
78 void VisibilityChanged(views::View* starting_from, bool is_visible) override;
80 // Overridden from gfx::AnimationDelegate:
81 void AnimationEnded(const gfx::Animation* animation) override;
82 void AnimationProgressed(const gfx::Animation* animation) override;
84 SearchResultListViewDelegate* delegate_; // Not owned.
85 AppListViewDelegate* view_delegate_; // Not owned.
87 views::View* results_container_;
88 views::View* auto_launch_indicator_;
89 scoped_ptr<gfx::LinearAnimation> auto_launch_animation_;
91 int last_visible_index_;
94 DISALLOW_COPY_AND_ASSIGN(SearchResultListView);
97 } // namespace app_list
99 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_