| 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 | |
| 100 const int size = bubble_border_->GetBorderThickness() + 4; | 97 const int size = bubble_border_->GetBorderThickness() + 4; |
| 101 const int hit = GetHTComponentForFrame(point, size, size, size, size, true); | 98 const int sizes = GetHTComponentForFrame(point, size, size, size, size, true); |
| 102 if (hit == HTNOWHERE && point.y() < title_->bounds().bottom()) | 99 if (GetWidget()->widget_delegate()->CanResize() && sizes != HTNOWHERE) |
| 100 return sizes; |
| 101 // Allow dialogs with bubble frames to be dragged and show the system menu. |
| 102 const int move = std::max(title_->bounds().bottom(), size + 4); |
| 103 if (GetWidget()->widget_delegate()->AsDialogDelegate() != NULL && |
| 104 GetHTComponentForFrame(point, move, move, move, move, true) != HTNOWHERE) |
| 103 return HTCAPTION; | 105 return HTCAPTION; |
| 104 return hit; | 106 return GetWidget()->client_view()->NonClientHitTest(point); |
| 105 } | 107 } |
| 106 | 108 |
| 107 void BubbleFrameView::GetWindowMask(const gfx::Size& size, | 109 void BubbleFrameView::GetWindowMask(const gfx::Size& size, |
| 108 gfx::Path* window_mask) { | 110 gfx::Path* window_mask) { |
| 109 if (bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER) | 111 if (bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER) |
| 110 return; | 112 return; |
| 111 | 113 |
| 112 // Use a window mask roughly matching the border in the image assets. | 114 // Use a window mask roughly matching the border in the image assets. |
| 113 static const int kBorderStrokeSize = 1; | 115 static const int kBorderStrokeSize = 1; |
| 114 static const SkScalar kCornerRadius = SkIntToScalar(6); | 116 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 | 306 // |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 | 307 // 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. | 308 // to the left, and that means negative offset. |
| 307 bubble_border_->set_arrow_offset( | 309 bubble_border_->set_arrow_offset( |
| 308 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); | 310 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); |
| 309 if (offscreen_adjust) | 311 if (offscreen_adjust) |
| 310 SchedulePaint(); | 312 SchedulePaint(); |
| 311 } | 313 } |
| 312 | 314 |
| 313 } // namespace views | 315 } // namespace views |
| OLD | NEW |