Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Unified Diff: ui/app_list/app_list_bubble_border.cc

Issue 10386224: app_list: Add search box and search result view for v2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, rename and add chrome search Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/app_list/app_list_bubble_border.cc
diff --git a/ui/app_list/app_list_bubble_border.cc b/ui/app_list/app_list_bubble_border.cc
index 64dc46c3a1fb1224b072e41c43716be97802add0..e23301d660c1f6c5b03a7ab97618c27316435340 100644
--- a/ui/app_list/app_list_bubble_border.cc
+++ b/ui/app_list/app_list_bubble_border.cc
@@ -8,6 +8,7 @@
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/effects/SkBlurDrawLooper.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
+#include "ui/app_list/view_ids.h"
#include "ui/gfx/canvas.h"
namespace {
@@ -27,6 +28,8 @@ const int kBorderSize = 1;
const SkColor kShadowColor = SkColorSetARGB(0xFF, 0, 0, 0);
const int kShadowRadius = 4;
+const SkColor kSearchBoxBackground = SK_ColorWHITE;
+
// Colors and sizes of top separator between searchbox and grid view.
const SkColor kTopSeparatorColor = SkColorSetRGB(0xDB, 0xDB, 0xDB);
const int kTopSeparatorSize = 1;
@@ -103,18 +106,74 @@ AppListBubbleBorder::AppListBubbleBorder(views::View* app_list_view)
AppListBubbleBorder::~AppListBubbleBorder() {
}
-void AppListBubbleBorder::PaintModelViewBackground(
+void AppListBubbleBorder::PaintSearchBoxBackground(
gfx::Canvas* canvas,
const gfx::Rect& bounds) const {
- const views::View* page_switcher = app_list_view_->child_at(1);
- const gfx::Rect page_switcher_bounds =
- app_list_view_->ConvertRectToWidget(page_switcher->bounds());
+ const views::View* search_box_view =
+ app_list_view_->GetViewByID(VIEW_ID_SEARCH_BOX);
+ const gfx::Rect search_box_view_bounds =
+ app_list_view_->ConvertRectToWidget(search_box_view->bounds());
gfx::Rect rect(bounds.x(),
bounds.y(),
bounds.width(),
- page_switcher_bounds.y() - bounds.y());
+ search_box_view_bounds.bottom() - bounds.y());
+
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(kSearchBoxBackground);
+ canvas->DrawRect(rect, paint);
+
+ gfx::Rect seperator_rect(rect);
+ seperator_rect.set_y(seperator_rect.bottom());
+ seperator_rect.set_height(kTopSeparatorSize);
+ canvas->FillRect(seperator_rect, kTopSeparatorColor);
+}
+
+void AppListBubbleBorder::PaintSearchResultListBackground(
+ gfx::Canvas* canvas,
+ const gfx::Rect& bounds) const {
+ const views::View* results_view =
+ app_list_view_->GetViewByID(VIEW_ID_SEARCH_RESULTS);
+ if (!results_view->visible())
+ return;
+
+ const views::View* search_box_view =
+ app_list_view_->GetViewByID(VIEW_ID_SEARCH_BOX);
+ const gfx::Rect search_box_view_bounds =
+ app_list_view_->ConvertRectToWidget(search_box_view->bounds());
+ int start_y = search_box_view_bounds.bottom() + kTopSeparatorSize;
+ gfx::Rect rect(bounds.x(),
+ start_y,
+ bounds.width(),
+ bounds.bottom() - start_y + kArrowHeight);
- // TODO(xiyuan): Draw 1px separator line after SearchBoxView is added.
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(kSearchBoxBackground);
+ canvas->DrawRect(rect, paint);
+}
+
+void AppListBubbleBorder::PaintAppsGridBackground(
+ gfx::Canvas* canvas,
+ const gfx::Rect& bounds) const {
+ const views::View* grid =
+ app_list_view_->GetViewByID(VIEW_ID_APPS_GRID);
+ if (!grid->visible())
+ return;
+
+ const views::View* search_box_view =
+ app_list_view_->GetViewByID(VIEW_ID_SEARCH_BOX);
+ const gfx::Rect search_box_view_bounds =
+ app_list_view_->ConvertRectToWidget(search_box_view->bounds());
+ const views::View* page_switcher =
+ app_list_view_->GetViewByID(VIEW_ID_PAGE_SWITCHER);
+ const gfx::Rect page_switcher_bounds =
+ app_list_view_->ConvertRectToWidget(page_switcher->bounds());
+ int start_y = search_box_view_bounds.bottom() + kTopSeparatorSize;
+ gfx::Rect rect(bounds.x(),
+ start_y,
+ bounds.width(),
+ page_switcher_bounds.y() - start_y);
SkPaint paint;
paint.setStyle(SkPaint::kFill_Style);
@@ -130,7 +189,11 @@ void AppListBubbleBorder::PaintModelViewBackground(
void AppListBubbleBorder::PaintPageSwitcherBackground(
gfx::Canvas* canvas,
const gfx::Rect& bounds) const {
- const views::View* page_switcher = app_list_view_->child_at(1);
+ const views::View* page_switcher =
+ app_list_view_->GetViewByID(VIEW_ID_PAGE_SWITCHER);
+ if (!page_switcher->visible())
+ return;
+
const gfx::Rect page_switcher_bounds =
app_list_view_->ConvertRectToWidget(page_switcher->bounds());
@@ -212,8 +275,10 @@ void AppListBubbleBorder::Paint(const views::View& view,
canvas->Save();
canvas->ClipPath(path);
- PaintModelViewBackground(canvas, bounds);
+ PaintSearchBoxBackground(canvas, bounds);
+ PaintAppsGridBackground(canvas, bounds);
PaintPageSwitcherBackground(canvas, bounds);
+ PaintSearchResultListBackground(canvas, bounds);
canvas->Restore();
}

Powered by Google App Engine
This is Rietveld 408576698