| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 return HTCAPTION; | 95 return HTCAPTION; |
| 96 return GetWidget()->client_view()->NonClientHitTest(point); | 96 return GetWidget()->client_view()->NonClientHitTest(point); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void BubbleFrameView::GetWindowMask(const gfx::Size& size, | 99 void BubbleFrameView::GetWindowMask(const gfx::Size& size, |
| 100 gfx::Path* window_mask) { | 100 gfx::Path* window_mask) { |
| 101 if (bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER) | 101 if (bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER) |
| 102 return; | 102 return; |
| 103 | 103 |
| 104 // Use a window mask roughly matching the border in the image assets. | 104 // Use a window mask roughly matching the border in the image assets. |
| 105 | |
| 106 // Stroke size in pixels of borders in image assets. | |
| 107 static const int kBorderStrokeSize = 1; | 105 static const int kBorderStrokeSize = 1; |
| 108 | 106 static const SkScalar kCornerRadius = SkIntToScalar(6); |
| 109 gfx::Insets border_insets = bubble_border_->GetInsets(); | 107 gfx::Insets border_insets = bubble_border_->GetInsets(); |
| 110 SkRect rect = {SkIntToScalar(border_insets.left() - kBorderStrokeSize), | 108 const SkRect rect = { SkIntToScalar(border_insets.left() - kBorderStrokeSize), |
| 111 SkIntToScalar(border_insets.top() - kBorderStrokeSize), | 109 SkIntToScalar(border_insets.top() - kBorderStrokeSize), |
| 112 SkIntToScalar(size.width() - border_insets.right() + | 110 SkIntToScalar(size.width() - border_insets.right() + |
| 113 kBorderStrokeSize), | 111 kBorderStrokeSize), |
| 114 SkIntToScalar(size.height() - border_insets.bottom() + | 112 SkIntToScalar(size.height() - border_insets.bottom() + |
| 115 kBorderStrokeSize)}; | 113 kBorderStrokeSize) }; |
| 116 | 114 window_mask->addRoundRect(rect, kCornerRadius, kCornerRadius); |
| 117 // Approximate rounded corners matching the border. | |
| 118 SkPoint polygon[] = { | |
| 119 {rect.left() + SkIntToScalar(2), rect.top()}, | |
| 120 {rect.left() + SkIntToScalar(1), rect.top() + SkIntToScalar(1)}, | |
| 121 {rect.left(), rect.top() + SkIntToScalar(2)}, | |
| 122 | |
| 123 {rect.left(), rect.bottom() - SkIntToScalar(3)}, | |
| 124 {rect.left() + SkIntToScalar(1), rect.bottom() - SkIntToScalar(2)}, | |
| 125 {rect.left() + SkIntToScalar(2), rect.bottom()}, | |
| 126 | |
| 127 {rect.right() - SkIntToScalar(3), rect.bottom()}, | |
| 128 {rect.right() - SkIntToScalar(1), rect.bottom() - SkIntToScalar(2)}, | |
| 129 {rect.right(), rect.bottom() - SkIntToScalar(3)}, | |
| 130 | |
| 131 {rect.right(), rect.top() + SkIntToScalar(2)}, | |
| 132 {rect.right() - SkIntToScalar(1), rect.top() + SkIntToScalar(1)}, | |
| 133 {rect.right() - SkIntToScalar(2), rect.top()} | |
| 134 }; | |
| 135 | |
| 136 window_mask->addPoly(polygon, sizeof(polygon)/sizeof(polygon[0]), true); | |
| 137 } | 115 } |
| 138 | 116 |
| 139 void BubbleFrameView::ResetWindowControls() {} | 117 void BubbleFrameView::ResetWindowControls() {} |
| 140 | 118 |
| 141 void BubbleFrameView::UpdateWindowIcon() {} | 119 void BubbleFrameView::UpdateWindowIcon() {} |
| 142 | 120 |
| 143 void BubbleFrameView::UpdateWindowTitle() {} | 121 void BubbleFrameView::UpdateWindowTitle() {} |
| 144 | 122 |
| 145 gfx::Insets BubbleFrameView::GetInsets() const { | 123 gfx::Insets BubbleFrameView::GetInsets() const { |
| 146 gfx::Insets insets = content_margins_; | 124 gfx::Insets insets = content_margins_; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble | 284 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble |
| 307 // window needs to be moved to the right and that means we need to move arrow | 285 // window needs to be moved to the right and that means we need to move arrow |
| 308 // to the left, and that means negative offset. | 286 // to the left, and that means negative offset. |
| 309 bubble_border_->set_arrow_offset( | 287 bubble_border_->set_arrow_offset( |
| 310 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); | 288 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); |
| 311 if (offscreen_adjust) | 289 if (offscreen_adjust) |
| 312 SchedulePaint(); | 290 SchedulePaint(); |
| 313 } | 291 } |
| 314 | 292 |
| 315 } // namespace views | 293 } // namespace views |
| OLD | NEW |