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_
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"
30 class ProgressBarView
;
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
{
43 // Internal class name.
44 static const char kViewClassName
[];
46 SearchResultView(SearchResultListView
* list_view
,
47 SearchResultViewDelegate
* delegate
);
48 virtual ~SearchResultView();
50 // Sets/gets SearchResult displayed by this view.
51 void SetResult(SearchResult
* result
);
52 SearchResult
* result() { return result_
; }
54 // Clears reference to SearchResult but don't schedule repaint.
55 void ClearResultNoRepaint();
57 // Clears the selected action.
58 void ClearSelectedAction();
61 void UpdateTitleText();
62 void UpdateDetailsText();
64 // views::View overrides:
65 virtual const char* GetClassName() const OVERRIDE
;
66 virtual gfx::Size
GetPreferredSize() OVERRIDE
;
67 virtual void Layout() OVERRIDE
;
68 virtual bool OnKeyPressed(const ui::KeyEvent
& event
) OVERRIDE
;
69 virtual void ChildPreferredSizeChanged(views::View
* child
) OVERRIDE
;
70 virtual void OnPaint(gfx::Canvas
* canvas
) OVERRIDE
;
72 // views::ButtonListener overrides:
73 virtual void ButtonPressed(views::Button
* sender
,
74 const ui::Event
& event
) OVERRIDE
;
76 // views::ContextMenuController overrides:
77 virtual void ShowContextMenuForView(views::View
* source
,
78 const gfx::Point
& point
,
79 ui::MenuSourceType source_type
) OVERRIDE
;
81 // SearchResultObserver overrides:
82 virtual void OnIconChanged() OVERRIDE
;
83 virtual void OnActionsChanged() OVERRIDE
;
84 virtual void OnIsInstallingChanged() OVERRIDE
;
85 virtual void OnPercentDownloadedChanged() OVERRIDE
;
86 virtual void OnItemInstalled() OVERRIDE
;
87 virtual void OnItemUninstalled() OVERRIDE
;
89 // SearchResultActionsViewDelegate overrides:
90 virtual void OnSearchResultActionActivated(size_t index
,
91 int event_flags
) OVERRIDE
;
93 SearchResult
* result_
; // Owned by AppListModel::SearchResults.
95 // Parent list view. Owned by views hierarchy.
96 SearchResultListView
* list_view_
;
99 SearchResultViewDelegate
* delegate_
;
101 views::ImageView
* icon_
; // Owned by views hierarchy.
102 scoped_ptr
<gfx::RenderText
> title_text_
;
103 scoped_ptr
<gfx::RenderText
> details_text_
;
104 SearchResultActionsView
* actions_view_
; // Owned by the views hierarchy.
105 ProgressBarView
* progress_bar_
; // Owned by views hierarchy.
107 scoped_ptr
<views::MenuRunner
> context_menu_runner_
;
109 DISALLOW_COPY_AND_ASSIGN(SearchResultView
);
112 } // namespace app_list
114 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_VIEW_H_