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 "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "chrome/browser/themes/theme_properties.h" | 8 #include "chrome/browser/themes/theme_properties.h" |
9 #include "chrome/browser/themes/theme_service_factory.h" | 9 #include "chrome/browser/themes/theme_service_factory.h" |
10 #include "chrome/browser/ui/layout_constants.h" | 10 #include "chrome/browser/ui/layout_constants.h" |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 } | 405 } |
406 | 406 |
407 /////////////////////////////////////////////////////////////////////////////// | 407 /////////////////////////////////////////////////////////////////////////////// |
408 // OpaqueBrowserFrameView, protected: | 408 // OpaqueBrowserFrameView, protected: |
409 | 409 |
410 // views::View: | 410 // views::View: |
411 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { | 411 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { |
412 if (frame()->IsFullscreen()) | 412 if (frame()->IsFullscreen()) |
413 return; // Nothing is visible, so don't bother to paint. | 413 return; // Nothing is visible, so don't bother to paint. |
414 | 414 |
415 frame_background_->set_frame_color(GetFrameColor()); | |
416 frame_background_->set_use_custom_frame(frame()->UseCustomFrame()); | |
417 frame_background_->set_is_active(ShouldPaintAsActive()); | |
418 frame_background_->set_incognito(browser_view()->IsIncognito()); | |
419 frame_background_->set_theme_image(GetFrameImage()); | |
420 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); | |
421 frame_background_->set_top_area_height(GetTopAreaHeight()); | |
422 | |
415 if (layout_->IsTitleBarCondensed()) | 423 if (layout_->IsTitleBarCondensed()) |
416 PaintMaximizedFrameBorder(canvas); | 424 PaintMaximizedFrameBorder(canvas); |
417 else | 425 else |
418 PaintRestoredFrameBorder(canvas); | 426 PaintRestoredFrameBorder(canvas); |
419 | 427 |
420 // The window icon and title are painted by their respective views. | 428 // The window icon and title are painted by their respective views. |
421 /* TODO(pkasting): If this window is active, we should also draw a drop | 429 /* TODO(pkasting): If this window is active, we should also draw a drop |
422 * shadow on the title. This is tricky, because we don't want to hardcode a | 430 * shadow on the title. This is tricky, because we don't want to hardcode a |
423 * shadow color (since we want to work with various themes), but we can't | 431 * shadow color (since we want to work with various themes), but we can't |
424 * alpha-blend either (since the Windows text APIs don't really do this). | 432 * alpha-blend either (since the Windows text APIs don't really do this). |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 | 502 |
495 // Do not show caption buttons if the window manager is forcefully providing a | 503 // Do not show caption buttons if the window manager is forcefully providing a |
496 // title bar (e.g., in Ubuntu Unity, if the window is maximized). | 504 // title bar (e.g., in Ubuntu Unity, if the window is maximized). |
497 if (!views::ViewsDelegate::GetInstance()) | 505 if (!views::ViewsDelegate::GetInstance()) |
498 return true; | 506 return true; |
499 return !views::ViewsDelegate::GetInstance()->WindowManagerProvidesTitleBar( | 507 return !views::ViewsDelegate::GetInstance()->WindowManagerProvidesTitleBar( |
500 IsMaximized()); | 508 IsMaximized()); |
501 } | 509 } |
502 | 510 |
503 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 511 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
504 // The top area height in dp (only used when there's no frame image). | |
505 // TODO(pkasting): investigate removing this constant. See crbug.com/590301 | |
506 const int kHeight = 64; | |
507 const gfx::ImageSkia frame_image = GetFrameImage(); | 512 const gfx::ImageSkia frame_image = GetFrameImage(); |
508 int top_area_height = frame_image.isNull() ? kHeight : frame_image.height(); | 513 int top_area_height = frame_image.height(); // Returns 0 if isNull() |
Peter Kasting
2017/01/17 21:05:16
Nit: Trailing period if you're keeping this commen
Tom (Use chromium acct)
2017/01/17 21:23:14
Done.
| |
509 if (browser_view()->IsTabStripVisible()) { | 514 if (browser_view()->IsTabStripVisible()) { |
510 top_area_height = | 515 top_area_height = |
511 std::max(top_area_height, | 516 std::max(top_area_height, |
512 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 517 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
513 } | 518 } |
514 return top_area_height; | 519 return top_area_height; |
515 } | 520 } |
516 | 521 |
517 void OpaqueBrowserFrameView::PaintRestoredFrameBorder( | 522 void OpaqueBrowserFrameView::PaintRestoredFrameBorder( |
518 gfx::Canvas* canvas) const { | 523 gfx::Canvas* canvas) const { |
519 frame_background_->set_frame_color(GetFrameColor()); | |
520 frame_background_->set_theme_image(GetFrameImage()); | |
521 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); | |
522 frame_background_->set_top_area_height(GetTopAreaHeight()); | |
523 | |
524 const ui::ThemeProvider* tp = GetThemeProvider(); | 524 const ui::ThemeProvider* tp = GetThemeProvider(); |
525 frame_background_->SetSideImages( | 525 frame_background_->SetSideImages( |
526 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), | 526 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), |
527 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), | 527 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), |
528 tp->GetImageSkiaNamed(IDR_WINDOW_RIGHT_SIDE), | 528 tp->GetImageSkiaNamed(IDR_WINDOW_RIGHT_SIDE), |
529 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_CENTER)); | 529 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_CENTER)); |
530 frame_background_->SetCornerImages( | 530 frame_background_->SetCornerImages( |
531 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_LEFT_CORNER), | 531 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_LEFT_CORNER), |
532 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_RIGHT_CORNER), | 532 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_RIGHT_CORNER), |
533 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER), | 533 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER), |
534 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER)); | 534 tp->GetImageSkiaNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER)); |
535 frame_background_->PaintRestored(canvas, this); | 535 frame_background_->PaintRestored(canvas, this); |
536 | 536 |
537 // Note: When we don't have a toolbar, we need to draw some kind of bottom | 537 // Note: When we don't have a toolbar, we need to draw some kind of bottom |
538 // edge here. Because the App Window graphics we use for this have an | 538 // edge here. Because the App Window graphics we use for this have an |
539 // attached client edge and their sizing algorithm is a little involved, we do | 539 // attached client edge and their sizing algorithm is a little involved, we do |
540 // all this in PaintRestoredClientEdge(). | 540 // all this in PaintRestoredClientEdge(). |
541 } | 541 } |
542 | 542 |
543 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder( | 543 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder( |
544 gfx::Canvas* canvas) const { | 544 gfx::Canvas* canvas) const { |
545 frame_background_->set_frame_color(GetFrameColor()); | |
546 frame_background_->set_theme_image(GetFrameImage()); | |
547 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); | |
548 frame_background_->set_top_area_height(GetTopAreaHeight()); | |
549 frame_background_->set_maximized_top_inset( | 545 frame_background_->set_maximized_top_inset( |
550 GetTopInset(true) - GetTopInset(false)); | 546 GetTopInset(true) - GetTopInset(false)); |
551 frame_background_->PaintMaximized(canvas, this); | 547 frame_background_->PaintMaximized(canvas, this); |
552 } | 548 } |
553 | 549 |
554 void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const { | 550 void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const { |
555 // TODO(estade): can this be shared with OpaqueBrowserFrameView? | 551 // TODO(estade): can this be shared with OpaqueBrowserFrameView? |
556 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 552 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
557 if (toolbar_bounds.IsEmpty()) | 553 if (toolbar_bounds.IsEmpty()) |
558 return; | 554 return; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 gfx::Rect side(x, y, kClientEdgeThickness, h); | 662 gfx::Rect side(x, y, kClientEdgeThickness, h); |
667 canvas->FillRect(side, color); | 663 canvas->FillRect(side, color); |
668 if (draw_bottom) { | 664 if (draw_bottom) { |
669 canvas->FillRect(gfx::Rect(x, y + h, w + (2 * kClientEdgeThickness), | 665 canvas->FillRect(gfx::Rect(x, y + h, w + (2 * kClientEdgeThickness), |
670 kClientEdgeThickness), | 666 kClientEdgeThickness), |
671 color); | 667 color); |
672 } | 668 } |
673 side.Offset(w + kClientEdgeThickness, 0); | 669 side.Offset(w + kClientEdgeThickness, 0); |
674 canvas->FillRect(side, color); | 670 canvas->FillRect(side, color); |
675 } | 671 } |
OLD | NEW |