| 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 121 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_->window_delegate()->GetWindowIcon(); | 643 return frame_->window_delegate()->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 if (browser_view_->IsFullscreen()) | 650 return browser_view_->CanCurrentlyResize() ? kFrameBorderThickness : 0; |
| 651 return 0; | |
| 652 return frame_->IsMaximized() ? | |
| 653 GetSystemMetrics(SM_CXSIZEFRAME) : kFrameBorderThickness; | |
| 654 } | 651 } |
| 655 | 652 |
| 656 int OpaqueBrowserFrameView::TopResizeHeight() const { | 653 int OpaqueBrowserFrameView::TopResizeHeight() const { |
| 657 return FrameBorderThickness() - kTopResizeAdjust; | 654 return FrameBorderThickness() - kTopResizeAdjust; |
| 658 } | 655 } |
| 659 | 656 |
| 660 int OpaqueBrowserFrameView::NonClientBorderThickness() const { | 657 int OpaqueBrowserFrameView::NonClientBorderThickness() const { |
| 661 // When we fill the screen, we don't show a client edge. | 658 // When we fill the screen, we don't show a client edge. |
| 662 return FrameBorderThickness() + | 659 return FrameBorderThickness() + |
| 663 (browser_view_->CanCurrentlyResize() ? kClientEdgeThickness : 0); | 660 (browser_view_->CanCurrentlyResize() ? kClientEdgeThickness : 0); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 // drawn flush with the screen edge, they still obey Fitts' Law. | 908 // drawn flush with the screen edge, they still obey Fitts' Law. |
| 912 bool is_maximized = frame_->IsMaximized(); | 909 bool is_maximized = frame_->IsMaximized(); |
| 913 int frame_thickness = FrameBorderThickness(); | 910 int frame_thickness = FrameBorderThickness(); |
| 914 int caption_y = is_maximized ? frame_thickness : kCaptionTopSpacing; | 911 int caption_y = is_maximized ? frame_thickness : kCaptionTopSpacing; |
| 915 int top_extra_height = is_maximized ? kCaptionTopSpacing : 0; | 912 int top_extra_height = is_maximized ? kCaptionTopSpacing : 0; |
| 916 // There should always be the same number of non-shadow pixels visible to the | 913 // There should always be the same number of non-shadow pixels visible to the |
| 917 // side of the caption buttons. In maximized mode we extend the rightmost | 914 // side of the caption buttons. In maximized mode we extend the rightmost |
| 918 // button to the screen corner to obey Fitts' Law. | 915 // button to the screen corner to obey Fitts' Law. |
| 919 int right_extra_width = is_maximized ? | 916 int right_extra_width = is_maximized ? |
| 920 (kFrameBorderThickness - kFrameShadowThickness) : 0; | 917 (kFrameBorderThickness - kFrameShadowThickness) : 0; |
| 921 int right_spacing = is_maximized ? | |
| 922 (GetSystemMetrics(SM_CXSIZEFRAME) + right_extra_width) : frame_thickness; | |
| 923 gfx::Size close_button_size = close_button_->GetPreferredSize(); | 918 gfx::Size close_button_size = close_button_->GetPreferredSize(); |
| 924 close_button_->SetBounds(width() - close_button_size.width() - right_spacing, | 919 close_button_->SetBounds(width() - close_button_size.width() - |
| 925 caption_y, | 920 right_extra_width - frame_thickness, caption_y, |
| 926 close_button_size.width() + right_extra_width, | 921 close_button_size.width() + right_extra_width, |
| 927 close_button_size.height() + top_extra_height); | 922 close_button_size.height() + top_extra_height); |
| 928 | 923 |
| 929 // When the window is restored, we show a maximized button; otherwise, we show | 924 // When the window is restored, we show a maximized button; otherwise, we show |
| 930 // a restore button. | 925 // a restore button. |
| 931 bool is_restored = !is_maximized && !frame_->IsMinimized(); | 926 bool is_restored = !is_maximized && !frame_->IsMinimized(); |
| 932 views::Button* invisible_button = is_restored ? | 927 views::Button* invisible_button = is_restored ? |
| 933 restore_button_ : maximize_button_; | 928 restore_button_ : maximize_button_; |
| 934 invisible_button->SetVisible(false); | 929 invisible_button->SetVisible(false); |
| 935 | 930 |
| 936 views::Button* visible_button = is_restored ? | 931 views::Button* visible_button = is_restored ? |
| 937 maximize_button_ : restore_button_; | 932 maximize_button_ : restore_button_; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 } | 1053 } |
| 1059 | 1054 |
| 1060 // static | 1055 // static |
| 1061 void OpaqueBrowserFrameView::InitAppWindowResources() { | 1056 void OpaqueBrowserFrameView::InitAppWindowResources() { |
| 1062 static bool initialized = false; | 1057 static bool initialized = false; |
| 1063 if (!initialized) { | 1058 if (!initialized) { |
| 1064 title_font_ = win_util::GetWindowTitleFont(); | 1059 title_font_ = win_util::GetWindowTitleFont(); |
| 1065 initialized = true; | 1060 initialized = true; |
| 1066 } | 1061 } |
| 1067 } | 1062 } |
| OLD | NEW |