OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/app_window_native_widget_mac.h" | 5 #include "chrome/browser/ui/views/apps/app_window_native_widget_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #import "chrome/browser/ui/cocoa/apps/titlebar_background_view.h" | 9 #import "chrome/browser/ui/cocoa/apps/titlebar_background_view.h" |
10 #import "chrome/browser/ui/views/frame/native_widget_mac_frameless_nswindow.h" | 10 #import "chrome/browser/ui/views/frame/native_widget_mac_frameless_nswindow.h" |
11 #include "extensions/browser/app_window/native_app_window.h" | 11 #include "extensions/browser/app_window/native_app_window.h" |
12 #import "ui/base/cocoa/window_size_constants.h" | 12 #import "ui/base/cocoa/window_size_constants.h" |
13 | 13 |
14 AppWindowNativeWidgetMac::AppWindowNativeWidgetMac( | 14 AppWindowNativeWidgetMac::AppWindowNativeWidgetMac( |
15 views::Widget* widget, | 15 views::Widget* widget, |
16 extensions::NativeAppWindow* native_app_window) | 16 extensions::NativeAppWindow* native_app_window) |
17 : NativeWidgetMac(widget), native_app_window_(native_app_window) { | 17 : NativeWidgetMac(widget), native_app_window_(native_app_window) { |
18 } | 18 } |
19 | 19 |
20 AppWindowNativeWidgetMac::~AppWindowNativeWidgetMac() { | 20 AppWindowNativeWidgetMac::~AppWindowNativeWidgetMac() { |
21 } | 21 } |
22 | 22 |
23 int AppWindowNativeWidgetMac::SheetPositionY() { | |
24 NSWindow* ns_window = GetNativeWindow(); | |
25 return NSHeight([ns_window frame]) - NSMaxY([[ns_window contentView] frame]); | |
tapted
2015/08/26 03:20:41
how does this look for frameless widgets? (is it c
jackhou1
2015/08/26 07:02:08
I had tried this with the USB selector dialog, but
| |
26 } | |
27 | |
23 NSWindow* AppWindowNativeWidgetMac::CreateNSWindow( | 28 NSWindow* AppWindowNativeWidgetMac::CreateNSWindow( |
24 const views::Widget::InitParams& params) { | 29 const views::Widget::InitParams& params) { |
25 // If the window has a native or colored frame, use the same NSWindow as | 30 // If the window has a native or colored frame, use the same NSWindow as |
26 // NativeWidgetMac. | 31 // NativeWidgetMac. |
27 if (!native_app_window_->IsFrameless()) { | 32 if (!native_app_window_->IsFrameless()) { |
28 NSWindow* ns_window = NativeWidgetMac::CreateNSWindow(params); | 33 NSWindow* ns_window = NativeWidgetMac::CreateNSWindow(params); |
29 if (native_app_window_->HasFrameColor()) { | 34 if (native_app_window_->HasFrameColor()) { |
30 [TitlebarBackgroundView | 35 [TitlebarBackgroundView |
31 addToNSWindow:ns_window | 36 addToNSWindow:ns_window |
32 activeColor:native_app_window_->ActiveFrameColor() | 37 activeColor:native_app_window_->ActiveFrameColor() |
33 inactiveColor:native_app_window_->InactiveFrameColor()]; | 38 inactiveColor:native_app_window_->InactiveFrameColor()]; |
34 } | 39 } |
35 return ns_window; | 40 return ns_window; |
36 } | 41 } |
37 | 42 |
38 // NSTexturedBackgroundWindowMask is needed to implement draggable window | 43 // NSTexturedBackgroundWindowMask is needed to implement draggable window |
39 // regions. | 44 // regions. |
40 NSUInteger style_mask = NSTexturedBackgroundWindowMask | NSTitledWindowMask | | 45 NSUInteger style_mask = NSTexturedBackgroundWindowMask | NSTitledWindowMask | |
41 NSClosableWindowMask | NSMiniaturizableWindowMask | | 46 NSClosableWindowMask | NSMiniaturizableWindowMask | |
42 NSResizableWindowMask; | 47 NSResizableWindowMask; |
43 return [[[NativeWidgetMacFramelessNSWindow alloc] | 48 return [[[NativeWidgetMacFramelessNSWindow alloc] |
44 initWithContentRect:ui::kWindowSizeDeterminedLater | 49 initWithContentRect:ui::kWindowSizeDeterminedLater |
45 styleMask:style_mask | 50 styleMask:style_mask |
46 backing:NSBackingStoreBuffered | 51 backing:NSBackingStoreBuffered |
47 defer:NO] autorelease]; | 52 defer:NO] autorelease]; |
48 } | 53 } |
OLD | NEW |