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 "ui/views/window/custom_frame_view.h" | 5 #include "ui/views/window/custom_frame_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
11 #include "grit/ui_strings.h" | 11 #include "grit/ui_strings.h" |
12 #include "ui/base/hit_test.h" | 12 #include "ui/base/hit_test.h" |
13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
16 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.h" |
17 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
18 #include "ui/gfx/path.h" | 18 #include "ui/gfx/path.h" |
19 #include "ui/views/color_constants.h" | 19 #include "ui/views/color_constants.h" |
20 #include "ui/views/controls/button/image_button.h" | 20 #include "ui/views/controls/button/image_button.h" |
21 #include "ui/views/views_delegate.h" | 21 #include "ui/views/views_delegate.h" |
22 #include "ui/views/widget/native_widget_aura.h" | |
23 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
24 #include "ui/views/widget/widget_delegate.h" | 23 #include "ui/views/widget/widget_delegate.h" |
25 #include "ui/views/window/client_view.h" | 24 #include "ui/views/window/client_view.h" |
26 #include "ui/views/window/frame_background.h" | 25 #include "ui/views/window/frame_background.h" |
27 #include "ui/views/window/window_resources.h" | 26 #include "ui/views/window/window_resources.h" |
28 #include "ui/views/window/window_shape.h" | 27 #include "ui/views/window/window_shape.h" |
29 | 28 |
| 29 #if defined(OS_MACOSX) |
| 30 #include "ui/views/widget/native_widget_aura.h" |
| 31 #else |
| 32 #include "ui/views/widget/native_widget_mac.h" |
| 33 #endif |
| 34 |
30 namespace views { | 35 namespace views { |
31 | 36 |
32 namespace { | 37 namespace { |
33 | 38 |
34 // The frame border is only visible in restored mode and is hardcoded to 4 px on | 39 // The frame border is only visible in restored mode and is hardcoded to 4 px on |
35 // each side regardless of the system window border size. | 40 // each side regardless of the system window border size. |
36 const int kFrameBorderThickness = 4; | 41 const int kFrameBorderThickness = 4; |
37 // In the window corners, the resize areas don't actually expand bigger, but the | 42 // In the window corners, the resize areas don't actually expand bigger, but the |
38 // 16 px at the end of each edge triggers diagonal resizing. | 43 // 16 px at the end of each edge triggers diagonal resizing. |
39 const int kResizeAreaCornerSize = 16; | 44 const int kResizeAreaCornerSize = 16; |
(...skipping 16 matching lines...) Expand all Loading... |
56 const SkColor kDefaultColorFrame = SkColorSetRGB(109, 109, 109); | 61 const SkColor kDefaultColorFrame = SkColorSetRGB(109, 109, 109); |
57 const SkColor kDefaultColorFrameInactive = SkColorSetRGB(176, 176, 176); | 62 const SkColor kDefaultColorFrameInactive = SkColorSetRGB(176, 176, 176); |
58 #else | 63 #else |
59 // Windows and Linux use a blue. | 64 // Windows and Linux use a blue. |
60 const SkColor kDefaultColorFrame = SkColorSetRGB(66, 116, 201); | 65 const SkColor kDefaultColorFrame = SkColorSetRGB(66, 116, 201); |
61 const SkColor kDefaultColorFrameInactive = SkColorSetRGB(161, 182, 228); | 66 const SkColor kDefaultColorFrameInactive = SkColorSetRGB(161, 182, 228); |
62 #endif | 67 #endif |
63 | 68 |
64 const gfx::FontList& GetTitleFontList() { | 69 const gfx::FontList& GetTitleFontList() { |
65 static const gfx::FontList title_font_list = | 70 static const gfx::FontList title_font_list = |
| 71 #if defined(OS_MACOSX) |
| 72 gfx::FontList(); |
| 73 #else |
66 NativeWidgetAura::GetWindowTitleFontList(); | 74 NativeWidgetAura::GetWindowTitleFontList(); |
| 75 #endif |
67 return title_font_list; | 76 return title_font_list; |
68 } | 77 } |
69 | 78 |
70 } // namespace | 79 } // namespace |
71 | 80 |
72 /////////////////////////////////////////////////////////////////////////////// | 81 /////////////////////////////////////////////////////////////////////////////// |
73 // CustomFrameView, public: | 82 // CustomFrameView, public: |
74 | 83 |
75 CustomFrameView::CustomFrameView() | 84 CustomFrameView::CustomFrameView() |
76 : frame_(NULL), | 85 : frame_(NULL), |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // drawn flush with the screen edge, they still obey Fitts' Law. | 286 // drawn flush with the screen edge, they still obey Fitts' Law. |
278 return frame_->IsMaximized() ? FrameBorderThickness() : kFrameShadowThickness; | 287 return frame_->IsMaximized() ? FrameBorderThickness() : kFrameShadowThickness; |
279 } | 288 } |
280 | 289 |
281 int CustomFrameView::TitlebarBottomThickness() const { | 290 int CustomFrameView::TitlebarBottomThickness() const { |
282 return kTitlebarTopAndBottomEdgeThickness + | 291 return kTitlebarTopAndBottomEdgeThickness + |
283 (ShouldShowClientEdge() ? kClientEdgeThickness : 0); | 292 (ShouldShowClientEdge() ? kClientEdgeThickness : 0); |
284 } | 293 } |
285 | 294 |
286 int CustomFrameView::IconSize() const { | 295 int CustomFrameView::IconSize() const { |
287 #if defined(OS_WIN) | |
288 // This metric scales up if either the titlebar height or the titlebar font | |
289 // size are increased. | |
290 return GetSystemMetrics(SM_CYSMICON); | |
291 #else | |
292 return std::max(GetTitleFontList().GetHeight(), kIconMinimumSize); | 296 return std::max(GetTitleFontList().GetHeight(), kIconMinimumSize); |
293 #endif | |
294 } | 297 } |
295 | 298 |
296 gfx::Rect CustomFrameView::IconBounds() const { | 299 gfx::Rect CustomFrameView::IconBounds() const { |
297 int size = IconSize(); | 300 int size = IconSize(); |
298 int frame_thickness = FrameBorderThickness(); | 301 int frame_thickness = FrameBorderThickness(); |
299 // Our frame border has a different "3D look" than Windows'. Theirs has a | 302 // Our frame border has a different "3D look" than Windows'. Theirs has a |
300 // more complex gradient on the top that they push their icon/title below; | 303 // more complex gradient on the top that they push their icon/title below; |
301 // then the maximized window cuts this off and the icon/title are centered | 304 // then the maximized window cuts this off and the icon/title are centered |
302 // in the remaining space. Because the apparent shape of our border is | 305 // in the remaining space. Because the apparent shape of our border is |
303 // simpler, using the same positioning makes things look slightly uncentered | 306 // simpler, using the same positioning makes things look slightly uncentered |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 rb.GetImageNamed(normal_image_id).ToImageSkia()); | 581 rb.GetImageNamed(normal_image_id).ToImageSkia()); |
579 button->SetImage(CustomButton::STATE_HOVERED, | 582 button->SetImage(CustomButton::STATE_HOVERED, |
580 rb.GetImageNamed(hot_image_id).ToImageSkia()); | 583 rb.GetImageNamed(hot_image_id).ToImageSkia()); |
581 button->SetImage(CustomButton::STATE_PRESSED, | 584 button->SetImage(CustomButton::STATE_PRESSED, |
582 rb.GetImageNamed(pushed_image_id).ToImageSkia()); | 585 rb.GetImageNamed(pushed_image_id).ToImageSkia()); |
583 AddChildView(button); | 586 AddChildView(button); |
584 return button; | 587 return button; |
585 } | 588 } |
586 | 589 |
587 } // namespace views | 590 } // namespace views |
OLD | NEW |