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 "base/containers/adapters.h" | 8 #include "base/containers/adapters.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/profiles/profiles_state.h" | 10 #include "chrome/browser/profiles/profiles_state.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void OpaqueBrowserFrameViewLayout::SetButtonOrdering( | 100 void OpaqueBrowserFrameViewLayout::SetButtonOrdering( |
101 const std::vector<views::FrameButton>& leading_buttons, | 101 const std::vector<views::FrameButton>& leading_buttons, |
102 const std::vector<views::FrameButton>& trailing_buttons) { | 102 const std::vector<views::FrameButton>& trailing_buttons) { |
103 leading_buttons_ = leading_buttons; | 103 leading_buttons_ = leading_buttons; |
104 trailing_buttons_ = trailing_buttons; | 104 trailing_buttons_ = trailing_buttons; |
105 } | 105 } |
106 | 106 |
107 gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip( | 107 gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip( |
108 const gfx::Size& tabstrip_preferred_size, | 108 const gfx::Size& tabstrip_preferred_size, |
109 int available_width) const { | 109 int available_width) const { |
110 int x = leading_button_start_ + GetLayoutInsets(AVATAR_ICON).right(); | 110 int x = leading_button_start_ + GetLayoutConstant(AVATAR_ICON_PADDING); |
111 available_width -= x + NewTabCaptionSpacing() + trailing_button_start_; | 111 available_width -= x + NewTabCaptionSpacing() + trailing_button_start_; |
112 return gfx::Rect(x, GetTabStripInsetsTop(false), std::max(0, available_width), | 112 return gfx::Rect(x, GetTabStripInsetsTop(false), std::max(0, available_width), |
113 tabstrip_preferred_size.height()); | 113 tabstrip_preferred_size.height()); |
114 } | 114 } |
115 | 115 |
116 gfx::Size OpaqueBrowserFrameViewLayout::GetMinimumSize( | 116 gfx::Size OpaqueBrowserFrameViewLayout::GetMinimumSize( |
117 int available_width) const { | 117 int available_width) const { |
118 gfx::Size min_size = delegate_->GetBrowserViewMinimumSize(); | 118 gfx::Size min_size = delegate_->GetBrowserViewMinimumSize(); |
119 int border_thickness = NonClientBorderThickness(); | 119 int border_thickness = NonClientBorderThickness(); |
120 min_size.Enlarge(2 * border_thickness, | 120 min_size.Enlarge(2 * border_thickness, |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 // Any buttons/icon/title were laid out based on the frame border thickness, | 363 // Any buttons/icon/title were laid out based on the frame border thickness, |
364 // but the tabstrip bounds need to be based on the non-client border thickness | 364 // but the tabstrip bounds need to be based on the non-client border thickness |
365 // on any side where there aren't other buttons forcing a larger inset. | 365 // on any side where there aren't other buttons forcing a larger inset. |
366 int min_button_width = NonClientBorderThickness(); | 366 int min_button_width = NonClientBorderThickness(); |
367 leading_button_start_ = std::max(leading_button_start_, min_button_width); | 367 leading_button_start_ = std::max(leading_button_start_, min_button_width); |
368 // The trailing corner is a mirror of the leading one. | 368 // The trailing corner is a mirror of the leading one. |
369 trailing_button_start_ = std::max(trailing_button_start_, min_button_width); | 369 trailing_button_start_ = std::max(trailing_button_start_, min_button_width); |
370 | 370 |
371 if (incognito_icon_) { | 371 if (incognito_icon_) { |
372 const gfx::Insets insets(GetLayoutInsets(AVATAR_ICON)); | 372 const int pad = GetLayoutConstant(AVATAR_ICON_PADDING); |
373 const gfx::Size size(delegate_->GetIncognitoAvatarIcon().size()); | 373 const gfx::Size size(delegate_->GetIncognitoAvatarIcon().size()); |
374 const int incognito_width = insets.left() + size.width(); | 374 const int incognito_width = pad + size.width(); |
375 int x; | 375 int x; |
376 if (ShouldIncognitoIconBeOnRight()) { | 376 if (ShouldIncognitoIconBeOnRight()) { |
377 trailing_button_start_ += incognito_width; | 377 trailing_button_start_ += incognito_width; |
378 x = host->width() - trailing_button_start_; | 378 x = host->width() - trailing_button_start_; |
379 } else { | 379 } else { |
380 x = leading_button_start_ + insets.left(); | 380 x = leading_button_start_ + pad; |
381 leading_button_start_ += incognito_width; | 381 leading_button_start_ += incognito_width; |
382 } | 382 } |
383 const int bottom = GetTabStripInsetsTop(false) + | 383 const int bottom = |
384 delegate_->GetTabStripHeight() - insets.bottom(); | 384 GetTabStripInsetsTop(false) + delegate_->GetTabStripHeight() - pad; |
385 incognito_icon_->SetBounds(x, bottom - size.height(), size.width(), | 385 incognito_icon_->SetBounds(x, bottom - size.height(), size.width(), |
386 size.height()); | 386 size.height()); |
387 } | 387 } |
388 | 388 |
389 minimum_size_for_buttons_ += | 389 minimum_size_for_buttons_ += |
390 (leading_button_start_ + trailing_button_start_ - old_button_size); | 390 (leading_button_start_ + trailing_button_start_ - old_button_size); |
391 } | 391 } |
392 | 392 |
393 void OpaqueBrowserFrameViewLayout::ConfigureButton( | 393 void OpaqueBrowserFrameViewLayout::ConfigureButton( |
394 views::View* host, | 394 views::View* host, |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 601 |
602 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, | 602 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, |
603 views::View* view) { | 603 views::View* view) { |
604 SetView(view->id(), view); | 604 SetView(view->id(), view); |
605 } | 605 } |
606 | 606 |
607 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, | 607 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, |
608 views::View* view) { | 608 views::View* view) { |
609 SetView(view->id(), nullptr); | 609 SetView(view->id(), nullptr); |
610 } | 610 } |
OLD | NEW |