diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-12 02:23:09 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-12 02:23:09 +0000 |
commit | 22f649e079ecab148c43314569a3ab74d1d9d8b8 (patch) | |
tree | be954776ee92906f63c77d49de4840df8f0ac92d /chrome/browser/cocoa/base_bubble_controller.mm | |
parent | 58c3a0962bb4dbd76bb556f036372f980467af71 (diff) | |
download | chromium_src-22f649e079ecab148c43314569a3ab74d1d9d8b8.zip chromium_src-22f649e079ecab148c43314569a3ab74d1d9d8b8.tar.gz chromium_src-22f649e079ecab148c43314569a3ab74d1d9d8b8.tar.bz2 |
[Mac] Fix the positioning of the page info bubble.
BUG=57306
TEST=Click the lock icon. Page info bubble positioned underneath it.
Review URL: http://codereview.chromium.org/3532021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62230 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/base_bubble_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/base_bubble_controller.mm | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/chrome/browser/cocoa/base_bubble_controller.mm b/chrome/browser/cocoa/base_bubble_controller.mm index 9cebc61..a67bc64 100644 --- a/chrome/browser/cocoa/base_bubble_controller.mm +++ b/chrome/browser/cocoa/base_bubble_controller.mm @@ -12,9 +12,14 @@ #import "chrome/browser/cocoa/info_bubble_view.h" #include "grit/generated_resources.h" +@interface BaseBubbleController (Private) +- (void)updateOriginFromAnchor; +@end + @implementation BaseBubbleController @synthesize parentWindow = parentWindow_; +@synthesize anchorPoint = anchor_; @synthesize bubble = bubble_; - (id)initWithWindowNibPath:(NSString*)nibPath @@ -92,6 +97,11 @@ [super dealloc]; } +- (void)setAnchorPoint:(NSPoint)anchor { + anchor_ = anchor; + [self updateOriginFromAnchor]; +} + - (void)parentWindowWillClose:(NSNotification*)notification { [self close]; } @@ -110,16 +120,7 @@ // showWindow:. Thus, we have our own version. - (void)showWindow:(id)sender { NSWindow* window = [self window]; // completes nib load - - NSPoint origin = anchor_; - NSSize offsets = NSMakeSize(info_bubble::kBubbleArrowXOffset + - info_bubble::kBubbleArrowWidth / 2.0, 0); - offsets = [[parentWindow_ contentView] convertSize:offsets toView:nil]; - origin.x += offsets.width; - if ([bubble_ arrowLocation] == info_bubble::kTopRight) - origin.x -= NSWidth([window frame]); - origin.y -= NSHeight([window frame]); - [window setFrameOrigin:origin]; + [self updateOriginFromAnchor]; [parentWindow_ addChildWindow:window ordered:NSWindowAbove]; [window makeKeyAndOrderFront:self]; } @@ -148,4 +149,21 @@ // undone. That's ok. [self close]; } + +// Takes the |anchor_| point and adjusts the window's origin accordingly. +- (void)updateOriginFromAnchor { + NSWindow* window = [self window]; + NSPoint origin = anchor_; + NSSize offsets = NSMakeSize(info_bubble::kBubbleArrowXOffset + + info_bubble::kBubbleArrowWidth / 2.0, 0); + offsets = [[parentWindow_ contentView] convertSize:offsets toView:nil]; + if ([bubble_ arrowLocation] == info_bubble::kTopRight) { + origin.x -= NSWidth([window frame]) + offsets.width; + } else { + origin.x -= offsets.width; + } + origin.y -= NSHeight([window frame]); + [window setFrameOrigin:origin]; +} + @end // BaseBubbleController |