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

Unified Diff: ui/app_list/views/contents_view.cc

Issue 657653002: Move app list search box into AppListView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « ui/app_list/views/contents_view.h ('k') | ui/app_list/views/search_box_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/contents_view.cc
diff --git a/ui/app_list/views/contents_view.cc b/ui/app_list/views/contents_view.cc
index 80df04b7628ebd54bb14ff86c8915ce658bfe3e7..42fc8f156395c1b35a253c8d7aa1287aef1c2ec4 100644
--- a/ui/app_list/views/contents_view.cc
+++ b/ui/app_list/views/contents_view.cc
@@ -16,6 +16,7 @@
#include "ui/app_list/views/apps_container_view.h"
#include "ui/app_list/views/apps_grid_view.h"
#include "ui/app_list/views/contents_switcher_view.h"
+#include "ui/app_list/views/search_box_view.h"
#include "ui/app_list/views/search_result_list_view.h"
#include "ui/app_list/views/start_page_view.h"
#include "ui/events/event.h"
@@ -80,9 +81,6 @@ void ContentsView::InitNamedPages(AppListModel* model,
page_before_search_ = initial_page_index;
pagination_model_.SelectPage(initial_page_index, false);
-
- // Needed to update the main search box visibility.
- ActivePageChanged(false);
}
void ContentsView::CancelDrag() {
@@ -216,7 +214,7 @@ void ContentsView::UpdatePageBounds() {
// Move |current_page| from 0 to its origin. Move |target_page| from its
// origin to 0.
- gfx::Rect on_screen(GetContentsBounds());
+ gfx::Rect on_screen(GetDefaultContentsBounds());
gfx::Rect current_page_origin(GetOffscreenPageBounds(current_page));
gfx::Rect target_page_origin(GetOffscreenPageBounds(target_page));
gfx::Rect current_page_rect(
@@ -266,7 +264,26 @@ int ContentsView::AddLauncherPage(views::View* view,
return page_index;
}
-gfx::Size ContentsView::GetPreferredSize() const {
+gfx::Rect ContentsView::GetDefaultSearchBoxBounds() const {
+ gfx::Rect search_box_bounds(
+ 0,
+ 0,
+ GetDefaultContentsSize().width(),
+ app_list_main_view_->search_box_view()->GetPreferredSize().height());
+ if (switches::IsExperimentalAppListEnabled()) {
+ search_box_bounds.set_y(kExperimentalWindowPadding);
+ search_box_bounds.Inset(kExperimentalWindowPadding, 0);
+ }
+ return search_box_bounds;
+}
+
+gfx::Rect ContentsView::GetDefaultContentsBounds() const {
+ gfx::Rect bounds(gfx::Point(0, GetDefaultSearchBoxBounds().bottom()),
+ GetDefaultContentsSize());
+ return bounds;
+}
+
+gfx::Size ContentsView::GetDefaultContentsSize() const {
const gfx::Size container_size =
apps_container_view_->apps_grid_view()->GetPreferredSize();
const gfx::Size results_size = search_results_view_
@@ -278,6 +295,16 @@ gfx::Size ContentsView::GetPreferredSize() const {
return gfx::Size(width, height);
}
+gfx::Size ContentsView::GetPreferredSize() const {
+ gfx::Rect search_box_bounds = GetDefaultSearchBoxBounds();
+ gfx::Rect default_contents_bounds = GetDefaultContentsBounds();
+ gfx::Vector2d bottom_right =
+ search_box_bounds.bottom_right().OffsetFromOrigin();
+ bottom_right.SetToMax(
+ default_contents_bounds.bottom_right().OffsetFromOrigin());
+ return gfx::Size(bottom_right.x(), bottom_right.y());
+}
+
void ContentsView::Layout() {
// Immediately finish all current animations.
pagination_model_.FinishAnimation();
@@ -285,7 +312,7 @@ void ContentsView::Layout() {
// Move the current view onto the screen, and all other views off screen to
// the left. (Since we are not animating, we don't need to be careful about
// which side we place the off-screen views onto.)
- gfx::Rect rect(GetContentsBounds());
+ gfx::Rect rect(GetDefaultContentsBounds());
if (rect.IsEmpty())
return;
« no previous file with comments | « ui/app_list/views/contents_view.h ('k') | ui/app_list/views/search_box_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698