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" |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 inMode:NSDefaultRunLoopMode | 429 inMode:NSDefaultRunLoopMode |
430 dequeue:YES]; | 430 dequeue:YES]; |
431 | 431 |
432 switch ([event type]) { | 432 switch ([event type]) { |
433 case NSLeftMouseDragged: | 433 case NSLeftMouseDragged: |
434 if (dragState_ == PANEL_DRAG_CAN_START) { | 434 if (dragState_ == PANEL_DRAG_CAN_START) { |
435 if (![self exceedsDragThreshold:[event locationInWindow]]) | 435 if (![self exceedsDragThreshold:[event locationInWindow]]) |
436 return; // Don't start real drag yet. | 436 return; // Don't start real drag yet. |
437 [self startDrag]; | 437 [self startDrag]; |
438 } | 438 } |
439 [self dragWithDeltaX:[event deltaX]]; | 439 [self dragWithDeltaX:[event deltaX] |
| 440 deltaY:[event deltaY]]; |
440 break; | 441 break; |
441 | 442 |
442 case NSKeyUp: | 443 case NSKeyUp: |
443 if ([event keyCode] == kVK_Escape) { | 444 if ([event keyCode] == kVK_Escape) { |
444 [self endDrag:YES]; | 445 [self endDrag:YES]; |
445 keepGoing = NO; | 446 keepGoing = NO; |
446 } | 447 } |
447 break; | 448 break; |
448 | 449 |
449 case NSLeftMouseUp: | 450 case NSLeftMouseUp: |
(...skipping 22 matching lines...) Expand all Loading... |
472 dragState_ = PANEL_DRAG_IN_PROGRESS; | 473 dragState_ = PANEL_DRAG_IN_PROGRESS; |
473 [controller_ startDrag]; | 474 [controller_ startDrag]; |
474 } | 475 } |
475 | 476 |
476 - (void)endDrag:(BOOL)cancelled { | 477 - (void)endDrag:(BOOL)cancelled { |
477 if (dragState_ == PANEL_DRAG_IN_PROGRESS) | 478 if (dragState_ == PANEL_DRAG_IN_PROGRESS) |
478 [controller_ endDrag:cancelled]; | 479 [controller_ endDrag:cancelled]; |
479 dragState_ = PANEL_DRAG_SUPPRESSED; | 480 dragState_ = PANEL_DRAG_SUPPRESSED; |
480 } | 481 } |
481 | 482 |
482 - (void)dragWithDeltaX:(int)deltaX { | 483 - (void)dragWithDeltaX:(int)deltaX |
| 484 deltaY:(int)deltaY { |
483 if (dragState_ != PANEL_DRAG_IN_PROGRESS) | 485 if (dragState_ != PANEL_DRAG_IN_PROGRESS) |
484 return; | 486 return; |
485 [controller_ dragWithDeltaX:deltaX]; | 487 [controller_ dragWithDeltaX:deltaX |
| 488 deltaY:deltaY]; |
486 } | 489 } |
487 | 490 |
488 - (void)drawAttention { | 491 - (void)drawAttention { |
489 if (isDrawingAttention_) | 492 if (isDrawingAttention_) |
490 return; | 493 return; |
491 isDrawingAttention_ = YES; | 494 isDrawingAttention_ = YES; |
492 | 495 |
493 [self startGlintAnimation]; | 496 [self startGlintAnimation]; |
494 } | 497 } |
495 | 498 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 576 |
574 - (void)releaseLeftMouseButtonTitlebar { | 577 - (void)releaseLeftMouseButtonTitlebar { |
575 NSEvent* event = MakeMouseEvent(NSLeftMouseUp, NSZeroPoint, 1); | 578 NSEvent* event = MakeMouseEvent(NSLeftMouseUp, NSZeroPoint, 1); |
576 [self mouseUp:event]; | 579 [self mouseUp:event]; |
577 } | 580 } |
578 | 581 |
579 - (void)dragTitlebarDeltaX:(double)delta_x | 582 - (void)dragTitlebarDeltaX:(double)delta_x |
580 deltaY:(double)delta_y { | 583 deltaY:(double)delta_y { |
581 if (dragState_ == PANEL_DRAG_CAN_START) | 584 if (dragState_ == PANEL_DRAG_CAN_START) |
582 [self startDrag]; | 585 [self startDrag]; |
583 [self dragWithDeltaX:delta_x]; | 586 [self dragWithDeltaX:delta_x |
| 587 deltaY:delta_y]; |
584 } | 588 } |
585 | 589 |
586 - (void)cancelDragTitlebar { | 590 - (void)cancelDragTitlebar { |
587 [self endDrag:YES]; | 591 [self endDrag:YES]; |
588 } | 592 } |
589 | 593 |
590 - (void)finishDragTitlebar { | 594 - (void)finishDragTitlebar { |
591 [self endDrag:NO]; | 595 [self endDrag:NO]; |
592 } | 596 } |
593 | 597 |
594 - (void)updateSettingsButtonVisibility:(BOOL)mouseOverWindow { | 598 - (void)updateSettingsButtonVisibility:(BOOL)mouseOverWindow { |
595 // The settings button is visible if the panel is main window or the mouse is | 599 // The settings button is visible if the panel is main window or the mouse is |
596 // over it. | 600 // over it. |
597 BOOL shouldShowSettingsButton = | 601 BOOL shouldShowSettingsButton = |
598 mouseOverWindow || [[self window] isMainWindow]; | 602 mouseOverWindow || [[self window] isMainWindow]; |
599 [[settingsButtonWrapper_ animator] | 603 [[settingsButtonWrapper_ animator] |
600 setAlphaValue:shouldShowSettingsButton ? 1.0 : 0.0]; | 604 setAlphaValue:shouldShowSettingsButton ? 1.0 : 0.0]; |
601 } | 605 } |
602 | 606 |
603 - (void)checkMouseAndUpdateSettingsButtonVisibility { | 607 - (void)checkMouseAndUpdateSettingsButtonVisibility { |
604 BOOL mouseOverWindow = NSPointInRect([NSEvent mouseLocation], | 608 BOOL mouseOverWindow = NSPointInRect([NSEvent mouseLocation], |
605 [[self window] frame]); | 609 [[self window] frame]); |
606 [self updateSettingsButtonVisibility:mouseOverWindow]; | 610 [self updateSettingsButtonVisibility:mouseOverWindow]; |
607 } | 611 } |
608 | 612 |
609 @end | 613 @end |
610 | 614 |
OLD | NEW |