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

Side by Side Diff: ui/views/bubble/bubble_border.cc

Issue 8565034: Add a drop shadow to the fullscreen exit bubble on windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: modify BubbleBorder Created 9 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/bubble/bubble_border.h ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/views/bubble/bubble_border.h" 5 #include "ui/views/bubble/bubble_border.h"
6 6
7 #include <algorithm> // for std::max 7 #include <algorithm> // for std::max
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 11 matching lines...) Expand all
22 top_left(NULL), 22 top_left(NULL),
23 top(NULL), 23 top(NULL),
24 top_right(NULL), 24 top_right(NULL),
25 right(NULL), 25 right(NULL),
26 bottom_right(NULL), 26 bottom_right(NULL),
27 bottom(NULL), 27 bottom(NULL),
28 bottom_left(NULL), 28 bottom_left(NULL),
29 left_arrow(NULL), 29 left_arrow(NULL),
30 top_arrow(NULL), 30 top_arrow(NULL),
31 right_arrow(NULL), 31 right_arrow(NULL),
32 bottom_arrow(NULL) { 32 bottom_arrow(NULL),
33 pixels_to_border(0) {
33 } 34 }
34 35
35 SkBitmap* left; 36 SkBitmap* left;
36 SkBitmap* top_left; 37 SkBitmap* top_left;
37 SkBitmap* top; 38 SkBitmap* top;
38 SkBitmap* top_right; 39 SkBitmap* top_right;
39 SkBitmap* right; 40 SkBitmap* right;
40 SkBitmap* bottom_right; 41 SkBitmap* bottom_right;
41 SkBitmap* bottom; 42 SkBitmap* bottom;
42 SkBitmap* bottom_left; 43 SkBitmap* bottom_left;
43 SkBitmap* left_arrow; 44 SkBitmap* left_arrow;
44 SkBitmap* top_arrow; 45 SkBitmap* top_arrow;
45 SkBitmap* right_arrow; 46 SkBitmap* right_arrow;
46 SkBitmap* bottom_arrow; 47 SkBitmap* bottom_arrow;
48 int pixels_to_border;
47 }; 49 };
48 50
49 // static 51 // static
50 struct BubbleBorder::BorderImages* BubbleBorder::normal_images_ = NULL; 52 struct BubbleBorder::BorderImages* BubbleBorder::normal_images_ = NULL;
51 struct BubbleBorder::BorderImages* BubbleBorder::shadow_images_ = NULL; 53 struct BubbleBorder::BorderImages* BubbleBorder::shadow_images_ = NULL;
52 54
53 55
54 // The height inside the arrow image, in pixels. 56 // The height inside the arrow image, in pixels.
55 static const int kArrowInteriorHeight = 7; 57 static const int kArrowInteriorHeight = 7;
56 58
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 break; 197 break;
196 198
197 case NONE: 199 case NONE:
198 case FLOAT: 200 case FLOAT:
199 // Nothing to do. 201 // Nothing to do.
200 break; 202 break;
201 } 203 }
202 insets->Set(top, left, bottom, right); 204 insets->Set(top, left, bottom, right);
203 } 205 }
204 206
207 int BubbleBorder::pixels_to_border() const {
208 return images_->pixels_to_border;
209 }
210
205 int BubbleBorder::SetArrowOffset(int offset, const gfx::Size& contents_size) { 211 int BubbleBorder::SetArrowOffset(int offset, const gfx::Size& contents_size) {
206 gfx::Size border_size(contents_size); 212 gfx::Size border_size(contents_size);
207 gfx::Insets insets; 213 gfx::Insets insets;
208 GetInsets(&insets); 214 GetInsets(&insets);
209 border_size.Enlarge(insets.left() + insets.right(), 215 border_size.Enlarge(insets.left() + insets.right(),
210 insets.top() + insets.bottom()); 216 insets.top() + insets.bottom());
211 offset = std::max(arrow_offset_, 217 offset = std::max(arrow_offset_,
212 std::min(offset, (is_arrow_on_horizontal(arrow_location_) ? 218 std::min(offset, (is_arrow_on_horizontal(arrow_location_) ?
213 border_size.width() : border_size.height()) - arrow_offset_)); 219 border_size.width() : border_size.height()) - arrow_offset_));
214 override_arrow_offset_ = offset; 220 override_arrow_offset_ = offset;
(...skipping 10 matching lines...) Expand all
225 shadow_images_->top = rb.GetBitmapNamed(IDR_BUBBLE_SHADOW_T); 231 shadow_images_->top = rb.GetBitmapNamed(IDR_BUBBLE_SHADOW_T);
226 shadow_images_->top_right = rb.GetBitmapNamed(IDR_BUBBLE_SHADOW_TR); 232 shadow_images_->top_right = rb.GetBitmapNamed(IDR_BUBBLE_SHADOW_TR);
227 shadow_images_->right = rb.GetBitmapNamed(IDR_BUBBLE_SHADOW_R); 233 shadow_images_->right = rb.GetBitmapNamed(IDR_BUBBLE_SHADOW_R);
228 shadow_images_->bottom_right = rb.GetBitmapNamed(IDR_BUBBLE_SHADOW_BR); 234 shadow_images_->bottom_right = rb.GetBitmapNamed(IDR_BUBBLE_SHADOW_BR);
229 shadow_images_->bottom = rb.GetBitmapNamed(IDR_BUBBLE_SHADOW_B); 235 shadow_images_->bottom = rb.GetBitmapNamed(IDR_BUBBLE_SHADOW_B);
230 shadow_images_->bottom_left = rb.GetBitmapNamed(IDR_BUBBLE_SHADOW_BL); 236 shadow_images_->bottom_left = rb.GetBitmapNamed(IDR_BUBBLE_SHADOW_BL);
231 shadow_images_->left_arrow = new SkBitmap(); 237 shadow_images_->left_arrow = new SkBitmap();
232 shadow_images_->top_arrow = new SkBitmap(); 238 shadow_images_->top_arrow = new SkBitmap();
233 shadow_images_->right_arrow = new SkBitmap(); 239 shadow_images_->right_arrow = new SkBitmap();
234 shadow_images_->bottom_arrow = new SkBitmap(); 240 shadow_images_->bottom_arrow = new SkBitmap();
241 shadow_images_->pixels_to_border = 10;
235 } else if (shadow == NO_SHADOW && normal_images_ == NULL) { 242 } else if (shadow == NO_SHADOW && normal_images_ == NULL) {
236 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 243 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
237 normal_images_ = new BorderImages(); 244 normal_images_ = new BorderImages();
238 normal_images_->left = rb.GetBitmapNamed(IDR_BUBBLE_L); 245 normal_images_->left = rb.GetBitmapNamed(IDR_BUBBLE_L);
239 normal_images_->top_left = rb.GetBitmapNamed(IDR_BUBBLE_TL); 246 normal_images_->top_left = rb.GetBitmapNamed(IDR_BUBBLE_TL);
240 normal_images_->top = rb.GetBitmapNamed(IDR_BUBBLE_T); 247 normal_images_->top = rb.GetBitmapNamed(IDR_BUBBLE_T);
241 normal_images_->top_right = rb.GetBitmapNamed(IDR_BUBBLE_TR); 248 normal_images_->top_right = rb.GetBitmapNamed(IDR_BUBBLE_TR);
242 normal_images_->right = rb.GetBitmapNamed(IDR_BUBBLE_R); 249 normal_images_->right = rb.GetBitmapNamed(IDR_BUBBLE_R);
243 normal_images_->bottom_right = rb.GetBitmapNamed(IDR_BUBBLE_BR); 250 normal_images_->bottom_right = rb.GetBitmapNamed(IDR_BUBBLE_BR);
244 normal_images_->bottom = rb.GetBitmapNamed(IDR_BUBBLE_B); 251 normal_images_->bottom = rb.GetBitmapNamed(IDR_BUBBLE_B);
245 normal_images_->bottom_left = rb.GetBitmapNamed(IDR_BUBBLE_BL); 252 normal_images_->bottom_left = rb.GetBitmapNamed(IDR_BUBBLE_BL);
246 normal_images_->left_arrow = rb.GetBitmapNamed(IDR_BUBBLE_L_ARROW); 253 normal_images_->left_arrow = rb.GetBitmapNamed(IDR_BUBBLE_L_ARROW);
247 normal_images_->top_arrow = rb.GetBitmapNamed(IDR_BUBBLE_T_ARROW); 254 normal_images_->top_arrow = rb.GetBitmapNamed(IDR_BUBBLE_T_ARROW);
248 normal_images_->right_arrow = rb.GetBitmapNamed(IDR_BUBBLE_R_ARROW); 255 normal_images_->right_arrow = rb.GetBitmapNamed(IDR_BUBBLE_R_ARROW);
249 normal_images_->bottom_arrow = rb.GetBitmapNamed(IDR_BUBBLE_B_ARROW); 256 normal_images_->bottom_arrow = rb.GetBitmapNamed(IDR_BUBBLE_B_ARROW);
257 normal_images_->pixels_to_border = 0;
250 } 258 }
251 return shadow == SHADOW ? shadow_images_ : normal_images_; 259 return shadow == SHADOW ? shadow_images_ : normal_images_;
252 } 260 }
253 261
254 BubbleBorder::~BubbleBorder() {} 262 BubbleBorder::~BubbleBorder() {}
255 263
256 void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) const { 264 void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) const {
257 // Convenience shorthand variables. 265 // Convenience shorthand variables.
258 const int tl_width = images_->top_left->width(); 266 const int tl_width = images_->top_left->width();
259 const int tl_height = images_->top_left->height(); 267 const int tl_height = images_->top_left->height();
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // contents, which we need to fill with the background color. 502 // contents, which we need to fill with the background color.
495 // NOTE: This doesn't handle an arrow location of "NONE", which has square top 503 // NOTE: This doesn't handle an arrow location of "NONE", which has square top
496 // corners. 504 // corners.
497 SkPaint paint; 505 SkPaint paint;
498 paint.setAntiAlias(true); 506 paint.setAntiAlias(true);
499 paint.setStyle(SkPaint::kFill_Style); 507 paint.setStyle(SkPaint::kFill_Style);
500 paint.setColor(border_->background_color()); 508 paint.setColor(border_->background_color());
501 gfx::Path path; 509 gfx::Path path;
502 gfx::Rect bounds(view->GetContentsBounds()); 510 gfx::Rect bounds(view->GetContentsBounds());
503 SkRect rect; 511 SkRect rect;
512 int offset = border_->pixels_to_border();
504 rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()), 513 rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()),
505 SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom())); 514 SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom()));
515 rect.inset(-border_->pixels_to_border(), -border_->pixels_to_border());
506 SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius()); 516 SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius());
507 path.addRoundRect(rect, radius, radius); 517 path.addRoundRect(rect, radius, radius);
508 canvas->GetSkCanvas()->drawPath(path, paint); 518 canvas->GetSkCanvas()->drawPath(path, paint);
509 } 519 }
510 520
511 } // namespace views 521 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_border.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698