Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc

Issue 1460483003: Fix opaque frame app mode windows to have correct toolbar/content separator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/profiles/profiles_state.h" 8 #include "chrome/browser/profiles/profiles_state.h"
9 #include "chrome/browser/ui/views/layout_constants.h" 9 #include "chrome/browser/ui/views/layout_constants.h"
10 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" 10 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
11 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
12 #include "components/signin/core/common/profile_management_switches.h" 12 #include "components/signin/core/common/profile_management_switches.h"
13 #include "ui/gfx/font.h" 13 #include "ui/gfx/font.h"
14 #include "ui/views/controls/button/image_button.h" 14 #include "ui/views/controls/button/image_button.h"
15 #include "ui/views/controls/label.h" 15 #include "ui/views/controls/label.h"
16 16
17 #if defined(ENABLE_SUPERVISED_USERS) 17 #if defined(ENABLE_SUPERVISED_USERS)
18 #include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h" 18 #include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h"
19 #endif 19 #endif
20 20
21 namespace { 21 namespace {
22 22
23 // Besides the frame border, there's empty space atop the window in restored 23 // Besides the frame border, there's empty space atop the window in restored
24 // mode, to use to drag the window around. 24 // mode, to use to drag the window around.
25 const int kNonClientRestoredExtraThickness = 11; 25 const int kNonClientRestoredExtraThickness = 11;
26 26
27 // The titlebar never shrinks too short to show the caption button plus some 27 // The titlebar never shrinks too short to show the caption button plus some
28 // padding below it. 28 // padding below it.
29 const int kCaptionButtonHeightWithPadding = 19; 29 const int kCaptionButtonHeight = 18;
30 const int kTitleBarAdditionalPadding = 3;
30 31
31 // There is a 5 px gap between the title text and the caption buttons. 32 // There is a 5 px gap between the title text and the caption buttons.
32 const int kTitleLogoSpacing = 5; 33 const int kTitleLogoSpacing = 5;
33 34
34 // The frame border is only visible in restored mode and is hardcoded to 4 px on 35 // The frame border is only visible in restored mode and is hardcoded to 4 px on
35 // each side regardless of the system window border size. 36 // each side regardless of the system window border size.
36 const int kFrameBorderThickness = 4; 37 const int kFrameBorderThickness = 4;
37 38
38 // The titlebar has a 2 px 3D edge along the top and bottom. 39 // The titlebar has a 2 px 3D edge along the top and bottom.
39 const int kTitlebarTopAndBottomEdgeThickness = 2; 40 const int kTitlebarTopAndBottomEdgeThickness = 2;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 const int frame = FrameBorderThickness(false); 209 const int frame = FrameBorderThickness(false);
209 // When we fill the screen, we don't show a client edge. 210 // When we fill the screen, we don't show a client edge.
210 return (IsTitleBarCondensed() || delegate_->IsFullscreen()) ? 211 return (IsTitleBarCondensed() || delegate_->IsFullscreen()) ?
211 frame : (frame + views::NonClientFrameView::kClientEdgeThickness); 212 frame : (frame + views::NonClientFrameView::kClientEdgeThickness);
212 } 213 }
213 214
214 int OpaqueBrowserFrameViewLayout::NonClientTopBorderHeight( 215 int OpaqueBrowserFrameViewLayout::NonClientTopBorderHeight(
215 bool restored) const { 216 bool restored) const {
216 if (delegate_->ShouldShowWindowTitle()) { 217 if (delegate_->ShouldShowWindowTitle()) {
217 return std::max(FrameBorderThickness(restored) + delegate_->GetIconSize(), 218 return std::max(FrameBorderThickness(restored) + delegate_->GetIconSize(),
218 CaptionButtonY(restored) + kCaptionButtonHeightWithPadding) + 219 CaptionButtonY(restored) + kCaptionButtonHeight) +
219 TitlebarBottomThickness(restored); 220 TitlebarBottomThickness(restored);
220 } 221 }
221 222
222 int thickness = FrameBorderThickness(restored); 223 int thickness = FrameBorderThickness(restored);
223 if (!restored && delegate_->IsTabStripVisible() && IsTitleBarCondensed()) 224 if (!restored && delegate_->IsTabStripVisible() && IsTitleBarCondensed())
224 thickness -= kTabstripTopShadowThickness; 225 thickness -= kTabstripTopShadowThickness;
225 return thickness; 226 return thickness;
226 } 227 }
227 228
228 int OpaqueBrowserFrameViewLayout::GetTabStripInsetsTop(bool restored) const { 229 int OpaqueBrowserFrameViewLayout::GetTabStripInsetsTop(bool restored) const {
229 const int top = NonClientTopBorderHeight(restored); 230 const int top = NonClientTopBorderHeight(restored);
230 // Annoyingly, the pre-MD layout uses different heights for the hit-test 231 // Annoyingly, the pre-MD layout uses different heights for the hit-test
231 // exclusion region (which we want here, since we're trying to size the border 232 // exclusion region (which we want here, since we're trying to size the border
232 // so that the region above the tab's hit-test zone matches) versus the shadow 233 // so that the region above the tab's hit-test zone matches) versus the shadow
233 // thickness. 234 // thickness.
234 const int exclusion = GetLayoutConstant(TAB_TOP_EXCLUSION_HEIGHT); 235 const int exclusion = GetLayoutConstant(TAB_TOP_EXCLUSION_HEIGHT);
235 return (!restored && (IsTitleBarCondensed() || delegate_->IsFullscreen())) ? 236 return (!restored && (IsTitleBarCondensed() || delegate_->IsFullscreen())) ?
236 top : (top + kNonClientRestoredExtraThickness - exclusion); 237 top : (top + kNonClientRestoredExtraThickness - exclusion);
237 } 238 }
238 239
239 int OpaqueBrowserFrameViewLayout::TitlebarBottomThickness(bool restored) const { 240 int OpaqueBrowserFrameViewLayout::TitlebarBottomThickness(bool restored) const {
240 const int edge = kTitlebarTopAndBottomEdgeThickness; 241 int thickness = kTitleBarAdditionalPadding;
242 // If there's a non-empty toolbar, it will render the bottom portion of the
243 // titlebar.
244 if (delegate_->IsToolbarVisible())
245 return thickness;
246 thickness += kTitlebarTopAndBottomEdgeThickness;
241 return (!restored && IsTitleBarCondensed()) ? 247 return (!restored && IsTitleBarCondensed()) ?
242 edge : (edge + views::NonClientFrameView::kClientEdgeThickness); 248 thickness : (thickness + views::NonClientFrameView::kClientEdgeThickness);
243 } 249 }
244 250
245 int OpaqueBrowserFrameViewLayout::CaptionButtonY(bool restored) const { 251 int OpaqueBrowserFrameViewLayout::CaptionButtonY(bool restored) const {
246 // Maximized buttons start at window top, since the window has no border. This 252 // Maximized buttons start at window top, since the window has no border. This
247 // offset is for the image (the actual clickable bounds extend all the way to 253 // offset is for the image (the actual clickable bounds extend all the way to
248 // the top to take Fitts' Law into account). 254 // the top to take Fitts' Law into account).
249 const int frame = (!restored && IsTitleBarCondensed()) ? 255 const int frame = (!restored && IsTitleBarCondensed()) ?
250 FrameBorderThickness(false) : 256 FrameBorderThickness(false) :
251 views::NonClientFrameView::kFrameShadowThickness; 257 views::NonClientFrameView::kFrameShadowThickness;
252 return frame + extra_caption_y_; 258 return frame + extra_caption_y_;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 minimum_size_for_buttons_ += button_width_with_offset; 411 minimum_size_for_buttons_ += button_width_with_offset;
406 trailing_button_start_ += button_width_with_offset; 412 trailing_button_start_ += button_width_with_offset;
407 413
408 // In non-maximized mode, allow the new tab button to completely slide under 414 // In non-maximized mode, allow the new tab button to completely slide under
409 // the avatar button. 415 // the avatar button.
410 if (!IsTitleBarCondensed()) { 416 if (!IsTitleBarCondensed()) {
411 trailing_button_start_ -= 417 trailing_button_start_ -=
412 GetLayoutConstant(NEW_TAB_BUTTON_WIDTH) + kNewTabCaptionNormalSpacing; 418 GetLayoutConstant(NEW_TAB_BUTTON_WIDTH) + kNewTabCaptionNormalSpacing;
413 } 419 }
414 420
415 // Do not include the 1px padding that is added for the caption buttons. 421 new_avatar_button_->SetBounds(button_x, button_y, button_width,
416 new_avatar_button_->SetBounds( 422 kCaptionButtonHeight);
417 button_x, button_y, button_width, kCaptionButtonHeightWithPadding - 1);
418 } 423 }
419 424
420 void OpaqueBrowserFrameViewLayout::LayoutAvatar(views::View* host) { 425 void OpaqueBrowserFrameViewLayout::LayoutAvatar(views::View* host) {
421 // Even though the avatar is used for both incognito and profiles we always 426 // Even though the avatar is used for both incognito and profiles we always
422 // use the incognito icon to layout the avatar button. The profile icon 427 // use the incognito icon to layout the avatar button. The profile icon
423 // can be customized so we can't depend on its size to perform layout. 428 // can be customized so we can't depend on its size to perform layout.
424 gfx::ImageSkia incognito_icon = delegate_->GetOTRAvatarIcon(); 429 gfx::ImageSkia incognito_icon = delegate_->GetOTRAvatarIcon();
425 430
426 bool avatar_on_right = ShouldAvatarBeOnRight(); 431 bool avatar_on_right = ShouldAvatarBeOnRight();
427 int avatar_bottom = GetTabStripInsetsTop(false) + 432 int avatar_bottom = GetTabStripInsetsTop(false) +
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 713
709 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, 714 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host,
710 views::View* view) { 715 views::View* view) {
711 SetView(view->id(), view); 716 SetView(view->id(), view);
712 } 717 }
713 718
714 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, 719 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host,
715 views::View* view) { 720 views::View* view) {
716 SetView(view->id(), nullptr); 721 SetView(view->id(), nullptr);
717 } 722 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698