| 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 27 matching lines...) Expand all Loading... |
| 38 namespace views { | 38 namespace views { |
| 39 | 39 |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 // Background color of the footnote view. | 42 // Background color of the footnote view. |
| 43 const SkColor kFootnoteBackgroundColor = SkColorSetRGB(245, 245, 245); | 43 const SkColor kFootnoteBackgroundColor = SkColorSetRGB(245, 245, 245); |
| 44 | 44 |
| 45 // Color of the top border of the footnote. | 45 // Color of the top border of the footnote. |
| 46 const SkColor kFootnoteBorderColor = SkColorSetRGB(229, 229, 229); | 46 const SkColor kFootnoteBorderColor = SkColorSetRGB(229, 229, 229); |
| 47 | 47 |
| 48 constexpr int kClosePaddingRight = 7; |
| 49 constexpr int kClosePaddingTop = 6; |
| 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 = 5; |
| 55 |
| 48 // Get the |vertical| or horizontal amount that |available_bounds| overflows | 56 // Get the |vertical| or horizontal amount that |available_bounds| overflows |
| 49 // |window_bounds|. | 57 // |window_bounds|. |
| 50 int GetOffScreenLength(const gfx::Rect& available_bounds, | 58 int GetOffScreenLength(const gfx::Rect& available_bounds, |
| 51 const gfx::Rect& window_bounds, | 59 const gfx::Rect& window_bounds, |
| 52 bool vertical) { | 60 bool vertical) { |
| 53 if (available_bounds.IsEmpty() || available_bounds.Contains(window_bounds)) | 61 if (available_bounds.IsEmpty() || available_bounds.Contains(window_bounds)) |
| 54 return 0; | 62 return 0; |
| 55 | 63 |
| 56 // window_bounds | 64 // window_bounds |
| 57 // +---------------------------------+ | 65 // +---------------------------------+ |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 // there's no title. | 315 // there's no title. |
| 308 DCHECK(!title_margins_.IsEmpty() || !title_->visible()); | 316 DCHECK(!title_margins_.IsEmpty() || !title_->visible()); |
| 309 | 317 |
| 310 gfx::Rect bounds(GetContentsBounds()); | 318 gfx::Rect bounds(GetContentsBounds()); |
| 311 bounds.Inset(title_margins_); | 319 bounds.Inset(title_margins_); |
| 312 if (bounds.IsEmpty()) | 320 if (bounds.IsEmpty()) |
| 313 return; | 321 return; |
| 314 | 322 |
| 315 // The close button is positioned somewhat closer to the edge of the bubble. | 323 // The close button is positioned somewhat closer to the edge of the bubble. |
| 316 gfx::Point close_position = GetContentsBounds().top_right(); | 324 gfx::Point close_position = GetContentsBounds().top_right(); |
| 317 close_position += gfx::Vector2d(-close_->width() - 7, 6); | 325 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 326 close_position += gfx::Vector2d(-close_->width() - kClosePaddingRightMd, |
| 327 kClosePaddingTopMd); |
| 328 } else { |
| 329 close_position += |
| 330 gfx::Vector2d(-close_->width() - kClosePaddingRight, kClosePaddingTop); |
| 331 } |
| 318 close_->SetPosition(close_position); | 332 close_->SetPosition(close_position); |
| 319 | 333 |
| 320 gfx::Size title_icon_pref_size(title_icon_->GetPreferredSize()); | 334 gfx::Size title_icon_pref_size(title_icon_->GetPreferredSize()); |
| 321 int padding = 0; | 335 int padding = 0; |
| 322 int title_height = title_icon_pref_size.height(); | 336 int title_height = title_icon_pref_size.height(); |
| 323 | 337 |
| 324 if (title_->visible() && !title_->text().empty()) { | 338 if (title_->visible() && !title_->text().empty()) { |
| 325 if (title_icon_pref_size.width() > 0) | 339 if (title_icon_pref_size.width() > 0) |
| 326 padding = title_margins_.left(); | 340 padding = title_margins_.left(); |
| 327 | 341 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 size.Enlarge(client_insets.width(), client_insets.height()); | 542 size.Enlarge(client_insets.width(), client_insets.height()); |
| 529 size.SetToMax(gfx::Size(title_bar_width, 0)); | 543 size.SetToMax(gfx::Size(title_bar_width, 0)); |
| 530 | 544 |
| 531 if (footnote_container_) | 545 if (footnote_container_) |
| 532 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); | 546 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); |
| 533 | 547 |
| 534 return size; | 548 return size; |
| 535 } | 549 } |
| 536 | 550 |
| 537 } // namespace views | 551 } // namespace views |
| OLD | NEW |