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

Side by Side Diff: ui/views/bubble/bubble_frame_view.h

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « ui/views/bubble/bubble_delegate_unittest.cc ('k') | ui/views/bubble/bubble_frame_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_
6 #define UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/gtest_prod_util.h"
11 #include "ui/gfx/insets.h"
12 #include "ui/views/controls/button/button.h"
13 #include "ui/views/window/non_client_view.h"
14
15 namespace gfx {
16 class FontList;
17 }
18
19 namespace views {
20
21 class Label;
22 class LabelButton;
23 class BubbleBorder;
24
25 // The non-client frame view of bubble-styled widgets.
26 class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView,
27 public ButtonListener {
28 public:
29 // Internal class name.
30 static const char kViewClassName[];
31
32 explicit BubbleFrameView(const gfx::Insets& content_margins);
33 virtual ~BubbleFrameView();
34
35 // Insets to make bubble contents align horizontal with the bubble title.
36 // NOTE: this does not take into account whether a title actually exists.
37 static gfx::Insets GetTitleInsets();
38
39 // Creates a close button used in the corner of the dialog.
40 static LabelButton* CreateCloseButton(ButtonListener* listener);
41
42 // NonClientFrameView overrides:
43 virtual gfx::Rect GetBoundsForClientView() const override;
44 virtual gfx::Rect GetWindowBoundsForClientBounds(
45 const gfx::Rect& client_bounds) const override;
46 virtual int NonClientHitTest(const gfx::Point& point) override;
47 virtual void GetWindowMask(const gfx::Size& size,
48 gfx::Path* window_mask) override;
49 virtual void ResetWindowControls() override;
50 virtual void UpdateWindowIcon() override;
51 virtual void UpdateWindowTitle() override;
52 virtual void SizeConstraintsChanged() override;
53
54 // Set the FontList to be used for the title of the bubble.
55 // Caller must arrange to update the layout to have the call take effect.
56 void SetTitleFontList(const gfx::FontList& font_list);
57
58 // View overrides:
59 virtual gfx::Insets GetInsets() const override;
60 virtual gfx::Size GetPreferredSize() const override;
61 virtual gfx::Size GetMinimumSize() const override;
62 virtual void Layout() override;
63 virtual const char* GetClassName() const override;
64 virtual void ChildPreferredSizeChanged(View* child) override;
65 virtual void OnThemeChanged() override;
66 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
67
68 // Overridden from ButtonListener:
69 virtual void ButtonPressed(Button* sender, const ui::Event& event) override;
70
71 // Use bubble_border() and SetBubbleBorder(), not border() and SetBorder().
72 BubbleBorder* bubble_border() const { return bubble_border_; }
73 void SetBubbleBorder(scoped_ptr<BubbleBorder> border);
74
75 gfx::Insets content_margins() const { return content_margins_; }
76
77 void SetTitlebarExtraView(View* view);
78
79 // Given the size of the contents and the rect to point at, returns the bounds
80 // of the bubble window. The bubble's arrow location may change if the bubble
81 // does not fit on the monitor and |adjust_if_offscreen| is true.
82 gfx::Rect GetUpdatedWindowBounds(const gfx::Rect& anchor_rect,
83 gfx::Size client_size,
84 bool adjust_if_offscreen);
85
86 protected:
87 // Returns the available screen bounds if the frame were to show in |rect|.
88 virtual gfx::Rect GetAvailableScreenBounds(const gfx::Rect& rect);
89
90 bool IsCloseButtonVisible() const;
91 gfx::Rect GetCloseButtonBounds() const;
92
93 private:
94 FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewTest, GetBoundsForClientView);
95
96 // Mirrors the bubble's arrow location on the |vertical| or horizontal axis,
97 // if the generated window bounds don't fit in the monitor bounds.
98 void MirrorArrowIfOffScreen(bool vertical,
99 const gfx::Rect& anchor_rect,
100 const gfx::Size& client_size);
101
102 // Adjust the bubble's arrow offsets if the generated window bounds don't fit
103 // in the monitor bounds.
104 void OffsetArrowIfOffScreen(const gfx::Rect& anchor_rect,
105 const gfx::Size& client_size);
106
107 // Calculates the size needed to accommodate the given client area.
108 gfx::Size GetSizeForClientSize(const gfx::Size& client_size) const;
109
110 // The bubble border.
111 BubbleBorder* bubble_border_;
112
113 // Margins between the content and the inside of the border, in pixels.
114 gfx::Insets content_margins_;
115
116 // The optional title and (x) close button.
117 Label* title_;
118 LabelButton* close_;
119
120 // When supplied, this view is placed in the titlebar between the title and
121 // (x) close button.
122 View* titlebar_extra_view_;
123
124 DISALLOW_COPY_AND_ASSIGN(BubbleFrameView);
125 };
126
127 } // namespace views
128
129 #endif // UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_delegate_unittest.cc ('k') | ui/views/bubble/bubble_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698