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

Side by Side Diff: chrome/browser/ui/panels/panel_window_controller_cocoa.mm

Issue 9616037: Change panel drag related methods to use mouse location in screen coordinates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac trybot Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/ui/panels/panel_window_controller_cocoa.h" 5 #include "chrome/browser/ui/panels/panel_window_controller_cocoa.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/bundle_locations.h" 10 #include "base/mac/bundle_locations.h"
(...skipping 14 matching lines...) Expand all
25 #import "chrome/browser/ui/cocoa/menu_controller.h" 25 #import "chrome/browser/ui/cocoa/menu_controller.h"
26 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" 26 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h"
27 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" 27 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
28 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" 28 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h"
29 #include "chrome/browser/ui/panels/panel_bounds_animation.h" 29 #include "chrome/browser/ui/panels/panel_bounds_animation.h"
30 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" 30 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h"
31 #include "chrome/browser/ui/panels/panel_manager.h" 31 #include "chrome/browser/ui/panels/panel_manager.h"
32 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" 32 #include "chrome/browser/ui/panels/panel_settings_menu_model.h"
33 #include "chrome/browser/ui/panels/panel_strip.h" 33 #include "chrome/browser/ui/panels/panel_strip.h"
34 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" 34 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h"
35 #import "chrome/browser/ui/panels/panel_utils_cocoa.h"
35 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 36 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
36 #include "chrome/common/chrome_notification_types.h" 37 #include "chrome/common/chrome_notification_types.h"
37 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
38 #include "content/public/browser/render_widget_host_view.h" 39 #include "content/public/browser/render_widget_host_view.h"
39 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
40 #include "grit/ui_resources.h" 41 #include "grit/ui_resources.h"
41 #include "ui/base/resource/resource_bundle.h" 42 #include "ui/base/resource/resource_bundle.h"
42 #include "ui/gfx/image/image.h" 43 #include "ui/gfx/image/image.h"
43 #include "ui/gfx/mac/nsimage_cache.h" 44 #include "ui/gfx/mac/nsimage_cache.h"
44 45
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 402
402 [NSMenu popUpContextMenu:[settingsMenuController menu] 403 [NSMenu popUpContextMenu:[settingsMenuController menu]
403 withEvent:[NSApp currentEvent] 404 withEvent:[NSApp currentEvent]
404 forView:button]; 405 forView:button];
405 } 406 }
406 407
407 - (BOOL)isDraggable { 408 - (BOOL)isDraggable {
408 return windowShim_->panel()->draggable(); 409 return windowShim_->panel()->draggable();
409 } 410 }
410 411
411 - (void)startDrag { 412 - (void)startDrag:(NSPoint)mouseLocation {
412 animateOnBoundsChange_ = NO; 413 animateOnBoundsChange_ = NO;
413 windowShim_->panel()->manager()->StartDragging(windowShim_->panel()); 414 windowShim_->panel()->manager()->StartDragging(
415 windowShim_->panel(),
416 cocoa_utils::ConvertPointFromCocoaCoordinates(mouseLocation));
jennb 2012/03/07 00:17:46 The .h said mouseLocation was already in screen co
jianli 2012/03/07 00:46:49 Added comment.
414 } 417 }
415 418
416 - (void)endDrag:(BOOL)cancelled { 419 - (void)endDrag:(BOOL)cancelled {
417 animateOnBoundsChange_ = YES; 420 animateOnBoundsChange_ = YES;
418 windowShim_->panel()->manager()->EndDragging(cancelled); 421 windowShim_->panel()->manager()->EndDragging(cancelled);
419 } 422 }
420 423
421 - (void)dragWithDeltaX:(int)deltaX 424 - (void)drag:(NSPoint)mouseLocation {
422 deltaY:(int)deltaY { 425 windowShim_->panel()->manager()->Drag(
423 windowShim_->panel()->manager()->Drag(deltaX, deltaY); 426 cocoa_utils::ConvertPointFromCocoaCoordinates(mouseLocation));
424 } 427 }
425 428
426 - (void)setPanelFrame:(NSRect)frame 429 - (void)setPanelFrame:(NSRect)frame
427 animate:(BOOL)animate { 430 animate:(BOOL)animate {
428 // Setup the whole window as the tracking area so that we can get notified 431 // Setup the whole window as the tracking area so that we can get notified
429 // when the mouse enters or leaves the window. This will make us be able to 432 // when the mouse enters or leaves the window. This will make us be able to
430 // show or hide settings button accordingly. 433 // show or hide settings button accordingly.
431 NSRect localBounds = frame; 434 NSRect localBounds = frame;
432 localBounds.origin = NSZeroPoint; 435 localBounds.origin = NSZeroPoint;
433 436
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 633
631 - (BOOL)canBecomeKeyWindow { 634 - (BOOL)canBecomeKeyWindow {
632 // Panel can only gain focus if it is expanded. Minimized panels do not 635 // Panel can only gain focus if it is expanded. Minimized panels do not
633 // participate in Cmd-~ rotation. 636 // participate in Cmd-~ rotation.
634 // TODO(dimich): If it will be ever desired to expand/focus the Panel on 637 // TODO(dimich): If it will be ever desired to expand/focus the Panel on
635 // keyboard navigation or via main menu, the care should be taken to avoid 638 // keyboard navigation or via main menu, the care should be taken to avoid
636 // cases when minimized Panel is getting keyboard input, invisibly. 639 // cases when minimized Panel is getting keyboard input, invisibly.
637 return windowShim_->panel()->expansion_state() == Panel::EXPANDED; 640 return windowShim_->panel()->expansion_state() == Panel::EXPANDED;
638 } 641 }
639 @end 642 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698