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

Side by Side Diff: ash/wm/frame_painter.cc

Issue 10993087: Handle titlebar text updates properly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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) 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 30 matching lines...) Expand all
41 // Space between top of window and popup window icon. 41 // Space between top of window and popup window icon.
42 const int kIconOffsetY = 9; 42 const int kIconOffsetY = 9;
43 // Height and width of window icon. 43 // Height and width of window icon.
44 const int kIconSize = 16; 44 const int kIconSize = 16;
45 // Space between the title text and the caption buttons. 45 // Space between the title text and the caption buttons.
46 const int kTitleLogoSpacing = 5; 46 const int kTitleLogoSpacing = 5;
47 // Space between window icon and title text. 47 // Space between window icon and title text.
48 const int kTitleIconOffsetX = 4; 48 const int kTitleIconOffsetX = 4;
49 // Space between window edge and title text, when there is no icon. 49 // Space between window edge and title text, when there is no icon.
50 const int kTitleNoIconOffsetX = 8; 50 const int kTitleNoIconOffsetX = 8;
51 // Space between title text and top of window.
52 const int kTitleOffsetY = 10;
53 // Color for the title text. 51 // Color for the title text.
54 const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40); 52 const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40);
55 // Size of header/content separator line below the header image. 53 // Size of header/content separator line below the header image.
56 const int kHeaderContentSeparatorSize = 1; 54 const int kHeaderContentSeparatorSize = 1;
57 // Color of header bottom edge line. 55 // Color of header bottom edge line.
58 const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(128, 128, 128); 56 const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(128, 128, 128);
59 // Space between close button and right edge of window. 57 // Space between close button and right edge of window.
60 const int kCloseButtonOffsetX = 0; 58 const int kCloseButtonOffsetX = 0;
61 // Space between close button and top edge of window. 59 // Space between close button and top edge of window.
62 const int kCloseButtonOffsetY = 0; 60 const int kCloseButtonOffsetY = 0;
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 int FramePainter::HeaderContentSeparatorSize() const { 443 int FramePainter::HeaderContentSeparatorSize() const {
446 return kHeaderContentSeparatorSize; 444 return kHeaderContentSeparatorSize;
447 } 445 }
448 446
449 void FramePainter::PaintTitleBar(views::NonClientFrameView* view, 447 void FramePainter::PaintTitleBar(views::NonClientFrameView* view,
450 gfx::Canvas* canvas, 448 gfx::Canvas* canvas,
451 const gfx::Font& title_font) { 449 const gfx::Font& title_font) {
452 // The window icon is painted by its own views::View. 450 // The window icon is painted by its own views::View.
453 views::WidgetDelegate* delegate = frame_->widget_delegate(); 451 views::WidgetDelegate* delegate = frame_->widget_delegate();
454 if (delegate && delegate->ShouldShowWindowTitle()) { 452 if (delegate && delegate->ShouldShowWindowTitle()) {
455 int title_x = GetTitleOffsetX(); 453 gfx::Rect title_bounds = GetTitleBounds(view, title_font);
456 int title_y = ui::LAYOUT_TOUCH == ui::GetDisplayLayout() ?
457 (view->GetBoundsForClientView().y() - title_font.GetHeight()) / 2
458 : kTitleOffsetY;
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(), 454 canvas->DrawStringInt(delegate->GetWindowTitle(),
465 title_font, 455 title_font,
466 kTitleTextColor, 456 kTitleTextColor,
467 view->GetMirroredXForRect(title_bounds), 457 view->GetMirroredXForRect(title_bounds),
468 title_bounds.y(), 458 title_bounds.y(),
469 title_bounds.width(), 459 title_bounds.width(),
470 title_bounds.height(), 460 title_bounds.height(),
471 gfx::Canvas::NO_SUBPIXEL_RENDERING); 461 gfx::Canvas::NO_SUBPIXEL_RENDERING);
472 } 462 }
473 } 463 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 close_button_->x() - size_button_size.width() + kButtonOverlap, 515 close_button_->x() - size_button_size.width() + kButtonOverlap,
526 close_button_->y(), 516 close_button_->y(),
527 size_button_size.width(), 517 size_button_size.width(),
528 size_button_size.height()); 518 size_button_size.height());
529 519
530 if (window_icon_) 520 if (window_icon_)
531 window_icon_->SetBoundsRect( 521 window_icon_->SetBoundsRect(
532 gfx::Rect(kIconOffsetX, kIconOffsetY, kIconSize, kIconSize)); 522 gfx::Rect(kIconOffsetX, kIconOffsetY, kIconSize, kIconSize));
533 } 523 }
534 524
525 void FramePainter::SchedulePaintForTitle(views::NonClientFrameView* view,
526 const gfx::Font& title_font) {
527 frame_->non_client_view()->SchedulePaintInRect(
528 GetTitleBounds(view, title_font));
529 }
530
535 /////////////////////////////////////////////////////////////////////////////// 531 ///////////////////////////////////////////////////////////////////////////////
536 // aura::WindowObserver overrides: 532 // aura::WindowObserver overrides:
537 533
538 void FramePainter::OnWindowPropertyChanged(aura::Window* window, 534 void FramePainter::OnWindowPropertyChanged(aura::Window* window,
539 const void* key, 535 const void* key,
540 intptr_t old) { 536 intptr_t old) {
541 if (key != aura::client::kShowStateKey) 537 if (key != aura::client::kShowStateKey)
542 return; 538 return;
543 539
544 // Maximized and fullscreen windows don't want resize handles overlapping the 540 // Maximized and fullscreen windows don't want resize handles overlapping the
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 } 715 }
720 716
721 void FramePainter::SchedulePaintForHeader() { 717 void FramePainter::SchedulePaintForHeader() {
722 int top_left_height = top_left_corner_->height(); 718 int top_left_height = top_left_corner_->height();
723 int top_right_height = top_right_corner_->height(); 719 int top_right_height = top_right_corner_->height();
724 frame_->non_client_view()->SchedulePaintInRect( 720 frame_->non_client_view()->SchedulePaintInRect(
725 gfx::Rect(0, 0, frame_->non_client_view()->width(), 721 gfx::Rect(0, 0, frame_->non_client_view()->width(),
726 std::max(top_left_height, top_right_height))); 722 std::max(top_left_height, top_right_height)));
727 } 723 }
728 724
725 gfx::Rect FramePainter::GetTitleBounds(views::NonClientFrameView* view,
726 const gfx::Font& title_font) {
727 int title_x = GetTitleOffsetX();
728 // Center the text in the middle of the caption - this way it adapts
729 // automatically to the caption height (which is given by the owner).
730 int title_y =
731 (view->GetBoundsForClientView().y() - title_font.GetHeight()) / 2;
732 return gfx::Rect(
733 title_x,
734 std::max(0, title_y),
735 std::max(0, size_button_->x() - kTitleLogoSpacing - title_x),
736 title_font.GetHeight());
737 }
738
729 } // namespace ash 739 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698