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

Side by Side Diff: ui/app_list/views/contents_animator.cc

Issue 781833005: Make SearchResultPageView animation clip to its onscreen bounds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_overlay_one
Patch Set: address_comments Created 6 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/app_list/views/contents_animator.h" 5 #include "ui/app_list/views/contents_animator.h"
6 6
7 #include "ui/app_list/app_list_constants.h" 7 #include "ui/app_list/app_list_constants.h"
8 #include "ui/app_list/app_list_switches.h" 8 #include "ui/app_list/app_list_switches.h"
9 #include "ui/app_list/views/app_list_main_view.h" 9 #include "ui/app_list/views/app_list_main_view.h"
10 #include "ui/app_list/views/contents_view.h" 10 #include "ui/app_list/views/contents_view.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 contents_view()->GetSearchBoxBoundsForPageIndex(to_page)); 93 contents_view()->GetSearchBoxBoundsForPageIndex(to_page));
94 94
95 gfx::Rect search_box_rect = 95 gfx::Rect search_box_rect =
96 gfx::Tween::RectValueBetween(progress, search_box_from, search_box_to); 96 gfx::Tween::RectValueBetween(progress, search_box_from, search_box_to);
97 97
98 views::View* search_box = contents_view()->GetSearchBoxView(); 98 views::View* search_box = contents_view()->GetSearchBoxView();
99 search_box->GetWidget()->SetBounds( 99 search_box->GetWidget()->SetBounds(
100 contents_view()->ConvertRectToWidget(search_box_rect)); 100 contents_view()->ConvertRectToWidget(search_box_rect));
101 } 101 }
102 102
103 void ContentsAnimator::ClipPageToOnscreenBounds(
104 int page_index,
105 const gfx::Rect& current_bounds,
106 const gfx::Rect& onscreen_bounds) {
107 int search_results_index =
108 contents_view()->GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS);
109 if (page_index != search_results_index)
110 return;
111
112 contents_view()
113 ->GetPageView(page_index)
114 ->set_clip_insets(current_bounds.InsetsFrom(onscreen_bounds));
115 }
116
103 // DefaultAnimator 117 // DefaultAnimator
104 118
105 DefaultAnimator::DefaultAnimator(ContentsView* contents_view) 119 DefaultAnimator::DefaultAnimator(ContentsView* contents_view)
106 : ContentsAnimator(contents_view) { 120 : ContentsAnimator(contents_view) {
107 } 121 }
108 122
109 std::string DefaultAnimator::NameForTests() const { 123 std::string DefaultAnimator::NameForTests() const {
110 return "DefaultAnimator"; 124 return "DefaultAnimator";
111 } 125 }
112 126
113 void DefaultAnimator::Update(double progress, int from_page, int to_page) { 127 void DefaultAnimator::Update(double progress, int from_page, int to_page) {
114 // Move the from page from 0 to its origin. Move the to page from its origin 128 // Move the from page from 0 to its origin. Move the to page from its origin
115 // to 0. 129 // to 0.
116 gfx::Rect from_page_onscreen(GetOnscreenPageBounds(from_page)); 130 gfx::Rect from_page_onscreen(GetOnscreenPageBounds(from_page));
117 gfx::Rect to_page_onscreen(GetOnscreenPageBounds(to_page)); 131 gfx::Rect to_page_onscreen(GetOnscreenPageBounds(to_page));
118 gfx::Rect from_page_origin(GetOffscreenPageBounds(from_page)); 132 gfx::Rect from_page_origin(GetOffscreenPageBounds(from_page));
119 gfx::Rect to_page_origin(GetOffscreenPageBounds(to_page)); 133 gfx::Rect to_page_origin(GetOffscreenPageBounds(to_page));
120 gfx::Rect from_page_rect(gfx::Tween::RectValueBetween( 134 gfx::Rect from_page_rect(gfx::Tween::RectValueBetween(
121 progress, from_page_onscreen, from_page_origin)); 135 progress, from_page_onscreen, from_page_origin));
122 gfx::Rect to_page_rect( 136 gfx::Rect to_page_rect(
123 gfx::Tween::RectValueBetween(progress, to_page_origin, to_page_onscreen)); 137 gfx::Tween::RectValueBetween(progress, to_page_origin, to_page_onscreen));
124 138
125 contents_view()->GetPageView(from_page)->SetBoundsRect(from_page_rect); 139 contents_view()->GetPageView(from_page)->SetBoundsRect(from_page_rect);
140 ClipPageToOnscreenBounds(from_page, from_page_rect, from_page_onscreen);
141
126 contents_view()->GetPageView(to_page)->SetBoundsRect(to_page_rect); 142 contents_view()->GetPageView(to_page)->SetBoundsRect(to_page_rect);
143 ClipPageToOnscreenBounds(to_page, to_page_rect, to_page_onscreen);
127 144
128 UpdateCustomPageForDefaultAnimation(progress, from_page, to_page); 145 UpdateCustomPageForDefaultAnimation(progress, from_page, to_page);
129 UpdateSearchBoxForDefaultAnimation(progress, from_page, to_page); 146 UpdateSearchBoxForDefaultAnimation(progress, from_page, to_page);
130 } 147 }
131 148
132 // StartToAppsAnimator 149 // StartToAppsAnimator
133 150
134 StartToAppsAnimator::StartToAppsAnimator(ContentsView* contents_view) 151 StartToAppsAnimator::StartToAppsAnimator(ContentsView* contents_view)
135 : ContentsAnimator(contents_view) { 152 : ContentsAnimator(contents_view) {
136 } 153 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 gfx::Rect custom_page_rect(gfx::Tween::RectValueBetween( 198 gfx::Rect custom_page_rect(gfx::Tween::RectValueBetween(
182 progress, custom_page_origin, custom_page_on_screen)); 199 progress, custom_page_origin, custom_page_on_screen));
183 200
184 contents_view()->GetPageView(start_page)->SetBoundsRect(start_page_rect); 201 contents_view()->GetPageView(start_page)->SetBoundsRect(start_page_rect);
185 contents_view()->GetPageView(custom_page)->SetBoundsRect(custom_page_rect); 202 contents_view()->GetPageView(custom_page)->SetBoundsRect(custom_page_rect);
186 203
187 UpdateSearchBoxForDefaultAnimation(progress, start_page, custom_page); 204 UpdateSearchBoxForDefaultAnimation(progress, start_page, custom_page);
188 } 205 }
189 206
190 } // namespace app_list 207 } // namespace app_list
OLDNEW
« ui/app_list/views/contents_animator.h ('K') | « ui/app_list/views/contents_animator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698