Home | History | Annotate | Download | only in cocoa
      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 
     40   BOOL hasToolbar;
     41   BOOL hasLocationBar;
     42   CGFloat toolbarHeight;
     43 
     44   BOOL bookmarkBarHidden;
     45   // If the bookmark bar is not hidden, then the bookmark bar should either be
     46   // directly below the omnibox, or directly below the info bar. This parameter
     47   // selects between those 2 cases.
     48   BOOL placeBookmarkBarBelowInfoBar;
     49   CGFloat bookmarkBarHeight;
     50 
     51   // The height of the info bar, not including the top arrow.
     52   CGFloat infoBarHeight;
     53   // The distance from the bottom of the location icon to the bottom of the
     54   // toolbar.
     55   CGFloat pageInfoBubblePointY;
     56 
     57   BOOL hasDownloadShelf;
     58   CGFloat downloadShelfHeight;
     59 };
     60 
     61 // The output frames of the views managed by the BrowserWindowController.
     62 struct LayoutOutput {
     63   NSRect tabStripFrame;
     64   NSRect toolbarFrame;
     65   NSRect bookmarkFrame;
     66   NSRect fullscreenBackingBarFrame;
     67   CGFloat findBarMaxY;
     68   CGFloat fullscreenExitButtonMaxY;
     69   NSRect infoBarFrame;
     70   CGFloat infoBarMaxTopArrowHeight;
     71   NSRect downloadShelfFrame;
     72   NSRect contentAreaFrame;
     73 };
     74 
     75 }  // namespace chrome
     76 
     77 // This class is the sole entity responsible for calculating the layout of the
     78 // views managed by the BrowserWindowController. The parameters used to
     79 // calculate the layout are the fields of |parameters_|. These fields should be
     80 // filled by calling the appropriate setters on this class. Once the parameters
     81 // have been set, calling -computeLayout will return a LayoutOutput that
     82 // includes sufficient information to lay out all views managed by
     83 // BrowserWindowController.
     84 //
     85 // This is a lightweight class. It should be created on demand.
     86 @interface BrowserWindowLayout : NSObject {
     87  @private
     88   // Stores the parameters used to compute layout.
     89   chrome::LayoutParameters parameters_;
     90 
     91   // Stores the layout output as it's being computed.
     92   chrome::LayoutOutput output_;
     93 
     94   // The offset of the maxY of the tab strip during fullscreen mode.
     95   CGFloat fullscreenYOffset_;
     96 
     97   // The views are laid out from highest Y to lowest Y. This variable holds the
     98   // current highest Y that the next view is expected to be laid under.
     99   CGFloat maxY_;
    100 }
    101 
    102 // Performs the layout computation and returns the results. This method is fast
    103 // and does not perform any caching.
    104 - (chrome::LayoutOutput)computeLayout;
    105 
    106 - (void)setContentViewSize:(NSSize)size;
    107 - (void)setWindowSize:(NSSize)size;
    108 
    109 // Whether the controller is in any fullscreen mode. |inAnyFullscreen| should
    110 // be NO if the controller is in the process of entering fullscreen.
    111 - (void)setInAnyFullscreen:(BOOL)inAnyFullscreen;
    112 - (void)setFullscreenSlidingStyle:(fullscreen_mac::SlidingStyle)slidingStyle;
    113 - (void)setFullscreenMenubarOffset:(CGFloat)menubarOffset;
    114 - (void)setFullscreenToolbarFraction:(CGFloat)toolbarFraction;
    115 
    116 - (void)setHasTabStrip:(BOOL)hasTabStrip;
    117 
    118 - (void)setHasToolbar:(BOOL)hasToolbar;
    119 - (void)setHasLocationBar:(BOOL)hasLocationBar;
    120 - (void)setToolbarHeight:(CGFloat)toolbarHeight;
    121 
    122 - (void)setBookmarkBarHidden:(BOOL)bookmarkBarHidden;
    123 - (void)setPlaceBookmarkBarBelowInfoBar:(BOOL)placeBookmarkBarBelowInfoBar;
    124 - (void)setBookmarkBarHeight:(CGFloat)bookmarkBarHeight;
    125 
    126 // The height of the info bar, not including the top arrow.
    127 - (void)setInfoBarHeight:(CGFloat)infoBarHeight;
    128 // The min Y of the bubble point, relative to the toolbar.
    129 - (void)setPageInfoBubblePointY:(CGFloat)pageInfoBubblePointY;
    130 
    131 - (void)setHasDownloadShelf:(BOOL)hasDownloadShelf;
    132 - (void)setDownloadShelfHeight:(CGFloat)downloadShelfHeight;
    133 
    134 @end
    135 
    136 #endif  // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_LAYOUT_H_
    137