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 "ui/views/widget/native_widget_mac.h" | 5 #include "ui/views/widget/native_widget_mac.h" |
6 | 6 |
7 #include <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/mac/scoped_nsobject.h" | |
9 #include "ui/gfx/font_list.h" | 10 #include "ui/gfx/font_list.h" |
11 #import "ui/views/cocoa/bridged_content_view.h" | |
12 #import "ui/views/cocoa/bridged_native_widget.h" | |
10 | 13 |
11 namespace views { | 14 namespace views { |
12 | 15 |
13 //////////////////////////////////////////////////////////////////////////////// | 16 //////////////////////////////////////////////////////////////////////////////// |
14 // NativeWidgetMac, public: | 17 // NativeWidgetMac, public: |
15 | 18 |
16 NativeWidgetMac::NativeWidgetMac(internal::NativeWidgetDelegate* delegate) | 19 NativeWidgetMac::NativeWidgetMac(internal::NativeWidgetDelegate* delegate) |
17 : delegate_(delegate), window_(nil) { | 20 : delegate_(delegate), bridge_(new BridgedNativeWidget) { |
18 } | 21 } |
19 | 22 |
20 NativeWidgetMac::~NativeWidgetMac() { | 23 NativeWidgetMac::~NativeWidgetMac() { |
21 } | 24 } |
22 | 25 |
23 //////////////////////////////////////////////////////////////////////////////// | 26 //////////////////////////////////////////////////////////////////////////////// |
24 // NativeWidgetMac, internal::NativeWidgetPrivate implementation: | 27 // NativeWidgetMac, internal::NativeWidgetPrivate implementation: |
25 | 28 |
26 void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) { | 29 void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) { |
27 // TODO(tapted): Convert position into Cocoa's flipped coordinate space. | 30 // TODO(tapted): Convert position into Cocoa's flipped coordinate space. |
28 NSRect content_rect = | 31 NSRect content_rect = |
29 NSMakeRect(0, 0, params.bounds.width(), params.bounds.height()); | 32 NSMakeRect(0, 0, params.bounds.width(), params.bounds.height()); |
30 // TODO(tapted): Determine a good initial style mask from |params|. | 33 // TODO(tapted): Determine a good initial style mask from |params|. |
31 NSInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | | 34 NSInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | |
32 NSMiniaturizableWindowMask | NSResizableWindowMask; | 35 NSMiniaturizableWindowMask | NSResizableWindowMask; |
33 window_.reset([[NSWindow alloc] initWithContentRect:content_rect | 36 base::scoped_nsobject<NSWindow> window( |
34 styleMask:style_mask | 37 [[NSWindow alloc] initWithContentRect:content_rect |
35 backing:NSBackingStoreBuffered | 38 styleMask:style_mask |
36 defer:NO]); | 39 backing:NSBackingStoreBuffered |
40 defer:NO]); | |
41 bridge_->Init(window); | |
37 } | 42 } |
38 | 43 |
39 NonClientFrameView* NativeWidgetMac::CreateNonClientFrameView() { | 44 NonClientFrameView* NativeWidgetMac::CreateNonClientFrameView() { |
40 return NULL; | 45 return NULL; |
41 } | 46 } |
42 | 47 |
43 bool NativeWidgetMac::ShouldUseNativeFrame() const { | 48 bool NativeWidgetMac::ShouldUseNativeFrame() const { |
44 return false; | 49 return false; |
45 } | 50 } |
46 | 51 |
47 bool NativeWidgetMac::ShouldWindowContentsBeTransparent() const { | 52 bool NativeWidgetMac::ShouldWindowContentsBeTransparent() const { |
48 NOTIMPLEMENTED(); | 53 NOTIMPLEMENTED(); |
49 return false; | 54 return false; |
50 } | 55 } |
51 | 56 |
52 void NativeWidgetMac::FrameTypeChanged() { | 57 void NativeWidgetMac::FrameTypeChanged() { |
53 NOTIMPLEMENTED(); | 58 NOTIMPLEMENTED(); |
54 } | 59 } |
55 | 60 |
56 Widget* NativeWidgetMac::GetWidget() { | 61 Widget* NativeWidgetMac::GetWidget() { |
57 return delegate_->AsWidget(); | 62 return delegate_->AsWidget(); |
58 } | 63 } |
59 | 64 |
60 const Widget* NativeWidgetMac::GetWidget() const { | 65 const Widget* NativeWidgetMac::GetWidget() const { |
61 return delegate_->AsWidget(); | 66 return delegate_->AsWidget(); |
62 } | 67 } |
63 | 68 |
64 gfx::NativeView NativeWidgetMac::GetNativeView() const { | 69 gfx::NativeView NativeWidgetMac::GetNativeView() const { |
65 return [window_ contentView]; | 70 return bridge_->ns_view(); |
66 } | 71 } |
67 | 72 |
68 gfx::NativeWindow NativeWidgetMac::GetNativeWindow() const { | 73 gfx::NativeWindow NativeWidgetMac::GetNativeWindow() const { |
69 return window_; | 74 return bridge_->ns_window(); |
70 } | 75 } |
71 | 76 |
72 Widget* NativeWidgetMac::GetTopLevelWidget() { | 77 Widget* NativeWidgetMac::GetTopLevelWidget() { |
73 NOTIMPLEMENTED(); | 78 NOTIMPLEMENTED(); |
74 return GetWidget(); | 79 return GetWidget(); |
75 } | 80 } |
76 | 81 |
77 const ui::Compositor* NativeWidgetMac::GetCompositor() const { | 82 const ui::Compositor* NativeWidgetMac::GetCompositor() const { |
78 NOTIMPLEMENTED(); | 83 NOTIMPLEMENTED(); |
79 return NULL; | 84 return NULL; |
80 } | 85 } |
81 | 86 |
82 ui::Compositor* NativeWidgetMac::GetCompositor() { | 87 ui::Compositor* NativeWidgetMac::GetCompositor() { |
83 NOTIMPLEMENTED(); | 88 NOTIMPLEMENTED(); |
84 return NULL; | 89 return NULL; |
85 } | 90 } |
86 | 91 |
87 ui::Layer* NativeWidgetMac::GetLayer() { | 92 ui::Layer* NativeWidgetMac::GetLayer() { |
88 NOTIMPLEMENTED(); | 93 NOTIMPLEMENTED(); |
89 return NULL; | 94 return NULL; |
90 } | 95 } |
91 | 96 |
92 void NativeWidgetMac::ReorderNativeViews() { | 97 void NativeWidgetMac::ReorderNativeViews() { |
93 NOTIMPLEMENTED(); | 98 bridge_->SetRootView(GetWidget()->GetRootView()); |
94 } | 99 } |
95 | 100 |
96 void NativeWidgetMac::ViewRemoved(View* view) { | 101 void NativeWidgetMac::ViewRemoved(View* view) { |
97 NOTIMPLEMENTED(); | 102 NOTIMPLEMENTED(); |
98 } | 103 } |
99 | 104 |
100 void NativeWidgetMac::SetNativeWindowProperty(const char* name, void* value) { | 105 void NativeWidgetMac::SetNativeWindowProperty(const char* name, void* value) { |
101 NOTIMPLEMENTED(); | 106 NOTIMPLEMENTED(); |
102 } | 107 } |
103 | 108 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 gfx::Rect NativeWidgetMac::GetRestoredBounds() const { | 180 gfx::Rect NativeWidgetMac::GetRestoredBounds() const { |
176 NOTIMPLEMENTED(); | 181 NOTIMPLEMENTED(); |
177 return gfx::Rect(); | 182 return gfx::Rect(); |
178 } | 183 } |
179 | 184 |
180 void NativeWidgetMac::SetBounds(const gfx::Rect& bounds) { | 185 void NativeWidgetMac::SetBounds(const gfx::Rect& bounds) { |
181 NOTIMPLEMENTED(); | 186 NOTIMPLEMENTED(); |
182 } | 187 } |
183 | 188 |
184 void NativeWidgetMac::SetSize(const gfx::Size& size) { | 189 void NativeWidgetMac::SetSize(const gfx::Size& size) { |
185 [window_ setContentSize:NSMakeSize(size.width(), size.height())]; | 190 [bridge_->ns_window() setContentSize:NSMakeSize(size.width(), size.height())]; |
186 } | 191 } |
187 | 192 |
188 void NativeWidgetMac::StackAbove(gfx::NativeView native_view) { | 193 void NativeWidgetMac::StackAbove(gfx::NativeView native_view) { |
189 NOTIMPLEMENTED(); | 194 NOTIMPLEMENTED(); |
190 } | 195 } |
191 | 196 |
192 void NativeWidgetMac::StackAtTop() { | 197 void NativeWidgetMac::StackAtTop() { |
193 NOTIMPLEMENTED(); | 198 NOTIMPLEMENTED(); |
194 } | 199 } |
195 | 200 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 | 307 |
303 void NativeWidgetMac::RunShellDrag(View* view, | 308 void NativeWidgetMac::RunShellDrag(View* view, |
304 const ui::OSExchangeData& data, | 309 const ui::OSExchangeData& data, |
305 const gfx::Point& location, | 310 const gfx::Point& location, |
306 int operation, | 311 int operation, |
307 ui::DragDropTypes::DragEventSource source) { | 312 ui::DragDropTypes::DragEventSource source) { |
308 NOTIMPLEMENTED(); | 313 NOTIMPLEMENTED(); |
309 } | 314 } |
310 | 315 |
311 void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) { | 316 void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) { |
312 NOTIMPLEMENTED(); | 317 [bridge_->ns_view() setNeedsDisplay:YES]; |
sky
2014/06/11 16:15:53
setNeedsDisplayInRect?
tapted
2014/06/12 09:13:12
Yep - well spotted :) We will definitely want this
| |
313 } | 318 } |
314 | 319 |
315 void NativeWidgetMac::SetCursor(gfx::NativeCursor cursor) { | 320 void NativeWidgetMac::SetCursor(gfx::NativeCursor cursor) { |
316 NOTIMPLEMENTED(); | 321 NOTIMPLEMENTED(); |
317 } | 322 } |
318 | 323 |
319 bool NativeWidgetMac::IsMouseEventsEnabled() const { | 324 bool NativeWidgetMac::IsMouseEventsEnabled() const { |
320 NOTIMPLEMENTED(); | 325 NOTIMPLEMENTED(); |
321 return true; | 326 return true; |
322 } | 327 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 } | 437 } |
433 | 438 |
434 // static | 439 // static |
435 gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() { | 440 gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() { |
436 NOTIMPLEMENTED(); | 441 NOTIMPLEMENTED(); |
437 return gfx::FontList(); | 442 return gfx::FontList(); |
438 } | 443 } |
439 | 444 |
440 } // namespace internal | 445 } // namespace internal |
441 } // namespace views | 446 } // namespace views |
OLD | NEW |