Paint state transition for overlay 9 patch scrollbars
[chromium-blink-merge.git] / ui / app_list / views / search_result_view.h
blobbe7037ec4e7752ffd29b160b887371ab60db3a67
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_VIEW_H_
6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_VIEW_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/app_list/search_result_observer.h"
14 #include "ui/app_list/views/search_result_actions_view_delegate.h"
15 #include "ui/views/context_menu_controller.h"
16 #include "ui/views/controls/button/custom_button.h"
18 namespace gfx {
19 class RenderText;
22 namespace views {
23 class ImageButton;
24 class ImageView;
25 class MenuRunner;
28 namespace app_list {
30 class ProgressBarView;
31 class SearchResult;
32 class SearchResultListView;
33 class SearchResultViewDelegate;
34 class SearchResultActionsView;
36 // SearchResultView displays a SearchResult.
37 class SearchResultView : public views::CustomButton,
38 public views::ButtonListener,
39 public views::ContextMenuController,
40 public SearchResultObserver,
41 public SearchResultActionsViewDelegate {
42 public:
43 // Internal class name.
44 static const char kViewClassName[];
46 explicit SearchResultView(SearchResultListView* list_view);
47 virtual ~SearchResultView();
49 // Sets/gets SearchResult displayed by this view.
50 void SetResult(SearchResult* result);
51 SearchResult* result() { return result_; }
53 // Clears reference to SearchResult but don't schedule repaint.
54 void ClearResultNoRepaint();
56 // Clears the selected action.
57 void ClearSelectedAction();
59 private:
60 void UpdateTitleText();
61 void UpdateDetailsText();
63 // views::View overrides:
64 virtual const char* GetClassName() const OVERRIDE;
65 virtual gfx::Size GetPreferredSize() const OVERRIDE;
66 virtual void Layout() OVERRIDE;
67 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
68 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
69 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
71 // views::ButtonListener overrides:
72 virtual void ButtonPressed(views::Button* sender,
73 const ui::Event& event) OVERRIDE;
75 // views::ContextMenuController overrides:
76 virtual void ShowContextMenuForView(views::View* source,
77 const gfx::Point& point,
78 ui::MenuSourceType source_type) OVERRIDE;
80 // SearchResultObserver overrides:
81 virtual void OnIconChanged() OVERRIDE;
82 virtual void OnActionsChanged() OVERRIDE;
83 virtual void OnIsInstallingChanged() OVERRIDE;
84 virtual void OnPercentDownloadedChanged() OVERRIDE;
85 virtual void OnItemInstalled() OVERRIDE;
86 virtual void OnItemUninstalled() OVERRIDE;
88 // SearchResultActionsViewDelegate overrides:
89 virtual void OnSearchResultActionActivated(size_t index,
90 int event_flags) OVERRIDE;
92 SearchResult* result_; // Owned by AppListModel::SearchResults.
94 // Parent list view. Owned by views hierarchy.
95 SearchResultListView* list_view_;
97 views::ImageView* icon_; // Owned by views hierarchy.
98 scoped_ptr<gfx::RenderText> title_text_;
99 scoped_ptr<gfx::RenderText> details_text_;
100 SearchResultActionsView* actions_view_; // Owned by the views hierarchy.
101 ProgressBarView* progress_bar_; // Owned by views hierarchy.
103 scoped_ptr<views::MenuRunner> context_menu_runner_;
105 DISALLOW_COPY_AND_ASSIGN(SearchResultView);
108 } // namespace app_list
110 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_VIEW_H_