| OLD | NEW |
| 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/views/bubble/bubble_border.h" | 5 #include "ui/views/bubble/bubble_border.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if (set) | 105 if (set) |
| 106 return set; | 106 return set; |
| 107 | 107 |
| 108 switch (shadow) { | 108 switch (shadow) { |
| 109 case BubbleBorder::SHADOW: | 109 case BubbleBorder::SHADOW: |
| 110 // Note: SHADOW's border interior thickness is actually 10, but 0 is used | 110 // Note: SHADOW's border interior thickness is actually 10, but 0 is used |
| 111 // here to match the legacy appearance of SHADOW's extra large inset. | 111 // here to match the legacy appearance of SHADOW's extra large inset. |
| 112 set = new BorderImages(kShadowImages, kShadowArrows, 0, 0, 3); | 112 set = new BorderImages(kShadowImages, kShadowArrows, 0, 0, 3); |
| 113 break; | 113 break; |
| 114 case BubbleBorder::NO_SHADOW: | 114 case BubbleBorder::NO_SHADOW: |
| 115 case BubbleBorder::NO_SHADOW_OPAQUE_BORDER: |
| 115 set = new BorderImages(kNoShadowImages, kNoShadowArrows, 6, 7, 4); | 116 set = new BorderImages(kNoShadowImages, kNoShadowArrows, 6, 7, 4); |
| 116 break; | 117 break; |
| 117 case BubbleBorder::BIG_SHADOW: | 118 case BubbleBorder::BIG_SHADOW: |
| 118 set = new BorderImages(kBigShadowImages, kBigShadowArrows, 23, 9, 2); | 119 set = new BorderImages(kBigShadowImages, kBigShadowArrows, 23, 9, 2); |
| 119 break; | 120 break; |
| 120 case BubbleBorder::SMALL_SHADOW: | 121 case BubbleBorder::SMALL_SHADOW: |
| 121 set = new BorderImages(kSmallShadowImages, kSmallShadowArrows, 5, 6, 2); | 122 set = new BorderImages(kSmallShadowImages, kSmallShadowArrows, 5, 6, 2); |
| 122 break; | 123 break; |
| 123 case BubbleBorder::SHADOW_COUNT: | 124 case BubbleBorder::SHADOW_COUNT: |
| 124 NOTREACHED(); | 125 NOTREACHED(); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 path.close(); | 326 path.close(); |
| 326 | 327 |
| 327 SkPaint paint; | 328 SkPaint paint; |
| 328 paint.setStyle(SkPaint::kFill_Style); | 329 paint.setStyle(SkPaint::kFill_Style); |
| 329 paint.setColor(background_color_); | 330 paint.setColor(background_color_); |
| 330 | 331 |
| 331 canvas->DrawPath(path, paint); | 332 canvas->DrawPath(path, paint); |
| 332 } | 333 } |
| 333 | 334 |
| 334 void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const { | 335 void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const { |
| 336 if (border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER) |
| 337 canvas->DrawColor(border_->background_color()); |
| 338 |
| 335 // Clip out the client bounds to prevent overlapping transparent widgets. | 339 // Clip out the client bounds to prevent overlapping transparent widgets. |
| 336 if (!border_->client_bounds().IsEmpty()) { | 340 if (!border_->client_bounds().IsEmpty()) { |
| 337 SkRect client_rect(gfx::RectToSkRect(border_->client_bounds())); | 341 SkRect client_rect(gfx::RectToSkRect(border_->client_bounds())); |
| 338 canvas->sk_canvas()->clipRect(client_rect, SkRegion::kDifference_Op); | 342 canvas->sk_canvas()->clipRect(client_rect, SkRegion::kDifference_Op); |
| 339 } | 343 } |
| 340 | 344 |
| 341 // Fill the contents with a round-rect region to match the border images. | 345 // Fill the contents with a round-rect region to match the border images. |
| 342 SkPaint paint; | 346 SkPaint paint; |
| 343 paint.setAntiAlias(true); | 347 paint.setAntiAlias(true); |
| 344 paint.setStyle(SkPaint::kFill_Style); | 348 paint.setStyle(SkPaint::kFill_Style); |
| 345 paint.setColor(border_->background_color()); | 349 paint.setColor(border_->background_color()); |
| 346 SkPath path; | 350 SkPath path; |
| 347 gfx::Rect bounds(view->GetLocalBounds()); | 351 gfx::Rect bounds(view->GetLocalBounds()); |
| 348 bounds.Inset(border_->GetInsets()); | 352 bounds.Inset(border_->GetInsets()); |
| 349 | 353 |
| 350 // Note: This matches the legacy appearance of SHADOW's extra large inset. | 354 // Note: This matches the legacy appearance of SHADOW's extra large inset. |
| 351 if (border_->shadow() == BubbleBorder::SHADOW) | 355 if (border_->shadow() == BubbleBorder::SHADOW) |
| 352 bounds.Inset(-10, -10); | 356 bounds.Inset(-10, -10); |
| 353 | 357 |
| 354 SkScalar radius = SkIntToScalar(border_->GetBorderCornerRadius()); | 358 SkScalar radius = SkIntToScalar(border_->GetBorderCornerRadius()); |
| 355 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); | 359 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); |
| 356 canvas->DrawPath(path, paint); | 360 canvas->DrawPath(path, paint); |
| 357 } | 361 } |
| 358 | 362 |
| 359 } // namespace views | 363 } // namespace views |
| OLD | NEW |