Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/BuildPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ jobs:
with:
xcode-version: ${{ matrix.xcode }}
- name: Build project
run: xcodebuild -workspace MGScopeBar.xcodeproj/project.xcworkspace -scheme MGScopeBar archive ARCHS="arm64 x86_64"

run: xcodebuild -project MGScopeBar.xcodeproj -scheme MGScopeBar.framework build ARCHS="arm64 x86_64" CODE_SIGNING_ALLOWED=NO
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
xcuserdata
.build/
14 changes: 7 additions & 7 deletions MGScopeBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
32CA4F630368D1EE00C91783 /* MGScopeBar_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGScopeBar_Prefix.pch; sourceTree = "<group>"; };
6F9CFC08233273B60061EBAD /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
6F9CFC0A233273BB0061EBAD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
6F9CFC08233273B60061EBAD /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Sources/MGScopeBar/Resources/en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
6F9CFC0A233273BB0061EBAD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Sources/MGScopeBar/Resources/Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* MGScopeBar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MGScopeBar.app; sourceTree = BUILT_PRODUCTS_DIR; };
AAE785781419184700A6955E /* MGScopeBar.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MGScopeBar.framework; sourceTree = BUILT_PRODUCTS_DIR; };
AAE785791419184700A6955E /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
AAE7857D1419184700A6955E /* MGScopeBarFramework-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MGScopeBarFramework-Info.plist"; sourceTree = "<group>"; };
AAE7857F1419184700A6955E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
AAE785811419184700A6955E /* MGScopeBarFramework-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MGScopeBarFramework-Prefix.pch"; sourceTree = "<group>"; };
C95B43CE0EB73CE3008EE468 /* MGRecessedPopUpButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGRecessedPopUpButtonCell.h; sourceTree = "<group>"; };
C95B43CF0EB73CE3008EE468 /* MGRecessedPopUpButtonCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGRecessedPopUpButtonCell.m; sourceTree = "<group>"; };
C95B43CE0EB73CE3008EE468 /* MGRecessedPopUpButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sources/MGScopeBar/MGRecessedPopUpButtonCell.h; sourceTree = "<group>"; };
C95B43CF0EB73CE3008EE468 /* MGRecessedPopUpButtonCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Sources/MGScopeBar/MGRecessedPopUpButtonCell.m; sourceTree = "<group>"; };
C9FB61130E8FF8360019B961 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = "<group>"; };
C9FB61140E8FF8360019B961 /* AppController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppController.m; sourceTree = "<group>"; };
C9FB61170E8FF8810019B961 /* MGScopeBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGScopeBar.h; sourceTree = "<group>"; };
C9FB61180E8FF8810019B961 /* MGScopeBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGScopeBar.m; sourceTree = "<group>"; };
C9FB61190E8FF8810019B961 /* MGScopeBarDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGScopeBarDelegateProtocol.h; sourceTree = "<group>"; };
C9FB61170E8FF8810019B961 /* MGScopeBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sources/MGScopeBar/MGScopeBar.h; sourceTree = "<group>"; };
C9FB61180E8FF8810019B961 /* MGScopeBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Sources/MGScopeBar/MGScopeBar.m; sourceTree = "<group>"; };
C9FB61190E8FF8810019B961 /* MGScopeBarDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sources/MGScopeBar/include/MGScopeBarDelegateProtocol.h; sourceTree = "<group>"; };
C9FB61A80E8FFE7B0019B961 /* TODO */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TODO; sourceTree = "<group>"; };
C9FB61AA0E8FFE950019B961 /* ReadMe.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadMe.txt; sourceTree = "<group>"; };
C9FB61AC0E8FFEA90019B961 /* Source Code License.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = "Source Code License.rtf"; sourceTree = "<group>"; };
Expand Down
38 changes: 38 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// swift-tools-version: 5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "MGScopeBar",
defaultLocalization: "en",
platforms: [
.macOS(.v11)
Comment thread
hannesa2 marked this conversation as resolved.
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "MGScopeBar",
targets: ["MGScopeBar"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "MGScopeBar",
dependencies: [],
exclude: [
"Resources/Base.lproj/MainMenu.xib"
],
resources: [
.process("Resources")
Comment thread
hannesa2 marked this conversation as resolved.
]),
.testTarget(
name: "MGScopeBarTests",
dependencies: ["MGScopeBar"]),
]
)
5 changes: 2 additions & 3 deletions ReadMe.txt → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ MGScopeBar is a control which provides a "scope bar" or "filter bar", much like
What platforms does it support?
-------------------------------

MGScopeBar supports Mac OS X 10.5 (Leopard) or later.


MGScopeBar supports Mac OS X 10.5 (Leopard) or later when integrated directly from source files.
The Swift Package requires macOS 11 or later.

What are the licensing requirements?
------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ - (id)initTextCell:(NSString *)title pullsDown:(BOOL)pullsDown
return self;
}


- (void)dealloc
{
[recessedButton release];
[super dealloc];
}


- (void)drawTitleWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
// Inset title rect since its position is broken when NSPopUpButton
Expand Down
2 changes: 1 addition & 1 deletion MGScopeBar.h → Sources/MGScopeBar/MGScopeBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "MGScopeBarDelegateProtocol.h"

@interface MGScopeBar : NSView {
IBOutlet id <MGScopeBarDelegate, NSObject> delegate; // weak ref.
IBOutlet __unsafe_unretained id <MGScopeBarDelegate, NSObject> delegate; // weak ref.
NSMutableArray *_separatorPositions; // x-coords of separators, indexed by their group-number.
NSMutableArray *_groups; // groups of items.
NSView *_accessoryView; // weak ref since it's a subview.
Expand Down
31 changes: 7 additions & 24 deletions MGScopeBar.m → Sources/MGScopeBar/MGScopeBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ - (void)dealloc
[_accessoryView removeFromSuperview];
_accessoryView = nil; // weak ref
}
[_separatorPositions release];
[_groups release];
[_identifiers release];
[_selectedItems release];

[super dealloc];
}


Expand All @@ -124,15 +118,10 @@ - (void)reloadData

NSArray *subviews = [[self subviews] copy]; // so we don't mutate the collection we're iterating over.
[subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
[subviews release]; // because copies are retained.

[_separatorPositions release];
_separatorPositions = nil;
[_groups release];
_groups = nil;
[_identifiers release];
_identifiers = nil;
[_selectedItems release];
_selectedItems = nil;
_firstCollapsedGroup = NSNotFound;
_lastWidth = NSNotFound;
Expand Down Expand Up @@ -187,7 +176,6 @@ - (void)reloadData
ctrlRect.size = [labelField frame].size;
[labelField setFrame:ctrlRect];
[self addSubview:labelField];
[labelField release];

xCoord += ctrlRect.size.width + SCOPE_BAR_ITEM_SPACING;

Expand Down Expand Up @@ -712,7 +700,7 @@ - (NSButton *)buttonForItem:(NSString *)identifier inGroup:(NSInteger)groupNumbe

[self setControl:button forIdentifier:identifier inGroup:groupNumber];

return [button autorelease];
return button;
}


Expand All @@ -727,7 +715,7 @@ - (NSMenuItem *)menuItemForItem:(NSString *)identifier inGroup:(NSInteger)groupN

[self setControl:menuItem forIdentifier:identifier inGroup:groupNumber];

return [menuItem autorelease];
return menuItem;
}


Expand All @@ -742,12 +730,10 @@ - (NSPopUpButton *)popupButtonForGroup:(NSDictionary *)group
if (multiSelect) {
MGRecessedPopUpButtonCell *cell = [[MGRecessedPopUpButtonCell alloc] initTextCell:@"" pullsDown:NO];
[popup setCell:cell];
[cell release];

[[popup cell] setUsesItemFromMenu:NO];
NSMenuItem *titleItem = [[NSMenuItem alloc] init];
[[popup cell] setMenuItem:titleItem];
[titleItem release];
}

// Configure appearance and behaviour.
Expand Down Expand Up @@ -782,7 +768,7 @@ - (NSPopUpButton *)popupButtonForGroup:(NSDictionary *)group
popFrame.origin.y = ceil(([self frame].size.height - popFrame.size.height) / 2.0);
[popup setFrame:popFrame];

return [popup autorelease];
return popup;
}


Expand All @@ -794,7 +780,7 @@ - (void)setControl:(NSObject *)control forIdentifier:(NSString *)identifier inGr

NSMutableArray *identArray = [_identifiers objectForKey:identifier];
if (!identArray) {
identArray = [[[NSMutableArray alloc] initWithCapacity:groupNumber + 1] autorelease];
identArray = [[NSMutableArray alloc] initWithCapacity:groupNumber + 1];
[_identifiers setObject:identArray forKey:identifier];
}

Expand Down Expand Up @@ -872,8 +858,8 @@ - (void)updateMenuTitleForGroupAtIndex:(NSInteger)groupNumber
- (void)drawRect:(NSRect)rect
{
// Draw gradient background.
NSGradient *gradient = [[[NSGradient alloc] initWithStartingColor:SCOPE_BAR_START_COLOR_GRAY
endingColor:SCOPE_BAR_END_COLOR_GRAY] autorelease];
NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:SCOPE_BAR_START_COLOR_GRAY
endingColor:SCOPE_BAR_END_COLOR_GRAY];
[gradient drawInRect:[self bounds] angle:90.0];

// Draw border.
Expand Down Expand Up @@ -932,7 +918,6 @@ - (void)setSelected:(BOOL)selected forItem:(NSString *)identifier inGroup:(NSInt
BOOL informDelegate = YES;

if (group) {
[group retain];
NSDisableScreenUpdates();

// We found the group which this item belongs to. Obtain selection-mode and identifiers.
Expand All @@ -956,7 +941,6 @@ - (void)setSelected:(BOOL)selected forItem:(NSString *)identifier inGroup:(NSInt
informDelegate = NO;
}
}
[groupSelections release];
}

// Change selected state of this item.
Expand All @@ -967,7 +951,6 @@ - (void)setSelected:(BOOL)selected forItem:(NSString *)identifier inGroup:(NSInt
[self updateMenuTitleForGroupAtIndex:groupNumber];
}

[group release];
NSEnableScreenUpdates();
}
}
Expand Down Expand Up @@ -1012,7 +995,7 @@ - (void)updateSelectedState:(BOOL)selected forItem:(NSString *)identifier inGrou

- (NSArray *)selectedItems
{
return [[_selectedItems copy] autorelease];
return [_selectedItems copy];
}
- (BOOL) isItemSelectedWithIdentifier:(NSString*)identifier inGroup:(NSInteger)groupNumber;
{
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions Sources/MGScopeBar/include/MGScopeBar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Header.h
//
//
// Created by Christian Beer on 29.08.22.
//

#ifndef MGSCOPEBAR_PUBLIC_H
#define MGSCOPEBAR_PUBLIC_H

#include "../MGScopeBar.h"
#include "../MGRecessedPopUpButtonCell.h"

#endif /* MGSCOPEBAR_PUBLIC_H */
10 changes: 10 additions & 0 deletions Tests/MGScopeBarTests/MGScopeBarTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import XCTest
@testable import MGScopeBar

final class MGScopeBarTests: XCTestCase {
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
}
}