| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 return HTSYSMENU; | 148 return HTSYSMENU; |
| 149 if (point.y() < title_->bounds().bottom()) | 149 if (point.y() < title_->bounds().bottom()) |
| 150 return HTCAPTION; | 150 return HTCAPTION; |
| 151 } | 151 } |
| 152 | 152 |
| 153 return GetWidget()->client_view()->NonClientHitTest(point); | 153 return GetWidget()->client_view()->NonClientHitTest(point); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void BubbleFrameView::GetWindowMask(const gfx::Size& size, | 156 void BubbleFrameView::GetWindowMask(const gfx::Size& size, |
| 157 gfx::Path* window_mask) { | 157 gfx::Path* window_mask) { |
| 158 // NOTE: this only provides implementations for the types used by dialogs. | 158 if (bubble_border_->shadow() != BubbleBorder::SMALL_SHADOW && |
| 159 if ((bubble_border_->arrow() != BubbleBorder::NONE && | 159 bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER && |
| 160 bubble_border_->arrow() != BubbleBorder::FLOAT) || | 160 bubble_border_->shadow() != BubbleBorder::NO_ASSETS) |
| 161 (bubble_border_->shadow() != BubbleBorder::SMALL_SHADOW && | 161 return; |
| 162 bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER)) | 162 |
| 163 // We don't return a mask for windows with arrows unless they use |
| 164 // BubbleBorder::NO_ASSETS. |
| 165 if (bubble_border_->shadow() != BubbleBorder::NO_ASSETS && |
| 166 bubble_border_->arrow() != BubbleBorder::NONE && |
| 167 bubble_border_->arrow() != BubbleBorder::FLOAT) |
| 163 return; | 168 return; |
| 164 | 169 |
| 165 // Use a window mask roughly matching the border in the image assets. | 170 // Use a window mask roughly matching the border in the image assets. |
| 166 static const int kBorderStrokeSize = 1; | 171 const int kBorderStrokeSize = |
| 167 static const SkScalar kCornerRadius = SkIntToScalar(6); | 172 bubble_border_->shadow() == BubbleBorder::NO_ASSETS ? 0 : 1; |
| 173 const SkScalar kCornerRadius = |
| 174 SkIntToScalar(bubble_border_->GetBorderCornerRadius()); |
| 168 const gfx::Insets border_insets = bubble_border_->GetInsets(); | 175 const gfx::Insets border_insets = bubble_border_->GetInsets(); |
| 169 SkRect rect = { SkIntToScalar(border_insets.left() - kBorderStrokeSize), | 176 SkRect rect = { |
| 170 SkIntToScalar(border_insets.top() - kBorderStrokeSize), | 177 SkIntToScalar(border_insets.left() - kBorderStrokeSize), |
| 171 SkIntToScalar(size.width() - border_insets.right() + | 178 SkIntToScalar(border_insets.top() - kBorderStrokeSize), |
| 172 kBorderStrokeSize), | 179 SkIntToScalar(size.width() - border_insets.right() + kBorderStrokeSize), |
| 173 SkIntToScalar(size.height() - border_insets.bottom() + | 180 SkIntToScalar(size.height() - border_insets.bottom() + |
| 174 kBorderStrokeSize) }; | 181 kBorderStrokeSize)}; |
| 175 if (bubble_border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER) { | 182 |
| 183 if (bubble_border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER || |
| 184 bubble_border_->shadow() == BubbleBorder::NO_ASSETS) { |
| 176 window_mask->addRoundRect(rect, kCornerRadius, kCornerRadius); | 185 window_mask->addRoundRect(rect, kCornerRadius, kCornerRadius); |
| 177 } else { | 186 } else { |
| 178 static const int kBottomBorderShadowSize = 2; | 187 static const int kBottomBorderShadowSize = 2; |
| 179 rect.fBottom += SkIntToScalar(kBottomBorderShadowSize); | 188 rect.fBottom += SkIntToScalar(kBottomBorderShadowSize); |
| 180 window_mask->addRect(rect); | 189 window_mask->addRect(rect); |
| 181 } | 190 } |
| 191 gfx::Path arrow_path; |
| 192 if (bubble_border_->GetArrowPath(gfx::Rect(size), &arrow_path)) |
| 193 window_mask->addPath(arrow_path, 0, 0); |
| 182 } | 194 } |
| 183 | 195 |
| 184 void BubbleFrameView::ResetWindowControls() { | 196 void BubbleFrameView::ResetWindowControls() { |
| 185 close_->SetVisible(GetWidget()->widget_delegate()->ShouldShowCloseButton()); | 197 close_->SetVisible(GetWidget()->widget_delegate()->ShouldShowCloseButton()); |
| 186 } | 198 } |
| 187 | 199 |
| 188 void BubbleFrameView::UpdateWindowIcon() { | 200 void BubbleFrameView::UpdateWindowIcon() { |
| 189 gfx::ImageSkia image; | 201 gfx::ImageSkia image; |
| 190 if (GetWidget()->widget_delegate()->ShouldShowWindowIcon()) | 202 if (GetWidget()->widget_delegate()->ShouldShowWindowIcon()) |
| 191 image = GetWidget()->widget_delegate()->GetWindowIcon(); | 203 image = GetWidget()->widget_delegate()->GetWindowIcon(); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 size.Enlarge(client_insets.width(), client_insets.height()); | 518 size.Enlarge(client_insets.width(), client_insets.height()); |
| 507 size.SetToMax(gfx::Size(title_bar_width, 0)); | 519 size.SetToMax(gfx::Size(title_bar_width, 0)); |
| 508 | 520 |
| 509 if (footnote_container_) | 521 if (footnote_container_) |
| 510 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); | 522 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); |
| 511 | 523 |
| 512 return size; | 524 return size; |
| 513 } | 525 } |
| 514 | 526 |
| 515 } // namespace views | 527 } // namespace views |
| OLD | NEW |