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 "views/window/custom_frame_view.h" | 5 #include "views/window/custom_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 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include "app/win_util.h" | 10 #include "app/win_util.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 return kTitlebarTopAndBottomEdgeThickness + | 273 return kTitlebarTopAndBottomEdgeThickness + |
274 (ShouldShowClientEdge() ? kClientEdgeThickness : 0); | 274 (ShouldShowClientEdge() ? kClientEdgeThickness : 0); |
275 } | 275 } |
276 | 276 |
277 int CustomFrameView::IconSize() const { | 277 int CustomFrameView::IconSize() const { |
278 #if defined(OS_WIN) | 278 #if defined(OS_WIN) |
279 // This metric scales up if either the titlebar height or the titlebar font | 279 // This metric scales up if either the titlebar height or the titlebar font |
280 // size are increased. | 280 // size are increased. |
281 return GetSystemMetrics(SM_CYSMICON); | 281 return GetSystemMetrics(SM_CYSMICON); |
282 #else | 282 #else |
283 return std::max(title_font_->height(), kIconMinimumSize); | 283 return std::max(title_font_->GetHeight(), kIconMinimumSize); |
284 #endif | 284 #endif |
285 } | 285 } |
286 | 286 |
287 bool CustomFrameView::ShouldShowClientEdge() const { | 287 bool CustomFrameView::ShouldShowClientEdge() const { |
288 return should_show_client_edge_ && !frame_->IsMaximized(); | 288 return should_show_client_edge_ && !frame_->IsMaximized(); |
289 } | 289 } |
290 | 290 |
291 gfx::Rect CustomFrameView::IconBounds() const { | 291 gfx::Rect CustomFrameView::IconBounds() const { |
292 int size = IconSize(); | 292 int size = IconSize(); |
293 int frame_thickness = FrameBorderThickness(); | 293 int frame_thickness = FrameBorderThickness(); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 // The window title is based on the calculated icon position, even when there | 534 // The window title is based on the calculated icon position, even when there |
535 // is no icon. | 535 // is no icon. |
536 gfx::Rect icon_bounds(IconBounds()); | 536 gfx::Rect icon_bounds(IconBounds()); |
537 views::WindowDelegate* d = frame_->GetDelegate(); | 537 views::WindowDelegate* d = frame_->GetDelegate(); |
538 if (d->ShouldShowWindowIcon()) | 538 if (d->ShouldShowWindowIcon()) |
539 window_icon_->SetBounds(icon_bounds); | 539 window_icon_->SetBounds(icon_bounds); |
540 | 540 |
541 // Size the title. | 541 // Size the title. |
542 int title_x = d->ShouldShowWindowIcon() ? | 542 int title_x = d->ShouldShowWindowIcon() ? |
543 icon_bounds.right() + kIconTitleSpacing : icon_bounds.x(); | 543 icon_bounds.right() + kIconTitleSpacing : icon_bounds.x(); |
544 int title_height = title_font_->height(); | 544 int title_height = title_font_->GetHeight(); |
545 // We bias the title position so that when the difference between the icon and | 545 // We bias the title position so that when the difference between the icon and |
546 // title heights is odd, the extra pixel of the title is above the vertical | 546 // title heights is odd, the extra pixel of the title is above the vertical |
547 // midline rather than below. This compensates for how the icon is already | 547 // midline rather than below. This compensates for how the icon is already |
548 // biased downwards (see IconBounds()) and helps prevent descenders on the | 548 // biased downwards (see IconBounds()) and helps prevent descenders on the |
549 // title from overlapping the 3D edge at the bottom of the titlebar. | 549 // title from overlapping the 3D edge at the bottom of the titlebar. |
550 title_bounds_.SetRect(title_x, | 550 title_bounds_.SetRect(title_x, |
551 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), | 551 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), |
552 std::max(0, (should_show_minmax_buttons_ ? | 552 std::max(0, (should_show_minmax_buttons_ ? |
553 minimize_button_->x() : close_button_->x()) - kTitleCaptionSpacing - | 553 minimize_button_->x() : close_button_->x()) - kTitleCaptionSpacing - |
554 title_x), title_height); | 554 title_x), title_height); |
(...skipping 15 matching lines...) Expand all Loading... |
570 title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); | 570 title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); |
571 #elif defined(OS_LINUX) | 571 #elif defined(OS_LINUX) |
572 // TODO(ben): need to resolve what font this is. | 572 // TODO(ben): need to resolve what font this is. |
573 title_font_ = new gfx::Font(); | 573 title_font_ = new gfx::Font(); |
574 #endif | 574 #endif |
575 initialized = true; | 575 initialized = true; |
576 } | 576 } |
577 } | 577 } |
578 | 578 |
579 } // namespace views | 579 } // namespace views |
OLD | NEW |