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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view_layout.cc

Issue 10821002: Makes the min window size include the OTR image and caption buttons on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 8 years, 5 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 5 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
6 6
7 #include "chrome/browser/ui/find_bar/find_bar.h" 7 #include "chrome/browser/ui/find_bar/find_bar.h"
8 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 8 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
9 #include "chrome/browser/ui/view_ids.h" 9 #include "chrome/browser/ui/view_ids.h"
10 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 10 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
11 #include "chrome/browser/ui/views/download/download_shelf_view.h" 11 #include "chrome/browser/ui/views/download/download_shelf_view.h"
12 #include "chrome/browser/ui/views/frame/browser_frame.h" 12 #include "chrome/browser/ui/views/frame/browser_frame.h"
13 #include "chrome/browser/ui/views/frame/browser_view.h" 13 #include "chrome/browser/ui/views/frame/browser_view.h"
14 #include "chrome/browser/ui/views/frame/contents_container.h" 14 #include "chrome/browser/ui/views/frame/contents_container.h"
15 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 15 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
16 #include "chrome/browser/ui/views/tabs/tab_strip.h" 16 #include "chrome/browser/ui/views/tabs/tab_strip.h"
17 #include "chrome/browser/ui/views/toolbar_view.h" 17 #include "chrome/browser/ui/views/toolbar_view.h"
18 #include "ui/base/hit_test.h" 18 #include "ui/base/hit_test.h"
19 #include "ui/gfx/point.h" 19 #include "ui/gfx/point.h"
20 #include "ui/gfx/scrollbar_size.h" 20 #include "ui/gfx/scrollbar_size.h"
21 #include "ui/gfx/size.h" 21 #include "ui/gfx/size.h"
22 #include "ui/views/controls/single_split_view.h" 22 #include "ui/views/controls/single_split_view.h"
23 23
24
25 namespace { 24 namespace {
26 25
27 // The visible height of the shadow above the tabs. Clicks in this area are 26 // The visible height of the shadow above the tabs. Clicks in this area are
28 // treated as clicks to the frame, rather than clicks to the tab. 27 // treated as clicks to the frame, rather than clicks to the tab.
29 const int kTabShadowSize = 2; 28 const int kTabShadowSize = 2;
30 // The vertical overlap between the TabStrip and the Toolbar. 29 // The vertical overlap between the TabStrip and the Toolbar.
31 const int kToolbarTabStripVerticalOverlap = 3; 30 const int kToolbarTabStripVerticalOverlap = 3;
32 // The number of pixels the bookmark bar should overlap the spacer by if the 31 // The number of pixels the bookmark bar should overlap the spacer by if the
33 // spacer is visible. 32 // spacer is visible.
34 const int kSpacerBookmarkBarOverlap = 1; 33 const int kSpacerBookmarkBarOverlap = 1;
(...skipping 25 matching lines...) Expand all
60 download_shelf_(NULL), 59 download_shelf_(NULL),
61 active_bookmark_bar_(NULL), 60 active_bookmark_bar_(NULL),
62 browser_view_(NULL), 61 browser_view_(NULL),
63 find_bar_y_(0) { 62 find_bar_y_(0) {
64 } 63 }
65 64
66 BrowserViewLayout::~BrowserViewLayout() { 65 BrowserViewLayout::~BrowserViewLayout() {
67 } 66 }
68 67
69 gfx::Size BrowserViewLayout::GetMinimumSize() { 68 gfx::Size BrowserViewLayout::GetMinimumSize() {
70 // TODO(noname): In theory the tabstrip width should probably be
71 // (OTR + tabstrip + caption buttons) width.
72 gfx::Size tabstrip_size( 69 gfx::Size tabstrip_size(
73 browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? 70 browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ?
74 tabstrip_->GetMinimumSize() : gfx::Size()); 71 tabstrip_->GetMinimumSize() : gfx::Size());
72 BrowserNonClientFrameView::TabStripInsets tab_strip_insets(
73 browser_view_->frame()->GetTabStripInsets(false));
75 gfx::Size toolbar_size( 74 gfx::Size toolbar_size(
76 (browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || 75 (browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
77 browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ? 76 browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ?
78 toolbar_->GetMinimumSize() : gfx::Size()); 77 toolbar_->GetMinimumSize() : gfx::Size());
79 if (tabstrip_size.height() && toolbar_size.height()) 78 if (tabstrip_size.height() && toolbar_size.height())
80 toolbar_size.Enlarge(0, -kToolbarTabStripVerticalOverlap); 79 toolbar_size.Enlarge(0, -kToolbarTabStripVerticalOverlap);
81 gfx::Size bookmark_bar_size; 80 gfx::Size bookmark_bar_size;
82 if (active_bookmark_bar_ && 81 if (active_bookmark_bar_ &&
83 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { 82 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) {
84 bookmark_bar_size = active_bookmark_bar_->GetMinimumSize(); 83 bookmark_bar_size = active_bookmark_bar_->GetMinimumSize();
85 bookmark_bar_size.Enlarge(0, 84 bookmark_bar_size.Enlarge(0,
86 -(views::NonClientFrameView::kClientEdgeThickness + 85 -(views::NonClientFrameView::kClientEdgeThickness +
87 active_bookmark_bar_->GetToolbarOverlap(true))); 86 active_bookmark_bar_->GetToolbarOverlap(true)));
88 } 87 }
89 gfx::Size contents_size(contents_split_->GetMinimumSize()); 88 gfx::Size contents_size(contents_split_->GetMinimumSize());
90 89
91 int min_height = tabstrip_size.height() + toolbar_size.height() + 90 int min_height = tabstrip_size.height() + toolbar_size.height() +
92 bookmark_bar_size.height() + contents_size.height(); 91 bookmark_bar_size.height() + contents_size.height();
93 int widths[] = { tabstrip_size.width(), toolbar_size.width(), 92 int widths[] = {
94 bookmark_bar_size.width(), contents_size.width() }; 93 tabstrip_size.width() + tab_strip_insets.left + tab_strip_insets.right,
94 toolbar_size.width(),
95 bookmark_bar_size.width(),
96 contents_size.width() };
95 int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]); 97 int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]);
96 return gfx::Size(min_width, min_height); 98 return gfx::Size(min_width, min_height);
97 } 99 }
98 100
99 gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const { 101 gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const {
100 // This function returns the area the Find Bar can be laid out 102 // This function returns the area the Find Bar can be laid out
101 // within. This basically implies the "user-perceived content 103 // within. This basically implies the "user-perceived content
102 // area" of the browser window excluding the vertical 104 // area" of the browser window excluding the vertical
103 // scrollbar. This is not quite so straightforward as positioning 105 // scrollbar. This is not quite so straightforward as positioning
104 // based on the TabContentsContainer since the BookmarkBarView may 106 // based on the TabContentsContainer since the BookmarkBarView may
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 break; 252 break;
251 } 253 }
252 } 254 }
253 255
254 void BrowserViewLayout::Layout(views::View* host) { 256 void BrowserViewLayout::Layout(views::View* host) {
255 vertical_layout_rect_ = browser_view_->GetLocalBounds(); 257 vertical_layout_rect_ = browser_view_->GetLocalBounds();
256 int top = LayoutTabStripRegion(); 258 int top = LayoutTabStripRegion();
257 if (browser_view_->IsTabStripVisible()) { 259 if (browser_view_->IsTabStripVisible()) {
258 tabstrip_->SetBackgroundOffset(gfx::Point( 260 tabstrip_->SetBackgroundOffset(gfx::Point(
259 tabstrip_->GetMirroredX() + browser_view_->GetMirroredX(), 261 tabstrip_->GetMirroredX() + browser_view_->GetMirroredX(),
260 browser_view_->frame()->GetHorizontalTabStripVerticalOffset(false))); 262 browser_view_->frame()->GetTabStripInsets(false).top));
261 } 263 }
262 top = LayoutToolbar(top); 264 top = LayoutToolbar(top);
263 top = LayoutBookmarkAndInfoBars(top); 265 top = LayoutBookmarkAndInfoBars(top);
264 int bottom = LayoutDownloadShelf(browser_view_->height()); 266 int bottom = LayoutDownloadShelf(browser_view_->height());
265 int active_top_margin = GetTopMarginForActiveContent(); 267 int active_top_margin = GetTopMarginForActiveContent();
266 top -= active_top_margin; 268 top -= active_top_margin;
267 contents_container_->SetActiveTopMargin(active_top_margin); 269 contents_container_->SetActiveTopMargin(active_top_margin);
268 LayoutTabContents(top, bottom); 270 LayoutTabContents(top, bottom);
269 // This must be done _after_ we lay out the WebContents since this 271 // This must be done _after_ we lay out the WebContents since this
270 // code calls back into us to find the bounding box the find bar 272 // code calls back into us to find the bounding box the find bar
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 bottom -= height; 477 bottom -= height;
476 } 478 }
477 return bottom; 479 return bottom;
478 } 480 }
479 481
480 bool BrowserViewLayout::InfobarVisible() const { 482 bool BrowserViewLayout::InfobarVisible() const {
481 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. 483 // NOTE: Can't check if the size IsEmpty() since it's always 0-width.
482 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && 484 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) &&
483 (infobar_container_->GetPreferredSize().height() != 0); 485 (infobar_container_->GetPreferredSize().height() != 0);
484 } 486 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/views/frame/glass_browser_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698