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/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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 namespace { | 25 namespace { |
26 | 26 |
27 // The visible height of the shadow above the tabs. Clicks in this area are | 27 // 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. | 28 // treated as clicks to the frame, rather than clicks to the tab. |
29 const int kTabShadowSize = 2; | 29 const int kTabShadowSize = 2; |
30 // The vertical overlap between the TabStrip and the Toolbar. | 30 // The vertical overlap between the TabStrip and the Toolbar. |
31 const int kToolbarTabStripVerticalOverlap = 3; | 31 const int kToolbarTabStripVerticalOverlap = 3; |
32 // The number of pixels the bookmark bar should overlap the spacer by if the | 32 // The number of pixels the bookmark bar should overlap the spacer by if the |
33 // spacer is visible. | 33 // spacer is visible. |
34 const int kSpacerBookmarkBarOverlap = 1; | 34 const int kSpacerBookmarkBarOverlap = 1; |
| 35 // The number of pixels the metro switcher is offset from the right edge. |
| 36 const int kWindowSwitcherOffsetX = 5; |
35 | 37 |
36 // Combines View::ConvertPointToView and View::HitTest for a given |point|. | 38 // Combines View::ConvertPointToView and View::HitTest for a given |point|. |
37 // Converts |point| from |src| to |dst| and hit tests it against |dst|. The | 39 // Converts |point| from |src| to |dst| and hit tests it against |dst|. The |
38 // converted |point| can then be retrieved and used for additional tests. | 40 // converted |point| can then be retrieved and used for additional tests. |
39 bool ConvertedHitTest(views::View* src, views::View* dst, gfx::Point* point) { | 41 bool ConvertedHitTest(views::View* src, views::View* dst, gfx::Point* point) { |
40 DCHECK(src); | 42 DCHECK(src); |
41 DCHECK(dst); | 43 DCHECK(dst); |
42 DCHECK(point); | 44 DCHECK(point); |
43 views::View::ConvertPointToView(src, dst, point); | 45 views::View::ConvertPointToView(src, dst, point); |
44 return dst->HitTest(*point); | 46 return dst->HitTest(*point); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 const Browser* BrowserViewLayout::browser() const { | 292 const Browser* BrowserViewLayout::browser() const { |
291 return browser_view_->browser(); | 293 return browser_view_->browser(); |
292 } | 294 } |
293 | 295 |
294 int BrowserViewLayout::LayoutTabStripRegion() { | 296 int BrowserViewLayout::LayoutTabStripRegion() { |
295 if (!browser_view_->IsTabStripVisible()) { | 297 if (!browser_view_->IsTabStripVisible()) { |
296 tabstrip_->SetVisible(false); | 298 tabstrip_->SetVisible(false); |
297 tabstrip_->SetBounds(0, 0, 0, 0); | 299 tabstrip_->SetBounds(0, 0, 0, 0); |
298 return 0; | 300 return 0; |
299 } | 301 } |
300 | |
301 // This retrieves the bounds for the tab strip based on whether or not we show | 302 // This retrieves the bounds for the tab strip based on whether or not we show |
302 // anything to the left of it, like the incognito avatar. | 303 // anything to the left of it, like the incognito avatar. |
303 gfx::Rect tabstrip_bounds( | 304 gfx::Rect tabstrip_bounds( |
304 browser_view_->frame()->GetBoundsForTabStrip(tabstrip_)); | 305 browser_view_->frame()->GetBoundsForTabStrip(tabstrip_)); |
305 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); | 306 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); |
306 views::View::ConvertPointToView(browser_view_->parent(), browser_view_, | 307 views::View::ConvertPointToView(browser_view_->parent(), browser_view_, |
307 &tabstrip_origin); | 308 &tabstrip_origin); |
308 tabstrip_bounds.set_origin(tabstrip_origin); | 309 tabstrip_bounds.set_origin(tabstrip_origin); |
309 | 310 |
310 tabstrip_->SetVisible(true); | 311 tabstrip_->SetVisible(true); |
311 tabstrip_->SetBoundsRect(tabstrip_bounds); | 312 tabstrip_->SetBoundsRect(tabstrip_bounds); |
312 return tabstrip_bounds.bottom(); | 313 int bottom = tabstrip_bounds.bottom(); |
| 314 |
| 315 // The metro window switcher sits at the far right edge of the tabstrip |
| 316 // a |kWindowSwitcherOffsetY| pixels above the base of the tabstrip. |
| 317 views::Button* switcher_button = browser_view_->window_switcher_button_; |
| 318 if (switcher_button) { |
| 319 int width = browser_view_->width(); |
| 320 gfx::Size ps = switcher_button->GetPreferredSize(); |
| 321 if (width > ps.width()) { |
| 322 switcher_button->SetBounds(width - ps.width() - kWindowSwitcherOffsetX, 0, |
| 323 ps.width(), ps.height()); |
| 324 } |
| 325 } |
| 326 |
| 327 return bottom; |
313 } | 328 } |
314 | 329 |
315 int BrowserViewLayout::LayoutToolbar(int top) { | 330 int BrowserViewLayout::LayoutToolbar(int top) { |
316 int browser_view_width = vertical_layout_rect_.width(); | 331 int browser_view_width = vertical_layout_rect_.width(); |
317 bool toolbar_visible = browser_view_->IsToolbarVisible(); | 332 bool toolbar_visible = browser_view_->IsToolbarVisible(); |
318 toolbar_->location_bar()->SetLocationEntryFocusable(toolbar_visible); | 333 toolbar_->location_bar()->SetLocationEntryFocusable(toolbar_visible); |
319 int y = top; | 334 int y = top; |
320 y -= (toolbar_visible && browser_view_->IsTabStripVisible()) ? | 335 y -= (toolbar_visible && browser_view_->IsTabStripVisible()) ? |
321 kToolbarTabStripVerticalOverlap : 0; | 336 kToolbarTabStripVerticalOverlap : 0; |
322 int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; | 337 int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 bottom -= height; | 459 bottom -= height; |
445 } | 460 } |
446 return bottom; | 461 return bottom; |
447 } | 462 } |
448 | 463 |
449 bool BrowserViewLayout::InfobarVisible() const { | 464 bool BrowserViewLayout::InfobarVisible() const { |
450 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. | 465 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. |
451 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && | 466 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && |
452 (infobar_container_->GetPreferredSize().height() != 0); | 467 (infobar_container_->GetPreferredSize().height() != 0); |
453 } | 468 } |
OLD | NEW |