OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_ |
7 | 7 |
8 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" | 8 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
9 #include "ui/views/layout/layout_manager.h" | 9 #include "ui/views/layout/layout_manager.h" |
10 | 10 |
11 class OpaqueBrowserFrameViewLayoutDelegate; | 11 class OpaqueBrowserFrameViewLayoutDelegate; |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 class ImageButton; | 14 class ImageButton; |
15 class Label; | 15 class Label; |
16 } | 16 } |
17 | 17 |
18 // Calculates the position of the widgets in the opaque browser frame view. | 18 // Calculates the position of the widgets in the opaque browser frame view. |
19 // | 19 // |
20 // This is separated out for testing reasons. OpaqueBrowserFrameView has tight | 20 // This is separated out for testing reasons. OpaqueBrowserFrameView has tight |
21 // dependencies with Browser and classes that depend on Browser. | 21 // dependencies with Browser and classes that depend on Browser. |
22 class OpaqueBrowserFrameViewLayout : public views::LayoutManager { | 22 class OpaqueBrowserFrameViewLayout : public views::LayoutManager { |
23 public: | 23 public: |
24 enum ButtonID { | |
25 BUTTON_MINIMIZE, | |
26 BUTTON_MAXIMIZE, | |
27 BUTTON_CLOSE | |
28 }; | |
29 | |
24 explicit OpaqueBrowserFrameViewLayout( | 30 explicit OpaqueBrowserFrameViewLayout( |
25 OpaqueBrowserFrameViewLayoutDelegate* delegate); | 31 OpaqueBrowserFrameViewLayoutDelegate* delegate); |
26 virtual ~OpaqueBrowserFrameViewLayout(); | 32 virtual ~OpaqueBrowserFrameViewLayout(); |
27 | 33 |
28 // Whether we should add the (minimize,maximize,close) buttons. Can be false | 34 // Whether we should add the (minimize,maximize,close) buttons. Can be false |
29 // on Windows 8 in metro mode. | 35 // on Windows 8 in metro mode. |
30 static bool ShouldAddDefaultCaptionButtons(); | 36 static bool ShouldAddDefaultCaptionButtons(); |
31 | 37 |
32 gfx::Rect GetBoundsForTabStrip( | 38 gfx::Rect GetBoundsForTabStrip( |
33 const gfx::Size& tabstrip_preferred_size, | 39 const gfx::Size& tabstrip_preferred_size, |
34 int available_width) const; | 40 int available_width) const; |
35 gfx::Rect GetBoundsForTabStripAndAvatarArea( | |
36 const gfx::Size& tabstrip_preferred_size, | |
37 int available_width) const; | |
38 | 41 |
39 gfx::Size GetMinimumSize(int available_width) const; | 42 gfx::Size GetMinimumSize(int available_width) const; |
40 | 43 |
41 // Returns the bounds of the window required to display the content area at | 44 // Returns the bounds of the window required to display the content area at |
42 // the specified bounds. | 45 // the specified bounds. |
43 gfx::Rect GetWindowBoundsForClientBounds( | 46 gfx::Rect GetWindowBoundsForClientBounds( |
44 const gfx::Rect& client_bounds) const; | 47 const gfx::Rect& client_bounds) const; |
45 | 48 |
46 // Returns the thickness of the border that makes up the window frame edges. | 49 // Returns the thickness of the border that makes up the window frame edges. |
47 // This does not include any client edge. If |restored| is true, acts as if | 50 // This does not include any client edge. If |restored| is true, acts as if |
(...skipping 23 matching lines...) Expand all Loading... | |
71 // Returns the bounds of the titlebar icon (or where the icon would be if | 74 // Returns the bounds of the titlebar icon (or where the icon would be if |
72 // there was one). | 75 // there was one). |
73 gfx::Rect IconBounds() const; | 76 gfx::Rect IconBounds() const; |
74 | 77 |
75 // Returns the bounds of the client area for the specified view size. | 78 // Returns the bounds of the client area for the specified view size. |
76 gfx::Rect CalculateClientAreaBounds(int width, int height) const; | 79 gfx::Rect CalculateClientAreaBounds(int width, int height) const; |
77 | 80 |
78 const gfx::Rect& client_view_bounds() const { return client_view_bounds_; } | 81 const gfx::Rect& client_view_bounds() const { return client_view_bounds_; } |
79 | 82 |
80 private: | 83 private: |
84 // Whether a specific button should be inserted on the left or right side. | |
85 enum ButtonAlignment { | |
86 ALIGN_LEFT, | |
sky
2013/09/05 15:54:32
leading/trailing are a bit better since left/right
| |
87 ALIGN_RIGHT | |
88 }; | |
89 | |
81 // Layout various sub-components of this view. | 90 // Layout various sub-components of this view. |
82 void LayoutWindowControls(views::View* host); | 91 void LayoutWindowControls(views::View* host); |
83 void LayoutTitleBar(); | 92 void LayoutTitleBar(views::View* host); |
84 void LayoutAvatar(); | 93 void LayoutAvatar(); |
85 | 94 |
95 void ConfigureButton(views::View* host, | |
96 ButtonID button_id, | |
97 ButtonAlignment align, | |
98 int caption_y); | |
99 | |
100 // Adds a window caption button to either the left or right side. | |
101 void SetBoundsForButton(views::View* host, | |
102 views::ImageButton* button, | |
103 ButtonAlignment align, | |
104 int caption_y); | |
105 | |
86 // Internal implementation of ViewAdded() and ViewRemoved(). | 106 // Internal implementation of ViewAdded() and ViewRemoved(). |
87 void SetView(int id, views::View* view); | 107 void SetView(int id, views::View* view); |
88 | 108 |
89 // Overriden from views::LayoutManager: | 109 // Overriden from views::LayoutManager: |
90 virtual void Layout(views::View* host) OVERRIDE; | 110 virtual void Layout(views::View* host) OVERRIDE; |
91 virtual gfx::Size GetPreferredSize(views::View* host) OVERRIDE; | 111 virtual gfx::Size GetPreferredSize(views::View* host) OVERRIDE; |
92 virtual void ViewAdded(views::View* host, views::View* view) OVERRIDE; | 112 virtual void ViewAdded(views::View* host, views::View* view) OVERRIDE; |
93 virtual void ViewRemoved(views::View* host, views::View* view) OVERRIDE; | 113 virtual void ViewRemoved(views::View* host, views::View* view) OVERRIDE; |
94 | 114 |
95 OpaqueBrowserFrameViewLayoutDelegate* delegate_; | 115 OpaqueBrowserFrameViewLayoutDelegate* delegate_; |
96 | 116 |
97 // The layout rect of the avatar icon, if visible. | 117 // The layout rect of the avatar icon, if visible. |
98 gfx::Rect avatar_bounds_; | 118 gfx::Rect avatar_bounds_; |
99 | 119 |
100 // The bounds of the ClientView. | 120 // The bounds of the ClientView. |
101 gfx::Rect client_view_bounds_; | 121 gfx::Rect client_view_bounds_; |
102 | 122 |
123 // The layout of the window icon, if visible. | |
124 gfx::Rect window_icon_bounds_; | |
125 | |
126 // How far from the left/right edge of the view the next window control | |
127 // should be placed. | |
128 int left_button_start_; | |
sky
2013/09/05 15:54:32
Same comment about left/right here.
| |
129 int right_button_start_; | |
130 | |
131 // The size of the window buttons, and the avatar menu item (if any). This | |
132 // does not count labels or other elements that should be counted in a | |
133 // minimal frame. | |
134 int minimum_size_for_buttons_; | |
135 | |
136 // Whether any of the window control buttons were packed on the left. | |
137 bool has_left_buttons_; | |
138 bool has_right_buttons_; | |
139 | |
103 // Window controls. | 140 // Window controls. |
104 views::ImageButton* minimize_button_; | 141 views::ImageButton* minimize_button_; |
105 views::ImageButton* maximize_button_; | 142 views::ImageButton* maximize_button_; |
106 views::ImageButton* restore_button_; | 143 views::ImageButton* restore_button_; |
107 views::ImageButton* close_button_; | 144 views::ImageButton* close_button_; |
108 | 145 |
109 views::View* window_icon_; | 146 views::View* window_icon_; |
110 views::Label* window_title_; | 147 views::Label* window_title_; |
111 | 148 |
112 views::View* avatar_label_; | 149 views::View* avatar_label_; |
113 views::View* avatar_button_; | 150 views::View* avatar_button_; |
114 | 151 |
115 DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameViewLayout); | 152 DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameViewLayout); |
116 }; | 153 }; |
117 | 154 |
118 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_ | 155 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_ |
OLD | NEW |