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 "ash/wm/frame_painter.h" | 5 #include "ash/wm/frame_painter.h" |
6 | 6 |
7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/property_util.h" | 10 #include "ash/wm/property_util.h" |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 int FramePainter::HeaderContentSeparatorSize() const { | 444 int FramePainter::HeaderContentSeparatorSize() const { |
445 return kHeaderContentSeparatorSize; | 445 return kHeaderContentSeparatorSize; |
446 } | 446 } |
447 | 447 |
448 void FramePainter::PaintTitleBar(views::NonClientFrameView* view, | 448 void FramePainter::PaintTitleBar(views::NonClientFrameView* view, |
449 gfx::Canvas* canvas, | 449 gfx::Canvas* canvas, |
450 const gfx::Font& title_font) { | 450 const gfx::Font& title_font) { |
451 // The window icon is painted by its own views::View. | 451 // The window icon is painted by its own views::View. |
452 views::WidgetDelegate* delegate = frame_->widget_delegate(); | 452 views::WidgetDelegate* delegate = frame_->widget_delegate(); |
453 if (delegate && delegate->ShouldShowWindowTitle()) { | 453 if (delegate && delegate->ShouldShowWindowTitle()) { |
454 int title_x = GetTitleOffsetX(); | 454 gfx::Rect title_bounds = GetTitleBounds(view, title_font); |
455 // Center the text in the middle of the caption - this way it adapts | |
456 // automatically to the caption height (which is given by the owner). | |
457 int title_y = | |
458 (view->GetBoundsForClientView().y() - title_font.GetHeight()) / 2; | |
459 gfx::Rect title_bounds( | |
460 title_x, | |
461 std::max(0, title_y), | |
462 std::max(0, size_button_->x() - kTitleLogoSpacing - title_x), | |
463 title_font.GetHeight()); | |
464 canvas->DrawStringInt(delegate->GetWindowTitle(), | 455 canvas->DrawStringInt(delegate->GetWindowTitle(), |
465 title_font, | 456 title_font, |
466 kTitleTextColor, | 457 kTitleTextColor, |
467 view->GetMirroredXForRect(title_bounds), | 458 view->GetMirroredXForRect(title_bounds), |
468 title_bounds.y(), | 459 title_bounds.y(), |
469 title_bounds.width(), | 460 title_bounds.width(), |
470 title_bounds.height(), | 461 title_bounds.height(), |
471 gfx::Canvas::NO_SUBPIXEL_RENDERING); | 462 gfx::Canvas::NO_SUBPIXEL_RENDERING); |
472 } | 463 } |
473 } | 464 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 close_button_->x() - size_button_size.width() + kButtonOverlap, | 517 close_button_->x() - size_button_size.width() + kButtonOverlap, |
527 close_button_->y(), | 518 close_button_->y(), |
528 size_button_size.width(), | 519 size_button_size.width(), |
529 size_button_size.height()); | 520 size_button_size.height()); |
530 | 521 |
531 if (window_icon_) | 522 if (window_icon_) |
532 window_icon_->SetBoundsRect( | 523 window_icon_->SetBoundsRect( |
533 gfx::Rect(kIconOffsetX, kIconOffsetY, kIconSize, kIconSize)); | 524 gfx::Rect(kIconOffsetX, kIconOffsetY, kIconSize, kIconSize)); |
534 } | 525 } |
535 | 526 |
| 527 void FramePainter::SchedulePaintForTitle(views::NonClientFrameView* view, |
| 528 const gfx::Font& title_font) { |
| 529 frame_->non_client_view()->SchedulePaintInRect( |
| 530 GetTitleBounds(view, title_font)); |
| 531 } |
| 532 |
536 /////////////////////////////////////////////////////////////////////////////// | 533 /////////////////////////////////////////////////////////////////////////////// |
537 // aura::WindowObserver overrides: | 534 // aura::WindowObserver overrides: |
538 | 535 |
539 void FramePainter::OnWindowPropertyChanged(aura::Window* window, | 536 void FramePainter::OnWindowPropertyChanged(aura::Window* window, |
540 const void* key, | 537 const void* key, |
541 intptr_t old) { | 538 intptr_t old) { |
542 if (key == internal::kWindowTrackedByWorkspaceKey && | 539 if (key == internal::kWindowTrackedByWorkspaceKey && |
543 GetTrackedByWorkspace(window)) { | 540 GetTrackedByWorkspace(window)) { |
544 // When 'kWindowTrackedByWorkspaceKey' changes we're going to paint the | 541 // When 'kWindowTrackedByWorkspaceKey' changes we're going to paint the |
545 // header differently. Schedule a paint to ensure everything is updated | 542 // header differently. Schedule a paint to ensure everything is updated |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 } | 726 } |
730 | 727 |
731 void FramePainter::SchedulePaintForHeader() { | 728 void FramePainter::SchedulePaintForHeader() { |
732 int top_left_height = top_left_corner_->height(); | 729 int top_left_height = top_left_corner_->height(); |
733 int top_right_height = top_right_corner_->height(); | 730 int top_right_height = top_right_corner_->height(); |
734 frame_->non_client_view()->SchedulePaintInRect( | 731 frame_->non_client_view()->SchedulePaintInRect( |
735 gfx::Rect(0, 0, frame_->non_client_view()->width(), | 732 gfx::Rect(0, 0, frame_->non_client_view()->width(), |
736 std::max(top_left_height, top_right_height))); | 733 std::max(top_left_height, top_right_height))); |
737 } | 734 } |
738 | 735 |
| 736 gfx::Rect FramePainter::GetTitleBounds(views::NonClientFrameView* view, |
| 737 const gfx::Font& title_font) { |
| 738 int title_x = GetTitleOffsetX(); |
| 739 // Center the text in the middle of the caption - this way it adapts |
| 740 // automatically to the caption height (which is given by the owner). |
| 741 int title_y = |
| 742 (view->GetBoundsForClientView().y() - title_font.GetHeight()) / 2; |
| 743 return gfx::Rect( |
| 744 title_x, |
| 745 std::max(0, title_y), |
| 746 std::max(0, size_button_->x() - kTitleLogoSpacing - title_x), |
| 747 title_font.GetHeight()); |
| 748 } |
| 749 |
739 } // namespace ash | 750 } // namespace ash |
OLD | NEW |