Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / browser_window_layout.h
1 // Copyright 2014 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_COCOA_BROWSER_WINDOW_CONTROLLER_LAYOUT_H_
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_LAYOUT_H_
7
8 #import <Cocoa/Cocoa.h>
9
10 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h"
11
12 namespace chrome {
13
14 // The height of the tab strip.
15 extern const CGFloat kTabStripHeight;
16
17 // The parameters used to calculate the layout of the views managed by the
18 // BrowserWindowController.
19 struct LayoutParameters {
20   // The size of the content view of the window.
21   NSSize contentViewSize;
22   // The size of the window.
23   NSSize windowSize;
24
25   // Whether the controller is in any fullscreen mode. This parameter should be
26   // NO if the controller is in the process of entering fullscreen.
27   BOOL inAnyFullscreen;
28   // The fullscreen sliding style. See presentation_mode_controller.h for more
29   // details.
30   fullscreen_mac::SlidingStyle slidingStyle;
31   // The minY of the AppKit Menu Bar, relative to the top of the screen. Ranges
32   // from 0 to -22. Only relevant in fullscreen mode.
33   CGFloat menubarOffset;
34   // The fraction of the sliding toolbar that is visible in fullscreenm mode.
35   // Ranges from 0 to 1. Only relevant in fullscreen mode.
36   CGFloat toolbarFraction;
37
38   BOOL hasTabStrip;
39   // The frame of the fullscreen button. May be NSZeroRect if the fullscreen
40   // button doesn't exist. Only needs to be set when hasTabStrip is YES.
41   NSRect fullscreenButtonFrame;
42   // Whether the avatar button should be shown. Only needs to be set when
43   // hasTabStrip is YES.
44   BOOL shouldShowAvatar;
45   // Whether to use the new avatar button. Only needs to be set when
46   // shouldShowAvatar is YES.
47   BOOL shouldUseNewAvatar;
48   // The size of the avatar button. Only needs to be set when shouldShowAvatar
49   // is YES.
50   NSSize avatarSize;
51   // The line width that will generate a 1 pixel wide line for the avatar's
52   // superview. Only needs to be set when shouldShowAvatar is YES.
53   CGFloat avatarLineWidth;
54
55   BOOL hasToolbar;
56   BOOL hasLocationBar;
57   CGFloat toolbarHeight;
58
59   BOOL bookmarkBarHidden;
60   // If the bookmark bar is not hidden, then the bookmark bar should either be
61   // directly below the omnibox, or directly below the info bar. This parameter
62   // selects between those 2 cases.
63   BOOL placeBookmarkBarBelowInfoBar;
64   CGFloat bookmarkBarHeight;
65
66   // The height of the info bar, not including the top arrow.
67   CGFloat infoBarHeight;
68   // The distance from the bottom of the location icon to the bottom of the
69   // toolbar. Only needs to be set if infoBarHeight is not 0 and hasToolbar is
70   // YES.
71   CGFloat pageInfoBubblePointY;
72
73   BOOL hasDownloadShelf;
74   CGFloat downloadShelfHeight;
75 };
76
77 // The parameters required to lay out the tab strip and its components.
78 struct TabStripLayout {
79   // The frame of the tab strip in window coordinates.
80   NSRect frame;
81   // The left indent for the controls of the TabStripController.
82   CGFloat leftIndent;
83   // The right indent for the controls of the TabStripController.
84   CGFloat rightIndent;
85   // Whether the TabStripController needs to add custom traffic light buttons.
86   BOOL addCustomWindowControls;
87   // The frame of the avatar in window coordinates.
88   NSRect avatarFrame;
89 };
90
91 // The output frames of the views managed by the BrowserWindowController. All
92 // frames are in the coordinate system of the window. The lower-left corner of
93 // the contentView coincides with the lower-left corner of the window, so these
94 // frames are also in the coordinate system of the contentView.
95 struct LayoutOutput {
96   TabStripLayout tabStripLayout;
97   NSRect toolbarFrame;
98   NSRect bookmarkFrame;
99   NSRect fullscreenBackingBarFrame;
100   CGFloat findBarMaxY;
101   CGFloat fullscreenExitButtonMaxY;
102   NSRect infoBarFrame;
103   CGFloat infoBarMaxTopArrowHeight;
104   NSRect downloadShelfFrame;
105   NSRect contentAreaFrame;
106 };
107
108 }  // namespace chrome
109
110 // This class is the sole entity responsible for calculating the layout of the
111 // views managed by the BrowserWindowController. The parameters used to
112 // calculate the layout are the fields of |parameters_|. These fields should be
113 // filled by calling the appropriate setters on this class. Once the parameters
114 // have been set, calling -computeLayout will return a LayoutOutput that
115 // includes sufficient information to lay out all views managed by
116 // BrowserWindowController.
117 //
118 // This is a lightweight class. It should be created on demand.
119 @interface BrowserWindowLayout : NSObject {
120  @private
121   // Stores the parameters used to compute layout.
122   chrome::LayoutParameters parameters_;
123
124   // Stores the layout output as it's being computed.
125   chrome::LayoutOutput output_;
126
127   // The offset of the maxY of the tab strip during fullscreen mode.
128   CGFloat fullscreenYOffset_;
129
130   // The views are laid out from highest Y to lowest Y. This variable holds the
131   // current highest Y that the next view is expected to be laid under.
132   CGFloat maxY_;
133 }
134
135 // Performs the layout computation and returns the results. This method is fast
136 // and does not perform any caching.
137 - (chrome::LayoutOutput)computeLayout;
138
139 - (void)setContentViewSize:(NSSize)size;
140 - (void)setWindowSize:(NSSize)size;
141
142 // Whether the controller is in any fullscreen mode. |inAnyFullscreen| should
143 // be NO if the controller is in the process of entering fullscreen.
144 - (void)setInAnyFullscreen:(BOOL)inAnyFullscreen;
145 - (void)setFullscreenSlidingStyle:(fullscreen_mac::SlidingStyle)slidingStyle;
146 - (void)setFullscreenMenubarOffset:(CGFloat)menubarOffset;
147 - (void)setFullscreenToolbarFraction:(CGFloat)toolbarFraction;
148
149 - (void)setHasTabStrip:(BOOL)hasTabStrip;
150 - (void)setFullscreenButtonFrame:(NSRect)frame;
151 - (void)setShouldShowAvatar:(BOOL)shouldShowAvatar;
152 - (void)setShouldUseNewAvatar:(BOOL)shouldUseNewAvatar;
153 - (void)setAvatarSize:(NSSize)avatarSize;
154 - (void)setAvatarLineWidth:(CGFloat)avatarLineWidth;
155
156 - (void)setHasToolbar:(BOOL)hasToolbar;
157 - (void)setHasLocationBar:(BOOL)hasLocationBar;
158 - (void)setToolbarHeight:(CGFloat)toolbarHeight;
159
160 - (void)setBookmarkBarHidden:(BOOL)bookmarkBarHidden;
161 - (void)setPlaceBookmarkBarBelowInfoBar:(BOOL)placeBookmarkBarBelowInfoBar;
162 - (void)setBookmarkBarHeight:(CGFloat)bookmarkBarHeight;
163
164 // The height of the info bar, not including the top arrow.
165 - (void)setInfoBarHeight:(CGFloat)infoBarHeight;
166 // The min Y of the bubble point, relative to the toolbar.
167 - (void)setPageInfoBubblePointY:(CGFloat)pageInfoBubblePointY;
168
169 - (void)setHasDownloadShelf:(BOOL)hasDownloadShelf;
170 - (void)setDownloadShelfHeight:(CGFloat)downloadShelfHeight;
171
172 @end
173
174 #endif  // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_LAYOUT_H_