OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/apps/glass_app_window_frame_view_win.h" | 5 #include "chrome/browser/ui/views/apps/glass_app_window_frame_view_win.h" |
6 | 6 |
7 #include "apps/ui/native_app_window.h" | 7 #include "apps/ui/native_app_window.h" |
8 #include "ui/base/hit_test.h" | 8 #include "ui/base/hit_test.h" |
| 9 #include "ui/gfx/win/dpi.h" |
9 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
10 #include "ui/views/widget/widget_delegate.h" | 11 #include "ui/views/widget/widget_delegate.h" |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 const int kResizeAreaCornerSize = 16; | 15 const int kResizeAreaCornerSize = 16; |
15 | 16 |
16 } // namespace | 17 } // namespace |
17 | 18 |
18 const char GlassAppWindowFrameViewWin::kViewClassName[] = | 19 const char GlassAppWindowFrameViewWin::kViewClassName[] = |
19 "ui/views/apps/GlassAppWindowFrameViewWin"; | 20 "ui/views/apps/GlassAppWindowFrameViewWin"; |
20 | 21 |
21 GlassAppWindowFrameViewWin::GlassAppWindowFrameViewWin( | 22 GlassAppWindowFrameViewWin::GlassAppWindowFrameViewWin( |
22 apps::NativeAppWindow* window, | 23 apps::NativeAppWindow* window, |
23 views::Widget* widget) | 24 views::Widget* widget) |
24 : window_(window), widget_(widget) { | 25 : window_(window), widget_(widget) { |
25 } | 26 } |
26 | 27 |
27 GlassAppWindowFrameViewWin::~GlassAppWindowFrameViewWin() { | 28 GlassAppWindowFrameViewWin::~GlassAppWindowFrameViewWin() { |
28 } | 29 } |
29 | 30 |
30 gfx::Insets GlassAppWindowFrameViewWin::GetGlassInsets() const { | 31 gfx::Insets GlassAppWindowFrameViewWin::GetGlassInsets() const { |
31 // If 1 is not subtracted, they are too big. There is possibly some reason | 32 // If 1 is not subtracted, they are too big. There is possibly some reason |
32 // for that. | 33 // for that. |
33 // Also make sure the insets don't go below 1, as bad things happen when they | 34 // Also make sure the insets don't go below 1, as bad things happen when they |
34 // do. | 35 // do. |
35 int caption_height = std::max( | 36 int caption_height = std::max(0, |
36 0, GetSystemMetrics(SM_CYSMICON) + GetSystemMetrics(SM_CYSIZEFRAME) - 1); | 37 gfx::win::GetSystemMetricsInDIP(SM_CYSMICON) + |
37 int frame_size = std::max(1, GetSystemMetrics(SM_CXSIZEFRAME) - 1); | 38 gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME) - 1); |
| 39 int frame_size = |
| 40 std::max(1, gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME) - 1); |
38 return gfx::Insets( | 41 return gfx::Insets( |
39 frame_size + caption_height, frame_size, frame_size, frame_size); | 42 frame_size + caption_height, frame_size, frame_size, frame_size); |
40 } | 43 } |
41 | 44 |
42 gfx::Rect GlassAppWindowFrameViewWin::GetBoundsForClientView() const { | 45 gfx::Rect GlassAppWindowFrameViewWin::GetBoundsForClientView() const { |
43 if (widget_->IsFullscreen()) | 46 if (widget_->IsFullscreen()) |
44 return bounds(); | 47 return bounds(); |
45 | 48 |
46 gfx::Insets insets = GetGlassInsets(); | 49 gfx::Insets insets = GetGlassInsets(); |
47 return gfx::Rect(insets.left(), | 50 return gfx::Rect(insets.left(), |
(...skipping 18 matching lines...) Expand all Loading... |
66 if (!bounds().Contains(point)) | 69 if (!bounds().Contains(point)) |
67 return HTNOWHERE; | 70 return HTNOWHERE; |
68 | 71 |
69 // Check the frame first, as we allow a small area overlapping the contents | 72 // Check the frame first, as we allow a small area overlapping the contents |
70 // to be used for resize handles. | 73 // to be used for resize handles. |
71 bool can_ever_resize = widget_->widget_delegate() | 74 bool can_ever_resize = widget_->widget_delegate() |
72 ? widget_->widget_delegate()->CanResize() | 75 ? widget_->widget_delegate()->CanResize() |
73 : false; | 76 : false; |
74 // Don't allow overlapping resize handles when the window is maximized or | 77 // Don't allow overlapping resize handles when the window is maximized or |
75 // fullscreen, as it can't be resized in those states. | 78 // fullscreen, as it can't be resized in those states. |
76 int resize_border = GetSystemMetrics(SM_CXSIZEFRAME); | 79 int resize_border = gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME); |
77 int frame_component = | 80 int frame_component = |
78 GetHTComponentForFrame(point, | 81 GetHTComponentForFrame(point, |
79 resize_border, | 82 resize_border, |
80 resize_border, | 83 resize_border, |
81 kResizeAreaCornerSize - resize_border, | 84 kResizeAreaCornerSize - resize_border, |
82 kResizeAreaCornerSize - resize_border, | 85 kResizeAreaCornerSize - resize_border, |
83 can_ever_resize); | 86 can_ever_resize); |
84 if (frame_component != HTNOWHERE) | 87 if (frame_component != HTNOWHERE) |
85 return frame_component; | 88 return frame_component; |
86 | 89 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 124 |
122 // Add to the client maximum size the height of any title bar and borders. | 125 // Add to the client maximum size the height of any title bar and borders. |
123 gfx::Size client_size = GetBoundsForClientView().size(); | 126 gfx::Size client_size = GetBoundsForClientView().size(); |
124 if (max_size.width()) | 127 if (max_size.width()) |
125 max_size.Enlarge(width() - client_size.width(), 0); | 128 max_size.Enlarge(width() - client_size.width(), 0); |
126 if (max_size.height()) | 129 if (max_size.height()) |
127 max_size.Enlarge(0, height() - client_size.height()); | 130 max_size.Enlarge(0, height() - client_size.height()); |
128 | 131 |
129 return max_size; | 132 return max_size; |
130 } | 133 } |
OLD | NEW |