| 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 "ui/views/bubble/bubble_frame_view.h" | 5 #include "ui/views/bubble/bubble_frame_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
| 10 #include "ui/base/hit_test.h" | 10 #include "ui/base/hit_test.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 const gfx::Rect& client_bounds) const { | 87 const gfx::Rect& client_bounds) const { |
| 88 return const_cast<BubbleFrameView*>(this)->GetUpdatedWindowBounds( | 88 return const_cast<BubbleFrameView*>(this)->GetUpdatedWindowBounds( |
| 89 gfx::Rect(), client_bounds.size(), false); | 89 gfx::Rect(), client_bounds.size(), false); |
| 90 } | 90 } |
| 91 | 91 |
| 92 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { | 92 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { |
| 93 if (!bounds().Contains(point)) | 93 if (!bounds().Contains(point)) |
| 94 return HTNOWHERE; | 94 return HTNOWHERE; |
| 95 if (close_->visible() && close_->GetMirroredBounds().Contains(point)) | 95 if (close_->visible() && close_->GetMirroredBounds().Contains(point)) |
| 96 return HTCLOSE; | 96 return HTCLOSE; |
| 97 if (!GetWidget()->widget_delegate()->CanResize()) | |
| 98 return GetWidget()->client_view()->NonClientHitTest(point); | |
| 99 | 97 |
| 100 const int size = bubble_border_->GetBorderThickness() + 4; | 98 // Allow dialogs to be resized, dragged, and to show the system menu. |
| 101 const int hit = GetHTComponentForFrame(point, size, size, size, size, true); | 99 if (GetWidget()->widget_delegate()->AsDialogDelegate()) { |
| 102 if (hit == HTNOWHERE && point.y() < title_->bounds().bottom()) | 100 const int size = bubble_border_->GetBorderThickness() + 4; |
| 103 return HTCAPTION; | 101 int sizes = GetHTComponentForFrame(point, size, size, size, size, true); |
| 104 return hit; | 102 if (GetWidget()->widget_delegate()->CanResize() && sizes != HTNOWHERE) |
| 103 return sizes; |
| 104 gfx::Rect sys_rect(0, 0, title_->x(), title_->y()); |
| 105 sys_rect.set_origin(gfx::Point(GetMirroredXForRect(sys_rect), 0)); |
| 106 if (sys_rect.Contains(point)) |
| 107 return HTSYSMENU; |
| 108 const int move = std::max(title_->bounds().bottom(), size + 4); |
| 109 int moves = GetHTComponentForFrame(point, move, move, move, move, true); |
| 110 if (moves != HTNOWHERE) |
| 111 return HTCAPTION; |
| 112 } |
| 113 |
| 114 return GetWidget()->client_view()->NonClientHitTest(point); |
| 105 } | 115 } |
| 106 | 116 |
| 107 void BubbleFrameView::GetWindowMask(const gfx::Size& size, | 117 void BubbleFrameView::GetWindowMask(const gfx::Size& size, |
| 108 gfx::Path* window_mask) { | 118 gfx::Path* window_mask) { |
| 109 if (bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER) | 119 if (bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER) |
| 110 return; | 120 return; |
| 111 | 121 |
| 112 // Use a window mask roughly matching the border in the image assets. | 122 // Use a window mask roughly matching the border in the image assets. |
| 113 static const int kBorderStrokeSize = 1; | 123 static const int kBorderStrokeSize = 1; |
| 114 static const SkScalar kCornerRadius = SkIntToScalar(6); | 124 static const SkScalar kCornerRadius = SkIntToScalar(6); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble | 314 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble |
| 305 // window needs to be moved to the right and that means we need to move arrow | 315 // window needs to be moved to the right and that means we need to move arrow |
| 306 // to the left, and that means negative offset. | 316 // to the left, and that means negative offset. |
| 307 bubble_border_->set_arrow_offset( | 317 bubble_border_->set_arrow_offset( |
| 308 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); | 318 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); |
| 309 if (offscreen_adjust) | 319 if (offscreen_adjust) |
| 310 SchedulePaint(); | 320 SchedulePaint(); |
| 311 } | 321 } |
| 312 | 322 |
| 313 } // namespace views | 323 } // namespace views |
| OLD | NEW |