Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: ui/views/bubble/bubble_frame_view.cc

Issue 14742002: Render opaque border with no shadow for web contents modal dialogs under Views/Win32 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing USE_AURA check Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
12 #include "ui/gfx/screen.h" 13 #include "ui/gfx/screen.h"
13 #include "ui/views/bubble/bubble_border.h" 14 #include "ui/views/bubble/bubble_border.h"
14 #include "ui/views/controls/button/label_button.h" 15 #include "ui/views/controls/button/label_button.h"
15 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
16 #include "ui/views/window/client_view.h" 17 #include "ui/views/window/client_view.h"
17 18
18 namespace { 19 namespace {
19 20
20 // Insets, in pixels, for the title view, when it exists. 21 // Insets, in pixels, for the title view, when it exists.
21 const int kTitleTopInset = 19; 22 const int kTitleTopInset = 19;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 90
90 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { 91 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) {
91 if (close_->visible() && close_->GetMirroredBounds().Contains(point)) 92 if (close_->visible() && close_->GetMirroredBounds().Contains(point))
92 return HTCLOSE; 93 return HTCLOSE;
93 if (can_drag_ && point.y() < GetInsets().top()) 94 if (can_drag_ && point.y() < GetInsets().top())
94 return HTCAPTION; 95 return HTCAPTION;
95 return GetWidget()->client_view()->NonClientHitTest(point); 96 return GetWidget()->client_view()->NonClientHitTest(point);
96 } 97 }
97 98
98 void BubbleFrameView::GetWindowMask(const gfx::Size& size, 99 void BubbleFrameView::GetWindowMask(const gfx::Size& size,
99 gfx::Path* window_mask) {} 100 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 }
100 136
101 void BubbleFrameView::ResetWindowControls() {} 137 void BubbleFrameView::ResetWindowControls() {}
102 138
103 void BubbleFrameView::UpdateWindowIcon() {} 139 void BubbleFrameView::UpdateWindowIcon() {}
104 140
105 void BubbleFrameView::UpdateWindowTitle() {} 141 void BubbleFrameView::UpdateWindowTitle() {}
106 142
107 gfx::Insets BubbleFrameView::GetInsets() const { 143 gfx::Insets BubbleFrameView::GetInsets() const {
108 gfx::Insets insets = content_margins_; 144 gfx::Insets insets = content_margins_;
109 insets += gfx::Insets( 145 insets += gfx::Insets(
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble 304 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble
269 // window needs to be moved to the right and that means we need to move arrow 305 // window needs to be moved to the right and that means we need to move arrow
270 // to the left, and that means negative offset. 306 // to the left, and that means negative offset.
271 bubble_border_->set_arrow_offset( 307 bubble_border_->set_arrow_offset(
272 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); 308 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust);
273 if (offscreen_adjust) 309 if (offscreen_adjust)
274 SchedulePaint(); 310 SchedulePaint();
275 } 311 }
276 312
277 } // namespace views 313 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698