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

Side by Side Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h

Issue 23531006: Factor out the layout code from OpaqueBrowserFrameView for testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More clean, hopefully fix that final chromeos test Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 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
8 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h"
9 #include "ui/views/layout/layout_manager.h"
10
11 class OpaqueBrowserFrameViewLayoutDelegate;
12
13 namespace views {
14 class ImageButton;
15 class Label;
16 }
17
18 // Calculates the position of the widgets in the opaque browser frame view.
19 //
20 // This is separated out for testing reasons. OpaqueBrowserFrameView has tight
21 // dependencies with Browser and classes that depend on Browser.
22 class OpaqueBrowserFrameViewLayout : public views::LayoutManager {
23 public:
24 explicit OpaqueBrowserFrameViewLayout(
25 OpaqueBrowserFrameViewLayoutDelegate* delegate);
26 virtual ~OpaqueBrowserFrameViewLayout();
27
28 // Whether we should add the (minimize,maximize,close) buttons. Can be false
29 // on Windows 8 in metro mode.
30 static bool ShouldAddDefaultCaptionButtons();
31
32 gfx::Rect GetBoundsForTabStrip(
33 const gfx::Size& tabstrip_preferred_size,
34 int available_width) const;
35 gfx::Rect GetBoundsForTabStripAndAvatarArea(
36 const gfx::Size& tabstrip_preferred_size,
37 int available_width) const;
38
39 gfx::Size GetMinimumSize(int available_width) const;
40
41 // Returns the bounds of the window required to display the content area at
42 // the specified bounds.
43 gfx::Rect GetWindowBoundsForClientBounds(
44 const gfx::Rect& client_bounds) const;
45
46 // 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
48 // the window is restored regardless of the real mode.
49 int FrameBorderThickness(bool restored) const;
50
51 // Returns the thickness of the entire nonclient left, right, and bottom
52 // borders, including both the window frame and any client edge.
53 int NonClientBorderThickness() const;
54
55 // Returns the height of the entire nonclient top border, including the window
56 // frame, any title area, and any connected client edge. If |restored| is
57 // true, acts as if the window is restored regardless of the real mode.
58 int NonClientTopBorderHeight(bool restored) const;
59
60 int GetTabStripInsetsTop(bool restored) const;
61
62 // Returns the y-coordinate of the caption buttons. If |restored| is true,
63 // acts as if the window is restored regardless of the real mode.
64 int CaptionButtonY(bool restored) const;
65
66 // Returns the thickness of the 3D edge along the bottom of the titlebar. If
67 // |restored| is true, acts as if the window is restored regardless of the
68 // real mode.
69 int TitlebarBottomThickness(bool restored) const;
70
71 // Returns the bounds of the titlebar icon (or where the icon would be if
72 // there was one).
73 gfx::Rect IconBounds() const;
74
75 // Returns the bounds of the client area for the specified view size.
76 gfx::Rect CalculateClientAreaBounds(int width, int height) const;
77
78 const gfx::Rect& client_view_bounds() const { return client_view_bounds_; }
79
80 private:
81 // Layout various sub-components of this view.
82 void LayoutWindowControls(views::View* host);
83 void LayoutTitleBar();
84 void LayoutAvatar();
85
86 // Internal implementation of ViewAdded() and ViewRemoved().
87 void SetView(int id, views::View* view);
88
89 // Overriden from views::LayoutManager:
90 virtual void Layout(views::View* host) OVERRIDE;
91 virtual gfx::Size GetPreferredSize(views::View* host) OVERRIDE;
92 virtual void ViewAdded(views::View* host, views::View* view) OVERRIDE;
93 virtual void ViewRemoved(views::View* host, views::View* view) OVERRIDE;
94
95 OpaqueBrowserFrameViewLayoutDelegate* delegate_;
96
97 // The layout rect of the avatar icon, if visible.
98 gfx::Rect avatar_bounds_;
99
100 // The bounds of the ClientView.
101 gfx::Rect client_view_bounds_;
102
103 // Window controls.
104 views::ImageButton* minimize_button_;
105 views::ImageButton* maximize_button_;
106 views::ImageButton* restore_button_;
107 views::ImageButton* close_button_;
108
109 views::View* window_icon_;
110 views::Label* window_title_;
111
112 views::View* avatar_label_;
113 views::View* avatar_button_;
114
115 DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameViewLayout);
116 };
117
118 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698