OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/sidebar/sidebar_manager.h" | 7 #include "chrome/browser/sidebar/sidebar_manager.h" |
8 #include "chrome/browser/ui/find_bar/find_bar.h" | 8 #include "chrome/browser/ui/find_bar/find_bar.h" |
9 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 9 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
10 #include "chrome/browser/ui/view_ids.h" | 10 #include "chrome/browser/ui/view_ids.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 tabstrip_ = NULL; | 242 tabstrip_ = NULL; |
243 compact_navigation_bar_ = NULL; | 243 compact_navigation_bar_ = NULL; |
244 compact_options_bar_ = NULL; | 244 compact_options_bar_ = NULL; |
245 compact_spacer_ = NULL; | 245 compact_spacer_ = NULL; |
246 browser_view_ = static_cast<BrowserView*>(host); | 246 browser_view_ = static_cast<BrowserView*>(host); |
247 } | 247 } |
248 | 248 |
249 void BrowserViewLayout::Uninstalled(views::View* host) {} | 249 void BrowserViewLayout::Uninstalled(views::View* host) {} |
250 | 250 |
251 void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) { | 251 void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) { |
252 switch (view->GetID()) { | 252 switch (view->id()) { |
253 case VIEW_ID_CONTENTS_SPLIT: { | 253 case VIEW_ID_CONTENTS_SPLIT: { |
254 contents_split_ = static_cast<views::SingleSplitView*>(view); | 254 contents_split_ = static_cast<views::SingleSplitView*>(view); |
255 // We're installed as the LayoutManager before BrowserView creates the | 255 // We're installed as the LayoutManager before BrowserView creates the |
256 // contents, so we have to set contents_container_ here rather than in | 256 // contents, so we have to set contents_container_ here rather than in |
257 // Installed. | 257 // Installed. |
258 contents_container_ = browser_view_->contents_; | 258 contents_container_ = browser_view_->contents_; |
259 break; | 259 break; |
260 } | 260 } |
261 case VIEW_ID_INFO_BAR_CONTAINER: | 261 case VIEW_ID_INFO_BAR_CONTAINER: |
262 infobar_container_ = view; | 262 infobar_container_ = view; |
(...skipping 16 matching lines...) Expand all Loading... |
279 case VIEW_ID_COMPACT_NAV_BAR: | 279 case VIEW_ID_COMPACT_NAV_BAR: |
280 compact_navigation_bar_ = view; | 280 compact_navigation_bar_ = view; |
281 break; | 281 break; |
282 case VIEW_ID_COMPACT_OPT_BAR: | 282 case VIEW_ID_COMPACT_OPT_BAR: |
283 compact_options_bar_ = view; | 283 compact_options_bar_ = view; |
284 break; | 284 break; |
285 } | 285 } |
286 } | 286 } |
287 | 287 |
288 void BrowserViewLayout::ViewRemoved(views::View* host, views::View* view) { | 288 void BrowserViewLayout::ViewRemoved(views::View* host, views::View* view) { |
289 switch (view->GetID()) { | 289 switch (view->id()) { |
290 case VIEW_ID_BOOKMARK_BAR: | 290 case VIEW_ID_BOOKMARK_BAR: |
291 active_bookmark_bar_ = NULL; | 291 active_bookmark_bar_ = NULL; |
292 break; | 292 break; |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 void BrowserViewLayout::Layout(views::View* host) { | 296 void BrowserViewLayout::Layout(views::View* host) { |
297 vertical_layout_rect_ = browser_view_->GetLocalBounds(); | 297 vertical_layout_rect_ = browser_view_->GetLocalBounds(); |
298 int top = LayoutTabStripRegion(); | 298 int top = LayoutTabStripRegion(); |
299 if (browser_view_->IsTabStripVisible() && !browser_view_->UseVerticalTabs()) { | 299 if (browser_view_->IsTabStripVisible() && !browser_view_->UseVerticalTabs()) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 // If we are in compact nav mode, we want to reduce the tab strip bounds from | 363 // If we are in compact nav mode, we want to reduce the tab strip bounds from |
364 // both ends enough to lay out the compact navigation and options bars. We | 364 // both ends enough to lay out the compact navigation and options bars. We |
365 // check the pointers to see if the mode is available, and then check the pref | 365 // check the pointers to see if the mode is available, and then check the pref |
366 // to see if the mode is enabled (and therefore if the additional bars should | 366 // to see if the mode is enabled (and therefore if the additional bars should |
367 // be made visible). | 367 // be made visible). |
368 if (compact_navigation_bar_ && compact_options_bar_) { | 368 if (compact_navigation_bar_ && compact_options_bar_) { |
369 compact_navigation_bar_->SetVisible( | 369 compact_navigation_bar_->SetVisible( |
370 browser_view_->UseCompactNavigationBar()); | 370 browser_view_->UseCompactNavigationBar()); |
371 compact_options_bar_->SetVisible(browser_view_->UseCompactNavigationBar()); | 371 compact_options_bar_->SetVisible(browser_view_->UseCompactNavigationBar()); |
372 | 372 |
373 if (compact_navigation_bar_->IsVisible()) { | 373 if (compact_navigation_bar_->visible()) { |
374 gfx::Rect cnav_bar_bounds; | 374 gfx::Rect cnav_bar_bounds; |
375 gfx::Size cnav_bar_size = compact_navigation_bar_->GetPreferredSize(); | 375 gfx::Size cnav_bar_size = compact_navigation_bar_->GetPreferredSize(); |
376 cnav_bar_bounds.set_origin(tabstrip_bounds.origin()); | 376 cnav_bar_bounds.set_origin(tabstrip_bounds.origin()); |
377 cnav_bar_bounds.set_size(cnav_bar_size); | 377 cnav_bar_bounds.set_size(cnav_bar_size); |
378 compact_navigation_bar_->SetBoundsRect(cnav_bar_bounds); | 378 compact_navigation_bar_->SetBoundsRect(cnav_bar_bounds); |
379 | 379 |
380 // The options bar is flush right of the tab strip region. | 380 // The options bar is flush right of the tab strip region. |
381 gfx::Rect copt_bar_bounds; | 381 gfx::Rect copt_bar_bounds; |
382 gfx::Size copt_bar_size = compact_options_bar_->GetPreferredSize(); | 382 gfx::Size copt_bar_size = compact_options_bar_->GetPreferredSize(); |
383 copt_bar_bounds.set_x(std::max(0, tabstrip_bounds.right() - | 383 copt_bar_bounds.set_x(std::max(0, tabstrip_bounds.right() - |
(...skipping 16 matching lines...) Expand all Loading... |
400 | 400 |
401 tabstrip_->SetVisible(true); | 401 tabstrip_->SetVisible(true); |
402 tabstrip_->SetBoundsRect(tabstrip_bounds); | 402 tabstrip_->SetBoundsRect(tabstrip_bounds); |
403 return browser_view_->UseVerticalTabs() ? | 403 return browser_view_->UseVerticalTabs() ? |
404 tabstrip_bounds.y() : tabstrip_bounds.bottom(); | 404 tabstrip_bounds.y() : tabstrip_bounds.bottom(); |
405 } | 405 } |
406 | 406 |
407 int BrowserViewLayout::LayoutToolbar(int top) { | 407 int BrowserViewLayout::LayoutToolbar(int top) { |
408 int browser_view_width = vertical_layout_rect_.width(); | 408 int browser_view_width = vertical_layout_rect_.width(); |
409 bool toolbar_visible = browser_view_->IsToolbarVisible(); | 409 bool toolbar_visible = browser_view_->IsToolbarVisible(); |
410 toolbar_->location_bar()->SetFocusable(toolbar_visible); | 410 // TODO(beng): This should not be needed. Focusability should include |
| 411 // visibility. |
| 412 toolbar_->location_bar()->set_focusable(toolbar_visible); |
411 int y = top; | 413 int y = top; |
412 if (!browser_view_->UseVerticalTabs()) { | 414 if (!browser_view_->UseVerticalTabs()) { |
413 y -= ((toolbar_visible || browser_view_->UseCompactNavigationBar()) && | 415 y -= ((toolbar_visible || browser_view_->UseCompactNavigationBar()) && |
414 browser_view_->IsTabStripVisible()) ? | 416 browser_view_->IsTabStripVisible()) ? |
415 kToolbarTabStripVerticalOverlap : 0; | 417 kToolbarTabStripVerticalOverlap : 0; |
416 } | 418 } |
417 int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; | 419 int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; |
418 toolbar_->SetVisible(toolbar_visible); | 420 toolbar_->SetVisible(toolbar_visible); |
419 toolbar_->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height); | 421 toolbar_->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height); |
420 | 422 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 sidebar_split->SetBoundsRect(sidebar_split_bounds); | 592 sidebar_split->SetBoundsRect(sidebar_split_bounds); |
591 } | 593 } |
592 | 594 |
593 int BrowserViewLayout::GetTopMarginForActiveContent() { | 595 int BrowserViewLayout::GetTopMarginForActiveContent() { |
594 if (!active_bookmark_bar_ || !browser_view_->IsBookmarkBarVisible() || | 596 if (!active_bookmark_bar_ || !browser_view_->IsBookmarkBarVisible() || |
595 !active_bookmark_bar_->IsDetached()) { | 597 !active_bookmark_bar_->IsDetached()) { |
596 return 0; | 598 return 0; |
597 } | 599 } |
598 | 600 |
599 if (contents_split_->GetChildViewAt(1) && | 601 if (contents_split_->GetChildViewAt(1) && |
600 contents_split_->GetChildViewAt(1)->IsVisible()) | 602 contents_split_->GetChildViewAt(1)->visible()) |
601 return 0; | 603 return 0; |
602 | 604 |
603 if (SidebarManager::IsSidebarAllowed()) { | 605 if (SidebarManager::IsSidebarAllowed()) { |
604 views::View* sidebar_split = contents_split_->GetChildViewAt(0); | 606 views::View* sidebar_split = contents_split_->GetChildViewAt(0); |
605 if (sidebar_split->GetChildViewAt(1) && | 607 if (sidebar_split->GetChildViewAt(1) && |
606 sidebar_split->GetChildViewAt(1)->IsVisible()) | 608 sidebar_split->GetChildViewAt(1)->visible()) |
607 return 0; | 609 return 0; |
608 } | 610 } |
609 | 611 |
610 // Adjust for separator. | 612 // Adjust for separator. |
611 return active_bookmark_bar_->height() - | 613 return active_bookmark_bar_->height() - |
612 views::NonClientFrameView::kClientEdgeThickness; | 614 views::NonClientFrameView::kClientEdgeThickness; |
613 } | 615 } |
614 | 616 |
615 int BrowserViewLayout::LayoutDownloadShelf(int bottom) { | 617 int BrowserViewLayout::LayoutDownloadShelf(int bottom) { |
616 // Re-layout the shelf either if it is visible or if it's close animation | 618 // Re-layout the shelf either if it is visible or if it's close animation |
(...skipping 11 matching lines...) Expand all Loading... |
628 bottom -= height; | 630 bottom -= height; |
629 } | 631 } |
630 return bottom; | 632 return bottom; |
631 } | 633 } |
632 | 634 |
633 bool BrowserViewLayout::InfobarVisible() const { | 635 bool BrowserViewLayout::InfobarVisible() const { |
634 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. | 636 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. |
635 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && | 637 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && |
636 (infobar_container_->GetPreferredSize().height() != 0); | 638 (infobar_container_->GetPreferredSize().height() != 0); |
637 } | 639 } |
OLD | NEW |