| 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, | 498 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, |
| 499 frame_->window_delegate()->CanResize()); | 499 frame_->window_delegate()->CanResize()); |
| 500 // Fall back to the caption if no other component matches. | 500 // Fall back to the caption if no other component matches. |
| 501 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; | 501 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
| 502 } | 502 } |
| 503 | 503 |
| 504 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, | 504 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, |
| 505 gfx::Path* window_mask) { | 505 gfx::Path* window_mask) { |
| 506 DCHECK(window_mask); | 506 DCHECK(window_mask); |
| 507 | 507 |
| 508 if (browser_view_->IsFullscreen()) | 508 if (!browser_view_->CanCurrentlyResize()) |
| 509 return; | 509 return; |
| 510 | 510 |
| 511 // Redefine the window visible region for the new size. | 511 // Redefine the window visible region for the new size. |
| 512 window_mask->moveTo(0, 3); | 512 window_mask->moveTo(0, 3); |
| 513 window_mask->lineTo(1, 2); | 513 window_mask->lineTo(1, 2); |
| 514 window_mask->lineTo(1, 1); | 514 window_mask->lineTo(1, 1); |
| 515 window_mask->lineTo(2, 1); | 515 window_mask->lineTo(2, 1); |
| 516 window_mask->lineTo(3, 0); | 516 window_mask->lineTo(3, 0); |
| 517 | 517 |
| 518 window_mask->lineTo(SkIntToScalar(size.width() - 3), 0); | 518 window_mask->lineTo(SkIntToScalar(size.width() - 3), 0); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 } | 642 } |
| 643 | 643 |
| 644 SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() { | 644 SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() { |
| 645 return frame_->window_delegate()->GetWindowIcon(); | 645 return frame_->window_delegate()->GetWindowIcon(); |
| 646 } | 646 } |
| 647 | 647 |
| 648 /////////////////////////////////////////////////////////////////////////////// | 648 /////////////////////////////////////////////////////////////////////////////// |
| 649 // OpaqueBrowserFrameView, private: | 649 // OpaqueBrowserFrameView, private: |
| 650 | 650 |
| 651 int OpaqueBrowserFrameView::FrameBorderThickness() const { | 651 int OpaqueBrowserFrameView::FrameBorderThickness() const { |
| 652 if (browser_view_->IsFullscreen()) | 652 return browser_view_->CanCurrentlyResize() ? kFrameBorderThickness : 0; |
| 653 return 0; | |
| 654 return frame_->IsMaximized() ? | |
| 655 GetSystemMetrics(SM_CXSIZEFRAME) : kFrameBorderThickness; | |
| 656 } | 653 } |
| 657 | 654 |
| 658 int OpaqueBrowserFrameView::TopResizeHeight() const { | 655 int OpaqueBrowserFrameView::TopResizeHeight() const { |
| 659 return FrameBorderThickness() - kTopResizeAdjust; | 656 return FrameBorderThickness() - kTopResizeAdjust; |
| 660 } | 657 } |
| 661 | 658 |
| 662 int OpaqueBrowserFrameView::NonClientBorderThickness() const { | 659 int OpaqueBrowserFrameView::NonClientBorderThickness() const { |
| 663 // When we fill the screen, we don't show a client edge. | 660 // When we fill the screen, we don't show a client edge. |
| 664 return FrameBorderThickness() + | 661 return FrameBorderThickness() + |
| 665 (browser_view_->CanCurrentlyResize() ? kClientEdgeThickness : 0); | 662 (browser_view_->CanCurrentlyResize() ? kClientEdgeThickness : 0); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 // drawn flush with the screen edge, they still obey Fitts' Law. | 910 // drawn flush with the screen edge, they still obey Fitts' Law. |
| 914 bool is_maximized = frame_->IsMaximized(); | 911 bool is_maximized = frame_->IsMaximized(); |
| 915 int frame_thickness = FrameBorderThickness(); | 912 int frame_thickness = FrameBorderThickness(); |
| 916 int caption_y = is_maximized ? frame_thickness : kCaptionTopSpacing; | 913 int caption_y = is_maximized ? frame_thickness : kCaptionTopSpacing; |
| 917 int top_extra_height = is_maximized ? kCaptionTopSpacing : 0; | 914 int top_extra_height = is_maximized ? kCaptionTopSpacing : 0; |
| 918 // There should always be the same number of non-shadow pixels visible to the | 915 // There should always be the same number of non-shadow pixels visible to the |
| 919 // side of the caption buttons. In maximized mode we extend the rightmost | 916 // side of the caption buttons. In maximized mode we extend the rightmost |
| 920 // button to the screen corner to obey Fitts' Law. | 917 // button to the screen corner to obey Fitts' Law. |
| 921 int right_extra_width = is_maximized ? | 918 int right_extra_width = is_maximized ? |
| 922 (kFrameBorderThickness - kFrameShadowThickness) : 0; | 919 (kFrameBorderThickness - kFrameShadowThickness) : 0; |
| 923 int right_spacing = is_maximized ? | |
| 924 (GetSystemMetrics(SM_CXSIZEFRAME) + right_extra_width) : frame_thickness; | |
| 925 gfx::Size close_button_size = close_button_->GetPreferredSize(); | 920 gfx::Size close_button_size = close_button_->GetPreferredSize(); |
| 926 close_button_->SetBounds(width() - close_button_size.width() - right_spacing, | 921 close_button_->SetBounds(width() - close_button_size.width() - |
| 927 caption_y, | 922 right_extra_width - frame_thickness, caption_y, |
| 928 close_button_size.width() + right_extra_width, | 923 close_button_size.width() + right_extra_width, |
| 929 close_button_size.height() + top_extra_height); | 924 close_button_size.height() + top_extra_height); |
| 930 | 925 |
| 931 // When the window is restored, we show a maximized button; otherwise, we show | 926 // When the window is restored, we show a maximized button; otherwise, we show |
| 932 // a restore button. | 927 // a restore button. |
| 933 bool is_restored = !is_maximized && !frame_->IsMinimized(); | 928 bool is_restored = !is_maximized && !frame_->IsMinimized(); |
| 934 views::Button* invisible_button = is_restored ? | 929 views::Button* invisible_button = is_restored ? |
| 935 restore_button_ : maximize_button_; | 930 restore_button_ : maximize_button_; |
| 936 invisible_button->SetVisible(false); | 931 invisible_button->SetVisible(false); |
| 937 | 932 |
| 938 views::Button* visible_button = is_restored ? | 933 views::Button* visible_button = is_restored ? |
| 939 maximize_button_ : restore_button_; | 934 maximize_button_ : restore_button_; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 } | 1055 } |
| 1061 | 1056 |
| 1062 // static | 1057 // static |
| 1063 void OpaqueBrowserFrameView::InitAppWindowResources() { | 1058 void OpaqueBrowserFrameView::InitAppWindowResources() { |
| 1064 static bool initialized = false; | 1059 static bool initialized = false; |
| 1065 if (!initialized) { | 1060 if (!initialized) { |
| 1066 title_font_ = win_util::GetWindowTitleFont(); | 1061 title_font_ = win_util::GetWindowTitleFont(); |
| 1067 initialized = true; | 1062 initialized = true; |
| 1068 } | 1063 } |
| 1069 } | 1064 } |
| OLD | NEW |