| OLD | NEW |
| 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_browser_frame_view.h" | 5 #include "chrome/browser/views/frame/opaque_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/views/frame/browser_frame.h" | 7 #include "chrome/browser/views/frame/browser_frame.h" |
| 8 #include "chrome/browser/views/frame/browser_view.h" | 8 #include "chrome/browser/views/frame/browser_view.h" |
| 9 #include "chrome/browser/views/tabs/tab_strip.h" | 9 #include "chrome/browser/views/tabs/tab_strip.h" |
| 10 #include "chrome/common/gfx/chrome_canvas.h" | 10 #include "chrome/common/gfx/chrome_canvas.h" |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), | 456 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), |
| 457 std::max(0, client_bounds.y() - top_height), | 457 std::max(0, client_bounds.y() - top_height), |
| 458 client_bounds.width() + (2 * border_thickness), | 458 client_bounds.width() + (2 * border_thickness), |
| 459 client_bounds.height() + top_height + border_thickness); | 459 client_bounds.height() + top_height + border_thickness); |
| 460 } | 460 } |
| 461 | 461 |
| 462 gfx::Point OpaqueBrowserFrameView::GetSystemMenuPoint() const { | 462 gfx::Point OpaqueBrowserFrameView::GetSystemMenuPoint() const { |
| 463 gfx::Point system_menu_point( | 463 gfx::Point system_menu_point( |
| 464 MirroredXCoordinateInsideView(FrameBorderThickness()), | 464 MirroredXCoordinateInsideView(FrameBorderThickness()), |
| 465 NonClientTopBorderHeight() + browser_view_->GetTabStripHeight() - | 465 NonClientTopBorderHeight() + browser_view_->GetTabStripHeight() - |
| 466 (browser_view_->IsFullscreen() ? 0 : kClientEdgeThickness)); | 466 (frame_->IsFullscreen() ? 0 : kClientEdgeThickness)); |
| 467 ConvertPointToScreen(this, &system_menu_point); | 467 ConvertPointToScreen(this, &system_menu_point); |
| 468 return system_menu_point; | 468 return system_menu_point; |
| 469 } | 469 } |
| 470 | 470 |
| 471 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { | 471 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
| 472 if (!bounds().Contains(point)) | 472 if (!bounds().Contains(point)) |
| 473 return HTNOWHERE; | 473 return HTNOWHERE; |
| 474 | 474 |
| 475 int frame_component = frame_->GetClientView()->NonClientHitTest(point); | 475 int frame_component = frame_->GetClientView()->NonClientHitTest(point); |
| 476 if (frame_component != HTNOWHERE) | 476 if (frame_component != HTNOWHERE) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 496 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, | 496 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, |
| 497 frame_->GetDelegate()->CanResize()); | 497 frame_->GetDelegate()->CanResize()); |
| 498 // Fall back to the caption if no other component matches. | 498 // Fall back to the caption if no other component matches. |
| 499 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; | 499 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
| 500 } | 500 } |
| 501 | 501 |
| 502 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, | 502 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, |
| 503 gfx::Path* window_mask) { | 503 gfx::Path* window_mask) { |
| 504 DCHECK(window_mask); | 504 DCHECK(window_mask); |
| 505 | 505 |
| 506 if (!browser_view_->CanCurrentlyResize()) | 506 if (frame_->IsMaximized() || frame_->IsFullscreen()) |
| 507 return; | 507 return; |
| 508 | 508 |
| 509 // Redefine the window visible region for the new size. | 509 // Redefine the window visible region for the new size. |
| 510 window_mask->moveTo(0, 3); | 510 window_mask->moveTo(0, 3); |
| 511 window_mask->lineTo(1, 2); | 511 window_mask->lineTo(1, 2); |
| 512 window_mask->lineTo(1, 1); | 512 window_mask->lineTo(1, 1); |
| 513 window_mask->lineTo(2, 1); | 513 window_mask->lineTo(2, 1); |
| 514 window_mask->lineTo(3, 0); | 514 window_mask->lineTo(3, 0); |
| 515 | 515 |
| 516 window_mask->lineTo(SkIntToScalar(size.width() - 3), 0); | 516 window_mask->lineTo(SkIntToScalar(size.width() - 3), 0); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 533 restore_button_->SetState(views::CustomButton::BS_NORMAL); | 533 restore_button_->SetState(views::CustomButton::BS_NORMAL); |
| 534 minimize_button_->SetState(views::CustomButton::BS_NORMAL); | 534 minimize_button_->SetState(views::CustomButton::BS_NORMAL); |
| 535 maximize_button_->SetState(views::CustomButton::BS_NORMAL); | 535 maximize_button_->SetState(views::CustomButton::BS_NORMAL); |
| 536 // The close button isn't affected by this constraint. | 536 // The close button isn't affected by this constraint. |
| 537 } | 537 } |
| 538 | 538 |
| 539 /////////////////////////////////////////////////////////////////////////////// | 539 /////////////////////////////////////////////////////////////////////////////// |
| 540 // OpaqueBrowserFrameView, views::View overrides: | 540 // OpaqueBrowserFrameView, views::View overrides: |
| 541 | 541 |
| 542 void OpaqueBrowserFrameView::Paint(ChromeCanvas* canvas) { | 542 void OpaqueBrowserFrameView::Paint(ChromeCanvas* canvas) { |
| 543 if (browser_view_->IsFullscreen()) | 543 if (frame_->IsFullscreen()) |
| 544 return; // Nothing is visible, so don't bother to paint. | 544 return; // Nothing is visible, so don't bother to paint. |
| 545 | 545 |
| 546 if (frame_->IsMaximized()) | 546 if (frame_->IsMaximized()) |
| 547 PaintMaximizedFrameBorder(canvas); | 547 PaintMaximizedFrameBorder(canvas); |
| 548 else | 548 else |
| 549 PaintRestoredFrameBorder(canvas); | 549 PaintRestoredFrameBorder(canvas); |
| 550 PaintDistributorLogo(canvas); | 550 PaintDistributorLogo(canvas); |
| 551 PaintTitleBar(canvas); | 551 PaintTitleBar(canvas); |
| 552 PaintToolbarBackground(canvas); | 552 PaintToolbarBackground(canvas); |
| 553 PaintOTRAvatar(canvas); | 553 PaintOTRAvatar(canvas); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 } | 640 } |
| 641 | 641 |
| 642 SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() { | 642 SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() { |
| 643 return frame_->GetDelegate()->GetWindowIcon(); | 643 return frame_->GetDelegate()->GetWindowIcon(); |
| 644 } | 644 } |
| 645 | 645 |
| 646 /////////////////////////////////////////////////////////////////////////////// | 646 /////////////////////////////////////////////////////////////////////////////// |
| 647 // OpaqueBrowserFrameView, private: | 647 // OpaqueBrowserFrameView, private: |
| 648 | 648 |
| 649 int OpaqueBrowserFrameView::FrameBorderThickness() const { | 649 int OpaqueBrowserFrameView::FrameBorderThickness() const { |
| 650 return browser_view_->CanCurrentlyResize() ? kFrameBorderThickness : 0; | 650 return (frame_->IsMaximized() || frame_->IsFullscreen()) ? |
| 651 0 : kFrameBorderThickness; |
| 651 } | 652 } |
| 652 | 653 |
| 653 int OpaqueBrowserFrameView::TopResizeHeight() const { | 654 int OpaqueBrowserFrameView::TopResizeHeight() const { |
| 654 return FrameBorderThickness() - kTopResizeAdjust; | 655 return FrameBorderThickness() - kTopResizeAdjust; |
| 655 } | 656 } |
| 656 | 657 |
| 657 int OpaqueBrowserFrameView::NonClientBorderThickness() const { | 658 int OpaqueBrowserFrameView::NonClientBorderThickness() const { |
| 658 // When we fill the screen, we don't show a client edge. | 659 // When we fill the screen, we don't show a client edge. |
| 659 return FrameBorderThickness() + | 660 return FrameBorderThickness() + |
| 660 (browser_view_->CanCurrentlyResize() ? kClientEdgeThickness : 0); | 661 ((frame_->IsMaximized() || frame_->IsFullscreen()) ? |
| 662 0 : kClientEdgeThickness); |
| 661 } | 663 } |
| 662 | 664 |
| 663 int OpaqueBrowserFrameView::NonClientTopBorderHeight() const { | 665 int OpaqueBrowserFrameView::NonClientTopBorderHeight() const { |
| 664 if (frame_->GetDelegate()->ShouldShowWindowTitle()) { | 666 if (frame_->GetDelegate()->ShouldShowWindowTitle()) { |
| 665 int title_top_spacing, title_thickness; | 667 int title_top_spacing, title_thickness; |
| 666 return TitleCoordinates(&title_top_spacing, &title_thickness); | 668 return TitleCoordinates(&title_top_spacing, &title_thickness); |
| 667 } | 669 } |
| 668 | 670 |
| 669 return FrameBorderThickness() + (browser_view_->CanCurrentlyResize() ? | 671 return FrameBorderThickness() + |
| 670 kNonClientRestoredExtraThickness : 0); | 672 ((frame_->IsMaximized() || frame_->IsFullscreen()) ? |
| 673 0 : kNonClientRestoredExtraThickness); |
| 671 } | 674 } |
| 672 | 675 |
| 673 int OpaqueBrowserFrameView::UnavailablePixelsAtBottomOfNonClientHeight() const { | 676 int OpaqueBrowserFrameView::UnavailablePixelsAtBottomOfNonClientHeight() const { |
| 674 // Tricky: When a toolbar is edging the titlebar, it not only draws its own | 677 // Tricky: When a toolbar is edging the titlebar, it not only draws its own |
| 675 // shadow and client edge, but an extra, light "shadow" pixel as well, which | 678 // shadow and client edge, but an extra, light "shadow" pixel as well, which |
| 676 // is treated as available space. Thus the nonclient area actually _fails_ to | 679 // is treated as available space. Thus the nonclient area actually _fails_ to |
| 677 // include some available pixels, leading to a negative number here. | 680 // include some available pixels, leading to a negative number here. |
| 678 if (browser_view_->IsToolbarVisible()) | 681 if (browser_view_->IsToolbarVisible()) |
| 679 return -kFrameShadowThickness; | 682 return -kFrameShadowThickness; |
| 680 | 683 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 } | 1057 } |
| 1055 | 1058 |
| 1056 // static | 1059 // static |
| 1057 void OpaqueBrowserFrameView::InitAppWindowResources() { | 1060 void OpaqueBrowserFrameView::InitAppWindowResources() { |
| 1058 static bool initialized = false; | 1061 static bool initialized = false; |
| 1059 if (!initialized) { | 1062 if (!initialized) { |
| 1060 title_font_ = win_util::GetWindowTitleFont(); | 1063 title_font_ = win_util::GetWindowTitleFont(); |
| 1061 initialized = true; | 1064 initialized = true; |
| 1062 } | 1065 } |
| 1063 } | 1066 } |
| OLD | NEW |