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 #ifndef UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ | 5 #ifndef UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ |
6 #define UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ | 6 #define UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "ui/gfx/insets.h" | 11 #include "ui/gfx/insets.h" |
12 #include "ui/views/window/non_client_view.h" | 12 #include "ui/views/window/non_client_view.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 | 15 |
16 class BubbleBorder; | 16 class BubbleBorder; |
17 | 17 |
18 // This is a NonClientFrameView used to render the BubbleBorder. | 18 // The non-client frame view of bubble-styled widgets. |
19 class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView { | 19 class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView { |
20 public: | 20 public: |
21 // Sets the border to |border|, taking ownership. Important: do not call | 21 |
22 // set_border() directly to change the border, use SetBubbleBorder() instead. | 22 explicit BubbleFrameView(const gfx::Insets& content_margins); |
23 BubbleFrameView(const gfx::Insets& margins, BubbleBorder* border); | |
24 virtual ~BubbleFrameView(); | 23 virtual ~BubbleFrameView(); |
25 | 24 |
26 // NonClientFrameView overrides: | 25 // NonClientFrameView overrides: |
27 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; | 26 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; |
28 virtual gfx::Rect GetWindowBoundsForClientBounds( | 27 virtual gfx::Rect GetWindowBoundsForClientBounds( |
29 const gfx::Rect& client_bounds) const OVERRIDE; | 28 const gfx::Rect& client_bounds) const OVERRIDE; |
30 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; | 29 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; |
31 virtual void GetWindowMask(const gfx::Size& size, | 30 virtual void GetWindowMask(const gfx::Size& size, |
32 gfx::Path* window_mask) OVERRIDE {} | 31 gfx::Path* window_mask) OVERRIDE {} |
33 virtual void ResetWindowControls() OVERRIDE {} | 32 virtual void ResetWindowControls() OVERRIDE {} |
34 virtual void UpdateWindowIcon() OVERRIDE {} | 33 virtual void UpdateWindowIcon() OVERRIDE {} |
35 virtual void UpdateWindowTitle() OVERRIDE {} | 34 virtual void UpdateWindowTitle() OVERRIDE {} |
36 | 35 |
37 // View overrides: | 36 // View overrides: |
38 virtual gfx::Size GetPreferredSize() OVERRIDE; | 37 virtual gfx::Size GetPreferredSize() OVERRIDE; |
39 | 38 |
| 39 // Use bubble_border() and SetBubbleBorder(), not border() and set_border(). |
40 BubbleBorder* bubble_border() const { return bubble_border_; } | 40 BubbleBorder* bubble_border() const { return bubble_border_; } |
| 41 void SetBubbleBorder(BubbleBorder* border); |
41 | 42 |
42 gfx::Insets content_margins() const { return content_margins_; } | 43 gfx::Insets content_margins() const { return content_margins_; } |
43 | 44 |
44 // Given the size of the contents and the rect to point at, returns the bounds | 45 // Given the size of the contents and the rect to point at, returns the bounds |
45 // of the bubble window. The bubble's arrow location may change if the bubble | 46 // of the bubble window. The bubble's arrow location may change if the bubble |
46 // does not fit on the monitor and |adjust_if_offscreen| is true. | 47 // does not fit on the monitor and |adjust_if_offscreen| is true. |
47 gfx::Rect GetUpdatedWindowBounds(const gfx::Rect& anchor_rect, | 48 gfx::Rect GetUpdatedWindowBounds(const gfx::Rect& anchor_rect, |
48 gfx::Size client_size, | 49 gfx::Size client_size, |
49 bool adjust_if_offscreen); | 50 bool adjust_if_offscreen); |
50 | 51 |
51 void SetBubbleBorder(BubbleBorder* border); | |
52 | |
53 protected: | 52 protected: |
54 // Returns the bounds for the monitor showing the specified |rect|. | 53 // Returns the bounds for the monitor showing the specified |rect|. |
55 // This function is virtual to support testing environments. | 54 // This function is virtual to support testing environments. |
56 virtual gfx::Rect GetMonitorBounds(const gfx::Rect& rect); | 55 virtual gfx::Rect GetMonitorBounds(const gfx::Rect& rect); |
57 | 56 |
58 private: | 57 private: |
59 FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewTest, GetBoundsForClientView); | 58 FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewTest, GetBoundsForClientView); |
60 | 59 |
61 // Mirrors the bubble's arrow location on the |vertical| or horizontal axis, | 60 // Mirrors the bubble's arrow location on the |vertical| or horizontal axis, |
62 // if the generated window bounds don't fit in the monitor bounds. | 61 // if the generated window bounds don't fit in the monitor bounds. |
(...skipping 11 matching lines...) Expand all Loading... |
74 | 73 |
75 // Margins between the content and the inside of the border, in pixels. | 74 // Margins between the content and the inside of the border, in pixels. |
76 gfx::Insets content_margins_; | 75 gfx::Insets content_margins_; |
77 | 76 |
78 DISALLOW_COPY_AND_ASSIGN(BubbleFrameView); | 77 DISALLOW_COPY_AND_ASSIGN(BubbleFrameView); |
79 }; | 78 }; |
80 | 79 |
81 } // namespace views | 80 } // namespace views |
82 | 81 |
83 #endif // UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ | 82 #endif // UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ |
OLD | NEW |