blob: eb101aac1a1c562d6c85253ce831a4e81526266d [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_
#define UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_
#include <stddef.h>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "ui/app_list/views/search_result_container_view.h"
#include "ui/views/view.h"
namespace app_list {
namespace test {
class SearchResultListViewTest;
}
class AppListMainView;
class AppListViewDelegate;
class SearchResultView;
// SearchResultListView displays SearchResultList with a list of
// SearchResultView.
class APP_LIST_EXPORT SearchResultListView : public SearchResultContainerView {
public:
SearchResultListView(AppListMainView* main_view,
AppListViewDelegate* view_delegate);
~SearchResultListView() override;
bool IsResultViewSelected(const SearchResultView* result_view) const;
void SearchResultActivated(SearchResultView* view, int event_flags);
void SearchResultActionActivated(SearchResultView* view,
size_t action_index,
int event_flags);
void OnSearchResultInstalled(SearchResultView* view);
// Overridden from views::View:
gfx::Size CalculatePreferredSize() const override;
const char* GetClassName() const override;
// Overridden from ui::ListModelObserver:
void ListItemsRemoved(size_t start, size_t count) override;
// Overridden from SearchResultContainerView:
void OnContainerSelected(bool from_bottom,
bool directional_movement) override;
void NotifyFirstResultYIndex(int y_index) override;
int GetYSize() override;
views::View* GetSelectedView() const override;
views::View* GetFirstResultView() override;
void SetFirstResultSelected(bool selected) override;
views::View* results_container_for_test() const { return results_container_; }
private:
friend class test::SearchResultListViewTest;
// Overridden from SearchResultContainerView:
int DoUpdate() override;
void UpdateSelectedIndex(int old_selected, int new_selected) override;
// Helper function to get SearchResultView at given |index|.
SearchResultView* GetResultViewAt(int index) const;
// Overridden from views::View:
void Layout() override;
int GetHeightForWidth(int w) const override;
AppListMainView* main_view_; // Owned by views hierarchy.
AppListViewDelegate* view_delegate_; // Not owned.
views::View* results_container_;
DISALLOW_COPY_AND_ASSIGN(SearchResultListView);
};
} // namespace app_list
#endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_