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