OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" | 5 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" |
6 | 6 |
7 #include <Carbon/Carbon.h> // kVK_Escape | 7 #include <Carbon/Carbon.h> // kVK_Escape |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/mac/scoped_nsautorelease_pool.h" | 11 #include "base/mac/scoped_nsautorelease_pool.h" |
12 #include "chrome/browser/themes/theme_service.h" | 12 #include "chrome/browser/themes/theme_service.h" |
13 #import "chrome/browser/ui/cocoa/hover_image_button.h" | 13 #import "chrome/browser/ui/cocoa/hover_image_button.h" |
14 #import "chrome/browser/ui/cocoa/nsview_additions.h" | 14 #import "chrome/browser/ui/cocoa/nsview_additions.h" |
15 #import "chrome/browser/ui/cocoa/themed_window.h" | 15 #import "chrome/browser/ui/cocoa/themed_window.h" |
16 #import "chrome/browser/ui/cocoa/tracking_area.h" | 16 #import "chrome/browser/ui/cocoa/tracking_area.h" |
17 #import "chrome/browser/ui/panels/panel_window_controller_cocoa.h" | 17 #import "chrome/browser/ui/panels/panel_window_controller_cocoa.h" |
18 #include "grit/theme_resources_standard.h" | 18 #include "grit/theme_resources_standard.h" |
19 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" | 19 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" |
20 #include "ui/gfx/mac/nsimage_cache.h" | 20 #include "ui/gfx/mac/nsimage_cache.h" |
21 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 21 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
22 | 22 |
23 const int kRoundedCornerSize = 3; | 23 const int kRoundedCornerSize = 3; |
24 const int kCloseButtonLeftPadding = 8; | 24 const int kCloseButtonLeftPadding = 8; |
25 | 25 |
26 // Used to implement TestingAPI | 26 // Used to implement TestingAPI |
27 static NSEvent* MakeMouseEvent(NSEventType type, NSPoint point) { | 27 static NSEvent* MakeMouseEvent(NSEventType type, |
28 NSPoint point, | |
29 int clickCount) { | |
28 return [NSEvent mouseEventWithType:type | 30 return [NSEvent mouseEventWithType:type |
29 location:point | 31 location:point |
30 modifierFlags:0 | 32 modifierFlags:0 |
31 timestamp:0 | 33 timestamp:0 |
32 windowNumber:0 | 34 windowNumber:0 |
33 context:nil | 35 context:nil |
34 eventNumber:0 | 36 eventNumber:0 |
35 clickCount:0 | 37 clickCount:clickCount |
jennb
2011/09/21 21:21:26
Curious why click count is needed now?
| |
36 pressure:0.0]; | 38 pressure:0.0]; |
37 } | 39 } |
38 | 40 |
39 @implementation PanelTitlebarViewCocoa | 41 @implementation PanelTitlebarViewCocoa |
40 | 42 |
41 - (id)initWithFrame:(NSRect)frame { | 43 - (id)initWithFrame:(NSRect)frame { |
42 if ((self = [super initWithFrame:frame])) { | 44 if ((self = [super initWithFrame:frame])) { |
43 dragState_ = PANEL_DRAG_SUPPRESSED; | 45 dragState_ = PANEL_DRAG_SUPPRESSED; |
44 // Create standard OSX Close Button. | 46 // Create standard OSX Close Button. |
45 closeButton_ = [NSWindow standardWindowButton:NSWindowCloseButton | 47 closeButton_ = [NSWindow standardWindowButton:NSWindowCloseButton |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 // (Private/TestingAPI) | 342 // (Private/TestingAPI) |
341 - (PanelWindowControllerCocoa*)controller { | 343 - (PanelWindowControllerCocoa*)controller { |
342 return controller_; | 344 return controller_; |
343 } | 345 } |
344 | 346 |
345 - (void)simulateCloseButtonClick { | 347 - (void)simulateCloseButtonClick { |
346 [[closeButton_ cell] performClick:closeButton_]; | 348 [[closeButton_ cell] performClick:closeButton_]; |
347 } | 349 } |
348 | 350 |
349 - (void)pressLeftMouseButtonTitlebar { | 351 - (void)pressLeftMouseButtonTitlebar { |
350 NSEvent* event = MakeMouseEvent(NSLeftMouseDown, NSZeroPoint); | 352 NSEvent* event = MakeMouseEvent(NSLeftMouseDown, NSZeroPoint, 0); |
351 [self mouseDown:event]; | 353 [self mouseDown:event]; |
352 } | 354 } |
353 | 355 |
354 - (void)releaseLeftMouseButtonTitlebar { | 356 - (void)releaseLeftMouseButtonTitlebar { |
355 NSEvent* event = MakeMouseEvent(NSLeftMouseUp, NSZeroPoint); | 357 NSEvent* event = MakeMouseEvent(NSLeftMouseUp, NSZeroPoint, 1); |
356 [self mouseUp:event]; | 358 [self mouseUp:event]; |
357 } | 359 } |
358 | 360 |
359 - (void)dragTitlebarDeltaX:(double)delta_x | 361 - (void)dragTitlebarDeltaX:(double)delta_x |
360 deltaY:(double)delta_y { | 362 deltaY:(double)delta_y { |
361 if (dragState_ == PANEL_DRAG_CAN_START) | 363 if (dragState_ == PANEL_DRAG_CAN_START) |
362 [self startDrag]; | 364 [self startDrag]; |
363 [self dragWithDeltaX:delta_x]; | 365 [self dragWithDeltaX:delta_x]; |
364 } | 366 } |
365 | 367 |
(...skipping 13 matching lines...) Expand all Loading... | |
379 } | 381 } |
380 | 382 |
381 - (void)checkMouseAndUpdateSettingsButtonVisibility { | 383 - (void)checkMouseAndUpdateSettingsButtonVisibility { |
382 BOOL mouseOverWindow = NSPointInRect([NSEvent mouseLocation], | 384 BOOL mouseOverWindow = NSPointInRect([NSEvent mouseLocation], |
383 [[controller_ window] frame]); | 385 [[controller_ window] frame]); |
384 [self updateSettingsButtonVisibility:mouseOverWindow]; | 386 [self updateSettingsButtonVisibility:mouseOverWindow]; |
385 } | 387 } |
386 | 388 |
387 @end | 389 @end |
388 | 390 |
OLD | NEW |