OLD | NEW |
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 "views/bubble/bubble_frame_view.h" | 5 #include "views/bubble/bubble_frame_view.h" |
6 | 6 |
7 #include "grit/ui_resources.h" | |
8 #include "ui/gfx/canvas.h" | 7 #include "ui/gfx/canvas.h" |
9 #include "ui/gfx/path.h" | |
10 #include "views/bubble/bubble_border.h" | 8 #include "views/bubble/bubble_border.h" |
11 #include "views/widget/widget_delegate.h" | 9 #include "views/widget/widget.h" |
12 #include "views/window/client_view.h" | 10 #include "views/window/client_view.h" |
13 | 11 |
14 namespace views { | 12 namespace views { |
15 | 13 |
16 BubbleFrameView::BubbleFrameView(Widget* frame, | 14 BubbleFrameView::BubbleFrameView(BubbleBorder::ArrowLocation location, |
17 const gfx::Rect& bounds, | 15 const gfx::Size& client_size, |
18 SkColor color, | 16 SkColor color) { |
19 BubbleBorder::ArrowLocation location) | 17 BubbleBorder* bubble_border = new BubbleBorder(location); |
20 : frame_(frame), | 18 bubble_border->set_background_color(color); |
21 frame_bounds_(bounds), | 19 set_border(bubble_border); |
22 bubble_border_(new BubbleBorder(location)), | 20 set_background(new BubbleBackground(bubble_border)); |
23 bubble_background_(new BubbleBackground(bubble_border_)) { | 21 // Calculate the frame bounds from the argument client size. |
24 SetBoundsRect(bounds); | 22 gfx::Rect frame_bounds(gfx::Point(), client_size); |
25 bubble_border_->set_background_color(color); | 23 SetBoundsRect(GetWindowBoundsForClientBounds(frame_bounds)); |
26 set_border(bubble_border_); | |
27 set_background(bubble_background_); | |
28 } | 24 } |
29 | 25 |
30 BubbleFrameView::~BubbleFrameView() {} | 26 BubbleFrameView::~BubbleFrameView() {} |
31 | 27 |
32 gfx::Rect BubbleFrameView::GetBoundsForClientView() const { | 28 gfx::Rect BubbleFrameView::GetBoundsForClientView() const { |
33 gfx::Insets insets; | 29 gfx::Rect client_bounds(gfx::Point(), size()); |
34 bubble_border_->GetInsets(&insets); | 30 client_bounds.Inset(GetInsets()); |
35 return gfx::Rect(insets.left(), insets.top(), | 31 return client_bounds; |
36 frame_bounds_.width() - insets.left() - insets.right(), | |
37 frame_bounds_.height() - insets.top() - insets.bottom()); | |
38 } | 32 } |
39 | 33 |
40 gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds( | 34 gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds( |
41 const gfx::Rect& client_bounds) const { | 35 const gfx::Rect& client_bounds) const { |
42 return bubble_border_->GetBounds(client_bounds, client_bounds.size()); | 36 return static_cast<const BubbleBorder*>(border())->GetBounds(client_bounds, |
43 } | 37 client_bounds.size()); |
44 | |
45 void BubbleFrameView::EnableClose(bool enable) { | |
46 } | |
47 | |
48 void BubbleFrameView::ResetWindowControls() { | |
49 } | |
50 | |
51 void BubbleFrameView::UpdateWindowIcon() { | |
52 } | 38 } |
53 | 39 |
54 void BubbleFrameView::OnPaint(gfx::Canvas* canvas) { | 40 void BubbleFrameView::OnPaint(gfx::Canvas* canvas) { |
55 border()->Paint(*this, canvas); | 41 border()->Paint(*this, canvas); |
56 bubble_background_->Paint(canvas, this); | 42 background()->Paint(canvas, this); |
57 } | 43 } |
58 | 44 |
59 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { | 45 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { |
60 return frame_->client_view()->NonClientHitTest(point); | 46 return GetWidget()->client_view()->NonClientHitTest(point); |
61 } | |
62 | |
63 void BubbleFrameView::GetWindowMask(const gfx::Size& size, | |
64 gfx::Path* window_mask) { | |
65 } | 47 } |
66 | 48 |
67 gfx::Size BubbleFrameView::GetPreferredSize() { | 49 gfx::Size BubbleFrameView::GetPreferredSize() { |
68 gfx::Size pref = frame_->client_view()->GetPreferredSize(); | 50 Widget* widget = GetWidget(); |
69 gfx::Rect bounds(0, 0, pref.width(), pref.height()); | 51 gfx::Rect rect(gfx::Point(), widget->client_view()->GetPreferredSize()); |
70 return frame_->non_client_view()->GetWindowBoundsForClientBounds( | 52 return widget->non_client_view()->GetWindowBoundsForClientBounds(rect).size(); |
71 bounds).size(); | |
72 } | 53 } |
| 54 |
73 } // namespace views | 55 } // namespace views |
OLD | NEW |