| 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/bookmarks/bookmark_button.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| 11 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
| 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" | 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" |
| 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" | 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
| 14 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 14 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 15 #import "chrome/browser/ui/cocoa/view_id_util.h" | 15 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 16 #include "components/bookmarks/browser/bookmark_model.h" | 16 #include "components/bookmarks/browser/bookmark_model.h" |
| 17 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
| 18 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 18 #import "ui/base/cocoa/nsview_additions.h" | 19 #import "ui/base/cocoa/nsview_additions.h" |
| 19 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 20 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 20 | 21 |
| 21 using base::UserMetricsAction; | 22 using base::UserMetricsAction; |
| 22 using bookmarks::BookmarkNode; | 23 using bookmarks::BookmarkNode; |
| 23 | 24 |
| 24 // The opacity of the bookmark button drag image. | 25 // The opacity of the bookmark button drag image. |
| 25 static const CGFloat kDragImageOpacity = 0.7; | 26 static const CGFloat kDragImageOpacity = 0.7; |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 if ([self isFlipped]) { | 103 if ([self isFlipped]) { |
| 103 point.y += [self bounds].size.height - dragMouseOffset_.y; | 104 point.y += [self bounds].size.height - dragMouseOffset_.y; |
| 104 } else { | 105 } else { |
| 105 point.y += dragMouseOffset_.y; | 106 point.y += dragMouseOffset_.y; |
| 106 } | 107 } |
| 107 } else { | 108 } else { |
| 108 // Use the middle of this button as the location. | 109 // Use the middle of this button as the location. |
| 109 NSRect bounds = [self bounds]; | 110 NSRect bounds = [self bounds]; |
| 110 point = NSMakePoint(NSMidX(bounds), NSMidY(bounds)); | 111 point = NSMakePoint(NSMidX(bounds), NSMidY(bounds)); |
| 111 point = [self convertPoint:point toView:nil]; | 112 point = [self convertPoint:point toView:nil]; |
| 112 point = [[self window] convertBaseToScreen:point]; | 113 point = ui::ConvertPointFromWindowToScreen([self window], point); |
| 113 } | 114 } |
| 114 | 115 |
| 115 return point; | 116 return point; |
| 116 } | 117 } |
| 117 | 118 |
| 118 | 119 |
| 119 - (void)updateTrackingAreas { | 120 - (void)updateTrackingAreas { |
| 120 [self installCustomTrackingArea]; | 121 [self installCustomTrackingArea]; |
| 121 [super updateTrackingAreas]; | 122 [super updateTrackingAreas]; |
| 122 } | 123 } |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 [[cell clipPathForFrame:bounds inView:self] setClip]; | 468 [[cell clipPathForFrame:bounds inView:self] setClip]; |
| 468 [cell drawWithFrame:bounds inView:self]; | 469 [cell drawWithFrame:bounds inView:self]; |
| 469 | 470 |
| 470 CGContextEndTransparencyLayer(cgContext); | 471 CGContextEndTransparencyLayer(cgContext); |
| 471 [image unlockFocus]; | 472 [image unlockFocus]; |
| 472 | 473 |
| 473 return image.autorelease(); | 474 return image.autorelease(); |
| 474 } | 475 } |
| 475 | 476 |
| 476 @end // @implementation BookmarkButton(Private) | 477 @end // @implementation BookmarkButton(Private) |
| OLD | NEW |