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> // 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 int arrow_interior_height; // The height inside the arrow image, in pixels. | 127 int arrow_interior_height; // The height inside the arrow image, in pixels. |
128 int border_thickness; | 128 int border_thickness; |
129 int corner_radius; | 129 int corner_radius; |
130 }; | 130 }; |
131 | 131 |
132 // static | 132 // static |
133 struct BubbleBorder::BorderImages* | 133 struct BubbleBorder::BorderImages* |
134 BubbleBorder::border_images_[SHADOW_COUNT] = { NULL }; | 134 BubbleBorder::border_images_[SHADOW_COUNT] = { NULL }; |
135 | 135 |
136 BubbleBorder::BubbleBorder(ArrowLocation arrow_location, Shadow shadow) | 136 BubbleBorder::BubbleBorder(ArrowLocation arrow, Shadow shadow, SkColor color) |
137 : override_arrow_offset_(0), | 137 : override_arrow_offset_(0), |
138 arrow_location_(arrow_location), | 138 arrow_location_(arrow), |
139 paint_arrow_(true), | 139 paint_arrow_(true), |
140 alignment_(ALIGN_ARROW_TO_MID_ANCHOR), | 140 alignment_(ALIGN_ARROW_TO_MID_ANCHOR), |
141 background_color_(SK_ColorWHITE) { | 141 background_color_(color) { |
142 DCHECK(shadow < SHADOW_COUNT); | 142 DCHECK(shadow < SHADOW_COUNT); |
143 images_ = GetBorderImages(shadow); | 143 images_ = GetBorderImages(shadow); |
144 | 144 |
145 // Calculate horizontal and vertical insets for arrow by ensuring that | 145 // Calculate horizontal and vertical insets for arrow by ensuring that |
146 // the widest arrow and corner images will have enough room to avoid overlap | 146 // the widest arrow and corner images will have enough room to avoid overlap |
147 int offset_x = | 147 int offset_x = |
148 (std::max(images_->top_arrow.width(), | 148 (std::max(images_->top_arrow.width(), |
149 images_->bottom_arrow.width()) / 2) + | 149 images_->bottom_arrow.width()) / 2) + |
150 std::max(std::max(images_->top_left.width(), | 150 std::max(std::max(images_->top_left.width(), |
151 images_->top_right.width()), | 151 images_->top_right.width()), |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 paint.setColor(border_->background_color()); | 624 paint.setColor(border_->background_color()); |
625 SkPath path; | 625 SkPath path; |
626 gfx::Rect bounds(view->GetContentsBounds()); | 626 gfx::Rect bounds(view->GetContentsBounds()); |
627 bounds.Inset(-border_->GetBorderThickness(), -border_->GetBorderThickness()); | 627 bounds.Inset(-border_->GetBorderThickness(), -border_->GetBorderThickness()); |
628 SkScalar radius = SkIntToScalar(border_->GetBorderCornerRadius()); | 628 SkScalar radius = SkIntToScalar(border_->GetBorderCornerRadius()); |
629 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); | 629 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); |
630 canvas->DrawPath(path, paint); | 630 canvas->DrawPath(path, paint); |
631 } | 631 } |
632 | 632 |
633 } // namespace views | 633 } // namespace views |
OLD | NEW |