| 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/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 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_constants.h" | 30 #include "chrome/browser/ui/panels/panel_constants.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_strip.h" | 32 #include "chrome/browser/ui/panels/panel_strip.h" |
| 33 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" | 33 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" |
| 34 #import "chrome/browser/ui/panels/panel_utils_cocoa.h" | 34 #import "chrome/browser/ui/panels/panel_utils_cocoa.h" |
| 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 36 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 36 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
| 37 #include "content/public/browser/render_widget_host_view.h" | 37 #include "content/public/browser/render_widget_host_view.h" |
| 38 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
| 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
| 39 #include "grit/ui_resources.h" | 40 #include "grit/ui_resources.h" |
| 40 #include "skia/ext/skia_utils_mac.h" | 41 #include "skia/ext/skia_utils_mac.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 "webkit/glue/webcursor.h" |
| 44 | 45 |
| 45 using content::WebContents; | 46 using content::WebContents; |
| 46 | 47 |
| 47 const int kMinimumWindowSize = 1; | 48 const int kMinimumWindowSize = 1; |
| 48 const double kBoundsAnimationSpeedPixelsPerSecond = 1000; | 49 const double kBoundsAnimationSpeedPixelsPerSecond = 1000; |
| 49 const double kBoundsAnimationMaxDurationSeconds = 0.18; | 50 const double kBoundsAnimationMaxDurationSeconds = 0.18; |
| 50 | 51 |
| 51 // Resize edge thickness, in screen pixels. | 52 // Resize edge thickness, in screen pixels. |
| 52 const double kWidthOfMouseResizeArea = 4.0; | 53 const double kWidthOfMouseResizeArea = 4.0; |
| 53 // The distance the user has to move the mouse while keeping the left button | 54 // The distance the user has to move the mouse while keeping the left button |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 NSRect rightCursorRect_; | 121 NSRect rightCursorRect_; |
| 121 NSRect topCursorRect_; | 122 NSRect topCursorRect_; |
| 122 NSRect bottomCursorRect_; | 123 NSRect bottomCursorRect_; |
| 123 NSRect topLeftCursorRect_; | 124 NSRect topLeftCursorRect_; |
| 124 NSRect topRightCursorRect_; | 125 NSRect topRightCursorRect_; |
| 125 NSRect bottomLeftCursorRect_; | 126 NSRect bottomLeftCursorRect_; |
| 126 NSRect bottomRightCursorRect_; | 127 NSRect bottomRightCursorRect_; |
| 127 } | 128 } |
| 128 @end | 129 @end |
| 129 | 130 |
| 131 namespace { |
| 132 NSCursor* LoadWebKitCursor(WebKit::WebCursorInfo::Type type) { |
| 133 return WebCursor(WebKit::WebCursorInfo(type)).GetNativeCursor(); |
| 134 } |
| 135 } |
| 136 |
| 130 @implementation PanelResizeByMouseOverlay | 137 @implementation PanelResizeByMouseOverlay |
| 131 - (PanelResizeByMouseOverlay*)initWithFrame:(NSRect)frame panel:(Panel*)panel { | 138 - (PanelResizeByMouseOverlay*)initWithFrame:(NSRect)frame panel:(Panel*)panel { |
| 132 if ((self = [super initWithFrame:frame])) { | 139 if ((self = [super initWithFrame:frame])) { |
| 133 panel_ = panel; | 140 panel_ = panel; |
| 134 // Initialize resize cursors, they are very likely to be needed so it's | 141 |
| 135 // better to pre-init them then stutter the mouse later when it hovers over | |
| 136 // a resize edge. We use WebKit cursors that look similar to what OSX Lion | |
| 137 // uses. NSCursor class does not yet have support for those new cursors. | |
| 138 NSImage* image = gfx::GetCachedImageWithName(@"eastWestResizeCursor.png"); | |
| 139 DCHECK(image); | |
| 140 eastWestCursor_.reset( | 142 eastWestCursor_.reset( |
| 141 [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(8,8)]); | 143 [LoadWebKitCursor(WebKit::WebCursorInfo::TypeEastWestResize) retain]); |
| 142 image = gfx::GetCachedImageWithName(@"northSouthResizeCursor.png"); | |
| 143 DCHECK(image); | |
| 144 northSouthCursor_.reset( | 144 northSouthCursor_.reset( |
| 145 [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(8,8)]); | 145 [LoadWebKitCursor(WebKit::WebCursorInfo::TypeNorthSouthResize) retain]); |
| 146 image = gfx::GetCachedImageWithName(@"northEastSouthWestResizeCursor.png"); | |
| 147 DCHECK(image); | |
| 148 northEastSouthWestCursor_.reset( | 146 northEastSouthWestCursor_.reset( |
| 149 [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(8,8)]); | 147 [LoadWebKitCursor(WebKit::WebCursorInfo::TypeNorthEastSouthWestResize) |
| 150 image = gfx::GetCachedImageWithName(@"northWestSouthEastResizeCursor.png"); | 148 retain]); |
| 151 DCHECK(image); | |
| 152 northWestSouthEastCursor_.reset( | 149 northWestSouthEastCursor_.reset( |
| 153 [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(8,8)]); | 150 [LoadWebKitCursor(WebKit::WebCursorInfo::TypeNorthWestSouthEastResize) |
| 151 retain]); |
| 154 } | 152 } |
| 155 return self; | 153 return self; |
| 156 } | 154 } |
| 157 | 155 |
| 158 - (BOOL)acceptsFirstMouse:(NSEvent*)event { | 156 - (BOOL)acceptsFirstMouse:(NSEvent*)event { |
| 159 return YES; | 157 return YES; |
| 160 } | 158 } |
| 161 | 159 |
| 162 // |pointInWindow| is in window coordinates. | 160 // |pointInWindow| is in window coordinates. |
| 163 - (panel::ResizingSides)edgeHitTest:(NSPoint)pointInWindow { | 161 - (panel::ResizingSides)edgeHitTest:(NSPoint)pointInWindow { |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 - (NSRect)contentRectForFrameRect:(NSRect)frameRect { | 1030 - (NSRect)contentRectForFrameRect:(NSRect)frameRect { |
| 1033 NSRect contentRect = [[[self window] contentView] convertRect:frameRect | 1031 NSRect contentRect = [[[self window] contentView] convertRect:frameRect |
| 1034 fromView:nil]; | 1032 fromView:nil]; |
| 1035 contentRect.size.height -= panel::kTitlebarHeight; | 1033 contentRect.size.height -= panel::kTitlebarHeight; |
| 1036 if (contentRect.size.height < 0) | 1034 if (contentRect.size.height < 0) |
| 1037 contentRect.size.height = 0; | 1035 contentRect.size.height = 0; |
| 1038 return contentRect; | 1036 return contentRect; |
| 1039 } | 1037 } |
| 1040 | 1038 |
| 1041 @end | 1039 @end |
| OLD | NEW |