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/glass_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "components/signin/core/browser/signin_header_helper.h" | 21 #include "components/signin/core/browser/signin_header_helper.h" |
22 #include "components/signin/core/common/profile_management_switches.h" | 22 #include "components/signin/core/common/profile_management_switches.h" |
23 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
24 #include "skia/ext/image_operations.h" | 24 #include "skia/ext/image_operations.h" |
25 #include "ui/base/resource/material_design/material_design_controller.h" | 25 #include "ui/base/resource/material_design/material_design_controller.h" |
26 #include "ui/base/resource/resource_bundle_win.h" | 26 #include "ui/base/resource/resource_bundle_win.h" |
27 #include "ui/base/theme_provider.h" | 27 #include "ui/base/theme_provider.h" |
28 #include "ui/gfx/canvas.h" | 28 #include "ui/gfx/canvas.h" |
29 #include "ui/gfx/icon_util.h" | 29 #include "ui/gfx/icon_util.h" |
30 #include "ui/gfx/image/image.h" | 30 #include "ui/gfx/image/image.h" |
31 #include "ui/gfx/scoped_canvas.h" | |
31 #include "ui/gfx/win/dpi.h" | 32 #include "ui/gfx/win/dpi.h" |
32 #include "ui/resources/grit/ui_resources.h" | 33 #include "ui/resources/grit/ui_resources.h" |
33 #include "ui/views/controls/label.h" | 34 #include "ui/views/controls/label.h" |
34 #include "ui/views/layout/layout_constants.h" | 35 #include "ui/views/layout/layout_constants.h" |
35 #include "ui/views/resources/grit/views_resources.h" | 36 #include "ui/views/resources/grit/views_resources.h" |
36 #include "ui/views/win/hwnd_util.h" | 37 #include "ui/views/win/hwnd_util.h" |
37 #include "ui/views/window/client_view.h" | 38 #include "ui/views/window/client_view.h" |
38 | 39 |
39 HICON GlassBrowserFrameView::throbber_icons_[ | 40 HICON GlassBrowserFrameView::throbber_icons_[ |
40 GlassBrowserFrameView::kThrobberIconCount]; | 41 GlassBrowserFrameView::kThrobberIconCount]; |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_SEPARATOR); | 360 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_SEPARATOR); |
360 | 361 |
361 if (browser_view()->IsTabStripVisible()) { | 362 if (browser_view()->IsTabStripVisible()) { |
362 gfx::ImageSkia* bg = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); | 363 gfx::ImageSkia* bg = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
363 int x = toolbar_bounds.x(); | 364 int x = toolbar_bounds.x(); |
364 const int y = toolbar_bounds.y(); | 365 const int y = toolbar_bounds.y(); |
365 const int bg_y = | 366 const int bg_y = |
366 GetTopInset(false) + Tab::GetYInsetForActiveTabBackground(); | 367 GetTopInset(false) + Tab::GetYInsetForActiveTabBackground(); |
367 int w = toolbar_bounds.width(); | 368 int w = toolbar_bounds.width(); |
368 | 369 |
369 // Background. The top stroke is drawn using the IDR_CONTENT_TOP_XXX | 370 if (md) { |
370 // images, which overlay the toolbar. The top 2 px of these images is the | 371 // Background. The top stroke is drawn above the toolbar bounds, so |
371 // actual top stroke + shadow, and is partly transparent, so the toolbar | 372 // unlike in the non-Material Design code below, we don't need to exclude |
372 // background shouldn't be drawn over it. | 373 // any region from having the background image drawn over it. |
373 const int split_point = std::min(kContentEdgeShadowThickness, h); | 374 if (tp->HasCustomImage(IDR_THEME_TOOLBAR)) { |
374 if (h > split_point) { | 375 canvas->TileImageInt(*bg, x + GetThemeBackgroundXInset(), y - bg_y, x, |
375 const int split_y = y + split_point; | 376 y, w, h); |
376 canvas->TileImageInt(*bg, x + GetThemeBackgroundXInset(), split_y - bg_y, | 377 } else { |
377 x, split_y, w, h - split_point); | 378 canvas->FillRect(toolbar_bounds, |
379 tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); | |
380 } | |
381 | |
382 // Material Design has no corners to mask out. | |
383 | |
384 // Top stroke. For Material Design, the toolbar has no side strokes. | |
385 gfx::Rect separator_rect(x, y, w, 0); | |
386 gfx::ScopedCanvas scoped_canvas(canvas); | |
387 gfx::Rect tabstrip_bounds( | |
388 GetBoundsForTabStrip(browser_view()->tabstrip())); | |
389 tabstrip_bounds.set_x(GetMirroredXForRect(tabstrip_bounds)); | |
390 canvas->sk_canvas()->clipRect(gfx::RectToSkRect(tabstrip_bounds), | |
391 SkRegion::kDifference_Op); | |
392 separator_rect.set_y(tabstrip_bounds.bottom()); | |
393 BrowserView::Paint1pxHorizontalLine( | |
394 canvas, SkColorSetA(SK_ColorBLACK, 0x40), separator_rect, true); | |
395 } else { | |
Peter Kasting
2015/12/09 01:20:30
This arm is copied verbatim from before, just inde
| |
396 // Background. The top stroke is drawn using the IDR_CONTENT_TOP_XXX | |
397 // images, which overlay the toolbar. The top 2 px of these images is the | |
398 // actual top stroke + shadow, and is partly transparent, so the toolbar | |
399 // background shouldn't be drawn over it. | |
400 const int split_point = std::min(kContentEdgeShadowThickness, h); | |
401 if (h > split_point) { | |
402 const int split_y = y + split_point; | |
403 canvas->TileImageInt(*bg, x + GetThemeBackgroundXInset(), | |
404 split_y - bg_y, x, split_y, w, h - split_point); | |
405 } | |
406 | |
407 // On Windows 10+ where we don't draw our own window border but rather go | |
408 // right to the system border, the toolbar has no corners or side strokes. | |
409 if (base::win::GetVersion() < base::win::VERSION_WIN10) { | |
410 // Mask out the corners. | |
411 gfx::ImageSkia* left = | |
412 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER); | |
413 const int img_w = left->width(); | |
414 x -= kContentEdgeShadowThickness; | |
415 SkPaint paint; | |
416 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); | |
417 canvas->DrawImageInt( | |
418 *tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK), 0, 0, | |
419 img_w, h, x, y, img_w, h, false, paint); | |
420 const int right_x = | |
421 toolbar_bounds.right() + kContentEdgeShadowThickness - img_w; | |
422 canvas->DrawImageInt( | |
423 *tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK), 0, 0, | |
424 img_w, h, right_x, y, img_w, h, false, paint); | |
425 | |
426 // Corner and side strokes. | |
427 canvas->DrawImageInt(*left, 0, 0, img_w, h, x, y, img_w, h, false); | |
428 canvas->DrawImageInt( | |
429 *tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER), 0, 0, img_w, | |
430 h, right_x, y, img_w, h, false); | |
431 | |
432 x += img_w; | |
433 w = right_x - x; | |
434 } | |
435 | |
436 // Top stroke. | |
437 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER), x, y, | |
438 w, split_point); | |
378 } | 439 } |
379 | |
380 // On Windows 10+ where we don't draw our own window border but rather go | |
381 // right to the system border, the toolbar has no corners or side strokes. | |
382 if (base::win::GetVersion() < base::win::VERSION_WIN10) { | |
383 // Mask out the corners. | |
384 gfx::ImageSkia* left = tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER); | |
385 const int img_w = left->width(); | |
386 x -= kContentEdgeShadowThickness; | |
387 SkPaint paint; | |
388 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); | |
389 canvas->DrawImageInt( | |
390 *tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK), 0, 0, img_w, | |
391 h, x, y, img_w, h, false, paint); | |
392 const int right_x = | |
393 toolbar_bounds.right() + kContentEdgeShadowThickness - img_w; | |
394 canvas->DrawImageInt( | |
395 *tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK), 0, 0, | |
396 img_w, h, right_x, y, img_w, h, false, paint); | |
397 | |
398 // Corner and side strokes. | |
399 canvas->DrawImageInt(*left, 0, 0, img_w, h, x, y, img_w, h, false); | |
400 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER), | |
401 0, 0, img_w, h, right_x, y, img_w, h, false); | |
402 | |
403 x += img_w; | |
404 w = right_x - x; | |
405 } | |
406 | |
407 // Top stroke. | |
408 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER), x, y, | |
409 w, split_point); | |
410 } | 440 } |
411 | 441 |
412 // Toolbar/content separator. | 442 // Toolbar/content separator. |
413 toolbar_bounds.Inset(kClientEdgeThickness, h - kClientEdgeThickness, | 443 toolbar_bounds.Inset(kClientEdgeThickness, h - kClientEdgeThickness, |
414 kClientEdgeThickness, 0); | 444 kClientEdgeThickness, 0); |
415 if (md) { | 445 if (md) { |
416 BrowserView::Paint1pxHorizontalLine(canvas, separator_color, | 446 BrowserView::Paint1pxHorizontalLine(canvas, separator_color, |
417 toolbar_bounds, true); | 447 toolbar_bounds, true); |
418 } else { | 448 } else { |
419 canvas->FillRect(toolbar_bounds, separator_color); | 449 canvas->FillRect(toolbar_bounds, separator_color); |
(...skipping 21 matching lines...) Expand all Loading... | |
441 | 471 |
442 // Popup and app windows don't custom-draw any other edges, so we're done. | 472 // Popup and app windows don't custom-draw any other edges, so we're done. |
443 return; | 473 return; |
444 } | 474 } |
445 | 475 |
446 // In maximized mode, the only edge to draw is the top one, so we're done. | 476 // In maximized mode, the only edge to draw is the top one, so we're done. |
447 if (frame()->IsMaximized()) | 477 if (frame()->IsMaximized()) |
448 return; | 478 return; |
449 | 479 |
450 const int x = client_bounds.x(); | 480 const int x = client_bounds.x(); |
451 y += toolbar_bounds.bottom(); // The side edges start below the toolbar. | 481 // Pre-Material Design, the client edge images start below the toolbar. In MD |
452 const int img_y = y; | 482 // the client edge images start at the top of the toolbar. |
483 y += toolbar_bounds.bottom(); | |
484 const int img_y = ui::MaterialDesignController::IsModeMaterial() ? | |
485 (y - toolbar_bounds.height()) : y; | |
453 const int w = client_bounds.width(); | 486 const int w = client_bounds.width(); |
454 const int right = client_bounds.right(); | 487 const int right = client_bounds.right(); |
455 const int bottom = std::max(y, height() - NonClientBorderThickness(false)); | 488 const int bottom = std::max(y, height() - NonClientBorderThickness(false)); |
456 const int height = bottom - img_y; | 489 const int height = bottom - img_y; |
457 | 490 |
458 // Draw the client edge images. | 491 // Draw the client edge images. |
459 gfx::ImageSkia* right_image = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); | 492 gfx::ImageSkia* right_image = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); |
460 const int img_w = right_image->width(); | 493 const int img_w = right_image->width(); |
461 canvas->TileImageInt(*right_image, right, img_y, img_w, height); | 494 canvas->TileImageInt(*right_image, right, img_y, img_w, height); |
462 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), | 495 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 static bool initialized = false; | 671 static bool initialized = false; |
639 if (!initialized) { | 672 if (!initialized) { |
640 for (int i = 0; i < kThrobberIconCount; ++i) { | 673 for (int i = 0; i < kThrobberIconCount; ++i) { |
641 throbber_icons_[i] = | 674 throbber_icons_[i] = |
642 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 675 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
643 DCHECK(throbber_icons_[i]); | 676 DCHECK(throbber_icons_[i]); |
644 } | 677 } |
645 initialized = true; | 678 initialized = true; |
646 } | 679 } |
647 } | 680 } |
OLD | NEW |