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

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

Issue 1633403002: MacViews: Add native drop shadow to dialogs on OSX < 10.10. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Review comments. Added unit tests for NativeWidgetMac::SchedulePaintInRect Created 4 years, 10 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
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 #include <utility> 8 #include <utility>
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 return HTSYSMENU; 144 return HTSYSMENU;
145 if (point.y() < title_->bounds().bottom()) 145 if (point.y() < title_->bounds().bottom())
146 return HTCAPTION; 146 return HTCAPTION;
147 } 147 }
148 148
149 return GetWidget()->client_view()->NonClientHitTest(point); 149 return GetWidget()->client_view()->NonClientHitTest(point);
150 } 150 }
151 151
152 void BubbleFrameView::GetWindowMask(const gfx::Size& size, 152 void BubbleFrameView::GetWindowMask(const gfx::Size& size,
153 gfx::Path* window_mask) { 153 gfx::Path* window_mask) {
154 // NOTE: this only provides implementations for the types used by dialogs. 154 if (bubble_border_->shadow() != BubbleBorder::SMALL_SHADOW &&
155 if ((bubble_border_->arrow() != BubbleBorder::NONE && 155 bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER &&
156 bubble_border_->arrow() != BubbleBorder::FLOAT) || 156 bubble_border_->shadow() != BubbleBorder::NO_ASSETS)
157 (bubble_border_->shadow() != BubbleBorder::SMALL_SHADOW && 157 return;
158 bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER)) 158
159 // We don't return a mask for windows with arrows unless they use
160 // BubbleBorder::NO_ASSETS.
161 if (bubble_border_->shadow() != BubbleBorder::NO_ASSETS &&
162 bubble_border_->arrow() != BubbleBorder::NONE &&
163 bubble_border_->arrow() != BubbleBorder::FLOAT)
159 return; 164 return;
160 165
161 // Use a window mask roughly matching the border in the image assets. 166 // Use a window mask roughly matching the border in the image assets.
162 static const int kBorderStrokeSize = 1; 167 const int kBorderStrokeSize =
163 static const SkScalar kCornerRadius = SkIntToScalar(6); 168 bubble_border_->shadow() == BubbleBorder::NO_ASSETS ? 0 : 1;
169 const SkScalar kCornerRadius =
170 SkIntToScalar(bubble_border_->GetBorderCornerRadius());
164 const gfx::Insets border_insets = bubble_border_->GetInsets(); 171 const gfx::Insets border_insets = bubble_border_->GetInsets();
165 SkRect rect = { SkIntToScalar(border_insets.left() - kBorderStrokeSize), 172 SkRect rect = {
166 SkIntToScalar(border_insets.top() - kBorderStrokeSize), 173 SkIntToScalar(border_insets.left() - kBorderStrokeSize),
167 SkIntToScalar(size.width() - border_insets.right() + 174 SkIntToScalar(border_insets.top() - kBorderStrokeSize),
168 kBorderStrokeSize), 175 SkIntToScalar(size.width() - border_insets.right() + kBorderStrokeSize),
169 SkIntToScalar(size.height() - border_insets.bottom() + 176 SkIntToScalar(size.height() - border_insets.bottom() +
170 kBorderStrokeSize) }; 177 kBorderStrokeSize)};
171 if (bubble_border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER) { 178
179 if (bubble_border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER ||
180 bubble_border_->shadow() == BubbleBorder::NO_ASSETS) {
172 window_mask->addRoundRect(rect, kCornerRadius, kCornerRadius); 181 window_mask->addRoundRect(rect, kCornerRadius, kCornerRadius);
173 } else { 182 } else {
174 static const int kBottomBorderShadowSize = 2; 183 static const int kBottomBorderShadowSize = 2;
175 rect.fBottom += SkIntToScalar(kBottomBorderShadowSize); 184 rect.fBottom += SkIntToScalar(kBottomBorderShadowSize);
176 window_mask->addRect(rect); 185 window_mask->addRect(rect);
177 } 186 }
187 gfx::Path arrow_path;
188 if (bubble_border_->GetArrowPath(gfx::Rect(size), &arrow_path))
189 window_mask->addPath(arrow_path, 0, 0);
178 } 190 }
179 191
180 void BubbleFrameView::ResetWindowControls() { 192 void BubbleFrameView::ResetWindowControls() {
181 close_->SetVisible(GetWidget()->widget_delegate()->ShouldShowCloseButton()); 193 close_->SetVisible(GetWidget()->widget_delegate()->ShouldShowCloseButton());
182 } 194 }
183 195
184 void BubbleFrameView::UpdateWindowIcon() { 196 void BubbleFrameView::UpdateWindowIcon() {
185 gfx::ImageSkia image; 197 gfx::ImageSkia image;
186 if (GetWidget()->widget_delegate()->ShouldShowWindowIcon()) 198 if (GetWidget()->widget_delegate()->ShouldShowWindowIcon())
187 image = GetWidget()->widget_delegate()->GetWindowIcon(); 199 image = GetWidget()->widget_delegate()->GetWindowIcon();
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 if (titlebar_extra_view_ != NULL) 479 if (titlebar_extra_view_ != NULL)
468 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); 480 title_bar_width += titlebar_extra_view_->GetPreferredSize().width();
469 gfx::Size size(client_size); 481 gfx::Size size(client_size);
470 size.SetToMax(gfx::Size(title_bar_width, 0)); 482 size.SetToMax(gfx::Size(title_bar_width, 0));
471 const gfx::Insets insets(GetInsets()); 483 const gfx::Insets insets(GetInsets());
472 size.Enlarge(insets.width(), insets.height()); 484 size.Enlarge(insets.width(), insets.height());
473 return size; 485 return size;
474 } 486 }
475 487
476 } // namespace views 488 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698