From 7e08e48a8a65066bb74d13265fbebfb8b670e2e7 Mon Sep 17 00:00:00 2001 From: Didier Korthoudt Date: Fri, 23 Oct 2020 08:42:00 +0200 Subject: [PATCH] New: Adds a new theme parameter "menu-offset" to CPPopUpButton instead of hard coded value (#2923) --- AppKit/CPPopUpButton.j | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/AppKit/CPPopUpButton.j b/AppKit/CPPopUpButton.j index e5c669b44..d5d412466 100644 --- a/AppKit/CPPopUpButton.j +++ b/AppKit/CPPopUpButton.j @@ -45,6 +45,13 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down"); return "popup-button"; } ++ (CPDictionary)themeAttributes +{ + return @{ + @"menu-offset": CGSizeMake(0, 0) + }; +} + + (CPSet)keyPathsForValuesAffectingSelectedIndex { return [CPSet setWithObject:@"objectValue"]; @@ -685,14 +692,16 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down"); if ([self pullsDown]) { var positionedItem = nil, - location = CGPointMake(0.0, CGRectGetMaxY(bounds) - 1); + menuOffset = [self currentValueForThemeAttribute:@"menu-offset"], + location = CGPointMake(menuOffset.width, CGRectGetMaxY(bounds) + menuOffset.height); } else { var contentRect = [self contentRectForBounds:bounds], positionedItem = [self selectedItem], standardLeftMargin = [_CPMenuWindow _standardLeftMargin] + [_CPMenuItemStandardView _standardLeftMargin], - location = CGPointMake(CGRectGetMinX(contentRect) - standardLeftMargin, 0.0); + menuOffset = [self currentValueForThemeAttribute:@"menu-offset"], + location = CGPointMake(CGRectGetMinX(contentRect) - standardLeftMargin + menuOffset.width, menuOffset.height); minimumWidth += standardLeftMargin;