Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: ui/views/widget/native_widget_mac.mm

Issue 1964283002: MacViews: Implemented Drag & Drop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« ui/views/views.gyp ('K') | « ui/views/views.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/mac/foundation_util.h" 11 #include "base/mac/foundation_util.h"
12 #include "base/mac/scoped_nsobject.h" 12 #include "base/mac/scoped_nsobject.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" 14 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h"
15 #import "ui/base/cocoa/window_size_constants.h" 15 #import "ui/base/cocoa/window_size_constants.h"
16 #include "ui/gfx/font_list.h" 16 #include "ui/gfx/font_list.h"
17 #import "ui/gfx/mac/coordinate_conversion.h" 17 #import "ui/gfx/mac/coordinate_conversion.h"
18 #import "ui/gfx/mac/nswindow_frame_controls.h" 18 #import "ui/gfx/mac/nswindow_frame_controls.h"
19 #include "ui/native_theme/native_theme.h" 19 #include "ui/native_theme/native_theme.h"
20 #include "ui/native_theme/native_theme_mac.h" 20 #include "ui/native_theme/native_theme_mac.h"
21 #import "ui/views/cocoa/bridged_content_view.h" 21 #import "ui/views/cocoa/bridged_content_view.h"
22 #import "ui/views/cocoa/bridged_native_widget.h" 22 #import "ui/views/cocoa/bridged_native_widget.h"
23 #import "ui/views/cocoa/drag_drop_client_mac.h"
23 #import "ui/views/cocoa/native_widget_mac_nswindow.h" 24 #import "ui/views/cocoa/native_widget_mac_nswindow.h"
24 #import "ui/views/cocoa/views_nswindow_delegate.h" 25 #import "ui/views/cocoa/views_nswindow_delegate.h"
25 #include "ui/views/widget/widget_delegate.h" 26 #include "ui/views/widget/widget_delegate.h"
26 #include "ui/views/window/native_frame_view.h" 27 #include "ui/views/window/native_frame_view.h"
27 28
28 // Self-owning animation delegate that starts a hide animation, then calls 29 // Self-owning animation delegate that starts a hide animation, then calls
29 // -[NSWindow close] when the animation ends, releasing itself. 30 // -[NSWindow close] when the animation ends, releasing itself.
30 @interface ViewsNSWindowCloseAnimator : NSObject<NSAnimationDelegate> { 31 @interface ViewsNSWindowCloseAnimator : NSObject<NSAnimationDelegate> {
31 @private 32 @private
32 base::scoped_nsobject<NSWindow> window_; 33 base::scoped_nsobject<NSWindow> window_;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 195 }
195 196
196 void NativeWidgetMac::ReorderNativeViews() { 197 void NativeWidgetMac::ReorderNativeViews() {
197 if (bridge_) { 198 if (bridge_) {
198 bridge_->SetRootView(GetWidget()->GetRootView()); 199 bridge_->SetRootView(GetWidget()->GetRootView());
199 bridge_->ReorderChildViews(); 200 bridge_->ReorderChildViews();
200 } 201 }
201 } 202 }
202 203
203 void NativeWidgetMac::ViewRemoved(View* view) { 204 void NativeWidgetMac::ViewRemoved(View* view) {
204 // TODO(tapted): Something for drag and drop might be needed here in future. 205 DragDropClientMac* client = bridge_ ? bridge_->drag_drop_client() : nullptr;
205 // See http://crbug.com/464581. A NOTIMPLEMENTED() here makes a lot of spam, 206 if (client)
206 // so only emit it when a drag and drop could be likely. 207 client->drop_helper()->ResetTargetViewIfEquals(view);
207 if (IsMouseButtonDown())
208 NOTIMPLEMENTED();
209 } 208 }
210 209
211 void NativeWidgetMac::SetNativeWindowProperty(const char* name, void* value) { 210 void NativeWidgetMac::SetNativeWindowProperty(const char* name, void* value) {
212 if (bridge_) 211 if (bridge_)
213 bridge_->SetNativeWindowProperty(name, value); 212 bridge_->SetNativeWindowProperty(name, value);
214 } 213 }
215 214
216 void* NativeWidgetMac::GetNativeWindowProperty(const char* name) const { 215 void* NativeWidgetMac::GetNativeWindowProperty(const char* name) const {
217 if (bridge_) 216 if (bridge_)
218 return bridge_->GetNativeWindowProperty(name); 217 return bridge_->GetNativeWindowProperty(name);
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 499
501 void NativeWidgetMac::FlashFrame(bool flash_frame) { 500 void NativeWidgetMac::FlashFrame(bool flash_frame) {
502 NOTIMPLEMENTED(); 501 NOTIMPLEMENTED();
503 } 502 }
504 503
505 void NativeWidgetMac::RunShellDrag(View* view, 504 void NativeWidgetMac::RunShellDrag(View* view,
506 const ui::OSExchangeData& data, 505 const ui::OSExchangeData& data,
507 const gfx::Point& location, 506 const gfx::Point& location,
508 int operation, 507 int operation,
509 ui::DragDropTypes::DragEventSource source) { 508 ui::DragDropTypes::DragEventSource source) {
510 NOTIMPLEMENTED(); 509 bridge_->drag_drop_client()->StartDragAndDrop(view, data, operation, source);
511 } 510 }
512 511
513 void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) { 512 void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) {
514 // |rect| is relative to client area of the window. 513 // |rect| is relative to client area of the window.
515 NSWindow* window = GetNativeWindow(); 514 NSWindow* window = GetNativeWindow();
516 NSRect client_rect = [window contentRectForFrameRect:[window frame]]; 515 NSRect client_rect = [window contentRectForFrameRect:[window frame]];
517 NSRect target_rect = rect.ToCGRect(); 516 NSRect target_rect = rect.ToCGRect();
518 517
519 // Convert to Appkit coordinate system (origin at bottom left). 518 // Convert to Appkit coordinate system (origin at bottom left).
520 target_rect.origin.y = 519 target_rect.origin.y =
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; 746 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window];
748 } 747 }
749 748
750 - (void)animationDidEnd:(NSAnimation*)animation { 749 - (void)animationDidEnd:(NSAnimation*)animation {
751 [window_ close]; 750 [window_ close];
752 [animation_ setDelegate:nil]; 751 [animation_ setDelegate:nil];
753 [self release]; 752 [self release];
754 } 753 }
755 754
756 @end 755 @end
OLDNEW
« ui/views/views.gyp ('K') | « ui/views/views.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698