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

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

Issue 1636703002: Implement MD specs for non-tabbed windows in Ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tabstrip bottom edge Created 4 years, 11 months 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h" 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/ash_layout_constants.h" 9 #include "ash/ash_layout_constants.h"
10 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" 10 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/ui/browser_commands.h" 22 #include "chrome/browser/ui/browser_commands.h"
23 #include "chrome/browser/ui/layout_constants.h" 23 #include "chrome/browser/ui/layout_constants.h"
24 #include "chrome/browser/ui/views/frame/browser_frame.h" 24 #include "chrome/browser/ui/views/frame/browser_frame.h"
25 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h" 25 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h"
26 #include "chrome/browser/ui/views/frame/browser_view.h" 26 #include "chrome/browser/ui/views/frame/browser_view.h"
27 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 27 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
28 #include "chrome/browser/ui/views/frame/web_app_left_header_view_ash.h" 28 #include "chrome/browser/ui/views/frame/web_app_left_header_view_ash.h"
29 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" 29 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
30 #include "chrome/browser/ui/views/tab_icon_view.h" 30 #include "chrome/browser/ui/views/tab_icon_view.h"
31 #include "chrome/browser/ui/views/tabs/tab_strip.h" 31 #include "chrome/browser/ui/views/tabs/tab_strip.h"
32 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
32 #include "chrome/browser/web_applications/web_app.h" 33 #include "chrome/browser/web_applications/web_app.h"
33 #include "components/signin/core/common/profile_management_switches.h" 34 #include "components/signin/core/common/profile_management_switches.h"
34 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
35 #include "extensions/browser/extension_registry.h" 36 #include "extensions/browser/extension_registry.h"
36 #include "grit/theme_resources.h" 37 #include "grit/theme_resources.h"
37 #include "ui/accessibility/ax_view_state.h" 38 #include "ui/accessibility/ax_view_state.h"
38 #include "ui/aura/client/aura_constants.h" 39 #include "ui/aura/client/aura_constants.h"
39 #include "ui/aura/window.h" 40 #include "ui/aura/window.h"
40 #include "ui/base/hit_test.h" 41 #include "ui/base/hit_test.h"
41 #include "ui/base/layout.h" 42 #include "ui/base/layout.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored) ? 183 return ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored) ?
183 kTabstripTopSpacingShort : kTabstripTopSpacingTall; 184 kTabstripTopSpacingShort : kTabstripTopSpacingTall;
184 } 185 }
185 186
186 if (UsePackagedAppHeaderStyle() || UseWebAppHeaderStyle()) 187 if (UsePackagedAppHeaderStyle() || UseWebAppHeaderStyle())
187 return header_painter_->GetHeaderHeight(); 188 return header_painter_->GetHeaderHeight();
188 189
189 int caption_buttons_bottom = caption_button_container_->bounds().bottom(); 190 int caption_buttons_bottom = caption_button_container_->bounds().bottom();
190 191
191 // The toolbar partially overlaps the caption buttons. 192 // The toolbar partially overlaps the caption buttons.
192 if (browser_view()->IsToolbarVisible()) 193 if (IsToolbarVisible()) {
193 return caption_buttons_bottom - kContentShadowHeight; 194 return caption_buttons_bottom -
195 (ui::MaterialDesignController::IsModeMaterial() ?
196 0 : kContentShadowHeight);
197 }
194 198
195 return caption_buttons_bottom + kClientEdgeThickness; 199 return caption_buttons_bottom + kClientEdgeThickness;
196 } 200 }
197 201
198 int BrowserNonClientFrameViewAsh::GetThemeBackgroundXInset() const { 202 int BrowserNonClientFrameViewAsh::GetThemeBackgroundXInset() const {
199 return ash::HeaderPainterUtil::GetThemeBackgroundXInset(); 203 return ash::HeaderPainterUtil::GetThemeBackgroundXInset();
200 } 204 }
201 205
202 void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) { 206 void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) {
203 if (window_icon_) 207 if (window_icon_)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 return; 303 return;
300 } 304 }
301 305
302 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); 306 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive());
303 if (web_app_left_header_view_) 307 if (web_app_left_header_view_)
304 web_app_left_header_view_->SetPaintAsActive(ShouldPaintAsActive()); 308 web_app_left_header_view_->SetPaintAsActive(ShouldPaintAsActive());
305 309
306 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? 310 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ?
307 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; 311 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE;
308 header_painter_->PaintHeader(canvas, header_mode); 312 header_painter_->PaintHeader(canvas, header_mode);
309 if (browser_view()->IsToolbarVisible()) 313
314 if (IsToolbarVisible())
310 PaintToolbarBackground(canvas); 315 PaintToolbarBackground(canvas);
311 else if (!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()) 316 else
312 PaintContentEdge(canvas); 317 PaintContentEdge(canvas);
313 } 318 }
314 319
315 void BrowserNonClientFrameViewAsh::Layout() { 320 void BrowserNonClientFrameViewAsh::Layout() {
316 // The header must be laid out before computing |painted_height| because the 321 // The header must be laid out before computing |painted_height| because the
317 // computation of |painted_height| for app and popup windows depends on the 322 // computation of |painted_height| for app and popup windows depends on the
318 // position of the window controls. 323 // position of the window controls.
319 header_painter_->LayoutHeader(); 324 header_painter_->LayoutHeader();
320 325
321 int painted_height = GetTopInset(false); 326 int painted_height = GetTopInset(false);
322 if (browser_view()->IsTabStripVisible()) { 327 if (browser_view()->IsTabStripVisible()) {
323 painted_height += browser_view()->tabstrip()->GetPreferredSize().height(); 328 painted_height += browser_view()->tabstrip()->GetPreferredSize().height();
324 } else if (browser_view()->IsToolbarVisible()) { 329 } else if (IsToolbarVisible()) {
325 // Paint the header so that it overlaps with the top few pixels of the 330 // Paint the header so that it overlaps with the top few pixels of the
326 // toolbar because the top few pixels of the toolbar are not opaque. 331 // toolbar because the top few pixels of the toolbar are not opaque.
327 const int kToolbarTopEdgeExclusion = 2; 332 const int kToolbarTopEdgeExclusion = 2;
328 painted_height += kToolbarTopEdgeExclusion; 333 painted_height += kToolbarTopEdgeExclusion;
329 } 334 }
330 header_painter_->SetHeaderHeightForPainting(painted_height); 335 header_painter_->SetHeaderHeightForPainting(painted_height);
331 336
332 if (avatar_button()) { 337 if (avatar_button()) {
333 LayoutAvatar(); 338 LayoutAvatar();
334 header_painter_->UpdateLeftViewXInset(avatar_button()->bounds().right()); 339 header_painter_->UpdateLeftViewXInset(avatar_button()->bounds().right());
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 539 }
535 540
536 void BrowserNonClientFrameViewAsh::PaintImmersiveLightbarStyleHeader( 541 void BrowserNonClientFrameViewAsh::PaintImmersiveLightbarStyleHeader(
537 gfx::Canvas* canvas) { 542 gfx::Canvas* canvas) {
538 // The light bar header is not themed because theming it does not look good. 543 // The light bar header is not themed because theming it does not look good.
539 canvas->FillRect( 544 canvas->FillRect(
540 gfx::Rect(width(), header_painter_->GetHeaderHeightForPainting()), 545 gfx::Rect(width(), header_painter_->GetHeaderHeightForPainting()),
541 SK_ColorBLACK); 546 SK_ColorBLACK);
542 } 547 }
543 548
549 bool BrowserNonClientFrameViewAsh::IsToolbarVisible() const {
550 return browser_view()->IsToolbarVisible() &&
551 (ui::MaterialDesignController::IsModeMaterial() ?
Peter Kasting 2016/01/26 03:04:39 Why do you need to do an MD check here? The other
tdanderson 2016/01/29 22:28:43 Changed in next patch set.
552 !browser_view()->toolbar()->GetPreferredSize().IsEmpty() : true);
553 }
554
544 void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) { 555 void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) {
Peter Kasting 2016/01/26 03:04:39 I'd like to see you refactor these next two functi
tdanderson 2016/01/29 22:28:43 I have made an effort to do so in the next patch s
545 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); 556 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
546 if (toolbar_bounds.IsEmpty()) 557 if (toolbar_bounds.IsEmpty())
547 return; 558 return;
548 gfx::Point toolbar_origin(toolbar_bounds.origin()); 559 gfx::Point toolbar_origin(toolbar_bounds.origin());
549 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); 560 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin);
550 toolbar_bounds.set_origin(toolbar_origin); 561 toolbar_bounds.set_origin(toolbar_origin);
551 562
552 int x = toolbar_bounds.x(); 563 const int x = toolbar_bounds.x();
553 int w = toolbar_bounds.width(); 564 const int w = toolbar_bounds.width();
554 int y = toolbar_bounds.y(); 565 const int y = toolbar_bounds.y();
555 int h = toolbar_bounds.height(); 566 const int h = toolbar_bounds.height();
556 const ui::ThemeProvider* tp = GetThemeProvider(); 567 const ui::ThemeProvider* tp = GetThemeProvider();
557 568
558 if (ui::MaterialDesignController::IsModeMaterial()) { 569 if (ui::MaterialDesignController::IsModeMaterial()) {
559 if (tp->HasCustomImage(IDR_THEME_TOOLBAR)) { 570 if (tp->HasCustomImage(IDR_THEME_TOOLBAR)) {
560 // Paint the main toolbar image. Since this image is also used to draw 571 // Paint the main toolbar image. Since this image is also used to draw
561 // the tab background, we must use the tab strip offset to compute the 572 // the tab background, we must use the tab strip offset to compute the
562 // image source y position. If you have to debug this code use an image 573 // image source y position. If you have to debug this code use an image
563 // editor to paint a diagonal line through the toolbar image and ensure it 574 // editor to paint a diagonal line through the toolbar image and ensure it
564 // lines up across the tab and toolbar. 575 // lines up across the tab and toolbar.
565 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); 576 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR);
566 canvas->TileImageInt(*theme_toolbar, x + GetThemeBackgroundXInset(), 577 canvas->TileImageInt(*theme_toolbar, x + GetThemeBackgroundXInset(),
567 y - GetTopInset(false), x, y, w, 578 y - GetTopInset(false), x, y, w,
568 theme_toolbar->height()); 579 theme_toolbar->height());
569 } else { 580 } else {
570 canvas->FillRect(toolbar_bounds, 581 canvas->FillRect(toolbar_bounds,
571 tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); 582 tp->GetColor(ThemeProperties::COLOR_TOOLBAR));
572 } 583 }
573 584
574 // Draw the separator line atop the toolbar, on the left and right of the 585 // Draw the separator line atop the toolbar.
575 // tabstrip. 586 gfx::Rect separator_rect(
576 // TODO(tdanderson): Draw the separator line for non-tabbed windows. 587 x, caption_button_container_->bounds().bottom(), w, 0);
588 gfx::ScopedCanvas scoped_canvas(canvas);
Peter Kasting 2016/01/26 03:04:39 Why did you hoist this statement?
tdanderson 2016/01/29 22:28:43 Changed in next patch set.
577 if (browser_view()->IsTabStripVisible()) { 589 if (browser_view()->IsTabStripVisible()) {
578 gfx::Rect separator_rect(x, y, w, 0);
579 gfx::ScopedCanvas scoped_canvas(canvas);
580 gfx::Rect tabstrip_bounds( 590 gfx::Rect tabstrip_bounds(
581 GetBoundsForTabStrip(browser_view()->tabstrip())); 591 GetBoundsForTabStrip(browser_view()->tabstrip()));
582 tabstrip_bounds.set_x(GetMirroredXForRect(tabstrip_bounds)); 592 tabstrip_bounds.set_x(GetMirroredXForRect(tabstrip_bounds));
583 canvas->sk_canvas()->clipRect(gfx::RectToSkRect(tabstrip_bounds), 593 canvas->sk_canvas()->clipRect(gfx::RectToSkRect(tabstrip_bounds),
584 SkRegion::kDifference_Op); 594 SkRegion::kDifference_Op);
585 separator_rect.set_y(tabstrip_bounds.bottom()); 595 separator_rect.set_y(tabstrip_bounds.bottom());
586 BrowserView::Paint1pxHorizontalLine(
587 canvas, tp->GetColor(ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR),
588 separator_rect, true);
589 } 596 }
597 BrowserView::Paint1pxHorizontalLine(
598 canvas, tp->GetColor(ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR),
599 separator_rect, true);
590 600
591 // Draw the content/toolbar separator. 601 // Draw the content/toolbar separator.
592 toolbar_bounds.Inset(kClientEdgeThickness, 0); 602 toolbar_bounds.Inset(kClientEdgeThickness, 0);
593 BrowserView::Paint1pxHorizontalLine( 603 BrowserView::Paint1pxHorizontalLine(
594 canvas, 604 canvas,
595 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR), 605 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR),
596 toolbar_bounds, true); 606 toolbar_bounds, true);
597 } else { 607 } else {
598 // Gross hack: We split the toolbar images into two pieces, since sometimes 608 // Gross hack: We split the toolbar images into two pieces, since sometimes
599 // (popup mode) the toolbar isn't tall enough to show the whole image. The 609 // (popup mode) the toolbar isn't tall enough to show the whole image. The
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 // Draw the content/toolbar separator. 659 // Draw the content/toolbar separator.
650 canvas->FillRect( 660 canvas->FillRect(
651 gfx::Rect(x + kClientEdgeThickness, 661 gfx::Rect(x + kClientEdgeThickness,
652 toolbar_bounds.bottom() - kClientEdgeThickness, 662 toolbar_bounds.bottom() - kClientEdgeThickness,
653 w - (2 * kClientEdgeThickness), kClientEdgeThickness), 663 w - (2 * kClientEdgeThickness), kClientEdgeThickness),
654 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR)); 664 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR));
655 } 665 }
656 } 666 }
657 667
658 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { 668 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) {
659 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); 669 if (ui::MaterialDesignController::IsModeMaterial()) {
660 canvas->FillRect( 670 gfx::Rect separator_rect(
661 gfx::Rect(0, caption_button_container_->bounds().bottom(), width(), 671 0, caption_button_container_->bounds().bottom(), width(), 0);
662 kClientEdgeThickness), 672 BrowserView::Paint1pxHorizontalLine(
663 GetThemeProvider()->GetColor( 673 canvas, GetThemeProvider()->GetColor(
664 ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR)); 674 ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR),
675 separator_rect, true);
676 } else if (!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()) {
677 canvas->FillRect(
678 gfx::Rect(0, caption_button_container_->bounds().bottom(), width(),
679 kClientEdgeThickness),
680 GetThemeProvider()->GetColor(
681 ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR));
682 }
665 } 683 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h ('k') | chrome/browser/ui/views/toolbar/toolbar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698