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

Side by Side Diff: ui/app_list/app_list_bubble_border.cc

Issue 10534051: app_list: Add transition for apps grid and search results. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/app_list/app_list_bubble_border.h ('k') | ui/app_list/app_list_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/app_list_bubble_border.h" 5 #include "ui/app_list/app_list_bubble_border.h"
6 6
7 #include "third_party/skia/include/core/SkPath.h" 7 #include "third_party/skia/include/core/SkPath.h"
8 #include "third_party/skia/include/core/SkPaint.h" 8 #include "third_party/skia/include/core/SkPaint.h"
9 #include "third_party/skia/include/effects/SkGradientShader.h" 9 #include "third_party/skia/include/effects/SkGradientShader.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 path->close(); 113 path->close();
114 } 114 }
115 115
116 } // namespace 116 } // namespace
117 117
118 namespace app_list { 118 namespace app_list {
119 119
120 AppListBubbleBorder::AppListBubbleBorder(views::View* app_list_view, 120 AppListBubbleBorder::AppListBubbleBorder(views::View* app_list_view,
121 views::View* search_box_view, 121 views::View* search_box_view)
122 views::View* grid_view,
123 views::View* results_view)
124 : views::BubbleBorder(views::BubbleBorder::BOTTOM_RIGHT, 122 : views::BubbleBorder(views::BubbleBorder::BOTTOM_RIGHT,
125 views::BubbleBorder::NO_SHADOW), 123 views::BubbleBorder::NO_SHADOW),
126 app_list_view_(app_list_view), 124 app_list_view_(app_list_view),
127 search_box_view_(search_box_view), 125 search_box_view_(search_box_view) {
128 grid_view_(grid_view),
129 results_view_(results_view) {
130 const gfx::ShadowValue kShadows[] = { 126 const gfx::ShadowValue kShadows[] = {
131 // Offset (0, 5), blur=8, color=0.36 black 127 // Offset (0, 5), blur=8, color=0.36 black
132 gfx::ShadowValue(gfx::Point(0, 5), 8, SkColorSetARGB(0x5B, 0, 0, 0)), 128 gfx::ShadowValue(gfx::Point(0, 5), 30, SkColorSetARGB(0x72, 0, 0, 0)),
133 }; 129 };
134 shadows_.assign(kShadows, kShadows + arraysize(kShadows)); 130 shadows_.assign(kShadows, kShadows + arraysize(kShadows));
135 } 131 }
136 132
137 AppListBubbleBorder::~AppListBubbleBorder() { 133 AppListBubbleBorder::~AppListBubbleBorder() {
138 } 134 }
139 135
140 bool AppListBubbleBorder::ArrowAtTopOrBottom() const { 136 bool AppListBubbleBorder::ArrowAtTopOrBottom() const {
141 return arrow_location() == views::BubbleBorder::TOP_LEFT || 137 return arrow_location() == views::BubbleBorder::TOP_LEFT ||
142 arrow_location() == views::BubbleBorder::TOP_RIGHT || 138 arrow_location() == views::BubbleBorder::TOP_RIGHT ||
(...skipping 16 matching lines...) Expand all
159 return -offset_.x(); 155 return -offset_.x();
160 } else if (ArrowOnLeftOrRight()) { 156 } else if (ArrowOnLeftOrRight()) {
161 // Picks y offset and moves bubble arrow in the opposite direction. 157 // Picks y offset and moves bubble arrow in the opposite direction.
162 return -offset_.y(); 158 return -offset_.y();
163 } 159 }
164 160
165 // Other style does not have an arrow, so return 0. 161 // Other style does not have an arrow, so return 0.
166 return 0; 162 return 0;
167 } 163 }
168 164
169 void AppListBubbleBorder::PaintSearchBoxBackground( 165 void AppListBubbleBorder::PaintBackground(gfx::Canvas* canvas,
170 gfx::Canvas* canvas, 166 const gfx::Rect& bounds) const {
171 const gfx::Rect& bounds) const {
172 const gfx::Rect search_box_view_bounds = 167 const gfx::Rect search_box_view_bounds =
173 app_list_view_->ConvertRectToWidget(search_box_view_->bounds()); 168 app_list_view_->ConvertRectToWidget(search_box_view_->bounds());
174 gfx::Rect rect(bounds.x(), 169 gfx::Rect search_box_rect(bounds.x(),
175 bounds.y(), 170 bounds.y(),
176 bounds.width(), 171 bounds.width(),
177 search_box_view_bounds.bottom() - bounds.y()); 172 search_box_view_bounds.bottom() - bounds.y());
178 173
179 SkPaint paint; 174 SkPaint paint;
180 paint.setStyle(SkPaint::kFill_Style); 175 paint.setStyle(SkPaint::kFill_Style);
181 paint.setColor(kSearchBoxBackground); 176 paint.setColor(kSearchBoxBackground);
182 canvas->DrawRect(rect, paint); 177 canvas->DrawRect(search_box_rect, paint);
183 178
184 gfx::Rect seperator_rect(rect); 179 gfx::Rect seperator_rect(search_box_rect);
185 seperator_rect.set_y(seperator_rect.bottom()); 180 seperator_rect.set_y(seperator_rect.bottom());
186 seperator_rect.set_height(kTopSeparatorSize); 181 seperator_rect.set_height(kTopSeparatorSize);
187 canvas->FillRect(seperator_rect, kTopSeparatorColor); 182 canvas->FillRect(seperator_rect, kTopSeparatorColor);
188 }
189 183
190 void AppListBubbleBorder::PaintSearchResultListBackground( 184 gfx::Rect contents_rect(bounds.x(),
191 gfx::Canvas* canvas, 185 seperator_rect.bottom(),
192 const gfx::Rect& bounds) const { 186 bounds.width(),
193 if (!results_view_->visible()) 187 bounds.bottom() - seperator_rect.bottom());
194 return;
195 188
196 const gfx::Rect search_box_view_bounds =
197 app_list_view_->ConvertRectToWidget(search_box_view_->bounds());
198 int start_y = search_box_view_bounds.bottom() + kTopSeparatorSize;
199 gfx::Rect rect(bounds.x(),
200 start_y,
201 bounds.width(),
202 bounds.bottom() - start_y);
203
204 SkPaint paint;
205 paint.setStyle(SkPaint::kFill_Style);
206 paint.setColor(kContentsBackground); 189 paint.setColor(kContentsBackground);
207 canvas->DrawRect(rect, paint); 190 canvas->DrawRect(contents_rect, paint);
208 }
209
210 void AppListBubbleBorder::PaintAppsGridBackground(
211 gfx::Canvas* canvas,
212 const gfx::Rect& bounds) const {
213 if (!grid_view_->visible())
214 return;
215
216 const gfx::Rect search_box_view_bounds =
217 app_list_view_->ConvertRectToWidget(search_box_view_->bounds());
218 int start_y = search_box_view_bounds.bottom() + kTopSeparatorSize;
219 gfx::Rect rect(bounds.x(),
220 start_y,
221 bounds.width(),
222 bounds.bottom() - start_y);
223
224 SkPaint paint;
225 paint.setStyle(SkPaint::kFill_Style);
226 paint.setColor(kContentsBackground);
227 canvas->DrawRect(rect, paint);
228 } 191 }
229 192
230 void AppListBubbleBorder::GetInsets(gfx::Insets* insets) const { 193 void AppListBubbleBorder::GetInsets(gfx::Insets* insets) const {
231 // Negate to change from outer margin to inner padding. 194 // Negate to change from outer margin to inner padding.
232 gfx::Insets shadow_padding(-gfx::ShadowValue::GetMargin(shadows_)); 195 gfx::Insets shadow_padding(-gfx::ShadowValue::GetMargin(shadows_));
233 196
234 if (arrow_location() == views::BubbleBorder::TOP_LEFT || 197 if (arrow_location() == views::BubbleBorder::TOP_LEFT ||
235 arrow_location() == views::BubbleBorder::TOP_RIGHT) { 198 arrow_location() == views::BubbleBorder::TOP_RIGHT) {
236 // Arrow at top. 199 // Arrow at top.
237 insets->Set(shadow_padding.top() + kArrowHeight, 200 insets->Set(shadow_padding.top() + kArrowHeight,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 BuildShape(content_bounds, 320 BuildShape(content_bounds,
358 arrow_location(), 321 arrow_location(),
359 SkIntToScalar(GetArrowOffset()), 322 SkIntToScalar(GetArrowOffset()),
360 SkIntToScalar(kBorderSize), 323 SkIntToScalar(kBorderSize),
361 &path); 324 &path);
362 canvas->Save(); 325 canvas->Save();
363 canvas->ClipPath(path); 326 canvas->ClipPath(path);
364 327
365 // Use full bounds so that arrow is also painted. 328 // Use full bounds so that arrow is also painted.
366 const gfx::Rect& bounds = view.bounds(); 329 const gfx::Rect& bounds = view.bounds();
367 PaintSearchBoxBackground(canvas, bounds); 330 PaintBackground(canvas, bounds);
368 PaintAppsGridBackground(canvas, bounds);
369 PaintSearchResultListBackground(canvas, bounds);
370 331
371 canvas->Restore(); 332 canvas->Restore();
372 } 333 }
373 334
374 } // namespace app_list 335 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/app_list_bubble_border.h ('k') | ui/app_list/app_list_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698