Commit 9f4e9209 authored by calamity's avatar calamity Committed by Commit bot

Use a background for the main search box in the experimental app list.

This CL makes the DummySearchBoxBackground the standard SearchBoxView
background when using the experimental app list.

BUG=406222

Review URL: https://codereview.chromium.org/493293003

Cr-Commit-Position: refs/heads/master@{#291855}
parent f66329eb
...@@ -32,9 +32,6 @@ const SkColor kResultURLTextColor = SkColorSetRGB(0x00, 0x99, 0x33); ...@@ -32,9 +32,6 @@ const SkColor kResultURLTextColor = SkColorSetRGB(0x00, 0x99, 0x33);
const SkColor kGridTitleColor = SkColorSetRGB(0x5A, 0x5A, 0x5A); const SkColor kGridTitleColor = SkColorSetRGB(0x5A, 0x5A, 0x5A);
const SkColor kGridTitleHoverColor = SkColorSetRGB(0x3C, 0x3C, 0x3C); const SkColor kGridTitleHoverColor = SkColorSetRGB(0x3C, 0x3C, 0x3C);
// Color of the borders used in the experimental app list start page.
const SkColor kStartPageBorderColor = SkColorSetRGB(0xEE, 0xEE, 0xEE);
// Color of the folder ink bubble. // Color of the folder ink bubble.
const SkColor kFolderBubbleColor = SkColorSetRGB(0xD7, 0xD7, 0xD7); const SkColor kFolderBubbleColor = SkColorSetRGB(0xD7, 0xD7, 0xD7);
......
...@@ -35,8 +35,6 @@ APP_LIST_EXPORT extern const SkColor kResultURLTextColor; ...@@ -35,8 +35,6 @@ APP_LIST_EXPORT extern const SkColor kResultURLTextColor;
APP_LIST_EXPORT extern const SkColor kGridTitleColor; APP_LIST_EXPORT extern const SkColor kGridTitleColor;
APP_LIST_EXPORT extern const SkColor kGridTitleHoverColor; APP_LIST_EXPORT extern const SkColor kGridTitleHoverColor;
APP_LIST_EXPORT extern const SkColor kStartPageBorderColor;
APP_LIST_EXPORT extern const SkColor kFolderBubbleColor; APP_LIST_EXPORT extern const SkColor kFolderBubbleColor;
APP_LIST_EXPORT extern const int kPageTransitionDurationInMs; APP_LIST_EXPORT extern const int kPageTransitionDurationInMs;
......
...@@ -54,7 +54,8 @@ void AppListBackground::Paint(gfx::Canvas* canvas, ...@@ -54,7 +54,8 @@ void AppListBackground::Paint(gfx::Canvas* canvas,
int contents_top = bounds.y(); int contents_top = bounds.y();
views::View* search_box_view = main_view_->search_box_view(); views::View* search_box_view = main_view_->search_box_view();
if (main_view_->visible() && search_box_view->visible()) { if (main_view_->visible() && search_box_view->visible() &&
!app_list::switches::IsExperimentalAppListEnabled()) {
const gfx::Rect search_box_view_bounds = const gfx::Rect search_box_view_bounds =
search_box_view->ConvertRectToWidget(search_box_view->GetLocalBounds()); search_box_view->ConvertRectToWidget(search_box_view->GetLocalBounds());
gfx::Rect search_box_rect(bounds.x(), gfx::Rect search_box_rect(bounds.x(),
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "ui/app_list/views/contents_switcher_view.h" #include "ui/app_list/views/contents_switcher_view.h"
#include "ui/app_list/views/contents_view.h" #include "ui/app_list/views/contents_view.h"
#include "ui/app_list/views/search_box_view.h" #include "ui/app_list/views/search_box_view.h"
#include "ui/views/border.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
...@@ -41,6 +42,10 @@ const int kInnerPadding = 1; ...@@ -41,6 +42,10 @@ const int kInnerPadding = 1;
// The maximum allowed time to wait for icon loading in milliseconds. // The maximum allowed time to wait for icon loading in milliseconds.
const int kMaxIconLoadingWaitTimeInMs = 50; const int kMaxIconLoadingWaitTimeInMs = 50;
// The padding around the search box in the experimental app list.
const int kSearchBoxViewPadding = 24;
const int kSearchBoxViewPaddingBottom = 12;
// A view that holds another view and takes its preferred size. This is used for // A view that holds another view and takes its preferred size. This is used for
// wrapping the search box view so it still gets laid out while hidden. This is // wrapping the search box view so it still gets laid out while hidden. This is
// a separate class so it can notify the main view on search box visibility // a separate class so it can notify the main view on search box visibility
...@@ -120,7 +125,15 @@ AppListMainView::AppListMainView(AppListViewDelegate* delegate, ...@@ -120,7 +125,15 @@ AppListMainView::AppListMainView(AppListViewDelegate* delegate,
kInnerPadding)); kInnerPadding));
search_box_view_ = new SearchBoxView(this, delegate); search_box_view_ = new SearchBoxView(this, delegate);
AddChildView(new SearchBoxContainerView(this, search_box_view_)); views::View* container = new SearchBoxContainerView(this, search_box_view_);
if (switches::IsExperimentalAppListEnabled()) {
container->SetBorder(
views::Border::CreateEmptyBorder(kSearchBoxViewPadding,
kSearchBoxViewPadding,
kSearchBoxViewPaddingBottom,
kSearchBoxViewPadding));
}
AddChildView(container);
AddContentsViews(); AddContentsViews();
// Switch the apps grid view to the specified page. // Switch the apps grid view to the specified page.
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <algorithm> #include <algorithm>
#include "ui/app_list/app_list_model.h" #include "ui/app_list/app_list_model.h"
#include "ui/app_list/app_list_switches.h"
#include "ui/app_list/app_list_view_delegate.h" #include "ui/app_list/app_list_view_delegate.h"
#include "ui/app_list/search_box_model.h" #include "ui/app_list/search_box_model.h"
#include "ui/app_list/speech_ui_model.h" #include "ui/app_list/speech_ui_model.h"
...@@ -14,6 +15,7 @@ ...@@ -14,6 +15,7 @@
#include "ui/app_list/views/search_box_view_delegate.h" #include "ui/app_list/views/search_box_view_delegate.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/gfx/canvas.h"
#include "ui/resources/grit/ui_resources.h" #include "ui/resources/grit/ui_resources.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/button/image_button.h" #include "ui/views/controls/button/image_button.h"
...@@ -39,6 +41,40 @@ const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0); ...@@ -39,6 +41,40 @@ const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0);
const int kMenuYOffsetFromButton = -4; const int kMenuYOffsetFromButton = -4;
const int kMenuXOffsetFromButton = -7; const int kMenuXOffsetFromButton = -7;
// Experimental app list constants.
const int kExperimentalSearchBoxHeight = 37;
const int kBackgroundBorderWidth = 1;
const int kBackgroundBorderBottomWidth = 2;
const int kBackgroundBorderCornerRadius = 2;
const SkColor kBackgroundBorderColor = SkColorSetRGB(0xEE, 0xEE, 0xEE);
// A background that paints a solid white rounded rect with a thin grey border.
class SearchBoxBackground : public views::Background {
public:
SearchBoxBackground() {}
virtual ~SearchBoxBackground() {}
private:
// views::Background overrides:
virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE {
gfx::Rect bounds = view->GetContentsBounds();
SkPaint paint;
paint.setFlags(SkPaint::kAntiAlias_Flag);
paint.setColor(kBackgroundBorderColor);
canvas->DrawRoundRect(bounds, kBackgroundBorderCornerRadius, paint);
bounds.Inset(kBackgroundBorderWidth,
kBackgroundBorderWidth,
kBackgroundBorderWidth,
kBackgroundBorderBottomWidth);
paint.setColor(SK_ColorWHITE);
canvas->DrawRoundRect(bounds, kBackgroundBorderCornerRadius, paint);
}
DISALLOW_COPY_AND_ASSIGN(SearchBoxBackground);
};
} // namespace } // namespace
SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate, SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate,
...@@ -51,6 +87,8 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate, ...@@ -51,6 +87,8 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate,
search_box_(new views::Textfield), search_box_(new views::Textfield),
contents_view_(NULL) { contents_view_(NULL) {
AddChildView(icon_view_); AddChildView(icon_view_);
if (switches::IsExperimentalAppListEnabled())
set_background(new SearchBoxBackground());
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
...@@ -111,7 +149,10 @@ void SearchBoxView::InvalidateMenu() { ...@@ -111,7 +149,10 @@ void SearchBoxView::InvalidateMenu() {
} }
gfx::Size SearchBoxView::GetPreferredSize() const { gfx::Size SearchBoxView::GetPreferredSize() const {
return gfx::Size(kPreferredWidth, kPreferredHeight); return gfx::Size(kPreferredWidth,
switches::IsExperimentalAppListEnabled()
? kExperimentalSearchBoxHeight
: kPreferredHeight);
} }
void SearchBoxView::Layout() { void SearchBoxView::Layout() {
......
...@@ -36,55 +36,26 @@ const int kWebViewHeight = 105; ...@@ -36,55 +36,26 @@ const int kWebViewHeight = 105;
// DummySearchBoxView constants. // DummySearchBoxView constants.
const int kDummySearchBoxWidth = 490; const int kDummySearchBoxWidth = 490;
const int kDummySearchBoxHeight = 40;
const int kDummySearchBoxBorderWidth = 1;
const int kDummySearchBoxBorderBottomWidth = 2;
const int kDummySearchBoxBorderCornerRadius = 2;
// Tile container constants. // Tile container constants.
const size_t kNumStartPageTiles = 5; const size_t kNumStartPageTiles = 5;
const int kTileSpacing = 10; const int kTileSpacing = 10;
// A background that paints a solid white rounded rect with a thin grey border.
class DummySearchBoxBackground : public views::Background {
public:
DummySearchBoxBackground() {}
virtual ~DummySearchBoxBackground() {}
private:
// views::Background overrides:
virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE {
gfx::Rect bounds = view->GetContentsBounds();
SkPaint paint;
paint.setFlags(SkPaint::kAntiAlias_Flag);
paint.setColor(kStartPageBorderColor);
canvas->DrawRoundRect(bounds, kDummySearchBoxBorderCornerRadius, paint);
bounds.Inset(kDummySearchBoxBorderWidth,
kDummySearchBoxBorderWidth,
kDummySearchBoxBorderWidth,
kDummySearchBoxBorderBottomWidth);
paint.setColor(SK_ColorWHITE);
canvas->DrawRoundRect(bounds, kDummySearchBoxBorderCornerRadius, paint);
}
DISALLOW_COPY_AND_ASSIGN(DummySearchBoxBackground);
};
// A placeholder search box which is sized to fit within the start page view. // A placeholder search box which is sized to fit within the start page view.
class DummySearchBoxView : public SearchBoxView { class DummySearchBoxView : public SearchBoxView {
public: public:
DummySearchBoxView(SearchBoxViewDelegate* delegate, DummySearchBoxView(SearchBoxViewDelegate* delegate,
AppListViewDelegate* view_delegate) AppListViewDelegate* view_delegate)
: SearchBoxView(delegate, view_delegate) { : SearchBoxView(delegate, view_delegate) {
set_background(new DummySearchBoxBackground());
} }
virtual ~DummySearchBoxView() {} virtual ~DummySearchBoxView() {}
// Overridden from views::View: // Overridden from views::View:
virtual gfx::Size GetPreferredSize() const OVERRIDE { virtual gfx::Size GetPreferredSize() const OVERRIDE {
return gfx::Size(kDummySearchBoxWidth, kDummySearchBoxHeight); gfx::Size size(SearchBoxView::GetPreferredSize());
size.set_width(kDummySearchBoxWidth);
return size;
} }
private: private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment