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

Unified Diff: ui/views/bubble/bubble_border.cc

Issue 1633403002: MacViews: Add native drop shadow to dialogs on OSX < 10.10. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments. Created 4 years, 10 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/views/bubble/bubble_border.h ('k') | ui/views/bubble/bubble_frame_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/bubble/bubble_border.cc
diff --git a/ui/views/bubble/bubble_border.cc b/ui/views/bubble/bubble_border.cc
index c2892ca0fc7094b78cab5e286fcd496c30e6133a..d17b13d904b8a92b92d1835eb4a23823c6816508 100644
--- a/ui/views/bubble/bubble_border.cc
+++ b/ui/views/bubble/bubble_border.cc
@@ -12,6 +12,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/path.h"
#include "ui/gfx/skia_util.h"
#include "ui/resources/grit/ui_resources.h"
#include "ui/views/painter.h"
@@ -144,8 +145,13 @@ BubbleBorder::BubbleBorder(Arrow arrow, Shadow shadow, SkColor color)
shadow_(shadow),
background_color_(color),
use_theme_background_color_(false) {
- DCHECK(shadow < SHADOW_COUNT);
- images_ = GetBorderImages(shadow);
+#if defined(OS_MACOSX)
+ // On Mac, use the NO_ASSETS bubble border. WindowServer on Mac is able to
+ // generate drop shadows for dialogs, hence we don't use raster shadows.
+ shadow_ = NO_ASSETS;
+#endif // OS_MACOSX
+ DCHECK(shadow_ < SHADOW_COUNT);
+ images_ = GetBorderImages(shadow_);
}
BubbleBorder::~BubbleBorder() {}
@@ -211,6 +217,15 @@ int BubbleBorder::GetArrowOffset(const gfx::Size& border_size) const {
return std::max(min, std::min(arrow_offset_, edge_length - min));
}
+bool BubbleBorder::GetArrowPath(const gfx::Rect& view_bounds,
+ gfx::Path* path) const {
+ if (!has_arrow(arrow_) || arrow_paint_type_ != PAINT_NORMAL)
+ return false;
+
+ GetArrowPathFromArrowBounds(GetArrowRect(view_bounds), path);
+ return true;
+}
+
void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) {
gfx::Rect bounds(view.GetContentsBounds());
bounds.Inset(-GetBorderThickness(), -GetBorderThickness());
@@ -328,9 +343,8 @@ gfx::Rect BubbleBorder::GetArrowRect(const gfx::Rect& bounds) const {
return gfx::Rect(origin, gfx::Size(width, height));
}
-void BubbleBorder::DrawArrow(gfx::Canvas* canvas,
- const gfx::Rect& arrow_bounds) const {
- canvas->DrawImageInt(*GetArrowImage(), arrow_bounds.x(), arrow_bounds.y());
+void BubbleBorder::GetArrowPathFromArrowBounds(const gfx::Rect& arrow_bounds,
+ SkPath* path) const {
const bool horizontal = is_arrow_on_horizontal(arrow_);
const int thickness = images_->arrow_interior_thickness;
float tip_x = horizontal ? arrow_bounds.CenterPoint().x() :
@@ -344,16 +358,21 @@ void BubbleBorder::DrawArrow(gfx::Canvas* canvas,
const int offset_to_next_vertex = positive_offset ?
images_->arrow_interior_thickness : -images_->arrow_interior_thickness;
- SkPath path;
- path.incReserve(4);
- path.moveTo(SkDoubleToScalar(tip_x), SkDoubleToScalar(tip_y));
- path.lineTo(SkDoubleToScalar(tip_x + offset_to_next_vertex),
- SkDoubleToScalar(tip_y + offset_to_next_vertex));
+ path->incReserve(4);
+ path->moveTo(SkDoubleToScalar(tip_x), SkDoubleToScalar(tip_y));
+ path->lineTo(SkDoubleToScalar(tip_x + offset_to_next_vertex),
+ SkDoubleToScalar(tip_y + offset_to_next_vertex));
const int multiplier = horizontal ? 1 : -1;
- path.lineTo(SkDoubleToScalar(tip_x - multiplier * offset_to_next_vertex),
- SkDoubleToScalar(tip_y + multiplier * offset_to_next_vertex));
- path.close();
+ path->lineTo(SkDoubleToScalar(tip_x - multiplier * offset_to_next_vertex),
+ SkDoubleToScalar(tip_y + multiplier * offset_to_next_vertex));
+ path->close();
+}
+void BubbleBorder::DrawArrow(gfx::Canvas* canvas,
+ const gfx::Rect& arrow_bounds) const {
+ canvas->DrawImageInt(*GetArrowImage(), arrow_bounds.x(), arrow_bounds.y());
+ SkPath path;
+ GetArrowPathFromArrowBounds(arrow_bounds, &path);
SkPaint paint;
paint.setStyle(SkPaint::kFill_Style);
paint.setColor(background_color_);
« no previous file with comments | « ui/views/bubble/bubble_border.h ('k') | ui/views/bubble/bubble_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698