diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 03:55:50 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 03:55:50 +0000 |
commit | a94a94c85f9b1d110242035f54f3b3e9c90f2b28 (patch) | |
tree | 84db8655d04ab6372960fea57876e7e7d4b292dc /chrome/browser/ui/panels/panel_browser_window_cocoa.mm | |
parent | 4eb74ce100e75920f61a9e88684acfbb8e433770 (diff) | |
download | chromium_src-a94a94c85f9b1d110242035f54f3b3e9c90f2b28.zip chromium_src-a94a94c85f9b1d110242035f54f3b3e9c90f2b28.tar.gz chromium_src-a94a94c85f9b1d110242035f54f3b3e9c90f2b28.tar.bz2 |
Change panel drag related methods to use mouse location in screen coordinates.
This is in preparation for support inter-strip dragging.
BUG=none
TEST=existing tests due to no functionality change
Review URL: http://codereview.chromium.org/9616037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125319 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/panels/panel_browser_window_cocoa.mm')
-rw-r--r-- | chrome/browser/ui/panels/panel_browser_window_cocoa.mm | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/chrome/browser/ui/panels/panel_browser_window_cocoa.mm b/chrome/browser/ui/panels/panel_browser_window_cocoa.mm index 5f5a068..ff041d3 100644 --- a/chrome/browser/ui/panels/panel_browser_window_cocoa.mm +++ b/chrome/browser/ui/panels/panel_browser_window_cocoa.mm @@ -13,6 +13,7 @@ #include "chrome/browser/ui/panels/panel.h" #include "chrome/browser/ui/panels/panel_manager.h" #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" +#import "chrome/browser/ui/panels/panel_utils_cocoa.h" #import "chrome/browser/ui/panels/panel_window_controller_cocoa.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/public/browser/native_web_keyboard_event.h" @@ -26,19 +27,6 @@ namespace { // (according to avi@). const int kMinimumWindowSize = 1; -// TODO(dcheng): Move elsewhere so BrowserWindowCocoa can use them too. -// Converts global screen coordinates in platfrom-independent coordinates -// (with the (0,0) in the top-left corner of the primary screen) to the Cocoa -// screen coordinates (with (0,0) in the low-left corner). -NSRect ConvertCoordinatesToCocoa(const gfx::Rect& bounds) { - // Flip coordinates based on the primary screen. - NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; - - return NSMakeRect( - bounds.x(), NSHeight([screen frame]) - bounds.height() - bounds.y(), - bounds.width(), bounds.height()); -} - } // namespace // This creates a shim window class, which in turn creates a Cocoa window @@ -97,7 +85,7 @@ void PanelBrowserWindowCocoa::ShowPanelInactive() { SetPanelBoundsInstantly(bounds_); is_shown_ = true; - NSRect finalFrame = ConvertCoordinatesToCocoa(bounds_); + NSRect finalFrame = cocoa_utils::ConvertRectToCocoaCoordinates(bounds_); [controller_ revealAnimatedWithFrame:finalFrame]; } @@ -124,7 +112,7 @@ void PanelBrowserWindowCocoa::setBoundsInternal(const gfx::Rect& bounds, bounds_ = bounds; - NSRect frame = ConvertCoordinatesToCocoa(bounds); + NSRect frame = cocoa_utils::ConvertRectToCocoaCoordinates(bounds); [controller_ setPanelFrame:frame animate:animate]; } @@ -315,9 +303,10 @@ class NativePanelTestingCocoa : public NativePanelTesting { NativePanelTestingCocoa(NativePanel* native_panel); virtual ~NativePanelTestingCocoa() { } // Overridden from NativePanelTesting - virtual void PressLeftMouseButtonTitlebar(const gfx::Point& point) OVERRIDE; + virtual void PressLeftMouseButtonTitlebar( + const gfx::Point& mouse_location) OVERRIDE; virtual void ReleaseMouseButtonTitlebar() OVERRIDE; - virtual void DragTitlebar(int delta_x, int delta_y) OVERRIDE; + virtual void DragTitlebar(const gfx::Point& mouse_location) OVERRIDE; virtual void CancelDragTitlebar() OVERRIDE; virtual void FinishDragTitlebar() OVERRIDE; virtual bool VerifyDrawingAttention() const OVERRIDE; @@ -345,16 +334,24 @@ PanelTitlebarViewCocoa* NativePanelTestingCocoa::titlebar() const { } void NativePanelTestingCocoa::PressLeftMouseButtonTitlebar( - const gfx::Point& point) { - [titlebar() pressLeftMouseButtonTitlebar]; + const gfx::Point& mouse_location) { + // Convert from platform-indepedent screen coordinates to Cocoa's screen + // coordinates because PanelTitlebarViewCocoa method takes Cocoa's screen + // coordinates. + [titlebar() pressLeftMouseButtonTitlebar: + cocoa_utils::ConvertPointToCocoaCoordinates(mouse_location)]; } void NativePanelTestingCocoa::ReleaseMouseButtonTitlebar() { [titlebar() releaseLeftMouseButtonTitlebar]; } -void NativePanelTestingCocoa::DragTitlebar(int delta_x, int delta_y) { - [titlebar() dragTitlebarDeltaX:delta_x deltaY:delta_y]; +void NativePanelTestingCocoa::DragTitlebar(const gfx::Point& mouse_location) { + // Convert from platform-indepedent screen coordinates to Cocoa's screen + // coordinates because PanelTitlebarViewCocoa method takes Cocoa's screen + // coordinates. + [titlebar() dragTitlebar: + cocoa_utils::ConvertPointToCocoaCoordinates(mouse_location)]; } void NativePanelTestingCocoa::CancelDragTitlebar() { |