| 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/glass_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 11 #include "chrome/app/chrome_dll_resource.h" | 11 #include "chrome/app/chrome_dll_resource.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" |
| 14 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 15 #include "chrome/browser/ui/views/layout_constants.h" |
| 15 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 16 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 16 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" | 17 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" |
| 17 #include "chrome/browser/ui/views/tabs/tab.h" | 18 #include "chrome/browser/ui/views/tabs/tab.h" |
| 18 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 19 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 19 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 20 #include "components/signin/core/browser/signin_header_helper.h" | 21 #include "components/signin/core/browser/signin_header_helper.h" |
| 21 #include "components/signin/core/common/profile_management_switches.h" | 22 #include "components/signin/core/common/profile_management_switches.h" |
| 22 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
| 23 #include "skia/ext/image_operations.h" | 24 #include "skia/ext/image_operations.h" |
| 24 #include "ui/base/resource/material_design/material_design_controller.h" | 25 #include "ui/base/resource/material_design/material_design_controller.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 53 // user). | 54 // user). |
| 54 const int kAvatarBottomSpacing = 2; | 55 const int kAvatarBottomSpacing = 2; |
| 55 // Space between the frame border and the left edge of the avatar. | 56 // Space between the frame border and the left edge of the avatar. |
| 56 const int kAvatarLeftSpacing = 2; | 57 const int kAvatarLeftSpacing = 2; |
| 57 // Space between the right edge of the avatar and the tabstrip. | 58 // Space between the right edge of the avatar and the tabstrip. |
| 58 const int kAvatarRightSpacing = -2; | 59 const int kAvatarRightSpacing = -2; |
| 59 // How far the new avatar button is from the left of the minimize button. | 60 // How far the new avatar button is from the left of the minimize button. |
| 60 const int kNewAvatarButtonOffset = 5; | 61 const int kNewAvatarButtonOffset = 5; |
| 61 // The content left/right images have a shadow built into them. | 62 // The content left/right images have a shadow built into them. |
| 62 const int kContentEdgeShadowThickness = 2; | 63 const int kContentEdgeShadowThickness = 2; |
| 63 // The top 3 px of the tabstrip is shadow; in maximized mode we push this off | |
| 64 // the top of the screen so the tabs appear flush against the screen edge. | |
| 65 const int kTabstripTopShadowThickness = 3; | |
| 66 // In restored mode, the New Tab button isn't at the same height as the caption | 64 // In restored mode, the New Tab button isn't at the same height as the caption |
| 67 // buttons, but the space will look cluttered if it actually slides under them, | 65 // buttons, but the space will look cluttered if it actually slides under them, |
| 68 // so we stop it when the gap between the two is down to 5 px. | 66 // so we stop it when the gap between the two is down to 5 px. |
| 69 const int kNewTabCaptionRestoredSpacing = 5; | 67 const int kNewTabCaptionRestoredSpacing = 5; |
| 70 // In maximized mode, where the New Tab button and the caption buttons are at | 68 // In maximized mode, where the New Tab button and the caption buttons are at |
| 71 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid | 69 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid |
| 72 // looking too cluttered. | 70 // looking too cluttered. |
| 73 const int kNewTabCaptionMaximizedSpacing = 16; | 71 const int kNewTabCaptionMaximizedSpacing = 16; |
| 74 // How far to indent the tabstrip from the left side of the screen when there | 72 // How far to indent the tabstrip from the left side of the screen when there |
| 75 // is no avatar icon. | 73 // is no avatar icon. |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 338 |
| 341 int GlassBrowserFrameView::NonClientTopBorderHeight() const { | 339 int GlassBrowserFrameView::NonClientTopBorderHeight() const { |
| 342 if (frame()->IsFullscreen()) | 340 if (frame()->IsFullscreen()) |
| 343 return 0; | 341 return 0; |
| 344 | 342 |
| 345 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass | 343 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass |
| 346 // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border | 344 // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border |
| 347 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). | 345 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). |
| 348 return gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME) + | 346 return gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME) + |
| 349 (!frame()->ShouldLeaveOffsetNearTopBorder() ? | 347 (!frame()->ShouldLeaveOffsetNearTopBorder() ? |
| 350 -kTabstripTopShadowThickness : kNonClientRestoredExtraThickness); | 348 -GetLayoutConstant(TABSTRIP_TOP_SHADOW_HEIGHT) : |
| 349 kNonClientRestoredExtraThickness); |
| 351 } | 350 } |
| 352 | 351 |
| 353 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { | 352 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { |
| 354 ui::ThemeProvider* tp = GetThemeProvider(); | 353 ui::ThemeProvider* tp = GetThemeProvider(); |
| 355 | 354 |
| 356 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 355 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
| 357 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 356 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
| 358 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); | 357 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); |
| 359 toolbar_bounds.set_origin(toolbar_origin); | 358 toolbar_bounds.set_origin(toolbar_origin); |
| 360 int x = toolbar_bounds.x(); | 359 int x = toolbar_bounds.x(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 | 495 |
| 497 int button_x = frame()->GetMinimizeButtonOffset() - | 496 int button_x = frame()->GetMinimizeButtonOffset() - |
| 498 kNewAvatarButtonOffset - label_size.width(); | 497 kNewAvatarButtonOffset - label_size.width(); |
| 499 if (base::i18n::IsRTL()) | 498 if (base::i18n::IsRTL()) |
| 500 button_x = width() - frame()->GetMinimizeButtonOffset() + | 499 button_x = width() - frame()->GetMinimizeButtonOffset() + |
| 501 kNewAvatarButtonOffset; | 500 kNewAvatarButtonOffset; |
| 502 | 501 |
| 503 // We need to offset the button correctly in maximized mode, so that the | 502 // We need to offset the button correctly in maximized mode, so that the |
| 504 // custom glass style aligns with the native control glass style. The | 503 // custom glass style aligns with the native control glass style. The |
| 505 // glass shadow is off by 1px, which was determined by visual inspection. | 504 // glass shadow is off by 1px, which was determined by visual inspection. |
| 506 int button_y = !frame()->IsMaximized() ? 1 : | 505 const int shadow_height = GetLayoutConstant(TABSTRIP_TOP_SHADOW_HEIGHT); |
| 507 NonClientTopBorderHeight() + kTabstripTopShadowThickness - 1; | 506 int button_y = frame()->IsMaximized() ? |
| 507 (NonClientTopBorderHeight() + shadow_height - 1) : 1; |
| 508 | 508 |
| 509 new_avatar_button()->SetBounds( | 509 new_avatar_button()->SetBounds( |
| 510 button_x, | 510 button_x, |
| 511 button_y, | 511 button_y, |
| 512 label_size.width(), | 512 label_size.width(), |
| 513 gfx::win::GetSystemMetricsInDIP(SM_CYMENUSIZE) + 1); | 513 gfx::win::GetSystemMetricsInDIP(SM_CYMENUSIZE) + 1); |
| 514 } | 514 } |
| 515 | 515 |
| 516 void GlassBrowserFrameView::LayoutAvatar() { | 516 void GlassBrowserFrameView::LayoutAvatar() { |
| 517 // Even though the avatar is used for both incognito and profiles we always | 517 // Even though the avatar is used for both incognito and profiles we always |
| 518 // use the incognito icon to layout the avatar button. The profile icon | 518 // use the incognito icon to layout the avatar button. The profile icon |
| 519 // can be customized so we can't depend on its size to perform layout. | 519 // can be customized so we can't depend on its size to perform layout. |
| 520 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); | 520 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); |
| 521 | 521 |
| 522 int avatar_x = NonClientBorderThickness() + kAvatarLeftSpacing; | 522 int avatar_x = NonClientBorderThickness() + kAvatarLeftSpacing; |
| 523 // Move this avatar icon by the size of window controls to prevent it from | 523 // Move this avatar icon by the size of window controls to prevent it from |
| 524 // being rendered over them in RTL languages. This code also needs to adjust | 524 // being rendered over them in RTL languages. This code also needs to adjust |
| 525 // the width of a tab strip to avoid decreasing this size twice. (See the | 525 // the width of a tab strip to avoid decreasing this size twice. (See the |
| 526 // comment in GetBoundsForTabStrip().) | 526 // comment in GetBoundsForTabStrip().) |
| 527 if (base::i18n::IsRTL()) | 527 if (base::i18n::IsRTL()) |
| 528 avatar_x += width() - frame()->GetMinimizeButtonOffset(); | 528 avatar_x += width() - frame()->GetMinimizeButtonOffset(); |
| 529 | 529 |
| 530 int avatar_bottom = GetTopInset() + | 530 int avatar_bottom = GetTopInset() + |
| 531 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; | 531 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; |
| 532 int avatar_restored_y = avatar_bottom - incognito_icon.height(); | 532 int avatar_restored_y = avatar_bottom - incognito_icon.height(); |
| 533 const int shadow_height = GetLayoutConstant(TABSTRIP_TOP_SHADOW_HEIGHT); |
| 533 int avatar_y = frame()->IsMaximized() ? | 534 int avatar_y = frame()->IsMaximized() ? |
| 534 (NonClientTopBorderHeight() + kTabstripTopShadowThickness) : | 535 (NonClientTopBorderHeight() + shadow_height) : avatar_restored_y; |
| 535 avatar_restored_y; | |
| 536 avatar_bounds_.SetRect(avatar_x, avatar_y, incognito_icon.width(), | 536 avatar_bounds_.SetRect(avatar_x, avatar_y, incognito_icon.width(), |
| 537 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); | 537 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); |
| 538 if (avatar_button()) | 538 if (avatar_button()) |
| 539 avatar_button()->SetBoundsRect(avatar_bounds_); | 539 avatar_button()->SetBoundsRect(avatar_bounds_); |
| 540 } | 540 } |
| 541 | 541 |
| 542 void GlassBrowserFrameView::LayoutClientView() { | 542 void GlassBrowserFrameView::LayoutClientView() { |
| 543 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); | 543 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); |
| 544 } | 544 } |
| 545 | 545 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 static bool initialized = false; | 634 static bool initialized = false; |
| 635 if (!initialized) { | 635 if (!initialized) { |
| 636 for (int i = 0; i < kThrobberIconCount; ++i) { | 636 for (int i = 0; i < kThrobberIconCount; ++i) { |
| 637 throbber_icons_[i] = | 637 throbber_icons_[i] = |
| 638 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 638 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
| 639 DCHECK(throbber_icons_[i]); | 639 DCHECK(throbber_icons_[i]); |
| 640 } | 640 } |
| 641 initialized = true; | 641 initialized = true; |
| 642 } | 642 } |
| 643 } | 643 } |
| OLD | NEW |