Skip to content

Commit

Permalink
Move window outline submenu to WindowOutliningController
Browse files Browse the repository at this point in the history
  • Loading branch information
jslegendre committed Jan 23, 2023
1 parent 5a8a487 commit 3d07d28
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
12 changes: 6 additions & 6 deletions AfloatX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.4.2;
CURRENT_PROJECT_VERSION = 1.5;
DEPLOYMENT_LOCATION = YES;
DEVELOPMENT_TEAM = "";
DSTROOT = /;
Expand All @@ -324,8 +324,8 @@
INSTALL_PATH = "/Library/Application Support/MacEnhance/Plugins";
LLVM_LTO = YES;
MACH_O_TYPE = mh_dylib;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.4.2;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 1.5;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.github.jslegendre.AfloatX;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -347,7 +347,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.4.2;
CURRENT_PROJECT_VERSION = 1.5;
DEPLOYMENT_LOCATION = YES;
DEVELOPMENT_TEAM = "";
DSTROOT = /;
Expand All @@ -360,8 +360,8 @@
INSTALL_PATH = "/Library/Application Support/MacEnhance/Plugins";
LLVM_LTO = YES;
MACH_O_TYPE = mh_dylib;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.4.2;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 1.5;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.github.jslegendre.AfloatX;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Binary file not shown.
11 changes: 3 additions & 8 deletions AfloatX/AfloatX.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
NSMenuItem *invertColorItem;
NSMenuItem *clickPassthroughItem;
NSMenuItem *windowOutlineItem;
NSMenu *windowOutlineSubmenu;
NSArray *afloatXItems;
CIFilter* colorInvertFilter;

Expand Down Expand Up @@ -146,6 +145,7 @@ - (void)showTransparencySheet {
}

+ (void)load {
NSLog(@"AfloatX loaded");
if([NSBundle mainBundle] == NULL)
return;

Expand All @@ -169,8 +169,6 @@ + (void)load {

windowOutlineItem = [NSMenuItem new];
windowOutlineItem.title = @"Outline Window";
windowOutlineSubmenu = [NSMenu new];
windowOutlineItem.submenu = windowOutlineSubmenu;

floatItem = [[NSMenuItem alloc] initWithTitle:@"Float Window" action:@selector(toggleFloatMainWindow) keyEquivalent:@""];
[floatItem setTarget:plugin];
Expand Down Expand Up @@ -254,16 +252,13 @@ - (CFArrayRef)_createDockMenu:(BOOL)enabled {
}

/* Create a new WindowOutliningController per window */
[windowOutlineSubmenu removeAllItems];
if (!objc_getAssociatedObject(window, "outlineController")) {
WindowOutliningController *outlineController = [WindowOutliningController new];
for(NSMenuItem *item in [outlineController colorItems])
[windowOutlineSubmenu addItem:item];
windowOutlineItem.submenu = outlineController.menu;
objc_setAssociatedObject(window, "outlineController", outlineController, OBJC_ASSOCIATION_RETAIN);
} else {
WindowOutliningController *outlineController = objc_getAssociatedObject(window, "outlineController");
for(NSMenuItem *item in [outlineController colorItems])
[windowOutlineSubmenu addItem:item];
windowOutlineItem.submenu = outlineController.menu;
}

if ([objc_getAssociatedObject(window, "isColorInverted") boolValue]) {
Expand Down
2 changes: 2 additions & 0 deletions AfloatX/WindowOutliningController.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
NS_ASSUME_NONNULL_BEGIN

@interface WindowOutliningController : NSObject
@property (strong) NSMenuItem *accentColorItem;
@property (strong) NSMenuItem *whiteItem;
@property (strong) NSMenuItem *blackItem;
@property (strong) NSMenuItem *redItem;
Expand All @@ -20,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong) NSMenuItem *orangeItem;
@property (strong) NSMenuItem *purpleItem;
@property (strong) NSArray *colorItems;
@property (strong) NSMenu *menu;
@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions AfloatX/WindowOutliningController.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ - (instancetype)init {
self.purpleItem,
nil];
}

self.menu = [NSMenu new];
self.menu.itemArray = self.colorItems;

return self;
}
@end

0 comments on commit 3d07d28

Please sign in to comment.