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

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

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

Powered by Google App Engine
This is Rietveld 408576698