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 UpdateAutoLaunchState();
38 bool IsResultViewSelected(const SearchResultView
* result_view
) const;
40 void SearchResultActivated(SearchResultView
* view
, int event_flags
);
42 void SearchResultActionActivated(SearchResultView
* view
,
46 void OnSearchResultInstalled(SearchResultView
* view
);
48 // Overridden from views::View:
49 bool OnKeyPressed(const ui::KeyEvent
& event
) override
;
50 gfx::Size
GetPreferredSize() const override
;
52 // Overridden from ui::ListModelObserver:
53 void ListItemsRemoved(size_t start
, size_t count
) override
;
55 // Overridden from SearchResultContainerView:
56 void OnContainerSelected(bool from_bottom
,
57 bool directional_movement
) override
;
58 void NotifyFirstResultYIndex(int y_index
) override
;
59 int GetYSize() override
;
62 friend class test::SearchResultListViewTest
;
64 // Overridden from SearchResultContainerView:
65 int Update() override
;
66 void UpdateSelectedIndex(int old_selected
, int new_selected
) override
;
68 // Updates the auto launch states.
69 void SetAutoLaunchTimeout(const base::TimeDelta
& timeout
);
70 void CancelAutoLaunchTimeout();
72 // Helper function to get SearchResultView at given |index|.
73 SearchResultView
* GetResultViewAt(int index
);
75 // Forcibly auto-launch for test if it is in auto-launching state.
76 void ForceAutoLaunchForTest();
78 // Overridden from views::View:
79 void Layout() override
;
80 int GetHeightForWidth(int w
) const override
;
81 void VisibilityChanged(views::View
* starting_from
, bool is_visible
) override
;
83 // Overridden from gfx::AnimationDelegate:
84 void AnimationEnded(const gfx::Animation
* animation
) override
;
85 void AnimationProgressed(const gfx::Animation
* animation
) override
;
87 SearchResultListViewDelegate
* delegate_
; // Not owned.
88 AppListViewDelegate
* view_delegate_
; // Not owned.
90 views::View
* results_container_
;
91 views::View
* auto_launch_indicator_
;
92 scoped_ptr
<gfx::LinearAnimation
> auto_launch_animation_
;
94 DISALLOW_COPY_AND_ASSIGN(SearchResultListView
);
97 } // namespace app_list
99 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_