| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 static const int kBottomBorderShadowSize = 2; | 204 static const int kBottomBorderShadowSize = 2; |
| 205 rect.fBottom += SkIntToScalar(kBottomBorderShadowSize); | 205 rect.fBottom += SkIntToScalar(kBottomBorderShadowSize); |
| 206 window_mask->addRect(rect); | 206 window_mask->addRect(rect); |
| 207 } | 207 } |
| 208 gfx::Path arrow_path; | 208 gfx::Path arrow_path; |
| 209 if (bubble_border_->GetArrowPath(gfx::Rect(size), &arrow_path)) | 209 if (bubble_border_->GetArrowPath(gfx::Rect(size), &arrow_path)) |
| 210 window_mask->addPath(arrow_path, 0, 0); | 210 window_mask->addPath(arrow_path, 0, 0); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void BubbleFrameView::ResetWindowControls() { | 213 void BubbleFrameView::ResetWindowControls() { |
| 214 #if defined(OS_MACOSX) |
| 215 // On Mac, close buttons are never shown. |
| 216 close_->SetVisible(false); |
| 217 #else |
| 214 close_->SetVisible(GetWidget()->widget_delegate()->ShouldShowCloseButton()); | 218 close_->SetVisible(GetWidget()->widget_delegate()->ShouldShowCloseButton()); |
| 219 #endif |
| 215 } | 220 } |
| 216 | 221 |
| 217 void BubbleFrameView::UpdateWindowIcon() { | 222 void BubbleFrameView::UpdateWindowIcon() { |
| 218 gfx::ImageSkia image; | 223 gfx::ImageSkia image; |
| 219 if (GetWidget()->widget_delegate()->ShouldShowWindowIcon()) | 224 if (GetWidget()->widget_delegate()->ShouldShowWindowIcon()) |
| 220 image = GetWidget()->widget_delegate()->GetWindowIcon(); | 225 image = GetWidget()->widget_delegate()->GetWindowIcon(); |
| 221 title_icon_->SetImage(&image); | 226 title_icon_->SetImage(&image); |
| 222 } | 227 } |
| 223 | 228 |
| 224 void BubbleFrameView::UpdateWindowTitle() { | 229 void BubbleFrameView::UpdateWindowTitle() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 237 } | 242 } |
| 238 | 243 |
| 239 gfx::Insets BubbleFrameView::GetInsets() const { | 244 gfx::Insets BubbleFrameView::GetInsets() const { |
| 240 gfx::Insets insets = content_margins_; | 245 gfx::Insets insets = content_margins_; |
| 241 | 246 |
| 242 const int icon_height = title_icon_->GetPreferredSize().height(); | 247 const int icon_height = title_icon_->GetPreferredSize().height(); |
| 243 const int label_height = title_->GetPreferredSize().height(); | 248 const int label_height = title_->GetPreferredSize().height(); |
| 244 const bool has_title = icon_height > 0 || label_height > 0; | 249 const bool has_title = icon_height > 0 || label_height > 0; |
| 245 const int title_padding = has_title ? title_margins_.height() : 0; | 250 const int title_padding = has_title ? title_margins_.height() : 0; |
| 246 const int title_height = std::max(icon_height, label_height) + title_padding; | 251 const int title_height = std::max(icon_height, label_height) + title_padding; |
| 247 const int close_height = close_->visible() ? close_->height() : 0; | 252 const int close_height = |
| 253 GetWidget()->widget_delegate()->ShouldShowCloseButton() |
| 254 ? close_->height() |
| 255 : 0; |
| 248 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0); | 256 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0); |
| 249 return insets; | 257 return insets; |
| 250 } | 258 } |
| 251 | 259 |
| 252 gfx::Size BubbleFrameView::GetPreferredSize() const { | 260 gfx::Size BubbleFrameView::GetPreferredSize() const { |
| 253 // Get the preferred size of the client area. | 261 // Get the preferred size of the client area. |
| 254 gfx::Size client_size = GetWidget()->client_view()->GetPreferredSize(); | 262 gfx::Size client_size = GetWidget()->client_view()->GetPreferredSize(); |
| 255 // Expand it to include the bubble border and space for the arrow. | 263 // Expand it to include the bubble border and space for the arrow. |
| 256 return GetWindowBoundsForClientBounds(gfx::Rect(client_size)).size(); | 264 return GetWindowBoundsForClientBounds(gfx::Rect(client_size)).size(); |
| 257 } | 265 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 size.Enlarge(client_insets.width(), client_insets.height()); | 520 size.Enlarge(client_insets.width(), client_insets.height()); |
| 513 size.SetToMax(gfx::Size(title_bar_width, 0)); | 521 size.SetToMax(gfx::Size(title_bar_width, 0)); |
| 514 | 522 |
| 515 if (footnote_container_) | 523 if (footnote_container_) |
| 516 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); | 524 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); |
| 517 | 525 |
| 518 return size; | 526 return size; |
| 519 } | 527 } |
| 520 | 528 |
| 521 } // namespace views | 529 } // namespace views |
| OLD | NEW |