Index: views/bubble/bubble_frame_view.cc |
diff --git a/views/bubble/bubble_frame_view.cc b/views/bubble/bubble_frame_view.cc |
index b3c2f70931a4a0c96dc9574fd9985e1ad3333747..aa6ce9cd449533f910f695f98b2e779eca33b62c 100644 |
--- a/views/bubble/bubble_frame_view.cc |
+++ b/views/bubble/bubble_frame_view.cc |
@@ -4,70 +4,55 @@ |
#include "views/bubble/bubble_frame_view.h" |
-#include "grit/ui_resources.h" |
#include "ui/gfx/canvas.h" |
-#include "ui/gfx/path.h" |
#include "views/bubble/bubble_border.h" |
-#include "views/widget/widget_delegate.h" |
+#include "views/widget/widget.h" |
#include "views/window/client_view.h" |
namespace views { |
-BubbleFrameView::BubbleFrameView(Widget* frame, |
- const gfx::Rect& bounds, |
- SkColor color, |
- BubbleBorder::ArrowLocation location) |
- : frame_(frame), |
- frame_bounds_(bounds), |
- bubble_border_(new BubbleBorder(location)), |
- bubble_background_(new BubbleBackground(bubble_border_)) { |
- SetBoundsRect(bounds); |
- bubble_border_->set_background_color(color); |
- set_border(bubble_border_); |
- set_background(bubble_background_); |
+BubbleFrameView::BubbleFrameView(BubbleBorder::ArrowLocation location, |
+ const gfx::Size& client_size, |
+ SkColor color) { |
+ BubbleBorder* bubble_border = new BubbleBorder(location); |
+ bubble_border->set_background_color(color); |
+ set_border(bubble_border); |
+ set_background(new BubbleBackground(bubble_border)); |
+ // Calculate the frame size from the client size. |
+ gfx::Rect bounds(gfx::Point(), client_size); |
+ SetBoundsRect(GetWindowBoundsForClientBounds(bounds)); |
} |
BubbleFrameView::~BubbleFrameView() {} |
gfx::Rect BubbleFrameView::GetBoundsForClientView() const { |
- gfx::Insets insets; |
- bubble_border_->GetInsets(&insets); |
- return gfx::Rect(insets.left(), insets.top(), |
- frame_bounds_.width() - insets.left() - insets.right(), |
- frame_bounds_.height() - insets.top() - insets.bottom()); |
+ gfx::Rect client_bounds(gfx::Point(), size()); |
+ client_bounds.Inset(GetInsets()); |
+ return client_bounds; |
} |
gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds( |
const gfx::Rect& client_bounds) const { |
- return bubble_border_->GetBounds(client_bounds, client_bounds.size()); |
-} |
- |
-void BubbleFrameView::EnableClose(bool enable) { |
-} |
- |
-void BubbleFrameView::ResetWindowControls() { |
-} |
- |
-void BubbleFrameView::UpdateWindowIcon() { |
+ // The |client_bounds| origin is the bubble arrow anchor point. |
+ gfx::Rect position_relative_to(client_bounds.origin(), gfx::Size()); |
+ // The |client_bounds| size is the bubble client view size. |
+ return static_cast<const BubbleBorder*>(border())->GetBounds( |
+ position_relative_to, client_bounds.size()); |
} |
void BubbleFrameView::OnPaint(gfx::Canvas* canvas) { |
border()->Paint(*this, canvas); |
- bubble_background_->Paint(canvas, this); |
+ background()->Paint(canvas, this); |
} |
int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { |
- return frame_->client_view()->NonClientHitTest(point); |
-} |
- |
-void BubbleFrameView::GetWindowMask(const gfx::Size& size, |
- gfx::Path* window_mask) { |
+ return GetWidget()->client_view()->NonClientHitTest(point); |
} |
gfx::Size BubbleFrameView::GetPreferredSize() { |
- gfx::Size pref = frame_->client_view()->GetPreferredSize(); |
- gfx::Rect bounds(0, 0, pref.width(), pref.height()); |
- return frame_->non_client_view()->GetWindowBoundsForClientBounds( |
- bounds).size(); |
+ Widget* widget = GetWidget(); |
+ gfx::Rect rect(gfx::Point(), widget->client_view()->GetPreferredSize()); |
+ return widget->non_client_view()->GetWindowBoundsForClientBounds(rect).size(); |
} |
+ |
} // namespace views |