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

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

Issue 10066032: Enable user resizing for docked Panels (GTK and Mac). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor cleanup Created 8 years, 8 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/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 return self; 166 return self;
167 } 167 }
168 168
169 - (BOOL)acceptsFirstMouse:(NSEvent*)event { 169 - (BOOL)acceptsFirstMouse:(NSEvent*)event {
170 return YES; 170 return YES;
171 } 171 }
172 172
173 // |pointInWindow| is in window coordinates. 173 // |pointInWindow| is in window coordinates.
174 - (panel::ResizingSides)edgeHitTest:(NSPoint)pointInWindow { 174 - (panel::ResizingSides)edgeHitTest:(NSPoint)pointInWindow {
175 DCHECK(panel_->CanResizeByMouse()); 175 panel::Resizability resizability = panel_->CanResizeByMouse();
176 DCHECK_NE(panel::NOT_RESIZABLE, resizability);
176 177
177 NSPoint point = [self convertPoint:pointInWindow fromView:nil]; 178 NSPoint point = [self convertPoint:pointInWindow fromView:nil];
178 BOOL flipped = [self isFlipped]; 179 BOOL flipped = [self isFlipped];
179 if (NSMouseInRect(point, leftCursorRect_, flipped)) 180 if (NSMouseInRect(point, leftCursorRect_, flipped))
180 return panel::RESIZE_LEFT; 181 return panel::RESIZE_LEFT;
181 if (NSMouseInRect(point, rightCursorRect_, flipped)) 182 if (NSMouseInRect(point, rightCursorRect_, flipped))
182 return panel::RESIZE_RIGHT; 183 return panel::RESIZE_RIGHT;
183 if (NSMouseInRect(point, topCursorRect_, flipped)) 184 if (NSMouseInRect(point, topCursorRect_, flipped))
184 return panel::RESIZE_TOP; 185 return panel::RESIZE_TOP;
185 if (NSMouseInRect(point, bottomCursorRect_, flipped))
186 return panel::RESIZE_BOTTOM;
187 if (NSMouseInRect(point, topLeftCursorRect_, flipped)) 186 if (NSMouseInRect(point, topLeftCursorRect_, flipped))
188 return panel::RESIZE_TOP_LEFT; 187 return panel::RESIZE_TOP_LEFT;
189 if (NSMouseInRect(point, topRightCursorRect_, flipped)) 188 if (NSMouseInRect(point, topRightCursorRect_, flipped))
190 return panel::RESIZE_TOP_RIGHT; 189 return panel::RESIZE_TOP_RIGHT;
191 if (NSMouseInRect(point, bottomLeftCursorRect_, flipped)) 190
192 return panel::RESIZE_BOTTOM_LEFT; 191 // Special handling if bottom edge is not resizable.
193 if (NSMouseInRect(point, bottomRightCursorRect_, flipped)) 192 if (panel::ALL_SIDES == resizability) {
194 return panel::RESIZE_BOTTOM_RIGHT; 193 if (NSMouseInRect(point, bottomCursorRect_, flipped))
194 return panel::RESIZE_BOTTOM;
195 if (NSMouseInRect(point, bottomLeftCursorRect_, flipped))
196 return panel::RESIZE_BOTTOM_LEFT;
197 if (NSMouseInRect(point, bottomRightCursorRect_, flipped))
198 return panel::RESIZE_BOTTOM_RIGHT;
199 } else if (panel::ALL_SIDES_EXCEPT_BOTTOM == resizability) {
200 if (NSMouseInRect(point, bottomLeftCursorRect_, flipped))
Dmitry Titov 2012/04/13 02:55:45 Why do we want the bottom corners to do horizontal
jennb 2012/04/13 16:39:43 I tried ignoring the bottom corners, but it didn't
201 return panel::RESIZE_LEFT;
202 if (NSMouseInRect(point, bottomRightCursorRect_, flipped))
203 return panel::RESIZE_RIGHT;
204 }
195 205
196 return panel::RESIZE_NONE; 206 return panel::RESIZE_NONE;
197 } 207 }
198 208
199 // NSWindow uses this method to figure out if this view is under the mouse 209 // NSWindow uses this method to figure out if this view is under the mouse
200 // and hence the one to handle the incoming mouse event. 210 // and hence the one to handle the incoming mouse event.
201 // Since this view covers the whole panel, it is asked first. 211 // Since this view covers the whole panel, it is asked first.
202 // See if this is the mouse event we are interested in (in the resize areas) 212 // See if this is the mouse event we are interested in (in the resize areas)
203 // and return 'nil' to let NSWindow find another candidate otherwise. 213 // and return 'nil' to let NSWindow find another candidate otherwise.
204 // |point| is in coordinate system of the parent view. 214 // |point| is in coordinate system of the parent view.
205 - (NSView*)hitTest:(NSPoint)point { 215 - (NSView*)hitTest:(NSPoint)point {
206 // If panel is not resizable, let the mouse events fall through. 216 // If panel is not resizable, let the mouse events fall through.
207 if (!panel_->CanResizeByMouse()) 217 if (panel::NOT_RESIZABLE == panel_->CanResizeByMouse())
208 return nil; 218 return nil;
209 219
210 NSPoint pointInWindow = [[self superview] convertPoint:point toView:nil]; 220 NSPoint pointInWindow = [[self superview] convertPoint:point toView:nil];
211 return [self edgeHitTest:pointInWindow] == panel::RESIZE_NONE ? nil : self; 221 return [self edgeHitTest:pointInWindow] == panel::RESIZE_NONE ? nil : self;
212 } 222 }
213 223
214 - (void)mouseDown:(NSEvent*)event { 224 - (void)mouseDown:(NSEvent*)event {
215 // If the panel is not resizable, hitTest should have failed and no mouse 225 // If the panel is not resizable, hitTest should have failed and no mouse
216 // events should have came here. 226 // events should have came here.
217 DCHECK(panel_->CanResizeByMouse()); 227 DCHECK_NE(panel::NOT_RESIZABLE, panel_->CanResizeByMouse());
218 [self prepareForDrag:event]; 228 [self prepareForDrag:event];
219 } 229 }
220 230
221 - (void)mouseUp:(NSEvent*)event { 231 - (void)mouseUp:(NSEvent*)event {
222 // The mouseUp while in drag should be processed by nested message loop 232 // The mouseUp while in drag should be processed by nested message loop
223 // in mouseDragged: method. 233 // in mouseDragged: method.
224 DCHECK(dragState_ != PANEL_DRAG_IN_PROGRESS); 234 DCHECK(dragState_ != PANEL_DRAG_IN_PROGRESS);
225 // Cleanup in case the actual drag was not started (because of threshold). 235 // Cleanup in case the actual drag was not started (because of threshold).
226 [self cleanupAfterDrag]; 236 [self cleanupAfterDrag];
227 } 237 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 panel_->manager()->ResizeByMouse( 368 panel_->manager()->ResizeByMouse(
359 cocoa_utils::ConvertPointFromCocoaCoordinates(mouseLocationScreen)); 369 cocoa_utils::ConvertPointFromCocoaCoordinates(mouseLocationScreen));
360 } 370 }
361 371
362 - (void)endResize:(BOOL)cancelled { 372 - (void)endResize:(BOOL)cancelled {
363 DCHECK(dragState_ == PANEL_DRAG_IN_PROGRESS); 373 DCHECK(dragState_ == PANEL_DRAG_IN_PROGRESS);
364 panel_->manager()->EndResizingByMouse(cancelled); 374 panel_->manager()->EndResizingByMouse(cancelled);
365 } 375 }
366 376
367 - (void)resetCursorRects { 377 - (void)resetCursorRects {
368 if(!panel_->CanResizeByMouse()) 378 if(panel::NOT_RESIZABLE == panel_->CanResizeByMouse())
369 return; 379 return;
370 380
371 NSRect bounds = [self bounds]; 381 NSRect bounds = [self bounds];
372 382
373 // Left vertical edge. 383 // Left vertical edge.
374 leftCursorRect_ = NSMakeRect(NSMinX(bounds), 384 leftCursorRect_ = NSMakeRect(NSMinX(bounds),
375 NSMinY(bounds) + kWidthOfMouseResizeArea, 385 NSMinY(bounds) + kWidthOfMouseResizeArea,
376 kWidthOfMouseResizeArea, 386 kWidthOfMouseResizeArea,
377 NSHeight(bounds) - 2 * kWidthOfMouseResizeArea); 387 NSHeight(bounds) - 2 * kWidthOfMouseResizeArea);
378 [self addCursorRect:leftCursorRect_ cursor:eastWestCursor_]; 388 [self addCursorRect:leftCursorRect_ cursor:eastWestCursor_];
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 if (![self isWindowLoaded]) 1084 if (![self isWindowLoaded])
1075 return; 1085 return;
1076 [[self window] invalidateCursorRectsForView:overlayView_]; 1086 [[self window] invalidateCursorRectsForView:overlayView_];
1077 } 1087 }
1078 1088
1079 - (BOOL)isActivationByClickingTitlebarEnabled { 1089 - (BOOL)isActivationByClickingTitlebarEnabled {
1080 return !windowShim_->panel()->always_on_top(); 1090 return !windowShim_->panel()->always_on_top();
1081 } 1091 }
1082 1092
1083 @end 1093 @end
OLDNEW
« chrome/browser/ui/panels/panel_strip.h ('K') | « chrome/browser/ui/panels/panel_strip.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698