OLD | NEW |
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/browser_finder.h" | 7 #include "chrome/browser/ui/browser_finder.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 17 matching lines...) Expand all Loading... |
28 // The visible height of the shadow above the tabs. Clicks in this area are | 28 // The visible height of the shadow above the tabs. Clicks in this area are |
29 // treated as clicks to the frame, rather than clicks to the tab. | 29 // treated as clicks to the frame, rather than clicks to the tab. |
30 const int kTabShadowSize = 2; | 30 const int kTabShadowSize = 2; |
31 // The vertical overlap between the TabStrip and the Toolbar. | 31 // The vertical overlap between the TabStrip and the Toolbar. |
32 const int kToolbarTabStripVerticalOverlap = 3; | 32 const int kToolbarTabStripVerticalOverlap = 3; |
33 // The number of pixels the bookmark bar should overlap the spacer by if the | 33 // The number of pixels the bookmark bar should overlap the spacer by if the |
34 // spacer is visible. | 34 // spacer is visible. |
35 const int kSpacerBookmarkBarOverlap = 1; | 35 const int kSpacerBookmarkBarOverlap = 1; |
36 // The number of pixels the metro switcher is offset from the right edge. | 36 // The number of pixels the metro switcher is offset from the right edge. |
37 const int kWindowSwitcherOffsetX = 7; | 37 const int kWindowSwitcherOffsetX = 7; |
| 38 // The number of pixels the constrained window should overlap the bottom |
| 39 // of the omnibox. |
| 40 const int kConstrainedWindowOverlap = 3; |
38 | 41 |
39 // Combines View::ConvertPointToTarget and View::HitTest for a given |point|. | 42 // Combines View::ConvertPointToTarget and View::HitTest for a given |point|. |
40 // Converts |point| from |src| to |dst| and hit tests it against |dst|. The | 43 // Converts |point| from |src| to |dst| and hit tests it against |dst|. The |
41 // converted |point| can then be retrieved and used for additional tests. | 44 // converted |point| can then be retrieved and used for additional tests. |
42 bool ConvertedHitTest(views::View* src, views::View* dst, gfx::Point* point) { | 45 bool ConvertedHitTest(views::View* src, views::View* dst, gfx::Point* point) { |
43 DCHECK(src); | 46 DCHECK(src); |
44 DCHECK(dst); | 47 DCHECK(dst); |
45 DCHECK(point); | 48 DCHECK(point); |
46 views::View::ConvertPointToTarget(src, dst, point); | 49 views::View::ConvertPointToTarget(src, dst, point); |
47 return dst->HitTestPoint(*point); | 50 return dst->HitTestPoint(*point); |
(...skipping 12 matching lines...) Expand all Loading... |
60 infobar_container_(NULL), | 63 infobar_container_(NULL), |
61 download_shelf_(NULL), | 64 download_shelf_(NULL), |
62 active_bookmark_bar_(NULL), | 65 active_bookmark_bar_(NULL), |
63 browser_view_(NULL), | 66 browser_view_(NULL), |
64 find_bar_y_(0) { | 67 find_bar_y_(0) { |
65 } | 68 } |
66 | 69 |
67 BrowserViewLayout::~BrowserViewLayout() { | 70 BrowserViewLayout::~BrowserViewLayout() { |
68 } | 71 } |
69 | 72 |
| 73 int BrowserViewLayout::GetConstrainedWindowTopY() { |
| 74 return constrained_window_top_y; |
| 75 } |
| 76 |
70 gfx::Size BrowserViewLayout::GetMinimumSize() { | 77 gfx::Size BrowserViewLayout::GetMinimumSize() { |
71 gfx::Size tabstrip_size( | 78 gfx::Size tabstrip_size( |
72 browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? | 79 browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? |
73 tabstrip_->GetMinimumSize() : gfx::Size()); | 80 tabstrip_->GetMinimumSize() : gfx::Size()); |
74 BrowserNonClientFrameView::TabStripInsets tab_strip_insets( | 81 BrowserNonClientFrameView::TabStripInsets tab_strip_insets( |
75 browser_view_->frame()->GetTabStripInsets(false)); | 82 browser_view_->frame()->GetTabStripInsets(false)); |
76 gfx::Size toolbar_size( | 83 gfx::Size toolbar_size( |
77 (browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || | 84 (browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || |
78 browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ? | 85 browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ? |
79 toolbar_->GetMinimumSize() : gfx::Size()); | 86 toolbar_->GetMinimumSize() : gfx::Size()); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 kToolbarTabStripVerticalOverlap : 0; | 368 kToolbarTabStripVerticalOverlap : 0; |
362 int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; | 369 int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; |
363 toolbar_->SetVisible(toolbar_visible); | 370 toolbar_->SetVisible(toolbar_visible); |
364 toolbar_->location_bar_container()->SetVisible(toolbar_visible); | 371 toolbar_->location_bar_container()->SetVisible(toolbar_visible); |
365 toolbar_->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height); | 372 toolbar_->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height); |
366 | 373 |
367 return y + height; | 374 return y + height; |
368 } | 375 } |
369 | 376 |
370 int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top) { | 377 int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top) { |
| 378 constrained_window_top_y = |
| 379 top + browser_view_->y() - kConstrainedWindowOverlap; |
371 find_bar_y_ = top + browser_view_->y() - 1; | 380 find_bar_y_ = top + browser_view_->y() - 1; |
372 if (active_bookmark_bar_) { | 381 if (active_bookmark_bar_) { |
373 // If we're showing the Bookmark bar in detached style, then we | 382 // If we're showing the Bookmark bar in detached style, then we |
374 // need to show any Info bar _above_ the Bookmark bar, since the | 383 // need to show any Info bar _above_ the Bookmark bar, since the |
375 // Bookmark bar is styled to look like it's part of the page. | 384 // Bookmark bar is styled to look like it's part of the page. |
376 if (active_bookmark_bar_->IsDetached()) | 385 if (active_bookmark_bar_->IsDetached()) |
377 return LayoutBookmarkBar(LayoutInfoBar(top)); | 386 return LayoutBookmarkBar(LayoutInfoBar(top)); |
378 // Otherwise, Bookmark bar first, Info bar second. | 387 // Otherwise, Bookmark bar first, Info bar second. |
379 top = std::max(toolbar_->bounds().bottom(), LayoutBookmarkBar(top)); | 388 top = std::max(toolbar_->bounds().bottom(), LayoutBookmarkBar(top)); |
380 } | 389 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 bottom -= height; | 494 bottom -= height; |
486 } | 495 } |
487 return bottom; | 496 return bottom; |
488 } | 497 } |
489 | 498 |
490 bool BrowserViewLayout::InfobarVisible() const { | 499 bool BrowserViewLayout::InfobarVisible() const { |
491 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. | 500 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. |
492 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && | 501 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && |
493 (infobar_container_->GetPreferredSize().height() != 0); | 502 (infobar_container_->GetPreferredSize().height() != 0); |
494 } | 503 } |
OLD | NEW |