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

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

Issue 2381283003: Have Chrome draw top window border when using custom titlebar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove default Created 4 years, 2 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 <dwmapi.h> 7 #include <dwmapi.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view()->tabstrip()); 502 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view()->tabstrip());
503 503
504 gfx::ScopedCanvas scoped_canvas(canvas); 504 gfx::ScopedCanvas scoped_canvas(canvas);
505 float scale = canvas->UndoDeviceScaleFactor(); 505 float scale = canvas->UndoDeviceScaleFactor();
506 // This is the pixel-accurate version of WindowTopY(). Scaling the DIP values 506 // This is the pixel-accurate version of WindowTopY(). Scaling the DIP values
507 // here compounds precision error, which exposes the native Windows caption 507 // here compounds precision error, which exposes the native Windows caption
508 // buttons we need to draw over. (see the comment in 508 // buttons we need to draw over. (see the comment in
509 // BrowserDesktopWindowTreeHostWin::UpdateDWMFrame()). 509 // BrowserDesktopWindowTreeHostWin::UpdateDWMFrame()).
510 const int y = IsMaximized() ? FrameTopBorderThicknessPx(false) : 1; 510 const int y = IsMaximized() ? FrameTopBorderThicknessPx(false) : 1;
511 SkPaint paint; 511 SkPaint paint;
512
513 // Draw the top of the accent border.
514 //
515 // We let the DWM do this for the other sides of the window by insetting the
516 // client area to leave nonclient area available. However, along the top
517 // window edge, we have to have zero nonclient area or the DWM will draw a
518 // full native titlebar outside our client area. See
519 // BrowserDesktopWindowTreeHostWin::GetClientAreaInsets().
520 //
521 // We could ask the DWM to draw the top accent border in the client area (by
522 // calling DwmExtendFrameIntoClientArea() in
523 // BrowserDesktopWindowTreeHostWin::UpdateDWMFrame()), but this requires
524 // that we leave part of the client surface transparent. If we draw this
525 // ourselves, we can make the client surface fully opaque and avoid the
526 // power consumption needed for DWM to blend the window contents.
527 //
528 // So the accent border also has to be opaque, but native inactive borders
529 // are #565656 with 80% alpha. We copy Edge (which also custom-draws its top
530 // border) and use #A2A2A2 instead.
531 constexpr SkColor inactive_border_color = 0xFFA2A2A2;
532 paint.setColor(
533 ShouldPaintAsActive()
534 ? GetThemeProvider()->GetColor(ThemeProperties::COLOR_ACCENT_BORDER)
535 : inactive_border_color);
536 canvas->DrawRect(gfx::RectF(0, 0, width() * scale, y), paint);
537
512 paint.setColor(frame_color); 538 paint.setColor(frame_color);
513 canvas->DrawRect( 539 canvas->DrawRect(
514 gfx::RectF(0, y, width() * scale, tabstrip_bounds.bottom() * scale - y), 540 gfx::RectF(0, y, width() * scale, tabstrip_bounds.bottom() * scale - y),
515 paint); 541 paint);
516
517 // The 1 pixel line at the top is drawn by Windows when we leave that section
518 // of the window blank because we have called DwmExtendFrameIntoClientArea()
519 // inside BrowserDesktopWindowTreeHostWin::UpdateDWMFrame().
520 } 542 }
521 543
522 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const { 544 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const {
523 // TODO(estade): can this be shared with OpaqueBrowserFrameView? 545 // TODO(estade): can this be shared with OpaqueBrowserFrameView?
524 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); 546 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
525 if (toolbar_bounds.IsEmpty()) 547 if (toolbar_bounds.IsEmpty())
526 return; 548 return;
527 gfx::Point toolbar_origin(toolbar_bounds.origin()); 549 gfx::Point toolbar_origin(toolbar_bounds.origin());
528 ConvertPointToTarget(browser_view(), this, &toolbar_origin); 550 ConvertPointToTarget(browser_view(), this, &toolbar_origin);
529 toolbar_bounds.set_origin(toolbar_origin); 551 toolbar_bounds.set_origin(toolbar_origin);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 static bool initialized = false; 797 static bool initialized = false;
776 if (!initialized) { 798 if (!initialized) {
777 for (int i = 0; i < kThrobberIconCount; ++i) { 799 for (int i = 0; i < kThrobberIconCount; ++i) {
778 throbber_icons_[i] = 800 throbber_icons_[i] =
779 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); 801 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i);
780 DCHECK(throbber_icons_[i]); 802 DCHECK(throbber_icons_[i]);
781 } 803 }
782 initialized = true; 804 initialized = true;
783 } 805 }
784 } 806 }
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