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

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: 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // NOTE: this only provides implementations for the types used by dialogs.
155 if ((bubble_border_->arrow() != BubbleBorder::NONE && 155 bool is_dialog_shadow =
156 bubble_border_->arrow() != BubbleBorder::FLOAT) || 156 bubble_border_->shadow() == BubbleBorder::SMALL_SHADOW ||
157 (bubble_border_->shadow() != BubbleBorder::SMALL_SHADOW && 157 bubble_border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER;
158 bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER)) 158 bool is_arrow_type_ok = bubble_border_->arrow() == BubbleBorder::NONE ||
159 return; 159 bubble_border_->arrow() == BubbleBorder::FLOAT;
160 160
161 // Use a window mask roughly matching the border in the image assets. 161 #if defined(OS_MACOSX)
162 static const int kBorderStrokeSize = 1; 162 // On Mac versions earlier than Yosemite, GetWindowMask() is used to define
163 static const SkScalar kCornerRadius = SkIntToScalar(6); 163 // the window boundary. Hence on Mac, we provide mask for bubbles with arrows.
164 const gfx::Insets border_insets = bubble_border_->GetInsets(); 164 is_arrow_type_ok = true;
165 SkRect rect = { SkIntToScalar(border_insets.left() - kBorderStrokeSize), 165 // On Mac, BubbleBorder::NO_ASSETS is used as the border type for dialogs.
166 SkIntToScalar(border_insets.top() - kBorderStrokeSize), 166 is_dialog_shadow = is_dialog_shadow || BubbleBorder::NO_ASSETS;
167 SkIntToScalar(size.width() - border_insets.right() + 167 #endif // OS_MACOSX
tapted 2016/01/28 05:59:22 What actually needed to change for the bookmark bu
karandeepb 2016/02/04 03:39:28 We also need to return a mask for bubbles with arr
168 kBorderStrokeSize), 168
169 SkIntToScalar(size.height() - border_insets.bottom() + 169 if (is_dialog_shadow && is_arrow_type_ok) {
tapted 2016/01/28 05:59:22 There's a Chrome idiom "prefer early returns" for
karandeepb 2016/02/04 03:39:28 Done.
170 kBorderStrokeSize) }; 170 // Use a window mask roughly matching the border in the image assets.
171 if (bubble_border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER) { 171 const int kBorderStrokeSize =
172 window_mask->addRoundRect(rect, kCornerRadius, kCornerRadius); 172 bubble_border_->shadow() == BubbleBorder::NO_ASSETS ? 0 : 1;
173 } else { 173 const SkScalar kCornerRadius =
174 static const int kBottomBorderShadowSize = 2; 174 SkIntToScalar(bubble_border_->GetBorderCornerRadius());
175 rect.fBottom += SkIntToScalar(kBottomBorderShadowSize); 175 const gfx::Insets border_insets = bubble_border_->GetInsets();
176 window_mask->addRect(rect); 176 SkRect rect = {
177 SkIntToScalar(border_insets.left() - kBorderStrokeSize),
178 SkIntToScalar(border_insets.top() - kBorderStrokeSize),
179 SkIntToScalar(size.width() - border_insets.right() + kBorderStrokeSize),
180 SkIntToScalar(size.height() - border_insets.bottom() +
181 kBorderStrokeSize)};
182
183 if (bubble_border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER ||
184 bubble_border_->shadow() == BubbleBorder::NO_ASSETS) {
185 window_mask->addRoundRect(rect, kCornerRadius, kCornerRadius);
186 } else {
187 static const int kBottomBorderShadowSize = 2;
188 rect.fBottom += SkIntToScalar(kBottomBorderShadowSize);
189 window_mask->addRect(rect);
190 }
191 gfx::Path arrow_mask;
192 bubble_border_->GetArrowMask(gfx::Rect(size), &arrow_mask);
193 window_mask->addPath(arrow_mask, 0, 0);
tapted 2016/01/28 05:59:22 Should GetArrowMask/Path return a bool? (adding an
karandeepb 2016/02/04 03:39:28 Done.
177 } 194 }
178 } 195 }
179 196
180 void BubbleFrameView::ResetWindowControls() { 197 void BubbleFrameView::ResetWindowControls() {
181 close_->SetVisible(GetWidget()->widget_delegate()->ShouldShowCloseButton()); 198 close_->SetVisible(GetWidget()->widget_delegate()->ShouldShowCloseButton());
182 } 199 }
183 200
184 void BubbleFrameView::UpdateWindowIcon() { 201 void BubbleFrameView::UpdateWindowIcon() {
185 gfx::ImageSkia image; 202 gfx::ImageSkia image;
186 if (GetWidget()->widget_delegate()->ShouldShowWindowIcon()) 203 if (GetWidget()->widget_delegate()->ShouldShowWindowIcon())
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 if (titlebar_extra_view_ != NULL) 484 if (titlebar_extra_view_ != NULL)
468 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); 485 title_bar_width += titlebar_extra_view_->GetPreferredSize().width();
469 gfx::Size size(client_size); 486 gfx::Size size(client_size);
470 size.SetToMax(gfx::Size(title_bar_width, 0)); 487 size.SetToMax(gfx::Size(title_bar_width, 0));
471 const gfx::Insets insets(GetInsets()); 488 const gfx::Insets insets(GetInsets());
472 size.Enlarge(insets.width(), insets.height()); 489 size.Enlarge(insets.width(), insets.height());
473 return size; 490 return size;
474 } 491 }
475 492
476 } // namespace views 493 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698