summaryrefslogtreecommitdiffstats
path: root/ui/app_list/search_result.h
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-25 00:16:17 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-25 00:16:17 +0000
commitef59e6c4064973e58c923fbcfb51e68911cff8d8 (patch)
tree74b264a7a69765dc3c9b716b4f4b969612ec63e8 /ui/app_list/search_result.h
parent38ddaff588d764ac6a92ec1e8b6766732ba92efd (diff)
downloadchromium_src-ef59e6c4064973e58c923fbcfb51e68911cff8d8.zip
chromium_src-ef59e6c4064973e58c923fbcfb51e68911cff8d8.tar.gz
chromium_src-ef59e6c4064973e58c923fbcfb51e68911cff8d8.tar.bz2
app_list: Add search box and search result view for v2.
- Add a SearchBoxModel that represents search box's icon, placeholder text, user typed text and selection model (current selection and cursor position); - Add a SearchBoxView that displays SearchBoxModel and observes SearchBoxModel changes via SearchBoxModelObserver; When user typed/changed text in search box, the view also fires query changed notification to its SearchBoxViewDelegate; - Add a SearchResult that carries an icon, two tagged texts; - Add a SearchResultView that displays a SearchResult; - Change AppListModel to be a master model that has three sub models: apps list, search box and search results; - Add a SearchResultListView that display search results sub model of AppListModel using a list of SeachResultView; The view supports up/down key navigation and when user selects a result via mouse click or enter key, it asks its SearchResultListViewDelegate to OpenResult; - Update AppListViewDelegate: - Add new methods: StartSearch, StopSearch and OpenResult; - Deleted no-longer needed UpdateModel method; - Rename OnAppListItemActivated -> ActivateAppListItem; - Update ash_shell's app_list to support a simple substr match search; - Add a SearchBuilder that implements the search via AutoCompleteController; - Other changes: - Rename AppListModelBuilder -> AppsModelBuilder; - Rename AppListModelView -> AppsGridView; BUG=125964 TEST=Manual. In ash_shell, it searches the 5 example apps. In ash/chrome, it should show similar results as omnibox. Review URL: https://chromiumcodereview.appspot.com/10386224 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138938 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/app_list/search_result.h')
-rw-r--r--ui/app_list/search_result.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/ui/app_list/search_result.h b/ui/app_list/search_result.h
new file mode 100644
index 0000000..bd60d55
--- /dev/null
+++ b/ui/app_list/search_result.h
@@ -0,0 +1,78 @@
+// 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_SEARCH_RESULT_H_
+#define UI_APP_LIST_SEARCH_RESULT_H_
+#pragma once
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/string16.h"
+#include "ui/app_list/app_list_export.h"
+#include "ui/base/models/list_model.h"
+#include "ui/base/range/range.h"
+#include "ui/gfx/image/image_skia.h"
+
+namespace app_list {
+
+// SearchResult consists of an icon, title text and details text. Title and
+// details text can have tagged ranges that are displayed differently from
+// default style.
+class APP_LIST_EXPORT SearchResult {
+ public:
+ // A tagged range in search result text.
+ struct Tag {
+ // Similar to ACMatchClassification::Style, the style values are not
+ // mutually exclusive.
+ enum Style {
+ NONE = 0,
+ URL = 1 << 0,
+ MATCH = 1 << 1,
+ DIM = 1 << 2,
+ };
+
+ Tag(int styles, size_t start, size_t end)
+ : styles(styles),
+ range(start, end) {
+ }
+
+ int styles;
+ ui::Range range;
+ };
+ typedef std::vector<Tag> Tags;
+
+ SearchResult();
+ virtual ~SearchResult();
+
+ const gfx::ImageSkia& icon() const { return icon_; }
+ void set_icon(const gfx::ImageSkia& icon) { icon_ = icon; }
+
+ const string16& title() const { return title_; }
+ void set_title(const string16& title) { title_ = title;}
+
+ const Tags& title_tags() const { return title_tags_; }
+ void set_title_tags(const Tags& tags) { title_tags_ = tags; }
+
+ const string16& details() const { return details_; }
+ void set_details(const string16& details) { details_ = details; }
+
+ const Tags& details_tags() const { return details_tags_; }
+ void set_details_tags(const Tags& tags) { details_tags_ = tags; }
+
+ private:
+ gfx::ImageSkia icon_;
+
+ string16 title_;
+ Tags title_tags_;
+
+ string16 details_;
+ Tags details_tags_;
+
+ DISALLOW_COPY_AND_ASSIGN(SearchResult);
+};
+
+} // namespace app_list
+
+#endif // UI_APP_LIST_SEARCH_RESULT_H_