| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "chrome/browser/ui/cocoa/fullscreen_exit_bubble_view.h" |
| 6 |
| 7 #import "chrome/browser/ui/cocoa/nsview_additions.h" |
| 8 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 9 #import "chrome/browser/ui/cocoa/url_drop_target.h" |
| 10 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 11 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 12 |
| 13 namespace { |
| 14 CGFloat kCurveSize = 8; |
| 15 } // end namespace |
| 16 |
| 17 @implementation FullscreenExitBubbleView |
| 18 |
| 19 - (void)awakeFromNib { |
| 20 } |
| 21 |
| 22 - (void)drawRect:(NSRect)rect { |
| 23 const CGFloat lineWidth = [self cr_lineWidth]; |
| 24 const CGFloat halfLineWidth = lineWidth / 2.0; |
| 25 |
| 26 // TODO(rohitrao): Make this prettier. |
| 27 rect = NSInsetRect([self bounds], halfLineWidth, halfLineWidth); |
| 28 rect = NSOffsetRect(rect, 0, lineWidth); |
| 29 |
| 30 // TODO: i just haxed these to make it draw right. |
| 31 NSPoint topLeft = NSMakePoint(NSMinX(rect), NSMaxY(rect)); |
| 32 NSPoint topRight = NSMakePoint(NSMaxX(rect), NSMaxY(rect)); |
| 33 NSPoint midLeft1 = |
| 34 NSMakePoint(NSMinX(rect), NSMaxY(rect) - kCurveSize); |
| 35 NSPoint midLeft2 = |
| 36 NSMakePoint(NSMinX(rect), NSMinY(rect) + kCurveSize); |
| 37 NSPoint midRight1 = |
| 38 NSMakePoint(NSMaxX(rect), NSMinY(rect) + kCurveSize); |
| 39 NSPoint midRight2 = |
| 40 NSMakePoint(NSMaxX(rect), NSMaxY(rect) - kCurveSize); |
| 41 NSPoint bottomLeft = |
| 42 NSMakePoint(NSMinX(rect) + (1 * kCurveSize), NSMinY(rect)); |
| 43 NSPoint bottomRight = |
| 44 NSMakePoint(NSMaxX(rect) - (1 * kCurveSize), NSMinY(rect)); |
| 45 |
| 46 NSBezierPath* path = [NSBezierPath bezierPath]; |
| 47 [path moveToPoint:topLeft]; |
| 48 [path curveToPoint:midLeft1 |
| 49 controlPoint1:NSMakePoint(midLeft1.x, topLeft.y) |
| 50 controlPoint2:NSMakePoint(midLeft1.x, topLeft.y)]; |
| 51 [path lineToPoint:midLeft2]; |
| 52 [path curveToPoint:bottomLeft |
| 53 controlPoint1:NSMakePoint(midLeft2.x, bottomLeft.y) |
| 54 controlPoint2:NSMakePoint(midLeft2.x, bottomLeft.y)]; |
| 55 |
| 56 [path lineToPoint:bottomRight]; |
| 57 [path curveToPoint:midRight1 |
| 58 controlPoint1:NSMakePoint(midRight1.x, bottomLeft.y) |
| 59 controlPoint2:NSMakePoint(midRight1.x, bottomLeft.y)]; |
| 60 [path lineToPoint:midRight2]; |
| 61 [path curveToPoint:topRight |
| 62 controlPoint1:NSMakePoint(midRight2.x, topLeft.y) |
| 63 controlPoint2:NSMakePoint(midRight2.x, topLeft.y)]; |
| 64 |
| 65 { |
| 66 gfx::ScopedNSGraphicsContextSaveGState scopedGState; |
| 67 //NSGraphicsContext* context = [NSGraphicsContext currentContext]; |
| 68 [path addClip]; |
| 69 |
| 70 const NSRect bounds = [self bounds]; |
| 71 |
| 72 [[NSColor colorWithDeviceWhite:0 alpha:0.8] set]; |
| 73 NSRectFillUsingOperation(bounds, NSCompositeSourceOver); |
| 74 } |
| 75 |
| 76 //[[self strokeColor] set]; |
| 77 //[path setLineWidth:lineWidth]; |
| 78 //[path stroke]; |
| 79 } |
| 80 |
| 81 // The findbar is mostly opaque, but has an 8px transparent border on the left |
| 82 // and right sides (see |kCurveSize|). This is an artifact of the way it is |
| 83 // drawn. We override hitTest to return nil for points in this transparent |
| 84 // area. |
| 85 /*- (NSView*)hitTest:(NSPoint)point { |
| 86 NSView* hitView = [super hitTest:point]; |
| 87 if (hitView == self) { |
| 88 // |rect| is approximately equivalent to the opaque area of the findbar. |
| 89 NSRect rect = NSInsetRect([self bounds], kCurveSize, 0); |
| 90 if (!NSMouseInRect(point, rect, [self isFlipped])) |
| 91 return nil; |
| 92 } |
| 93 |
| 94 return hitView; |
| 95 }*/ |
| 96 |
| 97 // Eat all mouse events, to prevent clicks from falling through to views below. |
| 98 - (void)mouseDown:(NSEvent *)theEvent { |
| 99 } |
| 100 |
| 101 - (void)rightMouseDown:(NSEvent *)theEvent { |
| 102 } |
| 103 |
| 104 - (void)otherMouseDown:(NSEvent *)theEvent { |
| 105 } |
| 106 |
| 107 - (void)mouseUp:(NSEvent *)theEvent { |
| 108 } |
| 109 |
| 110 - (void)rightMouseUp:(NSEvent *)theEvent { |
| 111 } |
| 112 |
| 113 - (void)otherMouseUp:(NSEvent *)theEvent { |
| 114 } |
| 115 |
| 116 - (void)mouseMoved:(NSEvent *)theEvent { |
| 117 } |
| 118 |
| 119 - (void)mouseDragged:(NSEvent *)theEvent { |
| 120 } |
| 121 |
| 122 - (void)rightMouseDragged:(NSEvent *)theEvent { |
| 123 } |
| 124 |
| 125 - (void)otherMouseDragged:(NSEvent *)theEvent { |
| 126 } |
| 127 |
| 128 - (ViewID)viewID { |
| 129 return VIEW_ID_FIND_IN_PAGE; |
| 130 } |
| 131 |
| 132 // Specifies that mouse events over this view should be ignored by the |
| 133 // render host. |
| 134 - (BOOL)nonWebContentView { |
| 135 return YES; |
| 136 } |
| 137 |
| 138 @end |
| OLD | NEW |