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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
12 #include "chrome/app/chrome_dll_resource.h" | 12 #include "chrome/app/chrome_dll_resource.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/themes/theme_properties.h" | 14 #include "chrome/browser/themes/theme_properties.h" |
15 #include "chrome/browser/ui/layout_constants.h" | 15 #include "chrome/browser/ui/layout_constants.h" |
16 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
17 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h" | 17 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h" |
18 #include "chrome/browser/ui/views/tabs/tab.h" | 18 #include "chrome/browser/ui/views/tabs/tab.h" |
19 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 19 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
21 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
22 #include "components/signin/core/browser/signin_header_helper.h" | 22 #include "components/signin/core/browser/signin_header_helper.h" |
23 #include "components/signin/core/common/profile_management_switches.h" | 23 #include "components/signin/core/common/profile_management_switches.h" |
24 #include "dwmapi.h" | |
Peter Kasting
2016/07/18 19:12:15
This should be in <> and moved up above the <utili
kylix_rd
2016/07/18 20:35:10
Done.
| |
24 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
25 #include "skia/ext/image_operations.h" | 26 #include "skia/ext/image_operations.h" |
26 #include "ui/base/material_design/material_design_controller.h" | 27 #include "ui/base/material_design/material_design_controller.h" |
27 #include "ui/base/resource/resource_bundle_win.h" | 28 #include "ui/base/resource/resource_bundle_win.h" |
28 #include "ui/base/theme_provider.h" | 29 #include "ui/base/theme_provider.h" |
29 #include "ui/display/win/dpi.h" | 30 #include "ui/display/win/dpi.h" |
30 #include "ui/gfx/canvas.h" | 31 #include "ui/gfx/canvas.h" |
32 #include "ui/gfx/geometry/dip_util.h" | |
31 #include "ui/gfx/icon_util.h" | 33 #include "ui/gfx/icon_util.h" |
32 #include "ui/gfx/image/image.h" | 34 #include "ui/gfx/image/image.h" |
33 #include "ui/gfx/scoped_canvas.h" | 35 #include "ui/gfx/scoped_canvas.h" |
34 #include "ui/resources/grit/ui_resources.h" | 36 #include "ui/resources/grit/ui_resources.h" |
35 #include "ui/views/controls/label.h" | 37 #include "ui/views/controls/label.h" |
36 #include "ui/views/layout/layout_constants.h" | 38 #include "ui/views/layout/layout_constants.h" |
37 #include "ui/views/resources/grit/views_resources.h" | 39 #include "ui/views/resources/grit/views_resources.h" |
38 #include "ui/views/win/hwnd_util.h" | 40 #include "ui/views/win/hwnd_util.h" |
39 #include "ui/views/window/client_view.h" | 41 #include "ui/views/window/client_view.h" |
40 | 42 |
(...skipping 22 matching lines...) Expand all Loading... | |
63 const int kNewTabCaptionRestoredSpacing = 5; | 65 const int kNewTabCaptionRestoredSpacing = 5; |
64 // In maximized mode, where the New Tab button and the caption buttons are at | 66 // In maximized mode, where the New Tab button and the caption buttons are at |
65 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid | 67 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid |
66 // looking too cluttered. | 68 // looking too cluttered. |
67 const int kNewTabCaptionMaximizedSpacing = 16; | 69 const int kNewTabCaptionMaximizedSpacing = 16; |
68 // Height of the profile switcher button. Same as the height of the Windows 7/8 | 70 // Height of the profile switcher button. Same as the height of the Windows 7/8 |
69 // caption buttons. | 71 // caption buttons. |
70 // TODO(bsep): Windows 10 caption buttons look very different and we would like | 72 // TODO(bsep): Windows 10 caption buttons look very different and we would like |
71 // the profile switcher button to match on that platform. | 73 // the profile switcher button to match on that platform. |
72 const int kProfileSwitcherButtonHeight = 20; | 74 const int kProfileSwitcherButtonHeight = 20; |
75 // There is a small one-pixel strip right above the caption buttons in which the | |
76 // sizable frame "peeks" through. This will ensure that the behavior is | |
Peter Kasting
2016/07/18 19:12:16
Nit: sizable frame -> resize border
I would omit
kylix_rd
2016/07/18 20:35:10
Done.
| |
77 // consistent with most Windows applications. | |
78 const int kCaptionButtonTopInset = 1; | |
73 | 79 |
74 // Converts the |image| to a Windows icon and returns the corresponding HICON | 80 // Converts the |image| to a Windows icon and returns the corresponding HICON |
75 // handle. |image| is resized to desired |width| and |height| if needed. | 81 // handle. |image| is resized to desired |width| and |height| if needed. |
76 base::win::ScopedHICON CreateHICONFromSkBitmapSizedTo( | 82 base::win::ScopedHICON CreateHICONFromSkBitmapSizedTo( |
77 const gfx::ImageSkia& image, | 83 const gfx::ImageSkia& image, |
78 int width, | 84 int width, |
79 int height) { | 85 int height) { |
80 return IconUtil::CreateHICONFromSkBitmap( | 86 return IconUtil::CreateHICONFromSkBitmap( |
81 width == image.width() && height == image.height() | 87 width == image.width() && height == image.height() |
82 ? *image.bitmap() | 88 ? *image.bitmap() |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 gfx::Rect sys_menu_region(client_border_thickness, | 244 gfx::Rect sys_menu_region(client_border_thickness, |
239 display::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME), | 245 display::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME), |
240 display::win::GetSystemMetricsInDIP(SM_CXSMICON), | 246 display::win::GetSystemMetricsInDIP(SM_CXSMICON), |
241 display::win::GetSystemMetricsInDIP(SM_CYSMICON)); | 247 display::win::GetSystemMetricsInDIP(SM_CYSMICON)); |
242 if (sys_menu_region.Contains(point)) | 248 if (sys_menu_region.Contains(point)) |
243 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; | 249 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; |
244 | 250 |
245 if (frame_component != HTNOWHERE) | 251 if (frame_component != HTNOWHERE) |
246 return frame_component; | 252 return frame_component; |
247 | 253 |
254 // On Windows 8+, the caption buttons are almost butted up to the top right | |
255 // of the window. This code will ensure that the mouse isn't set to a size | |
Peter Kasting
2016/07/18 19:12:15
Nit: of -> corner of
kylix_rd
2016/07/18 20:35:10
Done.
| |
256 // cursor while hovering over the caption buttons, thus giving the incorrect | |
257 // impression that the user can resize the window. | |
258 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | |
259 RECT button_bounds = {0}; | |
260 const HWND hwnd = views::HWNDForWidget(frame()); | |
Peter Kasting
2016/07/18 19:12:15
Nit: I'd probably just inline this into the next s
kylix_rd
2016/07/18 20:35:10
Done.
| |
261 | |
Peter Kasting
2016/07/18 19:12:16
Nit: No blank here
kylix_rd
2016/07/18 20:35:10
Done.
| |
262 if (SUCCEEDED(DwmGetWindowAttribute(hwnd, DWMWA_CAPTION_BUTTON_BOUNDS, | |
263 &button_bounds, | |
264 sizeof(button_bounds)))) { | |
265 // Even though the tiny area above the caption buttons is very difficult | |
266 // to hit, this ensures behavioral consistency with other top-level | |
267 // windows. | |
Peter Kasting
2016/07/18 19:12:15
Nit: This comment really belongs on the Inset() ca
kylix_rd
2016/07/18 20:35:10
Done.
| |
268 gfx::Rect buttons = gfx::ConvertRectToDIP(display::win::GetDPIScale(), | |
269 gfx::Rect(button_bounds)); | |
270 buttons.Inset(0, kCaptionButtonTopInset, 0, 0); | |
Peter Kasting
2016/07/18 19:12:16
Is it correct to inset after scaling? It's hard f
kylix_rd
2016/07/18 20:35:10
From my (admittedly empirical) investigation, it d
| |
271 if (buttons.Contains(point)) | |
272 return (HTNOWHERE); | |
Peter Kasting
2016/07/18 19:12:16
Should this be HTCAPTION?
Nit: No parens
kylix_rd
2016/07/18 20:35:10
I want to ensure that subsequent processing lands
| |
273 } | |
274 } | |
275 | |
248 int top_border_thickness = FrameTopBorderThickness(false); | 276 int top_border_thickness = FrameTopBorderThickness(false); |
249 // We want the resize corner behavior to apply to the kResizeCornerWidth | 277 // We want the resize corner behavior to apply to the kResizeCornerWidth |
250 // pixels at each end of the top and bottom edges. Because |point|'s x | 278 // pixels at each end of the top and bottom edges. Because |point|'s x |
251 // coordinate is based on the DWM-inset portion of the window (so, it's 0 at | 279 // coordinate is based on the DWM-inset portion of the window (so, it's 0 at |
252 // the first pixel inside the left DWM margin), we need to subtract the DWM | 280 // the first pixel inside the left DWM margin), we need to subtract the DWM |
253 // margin thickness, which we calculate as the total frame border thickness | 281 // margin thickness, which we calculate as the total frame border thickness |
254 // minus the nonclient border thickness. | 282 // minus the nonclient border thickness. |
255 const int dwm_margin = FrameBorderThickness() - client_border_thickness; | 283 const int dwm_margin = FrameBorderThickness() - client_border_thickness; |
256 int window_component = GetHTComponentForFrame( | 284 int window_component = GetHTComponentForFrame( |
257 point, top_border_thickness, client_border_thickness, | 285 point, top_border_thickness, client_border_thickness, |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 static bool initialized = false; | 705 static bool initialized = false; |
678 if (!initialized) { | 706 if (!initialized) { |
679 for (int i = 0; i < kThrobberIconCount; ++i) { | 707 for (int i = 0; i < kThrobberIconCount; ++i) { |
680 throbber_icons_[i] = | 708 throbber_icons_[i] = |
681 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 709 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
682 DCHECK(throbber_icons_[i]); | 710 DCHECK(throbber_icons_[i]); |
683 } | 711 } |
684 initialized = true; | 712 initialized = true; |
685 } | 713 } |
686 } | 714 } |
OLD | NEW |