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

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

Issue 3129003: remove toolstrips (Closed)
Patch Set: merge Created 10 years, 4 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
« no previous file with comments | « chrome/browser/views/frame/browser_view_layout.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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/views/frame/browser_view_layout.h" 5 #include "chrome/browser/views/frame/browser_view_layout.h"
6 6
7 #include "chrome/browser/find_bar.h" 7 #include "chrome/browser/find_bar.h"
8 #include "chrome/browser/find_bar_controller.h" 8 #include "chrome/browser/find_bar_controller.h"
9 #include "chrome/browser/view_ids.h" 9 #include "chrome/browser/view_ids.h"
10 #include "chrome/browser/views/bookmark_bar_view.h" 10 #include "chrome/browser/views/bookmark_bar_view.h"
11 #include "chrome/browser/views/download_shelf_view.h" 11 #include "chrome/browser/views/download_shelf_view.h"
12 #include "chrome/browser/views/extensions/extension_shelf.h"
13 #include "chrome/browser/views/frame/browser_frame.h" 12 #include "chrome/browser/views/frame/browser_frame.h"
14 #include "chrome/browser/views/frame/browser_view.h" 13 #include "chrome/browser/views/frame/browser_view.h"
15 #include "chrome/browser/views/tabs/side_tab_strip.h" 14 #include "chrome/browser/views/tabs/side_tab_strip.h"
16 #include "chrome/browser/views/tabs/tab_strip.h" 15 #include "chrome/browser/views/tabs/tab_strip.h"
17 #include "chrome/browser/views/toolbar_view.h" 16 #include "chrome/browser/views/toolbar_view.h"
18 #include "gfx/scrollbar_size.h" 17 #include "gfx/scrollbar_size.h"
19 #include "views/window/window.h" 18 #include "views/window/window.h"
20 19
21 #if defined(OS_LINUX) 20 #if defined(OS_LINUX)
22 #include "views/window/hit_test.h" 21 #include "views/window/hit_test.h"
(...skipping 15 matching lines...) Expand all
38 //////////////////////////////////////////////////////////////////////////////// 37 ////////////////////////////////////////////////////////////////////////////////
39 // BrowserViewLayout, public: 38 // BrowserViewLayout, public:
40 39
41 BrowserViewLayout::BrowserViewLayout() 40 BrowserViewLayout::BrowserViewLayout()
42 : tabstrip_(NULL), 41 : tabstrip_(NULL),
43 toolbar_(NULL), 42 toolbar_(NULL),
44 contents_split_(NULL), 43 contents_split_(NULL),
45 contents_container_(NULL), 44 contents_container_(NULL),
46 infobar_container_(NULL), 45 infobar_container_(NULL),
47 download_shelf_(NULL), 46 download_shelf_(NULL),
48 extension_shelf_(NULL),
49 active_bookmark_bar_(NULL), 47 active_bookmark_bar_(NULL),
50 browser_view_(NULL), 48 browser_view_(NULL),
51 find_bar_y_(0) { 49 find_bar_y_(0) {
52 } 50 }
53 51
54 gfx::Size BrowserViewLayout::GetMinimumSize() { 52 gfx::Size BrowserViewLayout::GetMinimumSize() {
55 // TODO(noname): In theory the tabstrip width should probably be 53 // TODO(noname): In theory the tabstrip width should probably be
56 // (OTR + tabstrip + caption buttons) width. 54 // (OTR + tabstrip + caption buttons) width.
57 gfx::Size tabstrip_size( 55 gfx::Size tabstrip_size(
58 browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? 56 browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ?
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 190
193 ////////////////////////////////////////////////////////////////////////////// 191 //////////////////////////////////////////////////////////////////////////////
194 // BrowserViewLayout, views::LayoutManager implementation: 192 // BrowserViewLayout, views::LayoutManager implementation:
195 193
196 void BrowserViewLayout::Installed(views::View* host) { 194 void BrowserViewLayout::Installed(views::View* host) {
197 toolbar_ = NULL; 195 toolbar_ = NULL;
198 contents_split_ = NULL; 196 contents_split_ = NULL;
199 contents_container_ = NULL; 197 contents_container_ = NULL;
200 infobar_container_ = NULL; 198 infobar_container_ = NULL;
201 download_shelf_ = NULL; 199 download_shelf_ = NULL;
202 extension_shelf_ = NULL;
203 active_bookmark_bar_ = NULL; 200 active_bookmark_bar_ = NULL;
204 tabstrip_ = NULL; 201 tabstrip_ = NULL;
205 browser_view_ = static_cast<BrowserView*>(host); 202 browser_view_ = static_cast<BrowserView*>(host);
206 } 203 }
207 204
208 void BrowserViewLayout::Uninstalled(views::View* host) {} 205 void BrowserViewLayout::Uninstalled(views::View* host) {}
209 206
210 void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) { 207 void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) {
211 switch (view->GetID()) { 208 switch (view->GetID()) {
212 case VIEW_ID_CONTENTS_SPLIT: 209 case VIEW_ID_CONTENTS_SPLIT:
213 contents_split_ = view; 210 contents_split_ = view;
214 contents_container_ = contents_split_->GetChildViewAt(0); 211 contents_container_ = contents_split_->GetChildViewAt(0);
215 break; 212 break;
216 case VIEW_ID_INFO_BAR_CONTAINER: 213 case VIEW_ID_INFO_BAR_CONTAINER:
217 infobar_container_ = view; 214 infobar_container_ = view;
218 break; 215 break;
219 case VIEW_ID_DOWNLOAD_SHELF: 216 case VIEW_ID_DOWNLOAD_SHELF:
220 download_shelf_ = static_cast<DownloadShelfView*>(view); 217 download_shelf_ = static_cast<DownloadShelfView*>(view);
221 break; 218 break;
222 case VIEW_ID_DEV_EXTENSION_SHELF:
223 extension_shelf_ = static_cast<ExtensionShelf*>(view);
224 break;
225 case VIEW_ID_BOOKMARK_BAR: 219 case VIEW_ID_BOOKMARK_BAR:
226 active_bookmark_bar_ = static_cast<BookmarkBarView*>(view); 220 active_bookmark_bar_ = static_cast<BookmarkBarView*>(view);
227 break; 221 break;
228 case VIEW_ID_TOOLBAR: 222 case VIEW_ID_TOOLBAR:
229 toolbar_ = static_cast<ToolbarView*>(view); 223 toolbar_ = static_cast<ToolbarView*>(view);
230 break; 224 break;
231 case VIEW_ID_TAB_STRIP: 225 case VIEW_ID_TAB_STRIP:
232 tabstrip_ = static_cast<BaseTabStrip*>(view); 226 tabstrip_ = static_cast<BaseTabStrip*>(view);
233 break; 227 break;
234 } 228 }
235 } 229 }
236 230
237 void BrowserViewLayout::ViewRemoved(views::View* host, views::View* view) { 231 void BrowserViewLayout::ViewRemoved(views::View* host, views::View* view) {
238 switch (view->GetID()) { 232 switch (view->GetID()) {
239 case VIEW_ID_BOOKMARK_BAR: 233 case VIEW_ID_BOOKMARK_BAR:
240 active_bookmark_bar_ = NULL; 234 active_bookmark_bar_ = NULL;
241 break; 235 break;
242 } 236 }
243 } 237 }
244 238
245 void BrowserViewLayout::Layout(views::View* host) { 239 void BrowserViewLayout::Layout(views::View* host) {
246 vertical_layout_rect_ = browser_view_->GetLocalBounds(true); 240 vertical_layout_rect_ = browser_view_->GetLocalBounds(true);
247 int top = LayoutTabStrip(); 241 int top = LayoutTabStrip();
248 top = LayoutToolbar(top); 242 top = LayoutToolbar(top);
249 top = LayoutBookmarkAndInfoBars(top); 243 top = LayoutBookmarkAndInfoBars(top);
250 int bottom = LayoutExtensionAndDownloadShelves(); 244 int bottom = LayoutDownloadShelf(browser_view_->height());
251 LayoutTabContents(top, bottom); 245 LayoutTabContents(top, bottom);
252 // This must be done _after_ we lay out the TabContents since this 246 // This must be done _after_ we lay out the TabContents since this
253 // code calls back into us to find the bounding box the find bar 247 // code calls back into us to find the bounding box the find bar
254 // must be laid out within, and that code depends on the 248 // must be laid out within, and that code depends on the
255 // TabContentsContainer's bounds being up to date. 249 // TabContentsContainer's bounds being up to date.
256 if (browser()->HasFindBarController()) { 250 if (browser()->HasFindBarController()) {
257 browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary( 251 browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary(
258 gfx::Rect(), true); 252 gfx::Rect(), true);
259 } 253 }
260 // Align status bubble with the bottom of the contents_container. 254 // Align status bubble with the bottom of the contents_container.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 return top + height; 355 return top + height;
362 } 356 }
363 357
364 // Layout the TabContents container, between the coordinates |top| and 358 // Layout the TabContents container, between the coordinates |top| and
365 // |bottom|. 359 // |bottom|.
366 void BrowserViewLayout::LayoutTabContents(int top, int bottom) { 360 void BrowserViewLayout::LayoutTabContents(int top, int bottom) {
367 contents_split_->SetBounds(vertical_layout_rect_.x(), top, 361 contents_split_->SetBounds(vertical_layout_rect_.x(), top,
368 vertical_layout_rect_.width(), bottom - top); 362 vertical_layout_rect_.width(), bottom - top);
369 } 363 }
370 364
371 int BrowserViewLayout::LayoutExtensionAndDownloadShelves() {
372 // If we're showing the Extension bar in detached style, then we
373 // need to show Download shelf _above_ the Extension bar, since
374 // the Extension bar is styled to look like it's part of the page.
375 //
376 // TODO(Oshima): confirm this comment.
377 int bottom = browser_view_->height();
378 if (extension_shelf_) {
379 if (extension_shelf_->IsDetached()) {
380 bottom = LayoutDownloadShelf(bottom);
381 return LayoutExtensionShelf(bottom);
382 }
383 // Otherwise, Extension shelf first, Download shelf second.
384 bottom = LayoutExtensionShelf(bottom);
385 }
386 return LayoutDownloadShelf(bottom);
387 }
388
389 int BrowserViewLayout::LayoutDownloadShelf(int bottom) { 365 int BrowserViewLayout::LayoutDownloadShelf(int bottom) {
390 // Re-layout the shelf either if it is visible or if it's close animation 366 // Re-layout the shelf either if it is visible or if it's close animation
391 // is currently running. 367 // is currently running.
392 if (browser_view_->IsDownloadShelfVisible() || 368 if (browser_view_->IsDownloadShelfVisible() ||
393 (download_shelf_ && download_shelf_->IsClosing())) { 369 (download_shelf_ && download_shelf_->IsClosing())) {
394 bool visible = browser()->SupportsWindowFeature( 370 bool visible = browser()->SupportsWindowFeature(
395 Browser::FEATURE_DOWNLOADSHELF); 371 Browser::FEATURE_DOWNLOADSHELF);
396 DCHECK(download_shelf_); 372 DCHECK(download_shelf_);
397 int height = visible ? download_shelf_->GetPreferredSize().height() : 0; 373 int height = visible ? download_shelf_->GetPreferredSize().height() : 0;
398 download_shelf_->SetVisible(visible); 374 download_shelf_->SetVisible(visible);
399 download_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height, 375 download_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height,
400 vertical_layout_rect_.width(), height); 376 vertical_layout_rect_.width(), height);
401 download_shelf_->Layout(); 377 download_shelf_->Layout();
402 bottom -= height; 378 bottom -= height;
403 } 379 }
404 return bottom; 380 return bottom;
405 } 381 }
406 382
407 int BrowserViewLayout::LayoutExtensionShelf(int bottom) {
408 if (extension_shelf_) {
409 bool visible = browser()->SupportsWindowFeature(
410 Browser::FEATURE_EXTENSIONSHELF);
411 int height =
412 visible ? extension_shelf_->GetPreferredSize().height() : 0;
413 extension_shelf_->SetVisible(visible && height != 0);
414 extension_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height,
415 vertical_layout_rect_.width(), height);
416 extension_shelf_->Layout();
417 bottom -= height;
418 }
419 return bottom;
420 }
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/browser_view_layout.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698