diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 18:28:08 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 18:28:08 +0000 |
commit | ca18e6f3adf9c80dbc8cdcaf7812fade089350bc (patch) | |
tree | d3973c873faa6301bb4157b7da527610104b8914 /chrome/browser/cocoa | |
parent | 443a69517cb7c4325ee5be903806c0618b40e02c (diff) | |
download | chromium_src-ca18e6f3adf9c80dbc8cdcaf7812fade089350bc.zip chromium_src-ca18e6f3adf9c80dbc8cdcaf7812fade089350bc.tar.gz chromium_src-ca18e6f3adf9c80dbc8cdcaf7812fade089350bc.tar.bz2 |
Adjust size of location bar, update preference panels to new appearance.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16306 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/location_bar_cell.h | 12 | ||||
-rw-r--r-- | chrome/browser/cocoa/location_bar_cell.mm | 45 | ||||
-rw-r--r-- | chrome/browser/cocoa/location_bar_cell_unittest.mm | 42 | ||||
-rw-r--r-- | chrome/browser/cocoa/toolbar_button_cell.mm | 13 | ||||
-rw-r--r-- | chrome/browser/cocoa/toolbar_controller.mm | 1 |
5 files changed, 111 insertions, 2 deletions
diff --git a/chrome/browser/cocoa/location_bar_cell.h b/chrome/browser/cocoa/location_bar_cell.h new file mode 100644 index 0000000..0bfb1dd --- /dev/null +++ b/chrome/browser/cocoa/location_bar_cell.h @@ -0,0 +1,12 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import <Cocoa/Cocoa.h> + +// A cell that draws the location bar, for now all it does is shift +// the text down so it is vertically centered. + +@interface LocationBarCell : NSTextFieldCell { +} +@end diff --git a/chrome/browser/cocoa/location_bar_cell.mm b/chrome/browser/cocoa/location_bar_cell.mm new file mode 100644 index 0000000..2f8698da --- /dev/null +++ b/chrome/browser/cocoa/location_bar_cell.mm @@ -0,0 +1,45 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "chrome/browser/cocoa/location_bar_cell.h" + +const NSInteger kBaselineOffset = 1; + +@implementation LocationBarCell + +- (void)drawInteriorWithFrame:(NSRect)cellFrame + inView:(NSView *)controlView { + [super drawInteriorWithFrame:NSInsetRect(cellFrame, 0, kBaselineOffset) + inView:controlView]; +} + +// Override these methods so that the field editor shows up in the right place +- (void)editWithFrame:(NSRect)cellFrame + inView:(NSView *)controlView + editor:(NSText *)textObj + delegate:(id)anObject + event:(NSEvent *)theEvent { + [super editWithFrame:NSInsetRect(cellFrame, 0, kBaselineOffset) + inView:controlView + editor:textObj + delegate:anObject + event:theEvent]; +} + + +// Override these methods so that the field editor shows up in the right place +- (void)selectWithFrame:(NSRect)cellFrame + inView:(NSView *)controlView + editor:(NSText *)textObj + delegate:(id)anObject + start:(NSInteger)selStart + length:(NSInteger)selLength { + [super selectWithFrame:NSInsetRect(cellFrame, 0, kBaselineOffset) + inView:controlView editor:textObj + delegate:anObject + start:selStart + length:selLength]; +} + +@end diff --git a/chrome/browser/cocoa/location_bar_cell_unittest.mm b/chrome/browser/cocoa/location_bar_cell_unittest.mm new file mode 100644 index 0000000..1dd8e47 --- /dev/null +++ b/chrome/browser/cocoa/location_bar_cell_unittest.mm @@ -0,0 +1,42 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import <Cocoa/Cocoa.h> + +#include "base/scoped_nsobject.h" +#import "chrome/browser/cocoa/location_bar_cell.h" +#import "chrome/browser/cocoa/cocoa_test_helper.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +class LocationBarCellTest : public testing::Test { + public: + LocationBarCellTest() { + NSRect frame = NSMakeRect(0, 0, 50, 30); + view_.reset([[NSTextField alloc] initWithFrame:frame]); + scoped_nsobject<LocationBarCell> cell( + [[LocationBarCell alloc] initTextCell:@"Testing"]); + [view_ setCell:cell.get()]; + [cocoa_helper_.contentView() addSubview:view_.get()]; + } + + CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... + scoped_nsobject<NSTextField> view_; +}; + +// Test adding/removing from the view hierarchy, mostly to ensure nothing +// leaks or crashes. +TEST_F(LocationBarCellTest, AddRemove) { + EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); + [view_.get() removeFromSuperview]; + EXPECT_FALSE([view_ superview]); +} + +// Test drawing, mostly to ensure nothing leaks or crashes. +TEST_F(LocationBarCellTest, Display) { + [view_ display]; +} + +} // namespace diff --git a/chrome/browser/cocoa/toolbar_button_cell.mm b/chrome/browser/cocoa/toolbar_button_cell.mm index 54b2f7c..22030e6 100644 --- a/chrome/browser/cocoa/toolbar_button_cell.mm +++ b/chrome/browser/cocoa/toolbar_button_cell.mm @@ -11,7 +11,11 @@ NSBackgroundStyleLowered : NSBackgroundStyleRaised; } -- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView{ +- (void)awakeFromNib { + [[self image] setTemplate:YES]; +} + +- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { NSRect drawFrame = NSInsetRect(cellFrame, 1.5, 1.5); ButtonType type = [[(NSControl*)controlView cell] tag]; switch (type) { @@ -65,10 +69,15 @@ NSDivideRect(cellFrame, &borderRect, &contentRect, 1.0, NSMaxXEdge); [[NSColor colorWithCalibratedWhite:0.0 alpha:0.15] set]; NSRectFillUsingOperation(NSInsetRect(borderRect, 0, 2), - NSCompositeSourceOver); + NSCompositeHighlight); } + CGContextRef ctx = static_cast<CGContextRef> + ([[NSGraphicsContext currentContext] graphicsPort]); + CGContextSetAlpha(ctx, 0.8); + CGContextBeginTransparencyLayer(ctx, NULL); [self drawInteriorWithFrame:NSOffsetRect(cellFrame, 0, 1) inView:controlView]; + CGContextEndTransparencyLayer(ctx); } @end diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm index 0860a0b..46cc1e0 100644 --- a/chrome/browser/cocoa/toolbar_controller.mm +++ b/chrome/browser/cocoa/toolbar_controller.mm @@ -48,6 +48,7 @@ static NSString* const kStarredImageName = @"starred"; [self initCommandStatus:commands_]; locationBarView_.reset(new LocationBarViewMac(locationBar_, commands_, toolbarModel_, profile_)); + [locationBar_ setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]]; } - (void)dealloc { |