| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/frame/opaque_browser_frame_view.h" | 5 #include "chrome/browser/views/frame/opaque_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "app/theme_provider.h" | 9 #include "app/theme_provider.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 return kTitlebarTopAndBottomEdgeThickness + | 501 return kTitlebarTopAndBottomEdgeThickness + |
| 502 (frame_->GetWindow()->IsMaximized() ? 0 : kClientEdgeThickness); | 502 (frame_->GetWindow()->IsMaximized() ? 0 : kClientEdgeThickness); |
| 503 } | 503 } |
| 504 | 504 |
| 505 int OpaqueBrowserFrameView::IconSize() const { | 505 int OpaqueBrowserFrameView::IconSize() const { |
| 506 #if defined(OS_WIN) | 506 #if defined(OS_WIN) |
| 507 // This metric scales up if either the titlebar height or the titlebar font | 507 // This metric scales up if either the titlebar height or the titlebar font |
| 508 // size are increased. | 508 // size are increased. |
| 509 return GetSystemMetrics(SM_CYSMICON); | 509 return GetSystemMetrics(SM_CYSMICON); |
| 510 #else | 510 #else |
| 511 return std::max(BrowserFrame::GetTitleFont().height(), kIconMinimumSize); | 511 return std::max(BrowserFrame::GetTitleFont().GetHeight(), kIconMinimumSize); |
| 512 #endif | 512 #endif |
| 513 } | 513 } |
| 514 | 514 |
| 515 gfx::Rect OpaqueBrowserFrameView::IconBounds() const { | 515 gfx::Rect OpaqueBrowserFrameView::IconBounds() const { |
| 516 int size = IconSize(); | 516 int size = IconSize(); |
| 517 int frame_thickness = FrameBorderThickness(); | 517 int frame_thickness = FrameBorderThickness(); |
| 518 int y; | 518 int y; |
| 519 views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); | 519 views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); |
| 520 if (d->ShouldShowWindowIcon() || d->ShouldShowWindowTitle()) { | 520 if (d->ShouldShowWindowIcon() || d->ShouldShowWindowTitle()) { |
| 521 // Our frame border has a different "3D look" than Windows'. Theirs has a | 521 // Our frame border has a different "3D look" than Windows'. Theirs has a |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 // is no icon. | 1010 // is no icon. |
| 1011 gfx::Rect icon_bounds(IconBounds()); | 1011 gfx::Rect icon_bounds(IconBounds()); |
| 1012 views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); | 1012 views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); |
| 1013 if (d->ShouldShowWindowIcon()) | 1013 if (d->ShouldShowWindowIcon()) |
| 1014 window_icon_->SetBounds(icon_bounds); | 1014 window_icon_->SetBounds(icon_bounds); |
| 1015 | 1015 |
| 1016 // Size the title, if visible. | 1016 // Size the title, if visible. |
| 1017 if (d->ShouldShowWindowTitle()) { | 1017 if (d->ShouldShowWindowTitle()) { |
| 1018 int title_x = d->ShouldShowWindowIcon() ? | 1018 int title_x = d->ShouldShowWindowIcon() ? |
| 1019 icon_bounds.right() + kIconTitleSpacing : icon_bounds.x(); | 1019 icon_bounds.right() + kIconTitleSpacing : icon_bounds.x(); |
| 1020 int title_height = BrowserFrame::GetTitleFont().height(); | 1020 int title_height = BrowserFrame::GetTitleFont().GetHeight(); |
| 1021 // We bias the title position so that when the difference between the icon | 1021 // We bias the title position so that when the difference between the icon |
| 1022 // and title heights is odd, the extra pixel of the title is above the | 1022 // and title heights is odd, the extra pixel of the title is above the |
| 1023 // vertical midline rather than below. This compensates for how the icon is | 1023 // vertical midline rather than below. This compensates for how the icon is |
| 1024 // already biased downwards (see IconBounds()) and helps prevent descenders | 1024 // already biased downwards (see IconBounds()) and helps prevent descenders |
| 1025 // on the title from overlapping the 3D edge at the bottom of the titlebar. | 1025 // on the title from overlapping the 3D edge at the bottom of the titlebar. |
| 1026 title_bounds_.SetRect(title_x, | 1026 title_bounds_.SetRect(title_x, |
| 1027 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), | 1027 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), |
| 1028 std::max(0, minimize_button_->x() - kTitleLogoSpacing - title_x), | 1028 std::max(0, minimize_button_->x() - kTitleLogoSpacing - title_x), |
| 1029 title_height); | 1029 title_height); |
| 1030 } | 1030 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 // static | 1071 // static |
| 1072 gfx::Rect OpaqueBrowserFrameView::GetViewBounds(views::View* src, | 1072 gfx::Rect OpaqueBrowserFrameView::GetViewBounds(views::View* src, |
| 1073 views::View* dst) { | 1073 views::View* dst) { |
| 1074 gfx::Rect bounds(src->bounds()); | 1074 gfx::Rect bounds(src->bounds()); |
| 1075 | 1075 |
| 1076 gfx::Point origin_in_dst(bounds.origin()); | 1076 gfx::Point origin_in_dst(bounds.origin()); |
| 1077 View::ConvertPointToView(src->GetParent(), dst, &origin_in_dst); | 1077 View::ConvertPointToView(src->GetParent(), dst, &origin_in_dst); |
| 1078 bounds.set_origin(origin_in_dst); | 1078 bounds.set_origin(origin_in_dst); |
| 1079 return bounds; | 1079 return bounds; |
| 1080 } | 1080 } |
| OLD | NEW |