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 "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 Loading... |
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 Loading... |
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 |
| 415 // Convert from Cocoa's screen coordinates to platform-indepedent screen |
| 416 // coordinates because PanelManager method takes platform-indepedent screen |
| 417 // coordinates. |
| 418 windowShim_->panel()->manager()->StartDragging( |
| 419 windowShim_->panel(), |
| 420 cocoa_utils::ConvertPointFromCocoaCoordinates(mouseLocation)); |
414 } | 421 } |
415 | 422 |
416 - (void)endDrag:(BOOL)cancelled { | 423 - (void)endDrag:(BOOL)cancelled { |
417 animateOnBoundsChange_ = YES; | 424 animateOnBoundsChange_ = YES; |
418 windowShim_->panel()->manager()->EndDragging(cancelled); | 425 windowShim_->panel()->manager()->EndDragging(cancelled); |
419 } | 426 } |
420 | 427 |
421 - (void)dragWithDeltaX:(int)deltaX | 428 - (void)drag:(NSPoint)mouseLocation { |
422 deltaY:(int)deltaY { | 429 // Convert from Cocoa's screen coordinates to platform-indepedent screen |
423 windowShim_->panel()->manager()->Drag(deltaX, deltaY); | 430 // coordinates because PanelManager method takes platform-indepedent screen |
| 431 // coordinates. |
| 432 windowShim_->panel()->manager()->Drag( |
| 433 cocoa_utils::ConvertPointFromCocoaCoordinates(mouseLocation)); |
424 } | 434 } |
425 | 435 |
426 - (void)setPanelFrame:(NSRect)frame | 436 - (void)setPanelFrame:(NSRect)frame |
427 animate:(BOOL)animate { | 437 animate:(BOOL)animate { |
428 // Setup the whole window as the tracking area so that we can get notified | 438 // 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 | 439 // when the mouse enters or leaves the window. This will make us be able to |
430 // show or hide settings button accordingly. | 440 // show or hide settings button accordingly. |
431 NSRect localBounds = frame; | 441 NSRect localBounds = frame; |
432 localBounds.origin = NSZeroPoint; | 442 localBounds.origin = NSZeroPoint; |
433 | 443 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 | 640 |
631 - (BOOL)canBecomeKeyWindow { | 641 - (BOOL)canBecomeKeyWindow { |
632 // Panel can only gain focus if it is expanded. Minimized panels do not | 642 // Panel can only gain focus if it is expanded. Minimized panels do not |
633 // participate in Cmd-~ rotation. | 643 // participate in Cmd-~ rotation. |
634 // TODO(dimich): If it will be ever desired to expand/focus the Panel on | 644 // 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 | 645 // keyboard navigation or via main menu, the care should be taken to avoid |
636 // cases when minimized Panel is getting keyboard input, invisibly. | 646 // cases when minimized Panel is getting keyboard input, invisibly. |
637 return windowShim_->panel()->expansion_state() == Panel::EXPANDED; | 647 return windowShim_->panel()->expansion_state() == Panel::EXPANDED; |
638 } | 648 } |
639 @end | 649 @end |
OLD | NEW |