Home | History | Annotate | Download | only in frame
      1 // Copyright (c) 2011 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_BROWSER_VIEW_LAYOUT_H_
      6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_
      7 #pragma once
      8 
      9 #include "base/basictypes.h"
     10 #include "ui/gfx/rect.h"
     11 #include "views/layout/layout_manager.h"
     12 
     13 class AbstractTabStripView;
     14 class BookmarkBarView;
     15 class Browser;
     16 class BrowserView;
     17 class ContentsContainer;
     18 class DownloadShelfView;
     19 class TabContentsContainer;
     20 class ToolbarView;
     21 
     22 namespace gfx {
     23 class Point;
     24 class Size;
     25 }
     26 
     27 namespace views {
     28 class SingleSplitView;
     29 }
     30 
     31 // The layout manager used in chrome browser.
     32 class BrowserViewLayout : public views::LayoutManager {
     33  public:
     34   BrowserViewLayout();
     35   virtual ~BrowserViewLayout();
     36 
     37   // Returns the minimum size of the browser view.
     38   virtual gfx::Size GetMinimumSize();
     39 
     40   // Returns the bounding box for the find bar.
     41   virtual gfx::Rect GetFindBarBoundingBox() const;
     42 
     43   // Returns true if the specified point(BrowserView coordinates) is in
     44   // in the window caption area of the browser window.
     45   virtual bool IsPositionInWindowCaption(const gfx::Point& point);
     46 
     47   // Tests to see if the specified |point| (in nonclient view's coordinates)
     48   // is within the views managed by the laymanager. Returns one of
     49   // HitTestCompat enum defined in views/window/hit_test.h.
     50   // See also ClientView::NonClientHitTest.
     51   virtual int NonClientHitTest(const gfx::Point& point);
     52 
     53   // views::LayoutManager overrides:
     54   virtual void Installed(views::View* host);
     55   virtual void Uninstalled(views::View* host);
     56   virtual void ViewAdded(views::View* host, views::View* view);
     57   virtual void ViewRemoved(views::View* host, views::View* view);
     58   virtual void Layout(views::View* host);
     59   virtual gfx::Size GetPreferredSize(views::View* host);
     60 
     61  protected:
     62   Browser* browser();
     63   const Browser* browser() const;
     64 
     65   // Layout the TabStrip, returns the coordinate of the bottom of the TabStrip,
     66   // for laying out subsequent controls.
     67   virtual int LayoutTabStrip();
     68 
     69   // Layout the following controls, starting at |top|, returns the coordinate
     70   // of the bottom of the control, for laying out the next control.
     71   virtual int LayoutToolbar(int top);
     72   virtual int LayoutBookmarkAndInfoBars(int top);
     73   int LayoutBookmarkBar(int top);
     74   int LayoutInfoBar(int top);
     75 
     76   // Updates |source|'s reserved contents rect by mapping BrowserView's
     77   // |browser_reserved_rect| into |future_source_bounds| taking into
     78   // account |source|'s |future_parent_offset| (offset is relative to
     79   // browser_view_).
     80   void UpdateReservedContentsRect(const gfx::Rect& browser_reserved_rect,
     81                                   TabContentsContainer* source,
     82                                   const gfx::Rect& future_source_bounds,
     83                                   const gfx::Point& future_parent_offset);
     84 
     85   // Layout the TabContents container, between the coordinates |top| and
     86   // |bottom|.
     87   void LayoutTabContents(int top, int bottom);
     88 
     89   // Returns the top margin to adjust the contents_container_ by. This is used
     90   // to make the bookmark bar and contents_container_ overlap so that the
     91   // preview contents hides the bookmark bar.
     92   int GetTopMarginForActiveContent();
     93 
     94   // Layout the Download Shelf, returns the coordinate of the top of the
     95   // control, for laying out the previous control.
     96   int LayoutDownloadShelf(int bottom);
     97 
     98   // Returns true if an infobar is showing.
     99   bool InfobarVisible() const;
    100 
    101   // See description above vertical_layout_rect_ for details.
    102   void set_vertical_layout_rect(const gfx::Rect& bounds) {
    103     vertical_layout_rect_ = bounds;
    104   }
    105   const gfx::Rect& vertical_layout_rect() const {
    106     return vertical_layout_rect_;
    107   }
    108 
    109   // Child views that the layout manager manages.
    110   AbstractTabStripView* tabstrip_;
    111   ToolbarView* toolbar_;
    112   views::SingleSplitView* contents_split_;
    113   ContentsContainer* contents_container_;
    114   views::View* infobar_container_;
    115   DownloadShelfView* download_shelf_;
    116   BookmarkBarView* active_bookmark_bar_;
    117 
    118   BrowserView* browser_view_;
    119 
    120   // The bounds within which the vertically-stacked contents of the BrowserView
    121   // should be laid out within. When the SideTabstrip is not visible, this is
    122   // just the local bounds of the BrowserView, otherwise it's the local bounds
    123   // of the BrowserView less the width of the SideTabstrip.
    124   gfx::Rect vertical_layout_rect_;
    125 
    126   // The distance the FindBar is from the top of the window, in pixels.
    127   int find_bar_y_;
    128 
    129   DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout);
    130 };
    131 
    132 #endif  // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_
    133