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 "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 11 #include "chrome/app/chrome_dll_resource.h" |
11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/signin/signin_header_helper.h" | 13 #include "chrome/browser/signin/signin_header_helper.h" |
13 #include "chrome/browser/themes/theme_properties.h" | 14 #include "chrome/browser/themes/theme_properties.h" |
14 #include "chrome/browser/ui/views/frame/browser_view.h" | 15 #include "chrome/browser/ui/views/frame/browser_view.h" |
15 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 16 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
16 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" | 17 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" |
17 #include "chrome/browser/ui/views/tabs/tab.h" | 18 #include "chrome/browser/ui/views/tabs/tab.h" |
18 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 19 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
(...skipping 10 matching lines...) Expand all Loading... |
29 #include "ui/resources/grit/ui_resources.h" | 30 #include "ui/resources/grit/ui_resources.h" |
30 #include "ui/views/controls/label.h" | 31 #include "ui/views/controls/label.h" |
31 #include "ui/views/layout/layout_constants.h" | 32 #include "ui/views/layout/layout_constants.h" |
32 #include "ui/views/win/hwnd_util.h" | 33 #include "ui/views/win/hwnd_util.h" |
33 #include "ui/views/window/client_view.h" | 34 #include "ui/views/window/client_view.h" |
34 | 35 |
35 HICON GlassBrowserFrameView::throbber_icons_[ | 36 HICON GlassBrowserFrameView::throbber_icons_[ |
36 GlassBrowserFrameView::kThrobberIconCount]; | 37 GlassBrowserFrameView::kThrobberIconCount]; |
37 | 38 |
38 namespace { | 39 namespace { |
39 // There are 3 px of client edge drawn inside the outer frame borders. | 40 // Size of client edge drawn inside the outer frame borders. |
40 const int kNonClientBorderThickness = 3; | 41 const int kNonClientBorderThicknessPreWin10 = 3; |
| 42 const int kNonClientBorderThicknessWin10 = 1; |
41 // Besides the frame border, there's another 9 px of empty space atop the | 43 // Besides the frame border, there's another 9 px of empty space atop the |
42 // window in restored mode, to use to drag the window around. | 44 // window in restored mode, to use to drag the window around. |
43 const int kNonClientRestoredExtraThickness = 9; | 45 const int kNonClientRestoredExtraThickness = 9; |
44 // In the window corners, the resize areas don't actually expand bigger, but the | 46 // In the window corners, the resize areas don't actually expand bigger, but the |
45 // 16 px at the end of the top and bottom edges triggers diagonal resizing. | 47 // 16 px at the end of the top and bottom edges triggers diagonal resizing. |
46 const int kResizeAreaCornerSize = 16; | 48 const int kResizeAreaCornerSize = 16; |
47 // The avatar ends 2 px above the bottom of the tabstrip (which, given the | 49 // The avatar ends 2 px above the bottom of the tabstrip (which, given the |
48 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the | 50 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the |
49 // user). | 51 // user). |
50 const int kAvatarBottomSpacing = 2; | 52 const int kAvatarBottomSpacing = 2; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 323 |
322 int GlassBrowserFrameView::FrameBorderThickness() const { | 324 int GlassBrowserFrameView::FrameBorderThickness() const { |
323 return (frame()->IsMaximized() || frame()->IsFullscreen()) ? | 325 return (frame()->IsMaximized() || frame()->IsFullscreen()) ? |
324 0 : gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME); | 326 0 : gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME); |
325 } | 327 } |
326 | 328 |
327 int GlassBrowserFrameView::NonClientBorderThickness() const { | 329 int GlassBrowserFrameView::NonClientBorderThickness() const { |
328 if (frame()->IsMaximized() || frame()->IsFullscreen()) | 330 if (frame()->IsMaximized() || frame()->IsFullscreen()) |
329 return 0; | 331 return 0; |
330 | 332 |
331 return kNonClientBorderThickness; | 333 return (base::win::GetVersion() <= base::win::VERSION_WIN8_1) |
| 334 ? kNonClientBorderThicknessPreWin10 |
| 335 : kNonClientBorderThicknessWin10; |
332 } | 336 } |
333 | 337 |
334 int GlassBrowserFrameView::NonClientTopBorderHeight() const { | 338 int GlassBrowserFrameView::NonClientTopBorderHeight() const { |
335 if (frame()->IsFullscreen()) | 339 if (frame()->IsFullscreen()) |
336 return 0; | 340 return 0; |
337 | 341 |
338 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass | 342 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass |
339 // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border | 343 // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border |
340 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). | 344 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). |
341 return gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME) + | 345 return gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME) + |
342 (!frame()->ShouldLeaveOffsetNearTopBorder() ? | 346 (!frame()->ShouldLeaveOffsetNearTopBorder() ? |
343 -kTabstripTopShadowThickness : kNonClientRestoredExtraThickness); | 347 -kTabstripTopShadowThickness : kNonClientRestoredExtraThickness); |
344 } | 348 } |
345 | 349 |
346 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { | 350 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { |
347 ui::ThemeProvider* tp = GetThemeProvider(); | 351 ui::ThemeProvider* tp = GetThemeProvider(); |
348 | 352 |
349 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 353 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
350 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 354 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
351 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); | 355 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); |
352 toolbar_bounds.set_origin(toolbar_origin); | 356 toolbar_bounds.set_origin(toolbar_origin); |
353 int x = toolbar_bounds.x(); | 357 int x = toolbar_bounds.x(); |
354 int w = toolbar_bounds.width(); | 358 int w = toolbar_bounds.width(); |
355 int left_x = x - kContentEdgeShadowThickness; | |
356 | 359 |
357 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); | 360 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
358 gfx::ImageSkia* toolbar_left = tp->GetImageSkiaNamed( | |
359 IDR_CONTENT_TOP_LEFT_CORNER); | |
360 gfx::ImageSkia* toolbar_center = tp->GetImageSkiaNamed( | 361 gfx::ImageSkia* toolbar_center = tp->GetImageSkiaNamed( |
361 IDR_CONTENT_TOP_CENTER); | 362 IDR_CONTENT_TOP_CENTER); |
362 | 363 |
363 // Tile the toolbar image starting at the frame edge on the left and where | 364 // Tile the toolbar image starting at the frame edge on the left and where |
364 // the tabstrip is on the top. | 365 // the tabstrip is on the top. |
365 int y = toolbar_bounds.y(); | 366 int y = toolbar_bounds.y(); |
366 int dest_y = browser_view()->IsTabStripVisible() | 367 int dest_y = browser_view()->IsTabStripVisible() |
367 ? y + (kFrameShadowThickness * 2) | 368 ? y + (kFrameShadowThickness * 2) |
368 : y; | 369 : y; |
369 canvas->TileImageInt(*theme_toolbar, | 370 canvas->TileImageInt(*theme_toolbar, |
370 x + GetThemeBackgroundXInset(), | 371 x + GetThemeBackgroundXInset(), |
371 dest_y - GetTopInset(), x, | 372 dest_y - GetTopInset(), x, |
372 dest_y, w, theme_toolbar->height()); | 373 dest_y, w, theme_toolbar->height()); |
373 | 374 |
374 if (browser_view()->IsTabStripVisible()) { | 375 if (browser_view()->IsTabStripVisible()) { |
375 // Draw rounded corners for the tab. | 376 // On Windows 10, we don't draw our own window border but rather go right to |
376 gfx::ImageSkia* toolbar_left_mask = | 377 // the system border, so we don't need to draw the toolbar edges. |
377 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); | 378 if (base::win::GetVersion() < base::win::VERSION_WIN10) { |
378 gfx::ImageSkia* toolbar_right_mask = | 379 int left_x = x - kContentEdgeShadowThickness; |
379 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); | 380 // Draw rounded corners for the tab. |
| 381 gfx::ImageSkia* toolbar_left_mask = |
| 382 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); |
| 383 gfx::ImageSkia* toolbar_right_mask = |
| 384 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); |
380 | 385 |
381 // We mask out the corners by using the DestinationIn transfer mode, | 386 // We mask out the corners by using the DestinationIn transfer mode, |
382 // which keeps the RGB pixels from the destination and the alpha from | 387 // which keeps the RGB pixels from the destination and the alpha from |
383 // the source. | 388 // the source. |
384 SkPaint paint; | 389 SkPaint paint; |
385 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); | 390 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); |
386 | 391 |
387 // Mask out the top left corner. | 392 // Mask out the top left corner. |
388 canvas->DrawImageInt(*toolbar_left_mask, left_x, y, paint); | 393 canvas->DrawImageInt(*toolbar_left_mask, left_x, y, paint); |
389 | 394 |
390 // Mask out the top right corner. | 395 // Mask out the top right corner. |
391 int right_x = | 396 int right_x = |
392 x + w + kContentEdgeShadowThickness - toolbar_right_mask->width(); | 397 x + w + kContentEdgeShadowThickness - toolbar_right_mask->width(); |
393 canvas->DrawImageInt(*toolbar_right_mask, right_x, y, paint); | 398 canvas->DrawImageInt(*toolbar_right_mask, right_x, y, paint); |
394 | 399 |
395 // Draw left edge. | 400 // Draw left edge. |
396 canvas->DrawImageInt(*toolbar_left, left_x, y); | 401 gfx::ImageSkia* toolbar_left = |
| 402 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER); |
| 403 canvas->DrawImageInt(*toolbar_left, left_x, y); |
397 | 404 |
398 // Draw center edge. | 405 // Draw center edge. |
399 canvas->TileImageInt(*toolbar_center, left_x + toolbar_left->width(), y, | 406 canvas->TileImageInt(*toolbar_center, left_x + toolbar_left->width(), y, |
400 right_x - (left_x + toolbar_left->width()), toolbar_center->height()); | 407 right_x - (left_x + toolbar_left->width()), |
| 408 toolbar_center->height()); |
401 | 409 |
402 // Right edge. | 410 // Right edge. |
403 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER), | 411 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER), |
404 right_x, y); | 412 right_x, y); |
| 413 } else { |
| 414 canvas->TileImageInt(*toolbar_center, x, y, w, toolbar_center->height()); |
| 415 } |
405 } | 416 } |
406 | 417 |
407 // Draw the content/toolbar separator. | 418 // Draw the content/toolbar separator. |
408 canvas->FillRect( | 419 canvas->FillRect( |
409 gfx::Rect(x + kClientEdgeThickness, | 420 gfx::Rect(x + kClientEdgeThickness, |
410 toolbar_bounds.bottom() - kClientEdgeThickness, | 421 toolbar_bounds.bottom() - kClientEdgeThickness, |
411 w - (2 * kClientEdgeThickness), | 422 w - (2 * kClientEdgeThickness), |
412 kClientEdgeThickness), | 423 kClientEdgeThickness), |
413 ThemeProperties::GetDefaultColor( | 424 ThemeProperties::GetDefaultColor( |
414 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 425 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 static bool initialized = false; | 622 static bool initialized = false; |
612 if (!initialized) { | 623 if (!initialized) { |
613 for (int i = 0; i < kThrobberIconCount; ++i) { | 624 for (int i = 0; i < kThrobberIconCount; ++i) { |
614 throbber_icons_[i] = | 625 throbber_icons_[i] = |
615 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 626 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
616 DCHECK(throbber_icons_[i]); | 627 DCHECK(throbber_icons_[i]); |
617 } | 628 } |
618 initialized = true; | 629 initialized = true; |
619 } | 630 } |
620 } | 631 } |
OLD | NEW |