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

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

Issue 6913026: Compact Navigation prototype (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Clang build fix. After commit/revert. Created 9 years, 7 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) 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/opaque_browser_frame_view.h" 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Inset from the top of the toolbar/tabstrip to the shadow. Used only for 99 // Inset from the top of the toolbar/tabstrip to the shadow. Used only for
100 // vertical tabs. 100 // vertical tabs.
101 const int kVerticalTabBorderInset = 3; 101 const int kVerticalTabBorderInset = 3;
102 // Menu should display below the profile button tag image on the frame. This 102 // Menu should display below the profile button tag image on the frame. This
103 // offset size depends on whether the frame is in glass or opaque mode. 103 // offset size depends on whether the frame is in glass or opaque mode.
104 const int kMenuDisplayOffset = 7; 104 const int kMenuDisplayOffset = 7;
105 // Y position for profile tag inside the frame. 105 // Y position for profile tag inside the frame.
106 const int kProfileTagYPosition = 1; 106 const int kProfileTagYPosition = 1;
107 // Offset y position of profile button and tag by this amount when maximized. 107 // Offset y position of profile button and tag by this amount when maximized.
108 const int kProfileElementMaximizedYOffset = 6; 108 const int kProfileElementMaximizedYOffset = 6;
109
110 // Converts |bounds| from |src|'s coordinate system to |dst|, and checks if
111 // |pt| is contained within.
112 bool ConvertedContainsCheck(gfx::Rect bounds, const views::View* src,
113 const views::View* dst, const gfx::Point& pt) {
114 DCHECK(src);
115 DCHECK(dst);
116 gfx::Point origin(bounds.origin());
117 views::View::ConvertPointToView(src, dst, &origin);
118 bounds.set_origin(origin);
119 return bounds.Contains(pt);
120 }
121
109 } 122 }
110 123
111 /////////////////////////////////////////////////////////////////////////////// 124 ///////////////////////////////////////////////////////////////////////////////
112 // OpaqueBrowserFrameView, public: 125 // OpaqueBrowserFrameView, public:
113 126
114 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, 127 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
115 BrowserView* browser_view) 128 BrowserView* browser_view)
116 : BrowserNonClientFrameView(), 129 : BrowserNonClientFrameView(),
117 ALLOW_THIS_IN_INITIALIZER_LIST( 130 ALLOW_THIS_IN_INITIALIZER_LIST(
118 minimize_button_(new views::ImageButton(this))), 131 minimize_button_(new views::ImageButton(this))),
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { 449 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
437 views::Window* window = frame_->GetWindow(); 450 views::Window* window = frame_->GetWindow();
438 if (window->IsFullscreen()) 451 if (window->IsFullscreen())
439 return; // Nothing is visible, so don't bother to paint. 452 return; // Nothing is visible, so don't bother to paint.
440 453
441 if (window->IsMaximized()) 454 if (window->IsMaximized())
442 PaintMaximizedFrameBorder(canvas); 455 PaintMaximizedFrameBorder(canvas);
443 else 456 else
444 PaintRestoredFrameBorder(canvas); 457 PaintRestoredFrameBorder(canvas);
445 PaintTitleBar(canvas); 458 PaintTitleBar(canvas);
446 if (browser_view_->IsToolbarVisible()) 459 if (browser_view_->IsToolbarVisible() ||
460 browser_view_->UseCompactNavigationBar())
447 PaintToolbarBackground(canvas); 461 PaintToolbarBackground(canvas);
448 if (browser_view_->ShouldShowOffTheRecordAvatar()) 462 if (browser_view_->ShouldShowOffTheRecordAvatar())
449 PaintOTRAvatar(canvas); 463 PaintOTRAvatar(canvas);
450 if (!window->IsMaximized()) 464 if (!window->IsMaximized())
451 PaintRestoredClientEdge(canvas); 465 PaintRestoredClientEdge(canvas);
452 } 466 }
453 467
454 void OpaqueBrowserFrameView::Layout() { 468 void OpaqueBrowserFrameView::Layout() {
455 LayoutWindowControls(); 469 LayoutWindowControls();
456 LayoutTitleBar(); 470 LayoutTitleBar();
(...skipping 13 matching lines...) Expand all
470 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view_->tabstrip()); 484 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view_->tabstrip());
471 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); 485 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
472 View::ConvertPointToView(frame_->GetWindow()->client_view(), 486 View::ConvertPointToView(frame_->GetWindow()->client_view(),
473 this, &tabstrip_origin); 487 this, &tabstrip_origin);
474 tabstrip_bounds.set_origin(tabstrip_origin); 488 tabstrip_bounds.set_origin(tabstrip_origin);
475 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) || 489 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) ||
476 (vertical_tabs && l.x() > tabstrip_bounds.right())) { 490 (vertical_tabs && l.x() > tabstrip_bounds.right())) {
477 return false; 491 return false;
478 } 492 }
479 493
494 // Claim it only if we're also not in the compact navigation buttons.
495 if (browser_view_->UseCompactNavigationBar()) {
496 if (ConvertedContainsCheck(browser_view_->GetCompactNavigationBarBounds(),
497 frame_->GetWindow()->client_view(),
498 static_cast<const View*>(this),
499 l)) {
500 return false;
501 }
502 if (ConvertedContainsCheck(browser_view_->GetCompactOptionsBarBounds(),
503 frame_->GetWindow()->client_view(),
504 static_cast<const View*>(this),
505 l)) {
506 return false;
507 }
508 }
509
480 // We convert from our parent's coordinates since we assume we fill its bounds 510 // We convert from our parent's coordinates since we assume we fill its bounds
481 // completely. We need to do this since we're not a parent of the tabstrip, 511 // completely. We need to do this since we're not a parent of the tabstrip,
482 // meaning ConvertPointToView would otherwise return something bogus. 512 // meaning ConvertPointToView would otherwise return something bogus.
483 gfx::Point browser_view_point(l); 513 gfx::Point browser_view_point(l);
484 View::ConvertPointToView(parent(), browser_view_, &browser_view_point); 514 View::ConvertPointToView(parent(), browser_view_, &browser_view_point);
485 return browser_view_->IsPositionInWindowCaption(browser_view_point); 515 return browser_view_->IsPositionInWindowCaption(browser_view_point);
486 } 516 }
487 517
488 void OpaqueBrowserFrameView::GetAccessibleState( 518 void OpaqueBrowserFrameView::GetAccessibleState(
489 ui::AccessibleViewState* state) { 519 ui::AccessibleViewState* state) {
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 } 985 }
956 986
957 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { 987 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
958 ui::ThemeProvider* tp = GetThemeProvider(); 988 ui::ThemeProvider* tp = GetThemeProvider();
959 int client_area_top = frame_->GetWindow()->client_view()->y(); 989 int client_area_top = frame_->GetWindow()->client_view()->y();
960 int image_top = client_area_top; 990 int image_top = client_area_top;
961 991
962 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); 992 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
963 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); 993 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR);
964 994
965 if (browser_view_->IsToolbarVisible()) { 995 if (browser_view_->IsToolbarVisible() ||
996 browser_view_->UseCompactNavigationBar()) {
966 // The client edge images always start below the toolbar corner images. The 997 // The client edge images always start below the toolbar corner images. The
967 // client edge filled rects start there or at the bottom of the tooolbar, 998 // client edge filled rects start there or at the bottom of the toolbar,
968 // whichever is shorter. 999 // whichever is shorter.
969 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); 1000 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
970 image_top += toolbar_bounds.y() + 1001 image_top += toolbar_bounds.y() +
971 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); 1002 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height();
972 client_area_top = std::min(image_top, 1003 client_area_top = std::min(image_top,
973 client_area_top + toolbar_bounds.bottom() - kClientEdgeThickness); 1004 client_area_top + toolbar_bounds.bottom() - kClientEdgeThickness);
974 if (browser_view_->UseVerticalTabs()) { 1005 if (browser_view_->UseVerticalTabs()) {
975 client_area_top -= kVerticalTabBorderInset; 1006 client_area_top -= kVerticalTabBorderInset;
976 image_top -= kVerticalTabBorderInset; 1007 image_top -= kVerticalTabBorderInset;
977 } 1008 }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 std::max(0, width - (2 * border_thickness)), 1244 std::max(0, width - (2 * border_thickness)),
1214 std::max(0, height - GetReservedHeight() - 1245 std::max(0, height - GetReservedHeight() -
1215 top_height - border_thickness)); 1246 top_height - border_thickness));
1216 } 1247 }
1217 1248
1218 void OpaqueBrowserFrameView::RegisterLoginNotifications() { 1249 void OpaqueBrowserFrameView::RegisterLoginNotifications() {
1219 PrefService* pref_service = browser_view_->browser()->profile()->GetPrefs(); 1250 PrefService* pref_service = browser_view_->browser()->profile()->GetPrefs();
1220 DCHECK(pref_service); 1251 DCHECK(pref_service);
1221 username_pref_.Init(prefs::kGoogleServicesUsername, pref_service, this); 1252 username_pref_.Init(prefs::kGoogleServicesUsername, pref_service, this);
1222 } 1253 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view_layout.cc ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698