| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/profiles/profiles_state.h" | 9 #include "chrome/browser/profiles/profiles_state.h" |
| 10 #include "chrome/browser/ui/layout_constants.h" | 10 #include "chrome/browser/ui/layout_constants.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 const gfx::Rect& client_bounds) const { | 141 const gfx::Rect& client_bounds) const { |
| 142 int top_height = NonClientTopBorderHeight(false); | 142 int top_height = NonClientTopBorderHeight(false); |
| 143 int border_thickness = NonClientBorderThickness(); | 143 int border_thickness = NonClientBorderThickness(); |
| 144 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), | 144 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), |
| 145 std::max(0, client_bounds.y() - top_height), | 145 std::max(0, client_bounds.y() - top_height), |
| 146 client_bounds.width() + (2 * border_thickness), | 146 client_bounds.width() + (2 * border_thickness), |
| 147 client_bounds.height() + top_height + border_thickness); | 147 client_bounds.height() + top_height + border_thickness); |
| 148 } | 148 } |
| 149 | 149 |
| 150 int OpaqueBrowserFrameViewLayout::FrameBorderThickness(bool restored) const { | 150 int OpaqueBrowserFrameViewLayout::FrameBorderThickness(bool restored) const { |
| 151 #if defined(OS_WIN) |
| 152 const int border_thickness = |
| 153 base::win::GetVersion() >= base::win::VERSION_WIN10 ? |
| 154 kFrameBorderThicknessWin10 : kFrameBorderThickness; |
| 155 #else |
| 156 const int border_thickness = kFrameBorderThickness; |
| 157 #endif |
| 158 |
| 151 return (!restored && (IsTitleBarCondensed() || delegate_->IsFullscreen())) ? | 159 return (!restored && (IsTitleBarCondensed() || delegate_->IsFullscreen())) ? |
| 152 0 : kFrameBorderThickness; | 160 0 : border_thickness; |
| 153 } | 161 } |
| 154 | 162 |
| 155 int OpaqueBrowserFrameViewLayout::NonClientBorderThickness() const { | 163 int OpaqueBrowserFrameViewLayout::NonClientBorderThickness() const { |
| 156 const int frame = FrameBorderThickness(false); | 164 const int frame = FrameBorderThickness(false); |
| 157 // When we fill the screen, we don't show a client edge. | 165 // When we fill the screen, we don't show a client edge. |
| 158 return (IsTitleBarCondensed() || delegate_->IsFullscreen()) ? | 166 return (IsTitleBarCondensed() || delegate_->IsFullscreen()) ? |
| 159 frame : (frame + views::NonClientFrameView::kClientEdgeThickness); | 167 frame : (frame + views::NonClientFrameView::kClientEdgeThickness); |
| 160 } | 168 } |
| 161 | 169 |
| 162 int OpaqueBrowserFrameViewLayout::NonClientTopBorderHeight( | 170 int OpaqueBrowserFrameViewLayout::NonClientTopBorderHeight( |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 // When we are the first button on the leading side and are the close | 491 // When we are the first button on the leading side and are the close |
| 484 // button, we must flip ourselves, because the close button assets have | 492 // button, we must flip ourselves, because the close button assets have |
| 485 // a little notch to fit in the rounded frame. | 493 // a little notch to fit in the rounded frame. |
| 486 image_button->SetDrawImageMirrored( | 494 image_button->SetDrawImageMirrored( |
| 487 alignment == ALIGN_LEADING && !has_leading_buttons_ && | 495 alignment == ALIGN_LEADING && !has_leading_buttons_ && |
| 488 button == close_button_); | 496 button == close_button_); |
| 489 } | 497 } |
| 490 | 498 |
| 491 // If the window is maximized, align the buttons to its upper edge. | 499 // If the window is maximized, align the buttons to its upper edge. |
| 492 int extra_height = title_bar_condensed ? extra_caption_y_ : 0; | 500 int extra_height = title_bar_condensed ? extra_caption_y_ : 0; |
| 501 #if defined(OS_WIN) |
| 502 const int border_thickness = |
| 503 base::win::GetVersion() >= base::win::VERSION_WIN10 ? |
| 504 kFrameBorderThicknessWin10 : kFrameBorderThickness; |
| 505 #else |
| 506 const int border_thickness = kFrameBorderThickness; |
| 507 #endif |
| 493 | 508 |
| 494 switch (alignment) { | 509 switch (alignment) { |
| 495 case ALIGN_LEADING: { | 510 case ALIGN_LEADING: { |
| 496 if (has_leading_buttons_) | 511 if (has_leading_buttons_) |
| 497 leading_button_start_ += window_caption_spacing_; | 512 leading_button_start_ += window_caption_spacing_; |
| 498 | 513 |
| 499 // If we're the first button on the left and maximized, add width to the | 514 // If we're the first button on the left and maximized, add width to the |
| 500 // right hand side of the screen. | 515 // right hand side of the screen. |
| 501 int extra_width = (title_bar_condensed && !has_leading_buttons_) ? | 516 int extra_width = (title_bar_condensed && !has_leading_buttons_) ? |
| 502 (kFrameBorderThickness - | 517 (kFrameBorderThickness - |
| (...skipping 10 matching lines...) Expand all Loading... |
| 513 has_leading_buttons_ = true; | 528 has_leading_buttons_ = true; |
| 514 break; | 529 break; |
| 515 } | 530 } |
| 516 case ALIGN_TRAILING: { | 531 case ALIGN_TRAILING: { |
| 517 if (has_trailing_buttons_) | 532 if (has_trailing_buttons_) |
| 518 trailing_button_start_ += window_caption_spacing_; | 533 trailing_button_start_ += window_caption_spacing_; |
| 519 | 534 |
| 520 // If we're the first button on the right and maximized, add width to the | 535 // If we're the first button on the right and maximized, add width to the |
| 521 // right hand side of the screen. | 536 // right hand side of the screen. |
| 522 int extra_width = (title_bar_condensed && !has_trailing_buttons_) ? | 537 int extra_width = (title_bar_condensed && !has_trailing_buttons_) ? |
| 523 (kFrameBorderThickness - | 538 (border_thickness - |
| 524 views::NonClientFrameView::kFrameShadowThickness) : 0; | 539 views::NonClientFrameView::kFrameShadowThickness) : 0; |
| 525 | 540 |
| 526 button->SetBounds( | 541 button->SetBounds( |
| 527 host->width() - trailing_button_start_ - extra_width - | 542 host->width() - trailing_button_start_ - extra_width - |
| 528 button_size.width(), | 543 button_size.width(), |
| 529 caption_y - extra_height, | 544 caption_y - extra_height, |
| 530 button_size.width() + extra_width, | 545 button_size.width() + extra_width, |
| 531 button_size.height() + extra_height); | 546 button_size.height() + extra_height); |
| 532 | 547 |
| 533 trailing_button_start_ += extra_width + button_size.width(); | 548 trailing_button_start_ += extra_width + button_size.width(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 | 650 |
| 636 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, | 651 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, |
| 637 views::View* view) { | 652 views::View* view) { |
| 638 SetView(view->id(), view); | 653 SetView(view->id(), view); |
| 639 } | 654 } |
| 640 | 655 |
| 641 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, | 656 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, |
| 642 views::View* view) { | 657 views::View* view) { |
| 643 SetView(view->id(), nullptr); | 658 SetView(view->id(), nullptr); |
| 644 } | 659 } |
| OLD | NEW |