| 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 #import "chrome/browser/ui/cocoa/panels/panel_titlebar_view_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/panels/panel_titlebar_view_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/scoped_nsautorelease_pool.h" | 10 #include "base/mac/scoped_nsautorelease_pool.h" |
| 11 #import "chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.h" | 11 #import "chrome/browser/ui/cocoa/panels/panel_window_controller_cocoa.h" |
| 12 #import "chrome/browser/ui/panels/panel_constants.h" | 12 #import "chrome/browser/ui/panels/panel_constants.h" |
| 13 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
| 14 #include "grit/theme_resources.h" | 14 #include "grit/theme_resources.h" |
| 15 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSBezierPath+RoundRect
.h" | 15 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSBezierPath+RoundRect
.h" |
| 16 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h" | 16 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h" |
| 17 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 17 #import "ui/base/cocoa/hover_image_button.h" | 18 #import "ui/base/cocoa/hover_image_button.h" |
| 18 #import "ui/base/cocoa/nsview_additions.h" | 19 #import "ui/base/cocoa/nsview_additions.h" |
| 19 #include "ui/base/l10n/l10n_util_mac.h" | 20 #include "ui/base/l10n/l10n_util_mac.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
| 22 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 23 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 23 | 24 |
| 24 // 'Glint' is a glowing light animation on the titlebar to attract user's | 25 // 'Glint' is a glowing light animation on the titlebar to attract user's |
| 25 // attention. Numbers are arbitrary, based on several tries. | 26 // attention. Numbers are arbitrary, based on several tries. |
| 26 const double kGlintAnimationDuration = 1.5; | 27 const double kGlintAnimationDuration = 1.5; |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 - (void)mouseDragged:(NSEvent*)event { | 412 - (void)mouseDragged:(NSEvent*)event { |
| 412 [dragController_ mouseDragged:event]; | 413 [dragController_ mouseDragged:event]; |
| 413 } | 414 } |
| 414 | 415 |
| 415 // MouseDragControllerClient implementaiton | 416 // MouseDragControllerClient implementaiton |
| 416 | 417 |
| 417 - (void)prepareForDrag { | 418 - (void)prepareForDrag { |
| 418 } | 419 } |
| 419 | 420 |
| 420 - (void)dragStarted:(NSPoint)initialMouseLocation { | 421 - (void)dragStarted:(NSPoint)initialMouseLocation { |
| 421 NSPoint initialMouseLocationScreen = | 422 NSPoint initialMouseLocationScreen = ui::ConvertPointFromWindowToScreen( |
| 422 [[self window] convertBaseToScreen:initialMouseLocation]; | 423 [self window], initialMouseLocation); |
| 423 [controller_ startDrag:initialMouseLocationScreen]; | 424 [controller_ startDrag:initialMouseLocationScreen]; |
| 424 } | 425 } |
| 425 | 426 |
| 426 - (void)dragEnded:(BOOL)cancelled { | 427 - (void)dragEnded:(BOOL)cancelled { |
| 427 [controller_ endDrag:cancelled]; | 428 [controller_ endDrag:cancelled]; |
| 428 } | 429 } |
| 429 | 430 |
| 430 - (void)dragProgress:(NSPoint)mouseLocation { | 431 - (void)dragProgress:(NSPoint)mouseLocation { |
| 431 NSPoint mouseLocationScreen = | 432 NSPoint mouseLocationScreen = ui::ConvertPointFromWindowToScreen( |
| 432 [[self window] convertBaseToScreen:mouseLocation]; | 433 [self window], mouseLocation); |
| 433 [controller_ drag:mouseLocationScreen]; | 434 [controller_ drag:mouseLocationScreen]; |
| 434 } | 435 } |
| 435 | 436 |
| 436 - (void)cleanupAfterDrag { | 437 - (void)cleanupAfterDrag { |
| 437 } | 438 } |
| 438 | 439 |
| 439 // End of MouseDragControllerClient implementaiton | 440 // End of MouseDragControllerClient implementaiton |
| 440 | 441 |
| 441 - (void)drawAttention { | 442 - (void)drawAttention { |
| 442 if (isDrawingAttention_) | 443 if (isDrawingAttention_) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 - (void)simulateCloseButtonClick { | 524 - (void)simulateCloseButtonClick { |
| 524 [[customCloseButton_ cell] performClick:customCloseButton_]; | 525 [[customCloseButton_ cell] performClick:customCloseButton_]; |
| 525 } | 526 } |
| 526 | 527 |
| 527 - (void)pressLeftMouseButtonTitlebar:(NSPoint)mouseLocation | 528 - (void)pressLeftMouseButtonTitlebar:(NSPoint)mouseLocation |
| 528 modifiers:(int)modifierFlags { | 529 modifiers:(int)modifierFlags { |
| 529 // Override the drag controller. It's ok to create a new one for each drag. | 530 // Override the drag controller. It's ok to create a new one for each drag. |
| 530 dragController_.reset([[TestDragController alloc] initWithClient:self]); | 531 dragController_.reset([[TestDragController alloc] initWithClient:self]); |
| 531 // Convert from Cocoa's screen coordinates to base coordinates since the mouse | 532 // Convert from Cocoa's screen coordinates to base coordinates since the mouse |
| 532 // event takes base (NSWindow) coordinates. | 533 // event takes base (NSWindow) coordinates. |
| 533 NSPoint mouseLocationWindow = | 534 NSPoint mouseLocationWindow = ui::ConvertPointFromScreenToWindow( |
| 534 [[self window] convertScreenToBase:mouseLocation]; | 535 [self window], mouseLocation); |
| 535 NSEvent* event = MakeMouseEvent(NSLeftMouseDown, mouseLocationWindow, | 536 NSEvent* event = MakeMouseEvent(NSLeftMouseDown, mouseLocationWindow, |
| 536 modifierFlags, 0); | 537 modifierFlags, 0); |
| 537 [self mouseDown:event]; | 538 [self mouseDown:event]; |
| 538 } | 539 } |
| 539 | 540 |
| 540 - (void)releaseLeftMouseButtonTitlebar:(int)modifierFlags { | 541 - (void)releaseLeftMouseButtonTitlebar:(int)modifierFlags { |
| 541 NSEvent* event = MakeMouseEvent(NSLeftMouseUp, NSZeroPoint, modifierFlags, 1); | 542 NSEvent* event = MakeMouseEvent(NSLeftMouseUp, NSZeroPoint, modifierFlags, 1); |
| 542 [self mouseUp:event]; | 543 [self mouseUp:event]; |
| 543 } | 544 } |
| 544 | 545 |
| 545 - (void)dragTitlebar:(NSPoint)mouseLocation { | 546 - (void)dragTitlebar:(NSPoint)mouseLocation { |
| 546 // Convert from Cocoa's screen coordinates to base coordinates since the mouse | 547 // Convert from Cocoa's screen coordinates to base coordinates since the mouse |
| 547 // event takes base (NSWindow) coordinates. | 548 // event takes base (NSWindow) coordinates. |
| 548 NSPoint mouseLocationWindow = | 549 NSPoint mouseLocationWindow = ui::ConvertPointFromScreenToWindow( |
| 549 [[self window] convertScreenToBase:mouseLocation]; | 550 [self window], mouseLocation); |
| 550 NSEvent* event = | 551 NSEvent* event = |
| 551 MakeMouseEvent(NSLeftMouseDragged, mouseLocationWindow, 0, 0); | 552 MakeMouseEvent(NSLeftMouseDragged, mouseLocationWindow, 0, 0); |
| 552 [self mouseDragged:event]; | 553 [self mouseDragged:event]; |
| 553 } | 554 } |
| 554 | 555 |
| 555 - (void)cancelDragTitlebar { | 556 - (void)cancelDragTitlebar { |
| 556 [self dragEnded:YES]; | 557 [self dragEnded:YES]; |
| 557 } | 558 } |
| 558 | 559 |
| 559 - (void)finishDragTitlebar { | 560 - (void)finishDragTitlebar { |
| 560 [self dragEnded:NO]; | 561 [self dragEnded:NO]; |
| 561 } | 562 } |
| 562 | 563 |
| 563 - (NSButton*)closeButton { | 564 - (NSButton*)closeButton { |
| 564 return closeButton_; | 565 return closeButton_; |
| 565 } | 566 } |
| 566 | 567 |
| 567 - (NSButton*)minimizeButton { | 568 - (NSButton*)minimizeButton { |
| 568 return minimizeButton_; | 569 return minimizeButton_; |
| 569 } | 570 } |
| 570 | 571 |
| 571 - (NSButton*)restoreButton { | 572 - (NSButton*)restoreButton { |
| 572 return restoreButton_; | 573 return restoreButton_; |
| 573 } | 574 } |
| 574 | 575 |
| 575 @end | 576 @end |
| 576 | 577 |
| OLD | NEW |