| 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" |
| 11 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
| 12 #include "ui/gfx/path.h" | |
| 13 #include "ui/gfx/screen.h" | 12 #include "ui/gfx/screen.h" |
| 14 #include "ui/views/bubble/bubble_border.h" | 13 #include "ui/views/bubble/bubble_border.h" |
| 15 #include "ui/views/controls/button/label_button.h" | 14 #include "ui/views/controls/button/label_button.h" |
| 16 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 17 #include "ui/views/window/client_view.h" | 16 #include "ui/views/window/client_view.h" |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 // Insets, in pixels, for the title view, when it exists. | 20 // Insets, in pixels, for the title view, when it exists. |
| 22 const int kTitleTopInset = 19; | 21 const int kTitleTopInset = 19; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 89 |
| 91 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { | 90 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { |
| 92 if (close_->visible() && close_->GetMirroredBounds().Contains(point)) | 91 if (close_->visible() && close_->GetMirroredBounds().Contains(point)) |
| 93 return HTCLOSE; | 92 return HTCLOSE; |
| 94 if (can_drag_ && point.y() < GetInsets().top()) | 93 if (can_drag_ && point.y() < GetInsets().top()) |
| 95 return HTCAPTION; | 94 return HTCAPTION; |
| 96 return GetWidget()->client_view()->NonClientHitTest(point); | 95 return GetWidget()->client_view()->NonClientHitTest(point); |
| 97 } | 96 } |
| 98 | 97 |
| 99 void BubbleFrameView::GetWindowMask(const gfx::Size& size, | 98 void BubbleFrameView::GetWindowMask(const gfx::Size& size, |
| 100 gfx::Path* window_mask) { | 99 gfx::Path* window_mask) {} |
| 101 if (bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER) | |
| 102 return; | |
| 103 | |
| 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; | |
| 108 | |
| 109 gfx::Insets border_insets = bubble_border_->GetInsets(); | |
| 110 SkRect rect = {border_insets.left() - kBorderStrokeSize, | |
| 111 border_insets.top() - kBorderStrokeSize, | |
| 112 size.width() - border_insets.right() + kBorderStrokeSize, | |
| 113 size.height() - border_insets.bottom() + kBorderStrokeSize}; | |
| 114 | |
| 115 // Approximate rounded corners matching the border. | |
| 116 SkPoint polygon[] = { | |
| 117 {rect.left() + 2, rect.top()}, | |
| 118 {rect.left() + 1, rect.top() + 1}, | |
| 119 {rect.left(), rect.top() + 2}, | |
| 120 | |
| 121 {rect.left(), rect.bottom() - 3}, | |
| 122 {rect.left() + 1, rect.bottom() - 2}, | |
| 123 {rect.left() + 2, rect.bottom()}, | |
| 124 | |
| 125 {rect.right() - 3, rect.bottom()}, | |
| 126 {rect.right() - 1, rect.bottom() - 2}, | |
| 127 {rect.right(), rect.bottom() - 3}, | |
| 128 | |
| 129 {rect.right(), rect.top() + 2}, | |
| 130 {rect.right() - 1, rect.top() + 1}, | |
| 131 {rect.right() - 2, rect.top()} | |
| 132 }; | |
| 133 | |
| 134 window_mask->addPoly(polygon, sizeof(polygon)/sizeof(polygon[0]), true); | |
| 135 } | |
| 136 | 100 |
| 137 void BubbleFrameView::ResetWindowControls() {} | 101 void BubbleFrameView::ResetWindowControls() {} |
| 138 | 102 |
| 139 void BubbleFrameView::UpdateWindowIcon() {} | 103 void BubbleFrameView::UpdateWindowIcon() {} |
| 140 | 104 |
| 141 void BubbleFrameView::UpdateWindowTitle() {} | 105 void BubbleFrameView::UpdateWindowTitle() {} |
| 142 | 106 |
| 143 gfx::Insets BubbleFrameView::GetInsets() const { | 107 gfx::Insets BubbleFrameView::GetInsets() const { |
| 144 gfx::Insets insets = content_margins_; | 108 gfx::Insets insets = content_margins_; |
| 145 insets += gfx::Insets( | 109 insets += gfx::Insets( |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble | 268 // |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 | 269 // 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. | 270 // to the left, and that means negative offset. |
| 307 bubble_border_->set_arrow_offset( | 271 bubble_border_->set_arrow_offset( |
| 308 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); | 272 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); |
| 309 if (offscreen_adjust) | 273 if (offscreen_adjust) |
| 310 SchedulePaint(); | 274 SchedulePaint(); |
| 311 } | 275 } |
| 312 | 276 |
| 313 } // namespace views | 277 } // namespace views |
| OLD | NEW |