Commit 0b3ec609 authored by groby@chromium.org's avatar groby@chromium.org

[WebIntents, OSX] Add close button to inline disposition.

BUG=125219
TEST=


Review URL: http://codereview.chromium.org/10283008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134845 0039d316-1c4b-4281-b951-d872f2087c98
parent cb09f6ac
......@@ -540,6 +540,19 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing +
return NSHeight([button frame]);
}
- (void)addCloseButtonToSubviews:(NSMutableArray*)subviews {
if (!closeButton_.get()) {
NSRect buttonFrame = NSMakeRect(
kFramePadding + kImageSize + kTextWidth, kFramePadding,
kCloseButtonSize, kCloseButtonSize);
closeButton_.reset(
[[HoverCloseButton alloc] initWithFrame:buttonFrame]);
[closeButton_ setTarget:self];
[closeButton_ setAction:@selector(cancelOperation:)];
}
[subviews addObject:closeButton_];
}
// Adds a header (icon and explanatory text) to picker bubble.
// Returns the y position delta for the next offset.
- (CGFloat)addHeaderToSubviews:(NSMutableArray*)subviews
......@@ -566,17 +579,8 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing +
NSRect textFrame = [actionTextField_ frame];
textFrame.origin.y = offset;
NSRect buttonFrame = NSMakeRect(
kFramePadding + kImageSize + kTextWidth, offset,
kCloseButtonSize, kCloseButtonSize);
closeButton_.reset(
[[HoverCloseButton alloc] initWithFrame:buttonFrame]);
[closeButton_ setTarget:self];
[closeButton_ setAction:@selector(cancelOperation:)];
// Adjust view height to fit elements, center-align elements.
CGFloat maxHeight = std::max(NSHeight(buttonFrame),
std::max(NSHeight(imageFrame), NSHeight(textFrame)));
CGFloat maxHeight = std::max(NSHeight(imageFrame), NSHeight(textFrame));
textFrame.origin.y += (maxHeight - NSHeight(textFrame)) / 2;
imageFrame.origin.y += (maxHeight - NSHeight(imageFrame)) / 2;
......@@ -585,7 +589,6 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing +
[subviews addObject:actionTextField_];
[subviews addObject:imageView];
[subviews addObject:closeButton_];
return NSHeight([imageView frame]);
}
......@@ -652,8 +655,11 @@ const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing +
if (contents_) {
offset += [self addInlineHtmlToSubviews:subviews atOffset:offset];
[self addCloseButtonToSubviews:subviews];
} else {
offset += [self addHeaderToSubviews:subviews atOffset:offset];
[self addCloseButtonToSubviews:subviews];
if (model) {
[intentButtons_ removeAllObjects];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment