diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-27 20:25:59 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-27 20:25:59 +0000 |
commit | 987d3f969bde97b121b4144a980394ee777663b7 (patch) | |
tree | 53943f2ffd567ecc615121b5714abd7ef9169edd | |
parent | ae23c272faf85d4cf779ae15d28fc59f5a8162ab (diff) | |
download | chromium_src-987d3f969bde97b121b4144a980394ee777663b7.zip chromium_src-987d3f969bde97b121b4144a980394ee777663b7.tar.gz chromium_src-987d3f969bde97b121b4144a980394ee777663b7.tar.bz2 |
Pretties up the FindBar on Mac.
BUG=http://crbug.com/14903
BUG=http://crbug.com/14904
BUG=http://crbug.com/14905
TEST=Findbar should function normally, as before.
Review URL: http://codereview.chromium.org/160144
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21686 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/nibs/FindBar.xib | 67 | ||||
-rw-r--r-- | chrome/browser/cocoa/find_bar_cocoa_controller.mm | 12 | ||||
-rw-r--r-- | chrome/browser/cocoa/find_bar_view.mm | 33 | ||||
-rw-r--r-- | chrome/browser/cocoa/gradient_button_cell.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/gradient_button_cell.mm | 4 |
5 files changed, 94 insertions, 23 deletions
diff --git a/chrome/app/nibs/FindBar.xib b/chrome/app/nibs/FindBar.xib index 51cab7f..ad0a48c 100644 --- a/chrome/app/nibs/FindBar.xib +++ b/chrome/app/nibs/FindBar.xib @@ -2,9 +2,9 @@ <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9G55</string> + <string key="IBDocument.SystemVersion">9J61</string> <string key="IBDocument.InterfaceBuilderVersion">677</string> - <string key="IBDocument.AppKitVersion">949.43</string> + <string key="IBDocument.AppKitVersion">949.46</string> <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -42,7 +42,7 @@ <object class="NSTextField" id="445667"> <reference key="NSNextResponder" ref="612665518"/> <int key="NSvFlags">290</int> - <string key="NSFrame">{{175, 3}, {71, 22}}</string> + <string key="NSFrame">{{200, 3}, {31, 22}}</string> <reference key="NSSuperview" ref="612665518"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="236923920"> @@ -73,7 +73,7 @@ <object class="NSTextField" id="510660793"> <reference key="NSNextResponder" ref="612665518"/> <int key="NSvFlags">290</int> - <string key="NSFrame">{{20, 6}, {228, 22}}</string> + <string key="NSFrame">{{13, 6}, {216, 22}}</string> <reference key="NSSuperview" ref="612665518"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="926027568"> @@ -98,7 +98,7 @@ <object class="NSButton" id="455192438"> <reference key="NSNextResponder" ref="612665518"/> <int key="NSvFlags">289</int> - <string key="NSFrame">{{256, 6}, {22, 22}}</string> + <string key="NSFrame">{{228, 5}, {24, 24}}</string> <reference key="NSSuperview" ref="612665518"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="1064223545"> @@ -106,6 +106,7 @@ <int key="NSCellFlags2">134217728</int> <string key="NSContents"/> <reference key="NSSupport" ref="197084721"/> + <int key="NSTag">2</int> <reference key="NSControlView" ref="455192438"/> <int key="NSButtonFlags">-2033958657</int> <int key="NSButtonFlags2">134</int> @@ -122,7 +123,7 @@ <object class="NSButton" id="968135285"> <reference key="NSNextResponder" ref="612665518"/> <int key="NSvFlags">289</int> - <string key="NSFrame">{{277, 6}, {22, 22}}</string> + <string key="NSFrame">{{251, 5}, {26, 24}}</string> <reference key="NSSuperview" ref="612665518"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="9143312"> @@ -130,8 +131,9 @@ <int key="NSCellFlags2">134217728</int> <string key="NSContents"/> <reference key="NSSupport" ref="197084721"/> + <int key="NSTag">1</int> <reference key="NSControlView" ref="968135285"/> - <int key="NSButtonFlags">-2033958657</int> + <int key="NSButtonFlags">-2033434369</int> <int key="NSButtonFlags2">134</int> <object class="NSCustomResource" key="NSNormalImage"> <string key="NSClassName">NSImage</string> @@ -146,7 +148,7 @@ <object class="NSButton" id="742622660"> <reference key="NSNextResponder" ref="612665518"/> <int key="NSvFlags">289</int> - <string key="NSFrame">{{308, 6}, {22, 22}}</string> + <string key="NSFrame">{{280, 9}, {16, 16}}</string> <reference key="NSSuperview" ref="612665518"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="768031501"> @@ -155,11 +157,11 @@ <string key="NSContents"/> <reference key="NSSupport" ref="197084721"/> <reference key="NSControlView" ref="742622660"/> - <int key="NSButtonFlags">-2033958657</int> + <int key="NSButtonFlags">-2041822977</int> <int key="NSButtonFlags2">134</int> <object class="NSCustomResource" key="NSNormalImage"> <string key="NSClassName">NSImage</string> - <string key="NSResourceName">NSStopProgressTemplate</string> + <string key="NSResourceName">close_bar</string> </object> <string key="NSAlternateContents"/> <string type="base64-UTF8" key="NSKeyEquivalent">Gw</string> @@ -168,7 +170,7 @@ </object> </object> </object> - <string key="NSFrameSize">{350, 34}</string> + <string key="NSFrameSize">{310, 33}</string> <reference key="NSSuperview"/> <string key="NSClassName">FindBarView</string> </object> @@ -371,7 +373,9 @@ <string>-2.IBPluginDependency</string> <string>-3.IBPluginDependency</string> <string>10.IBPluginDependency</string> + <string>11.CustomClassName</string> <string>11.IBPluginDependency</string> + <string>12.CustomClassName</string> <string>12.IBPluginDependency</string> <string>2.IBEditorWindowLastContentRect</string> <string>2.IBPluginDependency</string> @@ -397,9 +401,11 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>ToolbarButtonCell</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>ToolbarButtonCell</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{481, 702}, {350, 34}}</string> + <string>{{481, 703}, {310, 33}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <real value="0.000000e+00" id="304884188"/> <reference ref="817558590"/> @@ -438,12 +444,20 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">24</int> + <int key="maxID">28</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBPartialClassDescription"> + <string key="className">BackgroundGradientView</string> + <string key="superclassName">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/background_gradient_view.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">FindBarCocoaController</string> <string key="superclassName">NSViewController</string> <object class="NSMutableDictionary" key="actions"> @@ -485,23 +499,46 @@ </object> <object class="IBPartialClassDescription"> <string key="className">FindBarView</string> - <string key="superclassName">NSView</string> + <string key="superclassName">BackgroundGradientView</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> <string key="minorKey">browser/cocoa/find_bar_view.h</string> </object> </object> <object class="IBPartialClassDescription"> + <string key="className">GradientButtonCell</string> + <string key="superclassName">NSButtonCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/gradient_button_cell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/status_bubble_mac.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">NSObject</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> <string key="minorKey">browser/cocoa/tab_strip_model_observer_bridge.h</string> </object> </object> + <object class="IBPartialClassDescription"> + <string key="className">ToolbarButtonCell</string> + <string key="superclassName">GradientButtonCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/toolbar_button_cell.h</string> + </object> + </object> </object> </object> <int key="IBDocument.localizationMode">0</int> - <string key="IBDocument.LastKnownRelativeProjectPath">../../../chrome.xcodeproj</string> + <string key="IBDocument.LastKnownRelativeProjectPath">../../chrome.xcodeproj</string> <int key="IBDocument.defaultPropertyAccessControl">3</int> </data> </archive> diff --git a/chrome/browser/cocoa/find_bar_cocoa_controller.mm b/chrome/browser/cocoa/find_bar_cocoa_controller.mm index 58e687c..f28fd56 100644 --- a/chrome/browser/cocoa/find_bar_cocoa_controller.mm +++ b/chrome/browser/cocoa/find_bar_cocoa_controller.mm @@ -168,6 +168,18 @@ // area. [resultsLabel_ setStringValue:@""]; } + + // Resize |resultsLabel_| to completely contain its string and right-justify + // it within |findText_|. sizeToFit may shrink the frame vertically, which we + // don't want, so we save the original vertical positioning. + NSRect labelFrame = [resultsLabel_ frame]; + [resultsLabel_ sizeToFit]; + labelFrame.size.width = [resultsLabel_ frame].size.width; + labelFrame.origin.x = NSMaxX([findText_ frame]) - labelFrame.size.width; + [resultsLabel_ setFrame:labelFrame]; + + // TODO(rohitrao): If the search string is too long, then it will overlap with + // the results label. Fix. } - (BOOL)isFindBarVisible { diff --git a/chrome/browser/cocoa/find_bar_view.mm b/chrome/browser/cocoa/find_bar_view.mm index 8c73f4e..238884d 100644 --- a/chrome/browser/cocoa/find_bar_view.mm +++ b/chrome/browser/cocoa/find_bar_view.mm @@ -14,20 +14,37 @@ NSPoint topLeft = NSMakePoint(NSMinX(rect), NSMaxY(rect)); NSPoint topRight = NSMakePoint(NSMaxX(rect), NSMaxY(rect)); - // Inset the bottom points by 1 so we draw the border entirely - // inside the frame. - NSPoint bottomLeft = NSMakePoint(NSMinX(rect) + curveSize, NSMinY(rect) + 1); - NSPoint bottomRight = NSMakePoint(NSMaxX(rect) - curveSize, NSMinY(rect) + 1); + NSPoint midLeft1 = + NSMakePoint(NSMinX(rect) + curveSize, NSMaxY(rect) - curveSize); + NSPoint midLeft2 = + NSMakePoint(NSMinX(rect) + curveSize, NSMinY(rect) + curveSize); + NSPoint midRight1 = + NSMakePoint(NSMaxX(rect) - curveSize, NSMinY(rect) + curveSize); + NSPoint midRight2 = + NSMakePoint(NSMaxX(rect) - curveSize, NSMaxY(rect) - curveSize); + NSPoint bottomLeft = + NSMakePoint(NSMinX(rect) + (2 * curveSize), NSMinY(rect)); + NSPoint bottomRight = + NSMakePoint(NSMaxX(rect) - (2 * curveSize), NSMinY(rect)); NSBezierPath *path = [NSBezierPath bezierPath]; [path moveToPoint:topLeft]; + [path curveToPoint:midLeft1 + controlPoint1:NSMakePoint(midLeft1.x, topLeft.y) + controlPoint2:NSMakePoint(midLeft1.x, topLeft.y)]; + [path lineToPoint:midLeft2]; [path curveToPoint:bottomLeft - controlPoint1:NSMakePoint(topLeft.x + curveSize, topLeft.y) - controlPoint2:NSMakePoint(bottomLeft.x - curveSize, bottomLeft.y)]; + controlPoint1:NSMakePoint(midLeft2.x, bottomLeft.y) + controlPoint2:NSMakePoint(midLeft2.x, bottomLeft.y)]; + [path lineToPoint:bottomRight]; + [path curveToPoint:midRight1 + controlPoint1:NSMakePoint(midRight1.x, bottomLeft.y) + controlPoint2:NSMakePoint(midRight1.x, bottomLeft.y)]; + [path lineToPoint:midRight2]; [path curveToPoint:topRight - controlPoint1:NSMakePoint(bottomRight.x + curveSize, bottomRight.y) - controlPoint2:NSMakePoint(topRight.x - curveSize, topRight.y)]; + controlPoint1:NSMakePoint(midRight2.x, topLeft.y) + controlPoint2:NSMakePoint(midRight2.x, topLeft.y)]; [NSGraphicsContext saveGraphicsState]; [path addClip]; diff --git a/chrome/browser/cocoa/gradient_button_cell.h b/chrome/browser/cocoa/gradient_button_cell.h index 61c9a4f..7492649 100644 --- a/chrome/browser/cocoa/gradient_button_cell.h +++ b/chrome/browser/cocoa/gradient_button_cell.h @@ -23,6 +23,7 @@ enum { kLeftButtonWithShadowType = -2, kStandardButtonType = 0, kRightButtonType = 1, + kMiddleButtonType = 2, }; typedef NSInteger ButtonType; diff --git a/chrome/browser/cocoa/gradient_button_cell.mm b/chrome/browser/cocoa/gradient_button_cell.mm index 4e6462d..99a0dc1 100644 --- a/chrome/browser/cocoa/gradient_button_cell.mm +++ b/chrome/browser/cocoa/gradient_button_cell.mm @@ -166,6 +166,10 @@ NSRect innerFrame = NSInsetRect(cellFrame, 2, 2); ButtonType type = [[(NSControl*)controlView cell] tag]; switch (type) { + case kMiddleButtonType: + drawFrame.size.width += 20; + innerFrame.size.width += 2; + // Fallthrough case kRightButtonType: drawFrame.origin.x -= 20; innerFrame.origin.x -= 2; |