| 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 13 matching lines...) Expand all Loading... |
| 24 #include "ui/native_theme/native_theme.h" | 24 #include "ui/native_theme/native_theme.h" |
| 25 #include "ui/resources/grit/ui_resources.h" | 25 #include "ui/resources/grit/ui_resources.h" |
| 26 #include "ui/strings/grit/ui_strings.h" | 26 #include "ui/strings/grit/ui_strings.h" |
| 27 #include "ui/views/bubble/bubble_border.h" | 27 #include "ui/views/bubble/bubble_border.h" |
| 28 #include "ui/views/controls/button/vector_icon_button.h" | 28 #include "ui/views/controls/button/vector_icon_button.h" |
| 29 #include "ui/views/controls/image_view.h" | 29 #include "ui/views/controls/image_view.h" |
| 30 #include "ui/views/controls/label.h" | 30 #include "ui/views/controls/label.h" |
| 31 #include "ui/views/layout/box_layout.h" | 31 #include "ui/views/layout/box_layout.h" |
| 32 #include "ui/views/layout/layout_constants.h" | 32 #include "ui/views/layout/layout_constants.h" |
| 33 #include "ui/views/resources/grit/views_resources.h" | 33 #include "ui/views/resources/grit/views_resources.h" |
| 34 #include "ui/views/views_delegate.h" |
| 34 #include "ui/views/widget/widget.h" | 35 #include "ui/views/widget/widget.h" |
| 35 #include "ui/views/widget/widget_delegate.h" | 36 #include "ui/views/widget/widget_delegate.h" |
| 36 #include "ui/views/window/client_view.h" | 37 #include "ui/views/window/client_view.h" |
| 37 | 38 |
| 38 namespace views { | 39 namespace views { |
| 39 | 40 |
| 40 namespace { | 41 namespace { |
| 41 | 42 |
| 42 // Background color of the footnote view. | 43 // Background color of the footnote view. |
| 43 const SkColor kFootnoteBackgroundColor = SkColorSetRGB(245, 245, 245); | 44 const SkColor kFootnoteBackgroundColor = SkColorSetRGB(245, 245, 245); |
| 44 | 45 |
| 45 // Color of the top border of the footnote. | 46 // Color of the top border of the footnote. |
| 46 const SkColor kFootnoteBorderColor = SkColorSetRGB(229, 229, 229); | 47 const SkColor kFootnoteBorderColor = SkColorSetRGB(229, 229, 229); |
| 47 | 48 |
| 48 constexpr int kClosePaddingRight = 7; | |
| 49 constexpr int kClosePaddingTop = 7; | |
| 50 | |
| 51 // The MD spec states that the center of the "x" should be 16x16 from the top | |
| 52 // right of the dialog. | |
| 53 constexpr int kClosePaddingRightMd = 4; | |
| 54 constexpr int kClosePaddingTopMd = 4; | |
| 55 | |
| 56 // Get the |vertical| or horizontal amount that |available_bounds| overflows | 49 // Get the |vertical| or horizontal amount that |available_bounds| overflows |
| 57 // |window_bounds|. | 50 // |window_bounds|. |
| 58 int GetOffScreenLength(const gfx::Rect& available_bounds, | 51 int GetOffScreenLength(const gfx::Rect& available_bounds, |
| 59 const gfx::Rect& window_bounds, | 52 const gfx::Rect& window_bounds, |
| 60 bool vertical) { | 53 bool vertical) { |
| 61 if (available_bounds.IsEmpty() || available_bounds.Contains(window_bounds)) | 54 if (available_bounds.IsEmpty() || available_bounds.Contains(window_bounds)) |
| 62 return 0; | 55 return 0; |
| 63 | 56 |
| 64 // window_bounds | 57 // window_bounds |
| 65 // +---------------------------------+ | 58 // +---------------------------------+ |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // there's no title. | 307 // there's no title. |
| 315 DCHECK(!title_margins_.IsEmpty() || !title_->visible()); | 308 DCHECK(!title_margins_.IsEmpty() || !title_->visible()); |
| 316 | 309 |
| 317 const gfx::Rect contents_bounds = GetContentsBounds(); | 310 const gfx::Rect contents_bounds = GetContentsBounds(); |
| 318 gfx::Rect bounds = contents_bounds; | 311 gfx::Rect bounds = contents_bounds; |
| 319 bounds.Inset(title_margins_); | 312 bounds.Inset(title_margins_); |
| 320 if (bounds.IsEmpty()) | 313 if (bounds.IsEmpty()) |
| 321 return; | 314 return; |
| 322 | 315 |
| 323 // The close button is positioned somewhat closer to the edge of the bubble. | 316 // The close button is positioned somewhat closer to the edge of the bubble. |
| 324 gfx::Point close_position = contents_bounds.top_right(); | 317 const int close_margin = |
| 325 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 318 ViewsDelegate::GetInstance()->GetDialogCloseButtonMargin(); |
| 326 close_position += gfx::Vector2d(-close_->width() - kClosePaddingRightMd, | 319 close_->SetPosition( |
| 327 kClosePaddingTopMd); | 320 gfx::Point(contents_bounds.right() - close_margin - close_->width(), |
| 328 } else { | 321 contents_bounds.y() + close_margin)); |
| 329 close_position += | |
| 330 gfx::Vector2d(-close_->width() - kClosePaddingRight, kClosePaddingTop); | |
| 331 } | |
| 332 close_->SetPosition(close_position); | |
| 333 | 322 |
| 334 gfx::Size title_icon_pref_size(title_icon_->GetPreferredSize()); | 323 gfx::Size title_icon_pref_size(title_icon_->GetPreferredSize()); |
| 335 int padding = 0; | 324 int padding = 0; |
| 336 int title_height = title_icon_pref_size.height(); | 325 int title_height = title_icon_pref_size.height(); |
| 337 | 326 |
| 338 if (title_->visible() && !title_->text().empty()) { | 327 if (title_->visible() && !title_->text().empty()) { |
| 339 if (title_icon_pref_size.width() > 0) | 328 if (title_icon_pref_size.width() > 0) |
| 340 padding = title_margins_.left(); | 329 padding = title_margins_.left(); |
| 341 | 330 |
| 342 const int title_label_x = | 331 const int title_label_x = |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 size.Enlarge(client_insets.width(), client_insets.height()); | 530 size.Enlarge(client_insets.width(), client_insets.height()); |
| 542 size.SetToMax(gfx::Size(title_bar_width, 0)); | 531 size.SetToMax(gfx::Size(title_bar_width, 0)); |
| 543 | 532 |
| 544 if (footnote_container_) | 533 if (footnote_container_) |
| 545 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); | 534 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); |
| 546 | 535 |
| 547 return size; | 536 return size; |
| 548 } | 537 } |
| 549 | 538 |
| 550 } // namespace views | 539 } // namespace views |
| OLD | NEW |