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

Side by Side Diff: chrome/browser/views/frame/opaque_non_client_view.cc

Issue 18255: Render maximized mode better when using nonstandard border widths.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 11 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
« no previous file with comments | « chrome/browser/views/frame/opaque_non_client_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_non_client_view.h" 5 #include "chrome/browser/views/frame/opaque_non_client_view.h"
6 6
7 #include "chrome/app/theme/theme_resources.h" 7 #include "chrome/app/theme/theme_resources.h"
8 #include "chrome/browser/tab_contents.h" 8 #include "chrome/browser/tab_contents.h"
9 #include "chrome/browser/views/frame/browser_view.h" 9 #include "chrome/browser/views/frame/browser_view.h"
10 #include "chrome/browser/views/tabs/tab_strip.h" 10 #include "chrome/browser/views/tabs/tab_strip.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 SkBitmap OpaqueNonClientView::app_top_center_; 284 SkBitmap OpaqueNonClientView::app_top_center_;
285 SkBitmap OpaqueNonClientView::app_top_right_; 285 SkBitmap OpaqueNonClientView::app_top_right_;
286 ChromeFont OpaqueNonClientView::title_font_; 286 ChromeFont OpaqueNonClientView::title_font_;
287 287
288 // The distance between the top of the window and the top of the window 288 // The distance between the top of the window and the top of the window
289 // controls when the window is restored. 289 // controls when the window is restored.
290 static const int kWindowControlsTopOffset = 1; 290 static const int kWindowControlsTopOffset = 1;
291 // The distance between the right edge of the window and the right edge of the 291 // The distance between the right edge of the window and the right edge of the
292 // right-most window control when the window is restored. 292 // right-most window control when the window is restored.
293 static const int kWindowControlsRightOffset = 4; 293 static const int kWindowControlsRightOffset = 4;
294 // The distance between the top of the window and the top of the window 294 // The distance between the bottom of the window's top border and the top of the
295 // controls' images when the window is maximized. We extend the clickable area 295 // window controls' images when the window is maximized. We extend the
296 // all the way to the top of the window to obey Fitts' Law. 296 // clickable area all the way to the top of the window to obey Fitts' Law.
297 static const int kWindowControlsZoomedTopExtraHeight = 5; 297 static const int kWindowControlsZoomedTopExtraHeight = 1;
298 // The distance between the right edge of the window and the right edge of the 298 // The distance between right edge of the right-most window control and the left
299 // right-most window control when the window is maximized. 299 // edge of the window's right border when the window is maximized.
300 static const int kWindowControlsZoomedRightOffset = 7; 300 static const int kWindowControlsZoomedRightOffset = 3;
301 // The distance between the left edge of the window and the left edge of the 301 // The distance between the left edge of the window and the left edge of the
302 // window icon when a title-bar is showing and the window is restored. 302 // window icon when a title-bar is showing and the window is restored.
303 static const int kWindowIconLeftOffset = 5; 303 static const int kWindowIconLeftOffset = 5;
304 // The distance between the left edge of the window and the left edge of the 304 // The distance between the right edge of the window's left border and the left
305 // window icon when a title-bar is showing and the window is maximized. 305 // edge of the window icon when a title-bar is showing and the window is
306 static const int kWindowIconZoomedLeftOffset = 6; 306 // maximized.
307 static const int kWindowIconZoomedLeftOffset = 2;
307 // The distance between the top edge of the window and the top edge of the 308 // The distance between the top edge of the window and the top edge of the
308 // window icon when a title-bar is showing and the window is restored. 309 // window icon and title when a title-bar is showing and the window is restored.
309 static const int kWindowIconTopOffset = 6; 310 static const int kWindowIconAndTitleTopOffset = 6;
310 // The distance between the top edge of the window and the top edge of the 311 // The distance between the bottom edge of the window's top border and the top
311 // window icon when a title-bar is showing and the window is maximized. 312 // edge of the window icon and title when a title-bar is showing and the window
312 static const int kWindowIconZoomedTopOffset = 8; 313 // is maximized.
314 static const int kWindowIconAndTitleZoomedTopOffset = 4;
313 // The distance between the window icon and the window title when a title-bar 315 // The distance between the window icon and the window title when a title-bar
314 // is showing. 316 // is showing.
315 static const int kWindowIconTitleSpacing = 4; 317 static const int kWindowIconTitleSpacing = 4;
316 // The distance between the top of the window and the title text when a
317 // title-bar is showing and the window is restored.
318 static const int kTitleTopOffset = 6;
319 // The distance between the top of the window and the title text when a
320 // title-bar is showing and the window is maximized.
321 static const int kTitleZoomedTopOffset = 8;
322 // The distance between the right edge of the title text bounding box and the 318 // The distance between the right edge of the title text bounding box and the
323 // left edge of the distributor logo. 319 // left edge of the distributor logo.
324 static const int kTitleLogoSpacing = 5; 320 static const int kTitleLogoSpacing = 5;
325 // The distance between the bottom of the title text and the TabStrip when a 321 // The distance between the bottom of the title text and the TabStrip when a
326 // title-bar is showing. 322 // title-bar is showing.
327 static const int kTitleBottomSpacing = 6; 323 static const int kTitleBottomSpacing = 6;
328 // The distance between the top edge of the window and the TabStrip when there 324 // The distance between the top edge of the window and the TabStrip when there
329 // is no title-bar showing, and the window is restored. 325 // is no title-bar showing, and the window is restored.
330 static const int kNoTitleTopSpacing = 15; 326 static const int kNoTitleTopSpacing = 15;
331 // The distance between the top edge of the window and the TabStrip when there 327 // The number of pixels to crop off the bottom of the images making up the top
332 // is no title-bar showing, and the window is maximized.
333 static const int kNoTitleZoomedTopSpacing = 4;
334 // The number of pixels to shave off the bottom of the images making up the top
335 // client edge when the window is maximized, so we only draw a shadowed titlebar 328 // client edge when the window is maximized, so we only draw a shadowed titlebar
336 // and not a grey client area border below it. 329 // and not a grey client area border below it.
337 static const int kClientEdgeZoomedOffset = 1; 330 static const int kClientEdgeZoomedBottomCrop = 1;
338 // The amount of horizontal and vertical distance from a corner of the window 331 // The amount of horizontal and vertical distance from a corner of the window
339 // within which a mouse-drive resize operation will resize the window in two 332 // within which a mouse-drive resize operation will resize the window in two
340 // dimensions. 333 // dimensions.
341 static const int kResizeAreaCornerSize = 16; 334 static const int kResizeAreaCornerSize = 16;
342 // The width of the sizing border on the left and right edge of the window. 335 // The width of the sizing border on the left and right edge of the window.
343 static const int kWindowHorizontalBorderSize = 5; 336 static const int kWindowHorizontalBorderSize = 5;
344 // The width of the sizing border on the left and right edge of the window when
345 // the window is maximized.
346 static const int kWindowHorizontalBorderZoomedSize = 4;
347 // The height of the sizing border at the top edge of the window 337 // The height of the sizing border at the top edge of the window
348 static const int kWindowVerticalBorderTopSize = 3; 338 static const int kWindowVerticalBorderTopSize = 3;
349 // The height of the sizing border on the bottom edge of the window. 339 // The height of the sizing border on the bottom edge of the window when the
340 // window is restored.
350 static const int kWindowVerticalBorderBottomSize = 5; 341 static const int kWindowVerticalBorderBottomSize = 5;
351 // The distance between the bottom edge of the window image and the true bottom 342 // The additional height beyond the system-provided thickness of the broder on
sky 2009/01/15 01:06:34 nit: broder -> border
352 // edge of the window when the window is maximized. 343 // the bottom edge of the window when the window is maximized.
353 static const int kWindowBottomZoomedSpacing = 4; 344 static const int kWindowVerticalBorderZoomedBottomSize = 1;
354 // The width and height of the window icon that appears at the top left of 345 // The width and height of the window icon that appears at the top left of
355 // pop-up and app windows. 346 // pop-up and app windows.
356 static const int kWindowIconSize = 16; 347 static const int kWindowIconSize = 16;
357 // The horizontal distance of the right edge of the distributor logo from the 348 // The horizontal distance of the right edge of the distributor logo from the
358 // left edge of the left-most window control. 349 // left edge of the left-most window control.
359 static const int kDistributorLogoHorizontalOffset = 7; 350 static const int kDistributorLogoHorizontalOffset = 7;
360 // The vertical distance of the top of the distributor logo from the top edge 351 // The vertical distance of the top of the distributor logo from the top edge
361 // of the window. 352 // of the window.
362 static const int kDistributorLogoVerticalOffset = 3; 353 static const int kDistributorLogoVerticalOffset = 3;
363 // The distance between the left edge of the window and the OTR avatar icon when 354 // The distance between the left edge of the window and the OTR avatar icon when
364 // the window is restored. 355 // the window is restored.
365 static const int kOTRLeftOffset = 7; 356 static const int kOTRLeftOffset = 7;
366 // The distance between the left edge of the window and the OTR avatar icon when 357 // The distance between the right edge of the window's left border and the OTR
367 // the window is maximized. 358 // avatar icon when the window is maximized.
368 static const int kOTRZoomedLeftOffset = 6; 359 static const int kOTRZoomedLeftOffset = 2;
369 // The distance between the top edge of the client area and the OTR avatar icon 360 // The distance between the top edge of the client area and the OTR avatar icon
370 // when the window is maximized. 361 // when the window is maximized.
371 static const int kOTRZoomedTopSpacing = 2; 362 static const int kOTRZoomedTopSpacing = 2;
372 // The distance between the bottom of the OTR avatar icon and the bottom of the 363 // The distance between the bottom of the OTR avatar icon and the bottom of the
373 // tabstrip. 364 // tabstrip.
374 static const int kOTRBottomSpacing = 2; 365 static const int kOTRBottomSpacing = 2;
375 // The number of pixels to crop off the top of the OTR image when the window is 366 // The number of pixels to crop off the top of the OTR image when the window is
376 // maximized. 367 // maximized.
377 static const int kOTRZoomedTopCrop = 4; 368 static const int kOTRZoomedTopCrop = 4;
378 // Horizontal distance between the right edge of the OTR avatar icon and the 369 // Horizontal distance between the right edge of the OTR avatar icon and the
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 476 }
486 477
487 gfx::Rect OpaqueNonClientView::GetWindowBoundsForClientBounds( 478 gfx::Rect OpaqueNonClientView::GetWindowBoundsForClientBounds(
488 const gfx::Rect& client_bounds) { 479 const gfx::Rect& client_bounds) {
489 int top_height = CalculateNonClientTopHeight(); 480 int top_height = CalculateNonClientTopHeight();
490 int horizontal_border = HorizontalBorderSize(); 481 int horizontal_border = HorizontalBorderSize();
491 int window_x = std::max(0, client_bounds.x() - horizontal_border); 482 int window_x = std::max(0, client_bounds.x() - horizontal_border);
492 int window_y = std::max(0, client_bounds.y() - top_height); 483 int window_y = std::max(0, client_bounds.y() - top_height);
493 int window_w = client_bounds.width() + (2 * horizontal_border); 484 int window_w = client_bounds.width() + (2 * horizontal_border);
494 int window_h = 485 int window_h =
495 client_bounds.height() + top_height + kWindowVerticalBorderBottomSize; 486 client_bounds.height() + top_height + VerticalBorderBottomSize();
496 return gfx::Rect(window_x, window_y, window_w, window_h); 487 return gfx::Rect(window_x, window_y, window_w, window_h);
497 } 488 }
498 489
499 gfx::Rect OpaqueNonClientView::GetBoundsForTabStrip(TabStrip* tabstrip) { 490 gfx::Rect OpaqueNonClientView::GetBoundsForTabStrip(TabStrip* tabstrip) {
500 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? 491 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ?
501 (otr_avatar_bounds_.right() + kOTRTabStripSpacing) : 492 (otr_avatar_bounds_.right() + kOTRTabStripSpacing) :
502 HorizontalBorderSize(); 493 HorizontalBorderSize();
503 int tabstrip_width = minimize_button_->x() - tabstrip_x - 494 int tabstrip_width = minimize_button_->x() - tabstrip_x -
504 (frame_->IsMaximized() ? 495 (frame_->IsMaximized() ?
505 kNewTabIconMinimizeZoomedSpacing : kNewTabIconMinimizeSpacing); 496 kNewTabIconMinimizeZoomedSpacing : kNewTabIconMinimizeSpacing);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 535
545 /////////////////////////////////////////////////////////////////////////////// 536 ///////////////////////////////////////////////////////////////////////////////
546 // OpaqueNonClientView, views::NonClientView implementation: 537 // OpaqueNonClientView, views::NonClientView implementation:
547 538
548 gfx::Rect OpaqueNonClientView::CalculateClientAreaBounds(int width, 539 gfx::Rect OpaqueNonClientView::CalculateClientAreaBounds(int width,
549 int height) const { 540 int height) const {
550 int top_margin = CalculateNonClientTopHeight(); 541 int top_margin = CalculateNonClientTopHeight();
551 int horizontal_border = HorizontalBorderSize(); 542 int horizontal_border = HorizontalBorderSize();
552 return gfx::Rect(horizontal_border, top_margin, 543 return gfx::Rect(horizontal_border, top_margin,
553 std::max(0, width - (2 * horizontal_border)), 544 std::max(0, width - (2 * horizontal_border)),
554 std::max(0, height - top_margin - kWindowVerticalBorderBottomSize)); 545 std::max(0, height - top_margin - VerticalBorderBottomSize()));
555 } 546 }
556 547
557 gfx::Size OpaqueNonClientView::CalculateWindowSizeForClientSize( 548 gfx::Size OpaqueNonClientView::CalculateWindowSizeForClientSize(
558 int width, 549 int width,
559 int height) const { 550 int height) const {
560 return gfx::Size(width + (2 * HorizontalBorderSize()), 551 return gfx::Size(width + (2 * HorizontalBorderSize()),
561 height + CalculateNonClientTopHeight() + kWindowVerticalBorderBottomSize); 552 height + CalculateNonClientTopHeight() + VerticalBorderBottomSize());
562 } 553 }
563 554
564 CPoint OpaqueNonClientView::GetSystemMenuPoint() const { 555 CPoint OpaqueNonClientView::GetSystemMenuPoint() const {
565 CPoint system_menu_point(icon_bounds_.x(), icon_bounds_.bottom()); 556 CPoint system_menu_point(icon_bounds_.x(), icon_bounds_.bottom());
566 MapWindowPoints(frame_->GetHWND(), HWND_DESKTOP, &system_menu_point, 1); 557 MapWindowPoints(frame_->GetHWND(), HWND_DESKTOP, &system_menu_point, 1);
567 return system_menu_point; 558 return system_menu_point;
568 } 559 }
569 560
570 int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) { 561 int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) {
571 // First see if it's within the grow box area, since that overlaps the client 562 // First see if it's within the grow box area, since that overlaps the client
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 restore_button_->SetState(views::Button::BS_NORMAL); 618 restore_button_->SetState(views::Button::BS_NORMAL);
628 minimize_button_->SetState(views::Button::BS_NORMAL); 619 minimize_button_->SetState(views::Button::BS_NORMAL);
629 maximize_button_->SetState(views::Button::BS_NORMAL); 620 maximize_button_->SetState(views::Button::BS_NORMAL);
630 // The close button isn't affected by this constraint. 621 // The close button isn't affected by this constraint.
631 } 622 }
632 623
633 /////////////////////////////////////////////////////////////////////////////// 624 ///////////////////////////////////////////////////////////////////////////////
634 // OpaqueNonClientView, views::View overrides: 625 // OpaqueNonClientView, views::View overrides:
635 626
636 void OpaqueNonClientView::Paint(ChromeCanvas* canvas) { 627 void OpaqueNonClientView::Paint(ChromeCanvas* canvas) {
637 // Clip the content area out of the rendering.
638 gfx::Rect contents_bounds = browser_view_->GetClientAreaBounds();
639 SkRect clip;
640 clip.set(SkIntToScalar(contents_bounds.x()),
641 SkIntToScalar(contents_bounds.y()),
642 SkIntToScalar(contents_bounds.right()),
643 SkIntToScalar(contents_bounds.bottom()));
644 canvas->clipRect(clip, SkRegion::kDifference_Op);
645
646 // Render the remaining portions of the non-client area.
647 if (frame_->IsMaximized()) 628 if (frame_->IsMaximized())
648 PaintMaximizedFrameBorder(canvas); 629 PaintMaximizedFrameBorder(canvas);
649 else 630 else
650 PaintFrameBorder(canvas); 631 PaintFrameBorder(canvas);
651 PaintDistributorLogo(canvas); 632 PaintDistributorLogo(canvas);
652 PaintTitleBar(canvas); 633 PaintTitleBar(canvas);
653 PaintToolbarBackground(canvas); 634 PaintToolbarBackground(canvas);
654 PaintOTRAvatar(canvas); 635 PaintOTRAvatar(canvas);
655 if (frame_->IsMaximized()) 636 if (frame_->IsMaximized())
656 PaintMaximizedClientEdge(canvas); 637 PaintMaximizedClientEdge(canvas);
657 else 638 else
658 PaintClientEdge(canvas); 639 PaintClientEdge(canvas);
659 } 640 }
660 641
661 void OpaqueNonClientView::Layout() { 642 void OpaqueNonClientView::Layout() {
662 LayoutWindowControls(); 643 LayoutWindowControls();
663 LayoutDistributorLogo(); 644 LayoutDistributorLogo();
664 LayoutTitleBar(); 645 LayoutTitleBar();
665 LayoutOTRAvatar(); 646 LayoutOTRAvatar();
666 LayoutClientView(); 647 LayoutClientView();
667 } 648 }
668 649
669 gfx::Size OpaqueNonClientView::GetPreferredSize() { 650 gfx::Size OpaqueNonClientView::GetPreferredSize() {
670 gfx::Size prefsize(frame_->client_view()->GetPreferredSize()); 651 gfx::Size prefsize(frame_->client_view()->GetPreferredSize());
671 prefsize.Enlarge(2 * HorizontalBorderSize(), 652 prefsize.Enlarge(2 * HorizontalBorderSize(),
672 CalculateNonClientTopHeight() + kWindowVerticalBorderBottomSize); 653 CalculateNonClientTopHeight() + VerticalBorderBottomSize());
673 return prefsize; 654 return prefsize;
674 } 655 }
675 656
676 views::View* OpaqueNonClientView::GetViewForPoint(const gfx::Point& point, 657 views::View* OpaqueNonClientView::GetViewForPoint(const gfx::Point& point,
677 bool can_create_floating) { 658 bool can_create_floating) {
678 // We override this function because the ClientView can overlap the non - 659 // We override this function because the ClientView can overlap the non -
679 // client view, making it impossible to click on the window controls. We need 660 // client view, making it impossible to click on the window controls. We need
680 // to ensure the window controls are checked _first_. 661 // to ensure the window controls are checked _first_.
681 views::View* views[] = { close_button_, restore_button_, maximize_button_, 662 views::View* views[] = { close_button_, restore_button_, maximize_button_,
682 minimize_button_ }; 663 minimize_button_ };
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 704 }
724 705
725 void OpaqueNonClientView::SetAccessibleName(const std::wstring& name) { 706 void OpaqueNonClientView::SetAccessibleName(const std::wstring& name) {
726 accessible_name_ = name; 707 accessible_name_ = name;
727 } 708 }
728 709
729 /////////////////////////////////////////////////////////////////////////////// 710 ///////////////////////////////////////////////////////////////////////////////
730 // OpaqueNonClientView, private: 711 // OpaqueNonClientView, private:
731 712
732 int OpaqueNonClientView::CalculateNonClientTopHeight() const { 713 int OpaqueNonClientView::CalculateNonClientTopHeight() const {
733 if (frame_->window_delegate()->ShouldShowWindowTitle()) 714 if (frame_->window_delegate()->ShouldShowWindowTitle()) {
734 return kTitleTopOffset + title_font_.height() + kTitleBottomSpacing; 715 int top_offset = frame_->IsMaximized() ? (GetSystemMetrics(SM_CYSIZEFRAME) +
735 return frame_->IsMaximized() ? kNoTitleZoomedTopSpacing : kNoTitleTopSpacing; 716 kWindowIconAndTitleZoomedTopOffset) : kWindowIconAndTitleTopOffset;
717 return top_offset + title_font_.height() + kTitleBottomSpacing;
718 }
719 return frame_->IsMaximized() ?
720 GetSystemMetrics(SM_CYSIZEFRAME) : kNoTitleTopSpacing;
736 } 721 }
737 722
738 int OpaqueNonClientView::HorizontalBorderSize() const { 723 int OpaqueNonClientView::HorizontalBorderSize() const {
739 return frame_->IsMaximized() ? 724 return frame_->IsMaximized() ?
740 kWindowHorizontalBorderZoomedSize : kWindowHorizontalBorderSize; 725 GetSystemMetrics(SM_CXSIZEFRAME) : kWindowHorizontalBorderSize;
726 }
727
728 int OpaqueNonClientView::VerticalBorderBottomSize() const {
729 return frame_->IsMaximized() ? (GetSystemMetrics(SM_CYSIZEFRAME) +
730 kWindowVerticalBorderZoomedBottomSize) : kWindowVerticalBorderBottomSize;
741 } 731 }
742 732
743 void OpaqueNonClientView::PaintFrameBorder(ChromeCanvas* canvas) { 733 void OpaqueNonClientView::PaintFrameBorder(ChromeCanvas* canvas) {
744 SkBitmap* top_left_corner = 734 SkBitmap* top_left_corner =
745 resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER); 735 resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER);
746 SkBitmap* top_right_corner = 736 SkBitmap* top_right_corner =
747 resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); 737 resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER);
748 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); 738 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE);
749 SkBitmap* right_edge = resources()->GetPartBitmap(FRAME_RIGHT_EDGE); 739 SkBitmap* right_edge = resources()->GetPartBitmap(FRAME_RIGHT_EDGE);
750 SkBitmap* left_edge = resources()->GetPartBitmap(FRAME_LEFT_EDGE); 740 SkBitmap* left_edge = resources()->GetPartBitmap(FRAME_LEFT_EDGE);
(...skipping 29 matching lines...) Expand all
780 height() - bottom_left_corner->height()); 770 height() - bottom_left_corner->height());
781 771
782 // Left. 772 // Left.
783 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), 773 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(),
784 left_edge->width(), 774 left_edge->width(),
785 height() - top_left_corner->height() - bottom_left_corner->height()); 775 height() - top_left_corner->height() - bottom_left_corner->height());
786 } 776 }
787 777
788 void OpaqueNonClientView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) { 778 void OpaqueNonClientView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) {
789 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_MAXIMIZED_TOP_EDGE); 779 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_MAXIMIZED_TOP_EDGE);
790 canvas->TileImageInt(*top_edge, 0, kNoTitleZoomedTopSpacing, width(), 780 int frame_thickness = GetSystemMetrics(SM_CYSIZEFRAME);
781 canvas->TileImageInt(*top_edge, 0, frame_thickness, width(),
791 top_edge->height()); 782 top_edge->height());
792 783
793 SkBitmap* bottom_edge = 784 SkBitmap* bottom_edge =
794 resources()->GetPartBitmap(FRAME_MAXIMIZED_BOTTOM_EDGE); 785 resources()->GetPartBitmap(FRAME_MAXIMIZED_BOTTOM_EDGE);
795 canvas->TileImageInt(*bottom_edge, 0, 786 canvas->TileImageInt(*bottom_edge, 0,
796 height() - bottom_edge->height() - kWindowBottomZoomedSpacing, width(), 787 height() - bottom_edge->height() - frame_thickness, width(),
797 bottom_edge->height()); 788 bottom_edge->height());
798 } 789 }
799 790
800 void OpaqueNonClientView::PaintDistributorLogo(ChromeCanvas* canvas) { 791 void OpaqueNonClientView::PaintDistributorLogo(ChromeCanvas* canvas) {
801 // The distributor logo is only painted when the frame is not maximized and 792 // The distributor logo is only painted when the frame is not maximized and
802 // when we actually have a logo. 793 // when we actually have a logo.
803 if (!frame_->IsMaximized() && !distributor_logo_.empty()) { 794 if (!frame_->IsMaximized() && !distributor_logo_.empty()) {
804 int logo_x = MirroredLeftPointForRect(logo_bounds_); 795 int logo_x = MirroredLeftPointForRect(logo_bounds_);
805 canvas->DrawBitmapInt(distributor_logo_, logo_x, logo_bounds_.y()); 796 canvas->DrawBitmapInt(distributor_logo_, logo_x, logo_bounds_.y());
806 } 797 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 // 857 //
867 // Note: We can get away with this hackery because we only draw a top edge 858 // Note: We can get away with this hackery because we only draw a top edge
868 // when there is no toolbar. If we tried to draw a top edge over the 859 // when there is no toolbar. If we tried to draw a top edge over the
869 // toolbar's top edge, we'd need a different solution. 860 // toolbar's top edge, we'd need a different solution.
870 gfx::Rect toolbar_bounds = browser_view_->GetToolbarBounds(); 861 gfx::Rect toolbar_bounds = browser_view_->GetToolbarBounds();
871 if (browser_view_->IsToolbarVisible()) 862 if (browser_view_->IsToolbarVisible())
872 toolbar_bounds.set_height(std::max(0, toolbar_bounds.height() - 1)); 863 toolbar_bounds.set_height(std::max(0, toolbar_bounds.height() - 1));
873 int client_area_top = frame_->client_view()->y() + toolbar_bounds.bottom(); 864 int client_area_top = frame_->client_view()->y() + toolbar_bounds.bottom();
874 865
875 // When we don't have a toolbar to draw a top edge for us, draw a top edge. 866 // When we don't have a toolbar to draw a top edge for us, draw a top edge.
876 gfx::Rect client_area_bounds = browser_view_->GetClientAreaBounds(); 867 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
877 if (!browser_view_->IsToolbarVisible()) { 868 if (!browser_view_->IsToolbarVisible()) {
878 // This is necessary because the top center bitmap is shorter than the top 869 // This is necessary because the top center bitmap is shorter than the top
879 // left and right bitmaps. We need their top edges to line up, and we 870 // left and right bitmaps. We need their top edges to line up, and we
880 // need the left and right edges to start below the corners' bottoms. 871 // need the left and right edges to start below the corners' bottoms.
881 int top_edge_y = client_area_top - app_top_center_.height(); 872 int top_edge_y = client_area_top - app_top_center_.height();
882 client_area_top = top_edge_y + app_top_left_.height(); 873 client_area_top = top_edge_y + app_top_left_.height();
883 canvas->DrawBitmapInt(app_top_left_, 874 canvas->DrawBitmapInt(app_top_left_,
884 client_area_bounds.x() - app_top_left_.width(), 875 client_area_bounds.x() - app_top_left_.width(),
885 top_edge_y); 876 top_edge_y);
886 canvas->TileImageInt(app_top_center_, client_area_bounds.x(), top_edge_y, 877 canvas->TileImageInt(app_top_center_, client_area_bounds.x(), top_edge_y,
887 client_area_bounds.width(), app_top_center_.height()); 878 client_area_bounds.width(), app_top_center_.height());
888 canvas->DrawBitmapInt(app_top_right_, client_area_bounds.right(), 879 canvas->DrawBitmapInt(app_top_right_, client_area_bounds.right(),
889 top_edge_y); 880 top_edge_y);
890 } 881 }
891 882
892 int client_area_bottom = 883 int client_area_bottom =
893 std::max(client_area_top, height() - kWindowVerticalBorderBottomSize); 884 std::max(client_area_top, height() - VerticalBorderBottomSize());
894 int client_area_height = client_area_bottom - client_area_top; 885 int client_area_height = client_area_bottom - client_area_top;
895 SkBitmap* right = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_RIGHT); 886 SkBitmap* right = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_RIGHT);
896 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, 887 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top,
897 right->width(), client_area_height); 888 right->width(), client_area_height);
898 889
899 canvas->DrawBitmapInt( 890 canvas->DrawBitmapInt(
900 *resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_RIGHT), 891 *resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_RIGHT),
901 client_area_bounds.right(), client_area_bottom); 892 client_area_bounds.right(), client_area_bottom);
902 893
903 SkBitmap* bottom = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM); 894 SkBitmap* bottom = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM);
904 canvas->TileImageInt(*bottom, client_area_bounds.x(), 895 canvas->TileImageInt(*bottom, client_area_bounds.x(),
905 client_area_bottom, client_area_bounds.width(), 896 client_area_bottom, client_area_bounds.width(),
906 bottom->height()); 897 bottom->height());
907 898
908 SkBitmap* bottom_left = 899 SkBitmap* bottom_left =
909 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_LEFT); 900 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_BOTTOM_LEFT);
910 canvas->DrawBitmapInt(*bottom_left, 901 canvas->DrawBitmapInt(*bottom_left,
911 client_area_bounds.x() - bottom_left->width(), client_area_bottom); 902 client_area_bounds.x() - bottom_left->width(), client_area_bottom);
912 903
913 SkBitmap* left = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_LEFT); 904 SkBitmap* left = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_LEFT);
914 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), 905 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(),
915 client_area_top, left->width(), client_area_height); 906 client_area_top, left->width(), client_area_height);
916 } 907 }
917 908
918 void OpaqueNonClientView::PaintMaximizedClientEdge(ChromeCanvas* canvas) { 909 void OpaqueNonClientView::PaintMaximizedClientEdge(ChromeCanvas* canvas) {
919 if (browser_view_->IsToolbarVisible()) 910 if (browser_view_->IsToolbarVisible())
920 return; // The toolbar draws its own client edge, which is sufficient. 911 return; // The toolbar draws its own client edge, which is sufficient.
921 912
922 int edge_height = app_top_center_.height() - kClientEdgeZoomedOffset; 913 int edge_height = app_top_center_.height() - kClientEdgeZoomedBottomCrop;
923 canvas->TileImageInt(app_top_center_, 0, 914 canvas->TileImageInt(app_top_center_, 0,
924 frame_->client_view()->y() - edge_height, width(), edge_height); 915 frame_->client_view()->y() - edge_height, width(), edge_height);
925 } 916 }
926 917
927 void OpaqueNonClientView::LayoutWindowControls() { 918 void OpaqueNonClientView::LayoutWindowControls() {
928 // TODO(pkasting): This function is almost identical to 919 // TODO(pkasting): This function is almost identical to
929 // DefaultNonClientView::LayoutWindowControls(), they should be combined. 920 // DefaultNonClientView::LayoutWindowControls(), they should be combined.
930 close_button_->SetImageAlignment(views::Button::ALIGN_LEFT, 921 close_button_->SetImageAlignment(views::Button::ALIGN_LEFT,
931 views::Button::ALIGN_BOTTOM); 922 views::Button::ALIGN_BOTTOM);
932 // Maximized buttons start at window top so that even if their images aren't 923 // Maximized buttons start at window top so that even if their images aren't
933 // drawn flush with the screen edge, they still obey Fitts' Law. 924 // drawn flush with the screen edge, they still obey Fitts' Law.
934 bool is_maximized = frame_->IsMaximized(); 925 bool is_maximized = frame_->IsMaximized();
935 int top_offset = is_maximized ? 0 : kWindowControlsTopOffset; 926 int top_offset = is_maximized ? 0 : kWindowControlsTopOffset;
936 int top_extra_height = is_maximized ? kWindowControlsZoomedTopExtraHeight : 0; 927 int top_extra_height = is_maximized ?
928 (GetSystemMetrics(SM_CYSIZEFRAME) + kWindowControlsZoomedTopExtraHeight) :
929 0;
930 int right_offset = is_maximized ?
931 (GetSystemMetrics(SM_CXSIZEFRAME) + kWindowControlsZoomedRightOffset) :
932 kWindowControlsRightOffset;
937 gfx::Size close_button_size = close_button_->GetPreferredSize(); 933 gfx::Size close_button_size = close_button_->GetPreferredSize();
938 close_button_->SetBounds( 934 close_button_->SetBounds(
939 (width() - close_button_size.width() - (is_maximized ? 935 (width() - close_button_size.width() - right_offset),
940 kWindowControlsZoomedRightOffset : kWindowControlsRightOffset)),
941 top_offset, 936 top_offset,
942 (is_maximized ? 937 (is_maximized ?
943 // We extend the maximized close button to the screen corner to obey 938 // We extend the maximized close button to the screen corner to obey
944 // Fitts' Law. 939 // Fitts' Law.
945 (close_button_size.width() + kWindowControlsZoomedRightOffset) : 940 (close_button_size.width() + kWindowControlsZoomedRightOffset) :
946 close_button_size.width()), 941 close_button_size.width()),
947 (close_button_size.height() + top_extra_height)); 942 (close_button_size.height() + top_extra_height));
948 943
949 // When the window is restored, we show a maximized button; otherwise, we show 944 // When the window is restored, we show a maximized button; otherwise, we show
950 // a restore button. 945 // a restore button.
(...skipping 27 matching lines...) Expand all
978 void OpaqueNonClientView::LayoutDistributorLogo() { 973 void OpaqueNonClientView::LayoutDistributorLogo() {
979 logo_bounds_.SetRect(minimize_button_->x() - distributor_logo_.width() - 974 logo_bounds_.SetRect(minimize_button_->x() - distributor_logo_.width() -
980 kDistributorLogoHorizontalOffset, kDistributorLogoVerticalOffset, 975 kDistributorLogoHorizontalOffset, kDistributorLogoVerticalOffset,
981 distributor_logo_.width(), distributor_logo_.height()); 976 distributor_logo_.width(), distributor_logo_.height());
982 } 977 }
983 978
984 void OpaqueNonClientView::LayoutTitleBar() { 979 void OpaqueNonClientView::LayoutTitleBar() {
985 // Size the window icon, even if it is hidden so we can size the title based 980 // Size the window icon, even if it is hidden so we can size the title based
986 // on its position. 981 // on its position.
987 int left_offset = frame_->IsMaximized() ? 982 int left_offset = frame_->IsMaximized() ?
988 kWindowIconZoomedLeftOffset : kWindowIconLeftOffset; 983 (GetSystemMetrics(SM_CXSIZEFRAME) + kWindowIconZoomedLeftOffset) :
984 kWindowIconLeftOffset;
989 int top_offset = frame_->IsMaximized() ? 985 int top_offset = frame_->IsMaximized() ?
990 kWindowIconZoomedTopOffset : kWindowIconTopOffset; 986 (GetSystemMetrics(SM_CYSIZEFRAME) + kWindowIconAndTitleZoomedTopOffset) :
987 kWindowIconAndTitleTopOffset;
991 views::WindowDelegate* d = frame_->window_delegate(); 988 views::WindowDelegate* d = frame_->window_delegate();
992 int icon_size = d->ShouldShowWindowIcon() ? kWindowIconSize : 0; 989 int icon_size = d->ShouldShowWindowIcon() ? kWindowIconSize : 0;
993 icon_bounds_.SetRect(left_offset, top_offset, icon_size, icon_size); 990 icon_bounds_.SetRect(left_offset, top_offset, icon_size, icon_size);
994 if (window_icon_) 991 if (window_icon_)
995 window_icon_->SetBounds(icon_bounds_); 992 window_icon_->SetBounds(icon_bounds_);
996 993
997 // Size the title, if visible. 994 // Size the title, if visible.
998 if (d->ShouldShowWindowTitle()) { 995 if (d->ShouldShowWindowTitle()) {
999 int title_right = logo_bounds_.x() - kTitleLogoSpacing; 996 int title_right = logo_bounds_.x() - kTitleLogoSpacing;
1000 int icon_right = icon_bounds_.right(); 997 int icon_right = icon_bounds_.right();
1001 int title_left = 998 int title_left =
1002 icon_right + (d->ShouldShowWindowIcon() ? kWindowIconTitleSpacing : 0); 999 icon_right + (d->ShouldShowWindowIcon() ? kWindowIconTitleSpacing : 0);
1003 int top_offset = frame_->IsMaximized() ?
1004 kTitleZoomedTopOffset : kTitleTopOffset;
1005 title_bounds_.SetRect(title_left, top_offset, 1000 title_bounds_.SetRect(title_left, top_offset,
1006 std::max(0, title_right - icon_right), title_font_.height()); 1001 std::max(0, title_right - icon_right), title_font_.height());
1007 } 1002 }
1008 } 1003 }
1009 1004
1010 void OpaqueNonClientView::LayoutOTRAvatar() { 1005 void OpaqueNonClientView::LayoutOTRAvatar() {
1011 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); 1006 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
1012 int non_client_height = CalculateNonClientTopHeight(); 1007 int non_client_height = CalculateNonClientTopHeight();
1013 int otr_bottom = non_client_height + browser_view_->GetTabStripHeight() - 1008 int otr_bottom = non_client_height + browser_view_->GetTabStripHeight() -
1014 kOTRBottomSpacing; 1009 kOTRBottomSpacing;
1015 int otr_x, otr_y, otr_height; 1010 int otr_x, otr_y, otr_height;
1016 if (frame_->IsMaximized()) { 1011 if (frame_->IsMaximized()) {
1017 otr_x = kOTRZoomedLeftOffset; 1012 otr_x = GetSystemMetrics(SM_CXSIZEFRAME) + kOTRZoomedLeftOffset;
1018 otr_y = non_client_height + kOTRZoomedTopSpacing; 1013 otr_y = non_client_height + kOTRZoomedTopSpacing;
1019 otr_height = otr_bottom - otr_y; 1014 otr_height = otr_bottom - otr_y;
1020 } else { 1015 } else {
1021 otr_x = kOTRLeftOffset; 1016 otr_x = kOTRLeftOffset;
1022 otr_height = otr_avatar_icon.height(); 1017 otr_height = otr_avatar_icon.height();
1023 otr_y = otr_bottom - otr_height; 1018 otr_y = otr_bottom - otr_height;
1024 } 1019 }
1025 otr_avatar_bounds_.SetRect(otr_x, otr_y, otr_avatar_icon.width(), otr_height); 1020 otr_avatar_bounds_.SetRect(otr_x, otr_y, otr_avatar_icon.width(), otr_height);
1026 } 1021 }
1027 1022
(...skipping 23 matching lines...) Expand all
1051 } 1046 }
1052 1047
1053 // static 1048 // static
1054 void OpaqueNonClientView::InitAppWindowResources() { 1049 void OpaqueNonClientView::InitAppWindowResources() {
1055 static bool initialized = false; 1050 static bool initialized = false;
1056 if (!initialized) { 1051 if (!initialized) {
1057 title_font_ = win_util::GetWindowTitleFont(); 1052 title_font_ = win_util::GetWindowTitleFont();
1058 initialized = true; 1053 initialized = true;
1059 } 1054 }
1060 } 1055 }
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/opaque_non_client_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698