OLD | NEW |
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 "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #include "ui/views/window/window_shape.h" | 54 #include "ui/views/window/window_shape.h" |
55 | 55 |
56 #if defined(OS_LINUX) | 56 #if defined(OS_LINUX) |
57 #include "ui/views/controls/menu/menu_runner.h" | 57 #include "ui/views/controls/menu/menu_runner.h" |
58 #endif | 58 #endif |
59 | 59 |
60 using content::WebContents; | 60 using content::WebContents; |
61 | 61 |
62 namespace { | 62 namespace { |
63 | 63 |
64 // While resize areas on Windows are normally the same size as the window | |
65 // borders, our top area is shrunk by 1 px to make it easier to move the window | |
66 // around with our thinner top grabbable strip. (Incidentally, our side and | |
67 // bottom resize areas don't match the frame border thickness either -- they | |
68 // span the whole nonclient area, so there's no "dead zone" for the mouse.) | |
69 const int kTopResizeAdjust = 1; | |
70 | |
71 // In the window corners, the resize areas don't actually expand bigger, but the | 64 // In the window corners, the resize areas don't actually expand bigger, but the |
72 // 16 px at the end of each edge triggers diagonal resizing. | 65 // 16 px at the end of each edge triggers diagonal resizing. |
73 const int kResizeAreaCornerSize = 16; | 66 const int kResizeAreaCornerSize = 16; |
74 | 67 |
75 // The content edge images have a shadow built into them. | 68 // The content edge images have a shadow built into them. |
76 const int kContentEdgeShadowThickness = 2; | 69 const int kContentEdgeShadowThickness = 2; |
77 | 70 |
78 #if !defined(OS_WIN) | 71 #if !defined(OS_WIN) |
79 // The icon never shrinks below 16 px on a side. | 72 // The icon never shrinks below 16 px on a side. |
80 const int kIconMinimumSize = 16; | 73 const int kIconMinimumSize = 16; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 return HTMAXBUTTON; | 239 return HTMAXBUTTON; |
247 if (minimize_button_ && minimize_button_->visible() && | 240 if (minimize_button_ && minimize_button_->visible() && |
248 minimize_button_->GetMirroredBounds().Contains(point)) | 241 minimize_button_->GetMirroredBounds().Contains(point)) |
249 return HTMINBUTTON; | 242 return HTMINBUTTON; |
250 | 243 |
251 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 244 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
252 if (!delegate) { | 245 if (!delegate) { |
253 LOG(WARNING) << "delegate is null, returning safe default."; | 246 LOG(WARNING) << "delegate is null, returning safe default."; |
254 return HTCAPTION; | 247 return HTCAPTION; |
255 } | 248 } |
256 int window_component = GetHTComponentForFrame(point, TopResizeHeight(), | 249 int window_component = GetHTComponentForFrame( |
257 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, | 250 point, FrameBorderThickness(false), NonClientBorderThickness(), |
258 delegate->CanResize()); | 251 kResizeAreaCornerSize, kResizeAreaCornerSize, delegate->CanResize()); |
259 // Fall back to the caption if no other component matches. | 252 // Fall back to the caption if no other component matches. |
260 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; | 253 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
261 } | 254 } |
262 | 255 |
263 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, | 256 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, |
264 gfx::Path* window_mask) { | 257 gfx::Path* window_mask) { |
265 DCHECK(window_mask); | 258 DCHECK(window_mask); |
266 | 259 |
267 if (layout_->IsTitleBarCondensed() || frame()->IsFullscreen()) | 260 if (layout_->IsTitleBarCondensed() || frame()->IsFullscreen()) |
268 return; | 261 return; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 l10n_util::GetStringUTF16(accessibility_string_id)); | 541 l10n_util::GetStringUTF16(accessibility_string_id)); |
549 button->set_id(view_id); | 542 button->set_id(view_id); |
550 AddChildView(button); | 543 AddChildView(button); |
551 return button; | 544 return button; |
552 } | 545 } |
553 | 546 |
554 int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const { | 547 int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const { |
555 return layout_->FrameBorderThickness(restored); | 548 return layout_->FrameBorderThickness(restored); |
556 } | 549 } |
557 | 550 |
558 int OpaqueBrowserFrameView::TopResizeHeight() const { | |
559 return FrameBorderThickness(false) - kTopResizeAdjust; | |
560 } | |
561 | |
562 int OpaqueBrowserFrameView::NonClientBorderThickness() const { | 551 int OpaqueBrowserFrameView::NonClientBorderThickness() const { |
563 return layout_->NonClientBorderThickness(); | 552 return layout_->NonClientBorderThickness(); |
564 } | 553 } |
565 | 554 |
566 gfx::Rect OpaqueBrowserFrameView::IconBounds() const { | 555 gfx::Rect OpaqueBrowserFrameView::IconBounds() const { |
567 return layout_->IconBounds(); | 556 return layout_->IconBounds(); |
568 } | 557 } |
569 | 558 |
570 bool OpaqueBrowserFrameView::ShouldShowWindowTitleBar() const { | 559 bool OpaqueBrowserFrameView::ShouldShowWindowTitleBar() const { |
571 // Do not show the custom title bar if the system title bar option is enabled. | 560 // Do not show the custom title bar if the system title bar option is enabled. |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 SkColor color, | 809 SkColor color, |
821 gfx::Canvas* canvas) const { | 810 gfx::Canvas* canvas) const { |
822 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness, | 811 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness, |
823 bottom + kClientEdgeThickness - y); | 812 bottom + kClientEdgeThickness - y); |
824 canvas->FillRect(side, color); | 813 canvas->FillRect(side, color); |
825 canvas->FillRect(gfx::Rect(x, bottom, right - x, kClientEdgeThickness), | 814 canvas->FillRect(gfx::Rect(x, bottom, right - x, kClientEdgeThickness), |
826 color); | 815 color); |
827 side.set_x(right); | 816 side.set_x(right); |
828 canvas->FillRect(side, color); | 817 canvas->FillRect(side, color); |
829 } | 818 } |
OLD | NEW |