mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-23 15:05:52 +00:00
Fixed it so that pop ups are properly placed over their buttons.
Reviewed by me.
This commit is contained in:
1 parent
d0db80335b
commit
3ac6b3c1fb
3 files changed
+18
-12
No files matched your search
@@ -949,6 +949,11 @@ var STICKY_TIME_INTERVAL = 500,
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGFloat)overlapOffsetWidth
|
||||
{
|
||||
return LEFT_MARGIN;
|
||||
}
|
||||
|
||||
- (void)setFont:(CPFont)aFont
|
||||
{
|
||||
[_menuView setFont:aFont];
|
||||
|
||||
+2
-6
@@ -1028,7 +1028,6 @@ var _CPMenuItemSelectionColor = nil,
|
||||
[_imageAndTextView setText:[_menuItem title]];
|
||||
[_imageAndTextView setTextColor:[self textColor]];
|
||||
[_imageAndTextView setFrameOrigin:CGPointMake(x, VERTICAL_MARGIN)];
|
||||
|
||||
[_imageAndTextView sizeToFit];
|
||||
|
||||
var frame = [_imageAndTextView frame];
|
||||
@@ -1066,12 +1065,9 @@ var _CPMenuItemSelectionColor = nil,
|
||||
[self setFrameSize:_minSize];
|
||||
}
|
||||
|
||||
- (float)calculatedLeftMargin
|
||||
- (CGFloat)overlapOffsetWidth
|
||||
{
|
||||
if (_belongsToMenuBar)
|
||||
return 0.0;
|
||||
|
||||
return LEFT_MARGIN + ([[_menuItem menu] showsStateColumn] ? STATE_COLUMN_WIDTH : 0.0) + [_menuItem indentationLevel] * INDENTATION_WIDTH;
|
||||
return LEFT_MARGIN + ([[_menuItem menu] showsStateColumn] ? STATE_COLUMN_WIDTH : 0.0);
|
||||
}
|
||||
|
||||
- (void)setShowsStateColumn:(BOOL)shouldShowStateColumn
|
||||
|
||||
+11
-6
@@ -639,19 +639,24 @@ var CPPopUpButtonArrowsImage = nil;
|
||||
[menuWindow setDelegate:self];
|
||||
[menuWindow setBackgroundStyle:_CPMenuWindowPopUpBackgroundStyle];
|
||||
|
||||
var menuOrigin = [theWindow convertBaseToBridge:[self convertPoint:CGPointMakeZero() toView:nil]];
|
||||
|
||||
// Pull Down Menus show up directly below their buttons.
|
||||
if (_pullsDown)
|
||||
menuOrigin.y += CGRectGetHeight([self frame]);
|
||||
var menuOrigin = [theWindow convertBaseToBridge:[self convertPoint:CGPointMake(0.0, CGRectGetMaxY([self bounds])) toView:nil]];
|
||||
|
||||
// Pop Up Menus attempt to show up "on top" of the selected item.
|
||||
else
|
||||
{
|
||||
var contentRect = [menuWindow rectForItemAtIndex:_selectedIndex];
|
||||
// This is confusing, I KNOW, so let me explain it to you.
|
||||
// We want the *content* of the selected menu item to overlap the *content* of our pop up.
|
||||
// 1. So calculate where our content is, then calculate where the menu item is.
|
||||
// 2. Move LEFT by whatever indentation we have (offsetWidths, aka, window margin, item margin, etc).
|
||||
// 3. MOVE UP by the difference in sizes of the content and menu item, this will only work if the content is vertically centered.
|
||||
var contentRect = [self convertRect:[self contentRectForBounds:[self bounds]] toView:nil],
|
||||
menuOrigin = [theWindow convertBaseToBridge:contentRect.origin],
|
||||
menuItemRect = [menuWindow rectForItemAtIndex:_selectedIndex];
|
||||
|
||||
menuOrigin.x -= CGRectGetMinX(contentRect) + [[[menu itemAtIndex:_selectedIndex] _menuItemView] calculatedLeftMargin];
|
||||
menuOrigin.y -= CGRectGetMinY(contentRect);
|
||||
menuOrigin.x -= CGRectGetMinX(menuItemRect) + [menuWindow overlapOffsetWidth] + [[[menu itemAtIndex:_selectedIndex] _menuItemView] overlapOffsetWidth];
|
||||
menuOrigin.y -= CGRectGetMinY(menuItemRect) + (CGRectGetHeight(menuItemRect) - CGRectGetHeight(contentRect)) / 2.0;
|
||||
}
|
||||
|
||||
[menuWindow setFrameOrigin:menuOrigin];
|
||||
|
||||
Reference in new issue
Block a user