From e2c3e0b6f62e68b0a1b63636cd9f138c2978297c Mon Sep 17 00:00:00 2001 From: Minder Softworks Date: Thu, 10 Sep 2015 12:26:26 -0400 Subject: [PATCH 1/2] Added notification for when a tab is selected --- MMTabBarView/MMTabBarView/MMAttachedTabBarButton.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MMTabBarView/MMTabBarView/MMAttachedTabBarButton.m b/MMTabBarView/MMTabBarView/MMAttachedTabBarButton.m index 406ef85d..1c33bb9f 100644 --- a/MMTabBarView/MMTabBarView/MMAttachedTabBarButton.m +++ b/MMTabBarView/MMTabBarView/MMAttachedTabBarButton.m @@ -13,6 +13,8 @@ #import "MMTabStyle.h" #import "NSView+MMTabBarViewExtensions.h" +#define MMTabBarViewDidSelectTab @"MMTabBarViewDidSelectTab" + @interface MMAttachedTabBarButton (/*Private*/) - (MMAttachedTabBarButton *)_selectedAttachedTabBarButton; @@ -166,6 +168,10 @@ - (void)mouseDown:(NSEvent *)theEvent { if ([tabBarView shouldStartDraggingAttachedTabBarButton:self withMouseDownEvent:theEvent]) { [tabBarView startDraggingAttachedTabBarButton:self withMouseDownEvent:theEvent]; } + + [[NSNotificationCenter defaultCenter] postNotificationName:MMTabBarViewDidSelectTab + object:self]; + } - (void)mouseUp:(NSEvent *)theEvent { From 13c5c1c9ec593868e7a553bb4e428c577d55ec2b Mon Sep 17 00:00:00 2001 From: Minder Softworks Date: Thu, 7 Apr 2016 15:47:39 -0400 Subject: [PATCH 2/2] Pushed changes from MiMo42/MMTabBarView master to MSW fork. Now up-to-date with master tag 1.2.1 --- .../MMTabBarView Demo/en.lproj/DemoWindow.xib | 570 +++++++++++----- .../MMTabBarView.xcodeproj/project.pbxproj | 2 + .../MMTabBarView/MMAttachedTabBarButton.h | 30 +- .../MMTabBarView/MMAttachedTabBarButton.m | 42 +- .../MMTabBarView/MMAttachedTabBarButtonCell.h | 11 +- .../MMTabBarView/MMAttachedTabBarButtonCell.m | 13 +- .../MMTabBarView/MMOverflowPopUpButton.h | 23 +- .../MMTabBarView/MMOverflowPopUpButton.m | 25 +- .../MMTabBarView/MMOverflowPopUpButtonCell.h | 15 +- .../MMTabBarView/MMOverflowPopUpButtonCell.m | 35 +- .../MMTabBarView/MMProgressIndicator.h | 3 +- MMTabBarView/MMTabBarView/MMRolloverButton.h | 12 +- MMTabBarView/MMTabBarView/MMRolloverButton.m | 10 +- .../MMTabBarView/MMRolloverButtonCell.h | 16 +- .../MMTabBarView/MMRolloverButtonCell.m | 22 +- .../MMTabBarView/MMSlideButtonsAnimation.h | 2 +- .../MMTabBarView/MMSlideButtonsAnimation.m | 4 +- .../MMTabBarView/MMTabBarButton.Common.h | 34 + .../MMTabBarView/MMTabBarButton.Private.h | 13 + MMTabBarView/MMTabBarView/MMTabBarButton.h | 71 +- MMTabBarView/MMTabBarView/MMTabBarButton.m | 37 +- .../MMTabBarView/MMTabBarButtonCell.Private.h | 18 + .../MMTabBarView/MMTabBarButtonCell.h | 185 +++--- .../MMTabBarView/MMTabBarButtonCell.m | 105 +-- .../MMTabBarView/MMTabBarController.h | 8 +- .../MMTabBarView/MMTabBarController.m | 25 +- MMTabBarView/MMTabBarView/MMTabBarItem.h | 47 +- .../MMTabBarView/MMTabBarView-Info.plist | 2 +- MMTabBarView/MMTabBarView/MMTabBarView.h | 613 +++++++++++++----- MMTabBarView/MMTabBarView/MMTabBarView.m | 249 ++++--- .../MMTabBarView/MMTabDragAssistant.h | 55 +- .../MMTabBarView/MMTabDragAssistant.m | 139 ++-- MMTabBarView/MMTabBarView/MMTabDragView.h | 16 +- MMTabBarView/MMTabBarView/MMTabDragView.m | 31 +- MMTabBarView/MMTabBarView/MMTabDragWindow.h | 13 +- MMTabBarView/MMTabBarView/MMTabDragWindow.m | 11 +- .../MMTabBarView/MMTabDragWindowController.h | 26 +- .../MMTabBarView/MMTabDragWindowController.m | 25 +- .../MMTabBarView/MMTabPasteboardItem.h | 4 +- .../MMTabBarView/MMTabPasteboardItem.m | 4 +- MMTabBarView/MMTabBarView/MMTabStyle.h | 399 +++++++++++- ...NSAffineTransform+MMTabBarViewExtensions.h | 2 +- ...NSAffineTransform+MMTabBarViewExtensions.m | 2 +- .../NSBezierPath+MMTabBarViewExtensions.h | 7 +- .../NSBezierPath+MMTabBarViewExtensions.m | 2 +- .../NSCell+MMTabBarViewExtensions.h | 2 +- .../NSCell+MMTabBarViewExtensions.m | 2 +- .../NSString+MMTabBarViewExtensions.h | 2 +- .../NSString+MMTabBarViewExtensions.m | 4 +- .../NSTabViewItem+MMTabBarViewExtensions.h | 2 +- .../NSTabViewItem+MMTabBarViewExtensions.m | 2 +- .../NSView+MMTabBarViewExtensions.m | 1 - .../MMTabBarView/Styles/MMAdiumTabStyle.h | 23 +- .../MMTabBarView/Styles/MMAdiumTabStyle.m | 123 +--- .../MMTabBarView/Styles/MMAquaTabStyle.h | 20 +- .../MMTabBarView/Styles/MMAquaTabStyle.m | 116 ++-- .../MMTabBarView/Styles/MMCardTabStyle.h | 11 - .../MMTabBarView/Styles/MMCardTabStyle.m | 41 +- .../MMTabBarView/Styles/MMLiveChatTabStyle.h | 13 +- .../MMTabBarView/Styles/MMLiveChatTabStyle.m | 58 +- .../MMTabBarView/Styles/MMMetalTabStyle.h | 14 +- .../MMTabBarView/Styles/MMMetalTabStyle.m | 67 +- .../MMTabBarView/Styles/MMUnifiedTabStyle.h | 12 +- .../MMTabBarView/Styles/MMUnifiedTabStyle.m | 69 +- .../Safari Tab Style/MMSafariTabStyle.h | 6 +- .../Safari Tab Style/MMSafariTabStyle.m | 28 +- .../Images/YosemiteTabClose_Front.png | Bin 0 -> 1233 bytes .../Images/YosemiteTabClose_Front@2x.png | Bin 0 -> 1307 bytes .../Images/YosemiteTabClose_Front_Pressed.png | Bin 0 -> 1330 bytes .../YosemiteTabClose_Front_Pressed@2x.png | Bin 0 -> 1466 bytes .../YosemiteTabClose_Front_Rollover.png | Bin 0 -> 1367 bytes .../YosemiteTabClose_Front_Rollover@2x.png | Bin 0 -> 1613 bytes .../Images/YosemiteTabNew.png | Bin 0 -> 1017 bytes .../Images/YosemiteTabNew@2x.png | Bin 0 -> 1036 bytes .../Images/YosemiteTabNewPressed.png | Bin 0 -> 1017 bytes .../Images/YosemiteTabNewPressed@2x.png | Bin 0 -> 1037 bytes .../Yosemite Tab Style/MMYosemiteTabStyle.h | 18 + .../Yosemite Tab Style/MMYosemiteTabStyle.m | 301 +++++++++ .../xcshareddata/default.xccheckout | 22 +- 79 files changed, 2367 insertions(+), 1568 deletions(-) create mode 100644 MMTabBarView/MMTabBarView/MMTabBarButton.Common.h create mode 100644 MMTabBarView/MMTabBarView/MMTabBarButton.Private.h create mode 100644 MMTabBarView/MMTabBarView/MMTabBarButtonCell.Private.h create mode 100755 MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front.png create mode 100755 MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front@2x.png create mode 100755 MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front_Pressed.png create mode 100755 MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front_Pressed@2x.png create mode 100755 MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front_Rollover.png create mode 100755 MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front_Rollover@2x.png create mode 100755 MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabNew.png create mode 100755 MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabNew@2x.png create mode 100755 MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabNewPressed.png create mode 100755 MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabNewPressed@2x.png create mode 100755 MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/MMYosemiteTabStyle.h create mode 100755 MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/MMYosemiteTabStyle.m diff --git a/MMTabBarView Demo/MMTabBarView Demo/en.lproj/DemoWindow.xib b/MMTabBarView Demo/MMTabBarView Demo/en.lproj/DemoWindow.xib index 18e8658e..080604c1 100644 --- a/MMTabBarView Demo/MMTabBarView Demo/en.lproj/DemoWindow.xib +++ b/MMTabBarView Demo/MMTabBarView Demo/en.lproj/DemoWindow.xib @@ -1,14 +1,14 @@ - 1070 - 11G63 - 3084 - 1138.51 - 569.00 + 1060 + 14F27 + 7706 + 1348.17 + 758.70 com.apple.InterfaceBuilder.CocoaPlugin - 3084 + 7706 NSBox @@ -67,10 +67,12 @@ 274 + + public.item + {{13, 83}, {510, 525}} - @@ -78,11 +80,10 @@ - 256 + 274 {{10, 33}, {490, 479}} - Tab @@ -99,7 +100,7 @@ - LucidaGrande + YES 13 1044 @@ -116,14 +117,13 @@ {{20, 20}, {493, 65}} - YES 67108864 272629760 Observe the changes in the reference NSTabView above in response to adding (New Tab from the File menu), rearranging (drag tabs above), removing (close button on above tabs), and selecting (click a tab above). You can also resize the window, and create an overflow of tabs to view the overflow menu. - LucidaGrande + YES 10 2843 @@ -139,6 +139,8 @@ + NO + 1 @@ -172,7 +174,7 @@ - + 256 @@ -205,10 +207,11 @@ + NO + 1 {461, 22} - NSView @@ -216,7 +219,7 @@ NSResponder - + 258 @@ -232,7 +235,6 @@ 256 {{16, 372}, {30, 13}} - YES @@ -244,20 +246,21 @@ + NO + 1 258 {{51, 367}, {130, 22}} - YES - -2076049856 + -2076180416 133120 - LucidaGrande + YES 11 3100 @@ -367,13 +370,13 @@ YES 1 + NO 258 {{13, 307}, {167, 18}} - YES @@ -396,13 +399,13 @@ 200 25 + NO 258 {{13, 227}, {145, 18}} - YES @@ -420,13 +423,13 @@ 200 25 + NO 258 {{13, 207}, {162, 18}} - YES @@ -444,6 +447,7 @@ 200 25 + NO @@ -458,7 +462,6 @@ 256 {{44, 88}, {25, 13}} - YES @@ -470,13 +473,14 @@ + NO + 1 256 {{41, 67}, {28, 13}} - YES @@ -488,13 +492,14 @@ + NO + 1 256 {{16, 46}, {53, 13}} - YES @@ -506,13 +511,14 @@ + NO + 1 256 {{77, 86}, {43, 19}} - YES @@ -525,13 +531,14 @@ + NO + 1 256 {{77, 65}, {43, 19}} - YES @@ -544,13 +551,14 @@ + NO + 1 256 {{77, 44}, {43, 19}} - YES @@ -563,13 +571,14 @@ + NO + 1 258 {{12, 29}, {140, 5}} - {0, 0} @@ -578,9 +587,11 @@ Box - - 3 - MCAwLjgwMDAwMDAxMTkAA + + 6 + System + labelColor + 3 @@ -593,7 +604,6 @@ 256 {{33, 9}, {73, 16}} - YES @@ -611,17 +621,16 @@ 200 25 + NO {{2, 2}, {164, 115}} - {{13, 9}, {168, 132}} - {0, 0} @@ -630,10 +639,7 @@ Tab Width - - 3 - MCAwLjgwMDAwMDAxMTkAA - + 3 @@ -646,7 +652,6 @@ 258 {{13, 187}, {148, 18}} - YES @@ -663,13 +668,13 @@ 200 25 + NO 258 {{13, 287}, {167, 18}} - YES @@ -687,13 +692,13 @@ 200 25 + NO 258 {{13, 267}, {167, 18}} - YES @@ -711,13 +716,13 @@ 200 25 + NO 258 {{14, 247}, {167, 18}} - YES @@ -735,13 +740,13 @@ 200 25 + NO 256 {{16, 351}, {62, 13}} - YES @@ -753,17 +758,18 @@ + NO + 1 258 {{83, 346}, {98, 22}} - YES - -2076049856 + -2076180416 133120 @@ -816,13 +822,13 @@ YES 1 + NO 258 {{13, 167}, {171, 18}} - YES @@ -839,13 +845,13 @@ 200 25 + NO 258 {{13, 147}, {171, 18}} - YES @@ -862,13 +868,13 @@ 200 25 + NO 256 {{16, 330}, {50, 13}} - YES @@ -880,17 +886,18 @@ + NO + 1 258 {{71, 325}, {110, 22}} - YES - -2076049856 + -2076180416 133120 @@ -940,17 +947,16 @@ YES 1 + NO {{2, 2}, {198, 398}} - {{15, 205}, {202, 415}} - {0, 0} @@ -959,10 +965,7 @@ Control Options - - 3 - MCAwLjgwMDAwMDAxMTkAA - + 3 @@ -983,7 +986,6 @@ 268 {{16, 141}, {28, 13}} - YES @@ -995,13 +997,14 @@ + NO + 1 268 {{16, 115}, {47, 13}} - YES @@ -1013,13 +1016,14 @@ + NO + 1 268 {{13, 71}, {80, 18}} - YES @@ -1036,17 +1040,17 @@ 200 25 + NO 266 {{45, 136}, {132, 22}} - YES - -2076049856 + -2076180416 133120 @@ -1130,13 +1134,13 @@ YES 1 + NO 266 {{72, 113}, {50, 19}} - YES @@ -1149,13 +1153,14 @@ + NO + 1 268 {{13, 51}, {80, 18}} - YES @@ -1172,13 +1177,13 @@ 200 25 + NO 268 {{13, 31}, {88, 18}} - YES @@ -1195,14 +1200,13 @@ 200 25 + NO 268 {{13, 11}, {113, 18}} - - YES 67108864 @@ -1218,13 +1222,13 @@ 200 25 + NO 268 {{13, 91}, {86, 18}} - YES @@ -1241,6 +1245,7 @@ 200 25 + NO @@ -1250,10 +1255,10 @@ {{130, 112}, {44, 21}} - _NS:1116 YES + NO YES 1 @@ -1263,13 +1268,11 @@ {{2, 2}, {196, 168}} - {{17, 16}, {200, 185}} - {0, 0} @@ -1278,10 +1281,7 @@ Tab-specific Values - - 3 - MCAwLjgwMDAwMDAxMTkAA - + 3 @@ -1291,8 +1291,6 @@ {228, 630} - - NSView @@ -1301,7 +1299,7 @@ - + button_allowScrubbing @@ -2658,21 +2656,6 @@ id id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id id id id @@ -2693,66 +2676,6 @@ closeTab: id - - configAddTabButton: - id - - - configAllowBackgroundClosing: - id - - - configAllowsScrubbing: - id - - - configAutomaticallyAnimates: - id - - - configCanCloseOnlyTab: - id - - - configDisableTabClose: - id - - - configHideForSingleTab: - id - - - configOnlyShowCloseOnHover: - id - - - configStyle: - id - - - configTabMaxWidth: - id - - - configTabMinWidth: - id - - - configTabOptimumWidth: - id - - - configTabSizeToFit: - id - - - configTearOffStyle: - id - - - configUseOverflowMenu: - id - hasCloseButtonAction: id @@ -2940,7 +2863,138 @@ IBProjectSource - ./Classes/DemoWindowController.h + MMTabBarView Demo/MMTabBarView Demo/DemoWindowController.h + + + + DemoWindowController + + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + + + + addNewTab: + id + + + closeTab: + id + + + configAddTabButton: + id + + + configAllowBackgroundClosing: + id + + + configAllowsScrubbing: + id + + + configAutomaticallyAnimates: + id + + + configCanCloseOnlyTab: + id + + + configDisableTabClose: + id + + + configHideForSingleTab: + id + + + configOnlyShowCloseOnHover: + id + + + configStyle: + id + + + configTabMaxWidth: + id + + + configTabMinWidth: + id + + + configTabOptimumWidth: + id + + + configTabSizeToFit: + id + + + configTearOffStyle: + id + + + configUseOverflowMenu: + id + + + hasCloseButtonAction: + id + + + hasLargeImageAction: + id + + + isEditedAction: + id + + + isProcessingAction: + id + + + setTabLabel: + id + + + showObjectCountAction: + id + + + toggleToolbar: + id + + + + IBProjectSource + MMTabBarView Demo/MMTabBarView Demo/DemoWindowController.m @@ -2967,18 +3021,220 @@ IBProjectSource - ./Classes/MMTabBarView.h + MMTabBarView/MMTabBarView/MMTabBarView.h + + + + + + NSActionCell + NSCell + + IBFrameworkSource + AppKit.framework/Headers/NSActionCell.h + + + + NSApplication + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSApplication.h + + + + NSBox + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSBox.h + + + + NSButton + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSButton.h + + + + NSButtonCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSButtonCell.h + + + + NSCell + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSCell.h + + + + NSColorWell + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSColorWell.h + + + + NSControl + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSControl.h + + + + NSDrawer + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSDrawer.h + + + + NSFormatter + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFormatter.h + + + + NSMenu + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSMenu.h + + + + NSMenuItem + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSMenuItem.h + + + + NSMenuItemCell + NSButtonCell + + IBFrameworkSource + AppKit.framework/Headers/NSMenuItemCell.h + + + + NSPopUpButton + NSButton + + IBFrameworkSource + AppKit.framework/Headers/NSPopUpButton.h + + + + NSPopUpButtonCell + NSMenuItemCell + + IBFrameworkSource + AppKit.framework/Headers/NSPopUpButtonCell.h + + + + NSResponder + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSResponder.h + + + + NSTabView + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSTabView.h + + + + NSTabViewItem + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTabViewItem.h + + + + NSTextField + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSTextField.h + + + + NSTextFieldCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSTextFieldCell.h + + + + NSView + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSView.h + + + + NSWindow + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSWindow.h + + + + NSWindowController + NSResponder + + showWindow: + id + + + showWindow: + + showWindow: + id + + + + IBFrameworkSource + AppKit.framework/Headers/NSWindowController.h 0 IBCocoaFramework + NO + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + YES 3 - {11, 11} - {10, 3} + {12, 12} + {10, 2} {15, 15} diff --git a/MMTabBarView/MMTabBarView.xcodeproj/project.pbxproj b/MMTabBarView/MMTabBarView.xcodeproj/project.pbxproj index fead80e5..b76f5b31 100644 --- a/MMTabBarView/MMTabBarView.xcodeproj/project.pbxproj +++ b/MMTabBarView/MMTabBarView.xcodeproj/project.pbxproj @@ -951,6 +951,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 0634F0C8160A1F8100A6C86A /* MMTabBarViewFramework-Debug.xcconfig */; buildSettings = { + CODE_SIGN_IDENTITY = "Developer ID Application: Michael LaMorte (2Z7Z6V9P5M)"; COMBINE_HIDPI_IMAGES = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -967,6 +968,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 0634F0C9160A1F8100A6C86A /* MMTabBarViewFramework-Release.xcconfig */; buildSettings = { + CODE_SIGN_IDENTITY = "Developer ID Application: Michael LaMorte (2Z7Z6V9P5M)"; COMBINE_HIDPI_IMAGES = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; diff --git a/MMTabBarView/MMTabBarView/MMAttachedTabBarButton.h b/MMTabBarView/MMTabBarView/MMAttachedTabBarButton.h index 2a73a1fb..a5e746a0 100644 --- a/MMTabBarView/MMTabBarView/MMAttachedTabBarButton.h +++ b/MMTabBarView/MMTabBarView/MMAttachedTabBarButton.h @@ -15,32 +15,30 @@ @protocol MMTabStyle; -@interface MMAttachedTabBarButton : MMTabBarButton { +@interface MMAttachedTabBarButton : MMTabBarButton -@private - NSTabViewItem *_tabViewItem; - BOOL _isInAnimatedSlide; - BOOL _isInDraggedSlide; -} +// designated initializer +- (instancetype)initWithFrame:(NSRect)frame tabViewItem:(NSTabViewItem *)anItem NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER; + +- (instancetype)initWithFrame:(NSRect)frame NS_UNAVAILABLE; + +// overidden accessors (casting) +@property (strong) MMAttachedTabBarButtonCell *cell; + +#pragma mark Properties -@property (retain) NSTabViewItem *tabViewItem; +@property (strong) NSTabViewItem *tabViewItem; @property (assign) NSRect slidingFrame; @property (readonly) BOOL isInAnimatedSlide; @property (assign) BOOL isInDraggedSlide; @property (readonly) BOOL isSliding; @property (assign) BOOL isOverflowButton; -// designated initializer -- (id)initWithFrame:(NSRect)frame tabViewItem:(NSTabViewItem *)anItem; - -// overidden accessors (casting) -- (MMAttachedTabBarButtonCell *)cell; -- (void)setCell:(MMAttachedTabBarButtonCell *)aCell; - #pragma mark Drag Support -- (NSRect)draggingRect; -- (NSImage *)dragImage; +@property (readonly) NSRect draggingRect; +@property (readonly) NSImage *dragImage; #pragma mark - #pragma mark Animation Support diff --git a/MMTabBarView/MMTabBarView/MMAttachedTabBarButton.m b/MMTabBarView/MMTabBarView/MMAttachedTabBarButton.m index 1c33bb9f..f43a9a6f 100644 --- a/MMTabBarView/MMTabBarView/MMAttachedTabBarButton.m +++ b/MMTabBarView/MMTabBarView/MMAttachedTabBarButton.m @@ -39,11 +39,11 @@ + (Class)cellClass { return [MMAttachedTabBarButtonCell class]; } -- (id)initWithFrame:(NSRect)frame tabViewItem:(NSTabViewItem *)anItem { +- (instancetype)initWithFrame:(NSRect)frame tabViewItem:(NSTabViewItem *)anItem { self = [super initWithFrame:frame]; if (self) { - _tabViewItem = [anItem retain]; + _tabViewItem = anItem; _isInAnimatedSlide = NO; _isInDraggedSlide = NO; } @@ -51,20 +51,13 @@ - (id)initWithFrame:(NSRect)frame tabViewItem:(NSTabViewItem *)anItem { return self; } -- (id)initWithFrame:(NSRect)frame { +- (instancetype)initWithFrame:(NSRect)frame { NSAssert(FALSE,@"please use designated initializer -initWithFrame:tabViewItem:"); - [self release]; return nil; } -- (void)dealloc -{ - [_tabViewItem release], _tabViewItem = nil; - [super dealloc]; -} - - (void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; } @@ -86,7 +79,7 @@ -(void)viewWillDraw { } #pragma mark - -#pragma mark Accessors +#pragma mark Properties - (NSRect)slidingFrame { @synchronized(self) { @@ -221,11 +214,11 @@ - (NSImage *)dragImage { [tabBarView lockFocus]; [tabBarView display]; // forces update to ensure that we get current state - NSBitmapImageRep *rep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect:draggingRect] autorelease]; + NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:draggingRect]; [tabBarView unlockFocus]; - NSImage *image = [[[NSImage alloc] initWithSize:[rep size]] autorelease]; + NSImage *image = [[NSImage alloc] initWithSize:[rep size]]; [image addRepresentation:rep]; - NSImage *returnImage = [[[NSImage alloc] initWithSize:[rep size]] autorelease]; + NSImage *returnImage = [[NSImage alloc] initWithSize:[rep size]]; [returnImage lockFocus]; [image drawAtPoint:NSMakePoint(0.0, 0.0) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; [returnImage unlockFocus]; @@ -235,7 +228,6 @@ - (NSImage *)dragImage { NSPoint indicatorPoint = NSMakePoint([self frame].size.width - MARGIN_X - kMMTabBarIndicatorWidth, MARGIN_Y); [pi drawAtPoint:indicatorPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; [returnImage unlockFocus]; - [pi release]; } return returnImage; } @@ -251,6 +243,26 @@ - (void)slideAnimationDidEnd { _isInAnimatedSlide = NO; } +#pragma mark - +#pragma mark NSCoding + +- (instancetype)initWithCoder:(NSCoder *)coder { + + self = [super initWithCoder:coder]; + if (self) { + _tabViewItem = nil; + _isInAnimatedSlide = NO; + _isInDraggedSlide = NO; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder +{ + [super encodeWithCoder:aCoder]; +} + #pragma mark - #pragma mark Private Methods diff --git a/MMTabBarView/MMTabBarView/MMAttachedTabBarButtonCell.h b/MMTabBarView/MMTabBarView/MMAttachedTabBarButtonCell.h index cc12200a..df74d575 100644 --- a/MMTabBarView/MMTabBarView/MMAttachedTabBarButtonCell.h +++ b/MMTabBarView/MMTabBarView/MMAttachedTabBarButtonCell.h @@ -7,18 +7,13 @@ // #import "MMTabBarButtonCell.h" -#import "MMTabBarView.h" -@class MMAttachedTabBarButton; +#import "MMAttachedTabBarButton.h" -@interface MMAttachedTabBarButtonCell : MMTabBarButtonCell { - - BOOL _isOverflowButton; -} +@interface MMAttachedTabBarButtonCell : MMTabBarButtonCell @property (assign) BOOL isOverflowButton; -- (MMAttachedTabBarButton *)controlView; -- (void)setControlView:(MMAttachedTabBarButton *)aView; +@property (assign) MMAttachedTabBarButton *controlView; @end diff --git a/MMTabBarView/MMTabBarView/MMAttachedTabBarButtonCell.m b/MMTabBarView/MMTabBarView/MMAttachedTabBarButtonCell.m index 3aa3945e..5a69c593 100644 --- a/MMTabBarView/MMTabBarView/MMAttachedTabBarButtonCell.m +++ b/MMTabBarView/MMTabBarView/MMAttachedTabBarButtonCell.m @@ -12,18 +12,15 @@ @implementation MMAttachedTabBarButtonCell -@synthesize isOverflowButton = _isOverflowButton; - -- (id)init { +- (instancetype)init { if ((self = [super init])) { _isOverflowButton = NO; } return self; } -- (void)dealloc { - [super dealloc]; -} +#pragma mark - +#pragma mark Properties - (MMAttachedTabBarButton *)controlView { return (MMAttachedTabBarButton *)[super controlView]; @@ -36,7 +33,7 @@ - (void)setControlView:(MMAttachedTabBarButton *)aView { #pragma mark - #pragma mark NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { MMAttachedTabBarButtonCell *cellCopy = [super copyWithZone:zone]; if (cellCopy) { @@ -57,7 +54,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { } } -- (id)initWithCoder:(NSCoder *)aDecoder { +- (instancetype)initWithCoder:(NSCoder *)aDecoder { if ((self = [super initWithCoder:aDecoder])) { if ([aDecoder allowsKeyedCoding]) { diff --git a/MMTabBarView/MMTabBarView/MMOverflowPopUpButton.h b/MMTabBarView/MMTabBarView/MMOverflowPopUpButton.h index d12d7ee7..47eebc2f 100644 --- a/MMTabBarView/MMTabBarView/MMOverflowPopUpButton.h +++ b/MMTabBarView/MMTabBarView/MMOverflowPopUpButton.h @@ -11,21 +11,16 @@ typedef void (^MMCellBezelDrawingBlock)(NSCell *cell, NSRect frame, NSView *controlView); -@interface MMOverflowPopUpButton : NSPopUpButton { +@interface MMOverflowPopUpButton : NSPopUpButton - BOOL _isAnimating; // pulsating animation of image and second image -} +/** + * Second image + */ +@property (strong) NSImage *secondImage; -// accessors -- (NSImage *)secondImage; -- (void)setSecondImage:(NSImage *)anImage; - -// archiving -- (void)encodeWithCoder:(NSCoder *)aCoder; -- (id)initWithCoder:(NSCoder *)aDecoder; - -// bezel drawing -- (MMCellBezelDrawingBlock)bezelDrawingBlock; -- (void)setBezelDrawingBlock:(MMCellBezelDrawingBlock)aBlock; +/** + * Block to be used for drawing the bezel + */ +@property (copy) MMCellBezelDrawingBlock bezelDrawingBlock; @end diff --git a/MMTabBarView/MMTabBarView/MMOverflowPopUpButton.m b/MMTabBarView/MMTabBarView/MMOverflowPopUpButton.m index f09a5778..e89f07d8 100644 --- a/MMTabBarView/MMTabBarView/MMOverflowPopUpButton.m +++ b/MMTabBarView/MMTabBarView/MMOverflowPopUpButton.m @@ -23,17 +23,11 @@ return image; \ } -@interface MMOverflowPopUpButton (/*Private*/) +@interface MMOverflowPopUpButton () @property (assign) CGFloat secondImageAlpha; -- (BOOL)isAnimating; -- (void)setIsAnimating:(BOOL)newState; - -- (void)_startCellAnimationIfNeeded; -- (void)_startCellAnimation; -- (void)_stopCellAnimationIfNeeded; -- (void)_stopCellAnimation; +@property (assign) BOOL isAnimating; // pulsating animation of image and second image @end @@ -48,7 +42,7 @@ + (Class)cellClass { return [MMOverflowPopUpButtonCell class]; } -- (id)initWithFrame:(NSRect)frameRect pullsDown:(BOOL)flag { +- (instancetype)initWithFrame:(NSRect)frameRect pullsDown:(BOOL)flag { if (self = [super initWithFrame:frameRect pullsDown:YES]) { _isAnimating = NO; @@ -67,9 +61,6 @@ - (id)initWithFrame:(NSRect)frameRect pullsDown:(BOOL)flag { return self; } -- (void)dealloc { - [super dealloc]; -} - (void)viewWillMoveToSuperview:(NSView *)newSuperview { [super viewWillMoveToSuperview:newSuperview]; @@ -194,7 +185,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { [super encodeWithCoder:aCoder]; } -- (id)initWithCoder:(NSCoder *)aDecoder { +- (instancetype)initWithCoder:(NSCoder *)aDecoder { if ((self = [super initWithCoder:aDecoder])) { } return self; @@ -203,14 +194,6 @@ - (id)initWithCoder:(NSCoder *)aDecoder { #pragma mark - #pragma mark Private Methods -- (BOOL)isAnimating { - return _isAnimating; -} - -- (void)setIsAnimating:(BOOL)newState { - _isAnimating = newState; -} - - (void)_startCellAnimationIfNeeded { if ([self window] == nil || [self isHidden] || NSEqualRects(NSZeroRect, [self frame])) diff --git a/MMTabBarView/MMTabBarView/MMOverflowPopUpButtonCell.h b/MMTabBarView/MMTabBarView/MMOverflowPopUpButtonCell.h index 0f418413..c396cd9a 100644 --- a/MMTabBarView/MMTabBarView/MMOverflowPopUpButtonCell.h +++ b/MMTabBarView/MMTabBarView/MMOverflowPopUpButtonCell.h @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/24/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import @@ -12,18 +12,11 @@ @class MMImageTransitionAnimation; -@interface MMOverflowPopUpButtonCell : NSPopUpButtonCell { - -@private - MMCellBezelDrawingBlock _bezelDrawingBlock; - NSImage *_image; - NSImage *_secondImage; - CGFloat _secondImageAlpha; -} +@interface MMOverflowPopUpButtonCell : NSPopUpButtonCell @property (copy) MMCellBezelDrawingBlock bezelDrawingBlock; -@property (retain) NSImage *image; -@property (retain) NSImage *secondImage; +@property (strong) NSImage *image; +@property (strong) NSImage *secondImage; @property (assign) CGFloat secondImageAlpha; - (void)drawImage:(NSImage *)image withFrame:(NSRect)frame inView:(NSView *)controlView alpha:(CGFloat)alpha; diff --git a/MMTabBarView/MMTabBarView/MMOverflowPopUpButtonCell.m b/MMTabBarView/MMTabBarView/MMOverflowPopUpButtonCell.m index ee083f27..404a5eef 100644 --- a/MMTabBarView/MMTabBarView/MMOverflowPopUpButtonCell.m +++ b/MMTabBarView/MMTabBarView/MMOverflowPopUpButtonCell.m @@ -3,26 +3,22 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/24/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import "MMOverflowPopUpButtonCell.h" #import "NSCell+MMTabBarViewExtensions.h" -@interface MMOverflowPopUpButtonCell (/*Private*/) - -- (NSRect)_imageRectForBounds:(NSRect)theRect forImage:(NSImage *)anImage; +@interface MMOverflowPopUpButtonCell () @end @implementation MMOverflowPopUpButtonCell +{ + NSImage *_image; +} -@dynamic image; -@synthesize secondImage = _secondImage; -@synthesize secondImageAlpha = _secondImageAlpha; -@synthesize bezelDrawingBlock = _bezelDrawingBlock; - -- (id)initTextCell:(NSString *)stringValue pullsDown:(BOOL)pullDown { +- (instancetype)initTextCell:(NSString *)stringValue pullsDown:(BOOL)pullDown { self = [super initTextCell:stringValue pullsDown:pullDown]; if (self) { _bezelDrawingBlock = nil; @@ -34,15 +30,6 @@ - (id)initTextCell:(NSString *)stringValue pullsDown:(BOOL)pullDown { return self; } -- (void)dealloc -{ - [_bezelDrawingBlock release], _bezelDrawingBlock = nil; - [_image release], _image = nil; - [_secondImage release], _secondImage = nil; - - [super dealloc]; -} - #pragma mark - #pragma mark Accessors @@ -54,10 +41,10 @@ - (void)setImage:(NSImage *)image { // as super class ignores setting image, we store it separately. if (_image) { - [_image release], _image = nil; + _image = nil; } - _image = [image retain]; + _image = image; } #pragma mark - @@ -130,12 +117,12 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { } } -- (id)initWithCoder:(NSCoder *)aDecoder { +- (instancetype)initWithCoder:(NSCoder *)aDecoder { if ((self = [super initWithCoder:aDecoder])) { if ([aDecoder allowsKeyedCoding]) { - _image = [[aDecoder decodeObjectForKey:@"MMTabBarOverflowPopUpImage"] retain]; - _secondImage = [[aDecoder decodeObjectForKey:@"MMTabBarOverflowPopUpSecondImage"] retain]; + _image = [aDecoder decodeObjectForKey:@"MMTabBarOverflowPopUpImage"]; + _secondImage = [aDecoder decodeObjectForKey:@"MMTabBarOverflowPopUpSecondImage"]; } } return self; diff --git a/MMTabBarView/MMTabBarView/MMProgressIndicator.h b/MMTabBarView/MMTabBarView/MMProgressIndicator.h index 79fcd0c1..f63e2c54 100644 --- a/MMTabBarView/MMTabBarView/MMProgressIndicator.h +++ b/MMTabBarView/MMTabBarView/MMProgressIndicator.h @@ -8,7 +8,6 @@ #import -@interface MMProgressIndicator : NSProgressIndicator { -} +@interface MMProgressIndicator : NSProgressIndicator @end \ No newline at end of file diff --git a/MMTabBarView/MMTabBarView/MMRolloverButton.h b/MMTabBarView/MMTabBarView/MMRolloverButton.h index 782f71b1..6261ec8d 100644 --- a/MMTabBarView/MMTabBarView/MMRolloverButton.h +++ b/MMTabBarView/MMTabBarView/MMRolloverButton.h @@ -13,15 +13,11 @@ #pragma mark Cell Interface -- (NSImage *)rolloverImage; -- (void)setRolloverImage:(NSImage *)image; +@property (strong) NSImage *rolloverImage; +@property (assign) MMRolloverButtonType rolloverButtonType; -- (MMRolloverButtonType)rolloverButtonType; -- (void)setRolloverButtonType:(MMRolloverButtonType)aType; +@property (readonly) BOOL mouseHovered; -- (BOOL)mouseHovered; - -- (BOOL)simulateClickOnMouseHovered; -- (void)setSimulateClickOnMouseHovered:(BOOL)flag; +@property (assign) BOOL simulateClickOnMouseHovered; @end \ No newline at end of file diff --git a/MMTabBarView/MMTabBarView/MMRolloverButton.m b/MMTabBarView/MMTabBarView/MMRolloverButton.m index eb91742f..00603639 100644 --- a/MMTabBarView/MMTabBarView/MMRolloverButton.m +++ b/MMTabBarView/MMTabBarView/MMRolloverButton.m @@ -15,7 +15,7 @@ + (Class)cellClass { return [MMRolloverButtonCell class]; } -- (id)initWithFrame:(NSRect)frameRect { +- (instancetype)initWithFrame:(NSRect)frameRect { self = [super initWithFrame:frameRect]; if (self) { @@ -25,10 +25,6 @@ - (id)initWithFrame:(NSRect)frameRect { return self; } -- (void)dealloc { - - [super dealloc]; -} - (void)awakeFromNib { if ([[self superclass] instancesRespondToSelector:@selector(awakeFromNib)]) { @@ -91,7 +87,7 @@ -(void)updateTrackingAreas { } // force reset of mouse hovered state if ([self mouseHovered]) - [[self cell] mouseExited:nil]; + [[self cell] mouseExited:[NSApp currentEvent]]; // recreate tracking areas and tool tip rects @@ -122,7 +118,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { } } -- (id)initWithCoder:(NSCoder *)aDecoder { +- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self) { if ([aDecoder allowsKeyedCoding]) { diff --git a/MMTabBarView/MMTabBarView/MMRolloverButtonCell.h b/MMTabBarView/MMTabBarView/MMRolloverButtonCell.h index 195b42b0..c5374a22 100644 --- a/MMTabBarView/MMTabBarView/MMRolloverButtonCell.h +++ b/MMTabBarView/MMTabBarView/MMRolloverButtonCell.h @@ -7,27 +7,21 @@ #import -typedef enum MMRolloverButtonType : NSUInteger +typedef NS_ENUM(NSUInteger, MMRolloverButtonType) { MMRolloverActionButton = 0, MMRolloverSwitchButton -} MMRolloverButtonType; +}; -@interface MMRolloverButtonCell : NSButtonCell { - -@private - NSImage *_rolloverImage; - BOOL _mouseHovered; - MMRolloverButtonType _rolloverButtonType; - BOOL _simulateClickOnMouseHovered; -} +@interface MMRolloverButtonCell : NSButtonCell @property (readonly) BOOL mouseHovered; -@property (retain) NSImage *rolloverImage; +@property (strong) NSImage *rolloverImage; @property (assign) MMRolloverButtonType rolloverButtonType; @property (assign) BOOL simulateClickOnMouseHovered; #pragma mark Tracking Area Support + - (void)addTrackingAreasForView:(NSView *)controlView inRect:(NSRect)cellFrame withUserInfo:(NSDictionary *)userInfo mouseLocation:(NSPoint)mouseLocation; - (void)mouseEntered:(NSEvent *)event; - (void)mouseExited:(NSEvent *)event; diff --git a/MMTabBarView/MMTabBarView/MMRolloverButtonCell.m b/MMTabBarView/MMTabBarView/MMRolloverButtonCell.m index 96f7dfcb..3d50fbdc 100644 --- a/MMTabBarView/MMTabBarView/MMRolloverButtonCell.m +++ b/MMTabBarView/MMTabBarView/MMRolloverButtonCell.m @@ -8,13 +8,13 @@ #import "MMRolloverButtonCell.h" @implementation MMRolloverButtonCell +{ + MMRolloverButtonType _rolloverButtonType; +} -@synthesize mouseHovered = _mouseHovered; -@synthesize rolloverImage = _rolloverImage; @dynamic rolloverButtonType; -@synthesize simulateClickOnMouseHovered = _simulateClickOnMouseHovered; -- (id)init +- (instancetype)init { self = [super init]; if (self) { @@ -25,12 +25,6 @@ - (id)init return self; } -- (void)dealloc -{ - [_rolloverImage release], _rolloverImage = nil; - [super dealloc]; -} - - (void)drawImage:(NSImage *)image withFrame:(NSRect)frame inView:(NSView *)controlView { if (_mouseHovered && ![self isHighlighted]) { @@ -90,7 +84,7 @@ - (void)addTrackingAreasForView:(NSView *)controlView inRect:(NSRect)cellFrame w // We make the view the owner, and it delegates the calls back to the cell after it is properly setup for the corresponding row/column in the outlineview area = [[NSTrackingArea alloc] initWithRect:cellFrame options:options owner:controlView userInfo:userInfo]; [controlView addTrackingArea:area]; - [area release], area = nil; + area = nil; } - (void)mouseEntered:(NSEvent *)event { @@ -122,11 +116,11 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { } } -- (id)initWithCoder:(NSCoder *)aDecoder { +- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self) { if ([aDecoder allowsKeyedCoding]) { - _rolloverImage = [[aDecoder decodeObjectForKey:@"rolloverImage"] retain]; + _rolloverImage = [aDecoder decodeObjectForKey:@"rolloverImage"]; _simulateClickOnMouseHovered = [aDecoder decodeIntegerForKey:@"simulateClickOnMouseHovered"]; _rolloverButtonType = [aDecoder decodeIntegerForKey:@"rolloverButtonType"]; } @@ -143,7 +137,7 @@ - (id)copyWithZone:(NSZone *)zone { if (cellCopy) { cellCopy->_rolloverButtonType = _rolloverButtonType; cellCopy->_simulateClickOnMouseHovered = _simulateClickOnMouseHovered; - cellCopy->_rolloverImage = [_rolloverImage retain]; + cellCopy->_rolloverImage = _rolloverImage; } return cellCopy; diff --git a/MMTabBarView/MMTabBarView/MMSlideButtonsAnimation.h b/MMTabBarView/MMTabBarView/MMSlideButtonsAnimation.h index 9d1f2c61..288f7e3f 100644 --- a/MMTabBarView/MMTabBarView/MMSlideButtonsAnimation.h +++ b/MMTabBarView/MMTabBarView/MMSlideButtonsAnimation.h @@ -10,7 +10,7 @@ @interface MMSlideButtonsAnimation : NSViewAnimation -- (id)initWithTabBarButtons:(NSSet *)buttons; +- (instancetype)initWithTabBarButtons:(NSSet *)buttons NS_DESIGNATED_INITIALIZER; - (void)addAnimationDictionary:(NSDictionary *)aDict; diff --git a/MMTabBarView/MMTabBarView/MMSlideButtonsAnimation.m b/MMTabBarView/MMTabBarView/MMSlideButtonsAnimation.m index 7c11a675..d6bf9d2e 100644 --- a/MMTabBarView/MMTabBarView/MMSlideButtonsAnimation.m +++ b/MMTabBarView/MMTabBarView/MMSlideButtonsAnimation.m @@ -12,7 +12,7 @@ @implementation MMSlideButtonsAnimation -- (id)initWithTabBarButtons:(NSSet *)buttons { +- (instancetype)initWithTabBarButtons:(NSSet *)buttons { NSArray *viewAnimations = [self _viewAnimationsForButtons:buttons]; @@ -32,7 +32,6 @@ - (void)addAnimationDictionary:(NSDictionary *)aDict { NSMutableArray *animations = [[self viewAnimations] mutableCopy]; [animations addObject:aDict]; [self setViewAnimations:animations]; - [animations release]; } #pragma mark - @@ -54,7 +53,6 @@ - (NSArray *)_viewAnimationsForButtons:(NSSet *)buttons { [animations addObject:animDict]; - [animDict release]; } return animations; diff --git a/MMTabBarView/MMTabBarView/MMTabBarButton.Common.h b/MMTabBarView/MMTabBarView/MMTabBarButton.Common.h new file mode 100644 index 00000000..112c9987 --- /dev/null +++ b/MMTabBarView/MMTabBarView/MMTabBarButton.Common.h @@ -0,0 +1,34 @@ +// +// MMTabBarButton.Common.h +// MMTabBarView +// +// Created by Michael Monscheuer on 23/05/15. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. +// + +typedef NS_ENUM(NSUInteger, MMCloseButtonImageType) +{ + MMCloseButtonImageTypeStandard = 0, + MMCloseButtonImageTypeRollover, + MMCloseButtonImageTypePressed, + MMCloseButtonImageTypeDirty, + MMCloseButtonImageTypeDirtyRollover, + MMCloseButtonImageTypeDirtyPressed +}; + +typedef NS_ENUM(NSUInteger,MMTabStateMask) +{ + MMTab_LeftIsSelectedMask = 1 << 2, + MMTab_RightIsSelectedMask = 1 << 3, + + MMTab_LeftIsSliding = 1 << 4, + MMTab_RightIsSliding = 1 << 5, + + MMTab_PlaceholderOnLeft = 1 << 6, + MMTab_PlaceholderOnRight = 1 << 7, + + MMTab_PositionLeftMask = 1 << 8, + MMTab_PositionMiddleMask = 1 << 9, + MMTab_PositionRightMask = 1 << 10, + MMTab_PositionSingleMask = 1 << 11 +}; diff --git a/MMTabBarView/MMTabBarView/MMTabBarButton.Private.h b/MMTabBarView/MMTabBarView/MMTabBarButton.Private.h new file mode 100644 index 00000000..728694ed --- /dev/null +++ b/MMTabBarView/MMTabBarView/MMTabBarButton.Private.h @@ -0,0 +1,13 @@ +// +// MMTabBarButton.Private.h +// MMTabBarView +// +// Created by Michael Monscheuer on 23/05/15. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. +// + +@interface MMTabBarButton(PrivateDrawing) + +- (NSRect)_indicatorRectForBounds:(NSRect)theRect; + +@end diff --git a/MMTabBarView/MMTabBarView/MMTabBarButton.h b/MMTabBarView/MMTabBarView/MMTabBarButton.h index 3b2523c9..b80afb14 100644 --- a/MMTabBarView/MMTabBarView/MMTabBarButton.h +++ b/MMTabBarView/MMTabBarView/MMTabBarButton.h @@ -11,42 +11,38 @@ #import "MMTabBarView.h" #import "MMRolloverButton.h" #import "MMProgressIndicator.h" -#import "MMTabBarButtonCell.h" +#import "MMTabBarButton.Common.h" @class MMTabBarView; +@class MMTabBarButtonCell; @protocol MMTabStyle; -@interface MMTabBarButton : MMRolloverButton { +@interface MMTabBarButton : MMRolloverButton - // the layouted frame rect - NSRect _stackingFrame; - - // close button - MMRolloverButton *_closeButton; - - // progress indicator - MMProgressIndicator *_indicator; -} +- (instancetype)initWithFrame:(NSRect)frame; + +#pragma mark Properties @property (assign) NSRect stackingFrame; -@property (retain) MMRolloverButton *closeButton; +@property (strong) MMRolloverButton *closeButton; @property (assign) SEL closeButtonAction; -@property (readonly, retain) MMProgressIndicator *indicator; - -- (id)initWithFrame:(NSRect)frame; +@property (readonly, strong) MMProgressIndicator *indicator; - (MMTabBarButtonCell *)cell; - (void)setCell:(MMTabBarButtonCell *)aCell; - (MMTabBarView *)tabBarView; +#pragma mark Update Cell + - (void)updateCell; +- (void)updateImages; #pragma mark Dividers -- (BOOL)shouldDisplayLeftDivider; -- (BOOL)shouldDisplayRightDivider; +@property (readonly) BOOL shouldDisplayLeftDivider; +@property (readonly) BOOL shouldDisplayRightDivider; #pragma mark Determine Sizes @@ -55,37 +51,24 @@ #pragma mark Interfacing Cell -- (id )style; -- (void)setStyle:(id )newStyle; - -- (MMTabStateMask)tabState; -- (void)setTabState:(MMTabStateMask)newState; - -- (NSImage *)icon; -- (void)setIcon:(NSImage *)anIcon; -- (NSImage *)largeImage; -- (void)setLargeImage:(NSImage *)anImage; -- (BOOL)showObjectCount; -- (void)setShowObjectCount:(BOOL)newState; -- (NSInteger)objectCount; -- (void)setObjectCount:(NSInteger)newCount; -- (NSColor *)objectCountColor; -- (void)setObjectCountColor:(NSColor *)newColor; -- (BOOL)isEdited; -- (void)setIsEdited:(BOOL)newState; -- (BOOL)isProcessing; -- (void)setIsProcessing:(BOOL)newState; +@property (strong) id style; +@property (assign) MMTabStateMask tabState; -- (void)updateImages; +@property (strong) NSImage *icon; +@property (strong) NSImage *largeImage; -#pragma mark Close Button Support +@property (assign) BOOL showObjectCount; +@property (assign) NSInteger objectCount; -- (BOOL)shouldDisplayCloseButton; +@property (strong) NSColor *objectCountColor; -- (BOOL)hasCloseButton; -- (void)setHasCloseButton:(BOOL)newState; +@property (assign) BOOL isEdited; +@property (assign) BOOL isProcessing; + +#pragma mark Close Button Support -- (BOOL)suppressCloseButton; -- (void)setSuppressCloseButton:(BOOL)newState; +@property (readonly) BOOL shouldDisplayCloseButton; +@property (assign) BOOL hasCloseButton; +@property (assign) BOOL suppressCloseButton; @end diff --git a/MMTabBarView/MMTabBarView/MMTabBarButton.m b/MMTabBarView/MMTabBarView/MMTabBarButton.m index 070666ef..3ec42b85 100644 --- a/MMTabBarView/MMTabBarView/MMTabBarButton.m +++ b/MMTabBarView/MMTabBarView/MMTabBarButton.m @@ -26,28 +26,24 @@ - (NSRect)_indicatorRectForBounds:(NSRect)bounds; @implementation MMTabBarButton -@synthesize stackingFrame = _stackingFrame; -@synthesize closeButton = _closeButton; -@dynamic closeButtonAction; -@synthesize indicator = _indicator; - -+ (void)initialize { - [super initialize]; - - [self exposeBinding:@"isProcessing"]; - [self exposeBinding:@"isEdited"]; - [self exposeBinding:@"objectCount"]; - [self exposeBinding:@"objectCountColor"]; - [self exposeBinding:@"icon"]; - [self exposeBinding:@"largeImage"]; - [self exposeBinding:@"hasCloseButton"]; ++ (void)initialize +{ + if (self == [MMTabBarButton class]) { + [self exposeBinding:@"isProcessing"]; + [self exposeBinding:@"isEdited"]; + [self exposeBinding:@"objectCount"]; + [self exposeBinding:@"objectCountColor"]; + [self exposeBinding:@"icon"]; + [self exposeBinding:@"largeImage"]; + [self exposeBinding:@"hasCloseButton"]; + } } + (Class)cellClass { return [MMTabBarButtonCell class]; } -- (id)initWithFrame:(NSRect)frame { +- (instancetype)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { [self _commonInit]; @@ -56,13 +52,6 @@ - (id)initWithFrame:(NSRect)frame { return self; } -- (void)dealloc -{ - [_closeButton release], _closeButton = nil; - [_indicator release], _indicator = nil; - [super dealloc]; -} - - (MMTabBarButtonCell *)cell { return (MMTabBarButtonCell *)[super cell]; } @@ -293,7 +282,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; - if (context == kMMTabBarButtonOberserverContext) + if (context == (__bridge void *)(kMMTabBarButtonOberserverContext)) { if ([[self tabBarView] sizeButtonsToFit]) { diff --git a/MMTabBarView/MMTabBarView/MMTabBarButtonCell.Private.h b/MMTabBarView/MMTabBarView/MMTabBarButtonCell.Private.h new file mode 100644 index 00000000..e5e80443 --- /dev/null +++ b/MMTabBarView/MMTabBarView/MMTabBarButtonCell.Private.h @@ -0,0 +1,18 @@ +// +// MMTabBarButtonCell.Private.h +// MMTabBarView +// +// Created by Michael Monscheuer on 23/05/15. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. +// + +@interface MMTabBarButtonCell (PrivateDrawing) + +- (NSRect)_closeButtonRectForBounds:(NSRect)theRect; +- (CGFloat)_leftMargin; +- (CGFloat)_rightMargin; + +- (void)_drawObjectCounterWithFrame:(NSRect)frame inView:(NSView *)controlView; +- (void)_drawIconWithFrame:(NSRect)frame inView:(NSView *)controlView; + +@end \ No newline at end of file diff --git a/MMTabBarView/MMTabBarView/MMTabBarButtonCell.h b/MMTabBarView/MMTabBarView/MMTabBarButtonCell.h index 57ed7e77..8f8efb84 100644 --- a/MMTabBarView/MMTabBarView/MMTabBarButtonCell.h +++ b/MMTabBarView/MMTabBarView/MMTabBarButtonCell.h @@ -11,99 +11,135 @@ #import "MMTabBarView.h" #import "MMRolloverButton.h" +#import "MMTabBarButton.h" + @class MMTabBarView; -@class MMTabBarButton; @class MMProgressIndicator; @protocol MMTabStyle; -typedef enum MMCloseButtonImageType : NSUInteger -{ - MMCloseButtonImageTypeStandard = 0, - MMCloseButtonImageTypeRollover, - MMCloseButtonImageTypePressed, - MMCloseButtonImageTypeDirty, - MMCloseButtonImageTypeDirtyRollover, - MMCloseButtonImageTypeDirtyPressed -} MMCloseButtonImageType; - -typedef enum MMTabStateMask : NSUInteger { - MMTab_LeftIsSelectedMask = 1 << 2, - MMTab_RightIsSelectedMask = 1 << 3, - - MMTab_LeftIsSliding = 1 << 4, - MMTab_RightIsSliding = 1 << 5, - - MMTab_PlaceholderOnLeft = 1 << 6, - MMTab_PlaceholderOnRight = 1 << 7, - - MMTab_PositionLeftMask = 1 << 8, - MMTab_PositionMiddleMask = 1 << 9, - MMTab_PositionRightMask = 1 << 10, - MMTab_PositionSingleMask = 1 << 11 -} MMTabStateMask; - -@interface MMTabBarButtonCell : MMRolloverButtonCell { - -@private - id _style; - - // state - MMTabStateMask _tabState; - - // cell values - NSImage *_icon; - NSImage *_largeImage; - BOOL _showObjectCount; - NSInteger _objectCount; - NSColor *_objectCountColor; - BOOL _isEdited; - BOOL _isProcessing; - - // close button - BOOL _hasCloseButton; - BOOL _suppressCloseButton; - BOOL _closeButtonOver; -} - -@property (retain) id style; - -@property (retain) NSImage *icon; -@property (retain) NSImage *largeImage; +@interface MMTabBarButtonCell : MMRolloverButtonCell + +/** + * Default color for object count display + * + * @return The default color + */ ++ (NSColor *)defaultObjectCountColor; + +/** + * The control view + */ +@property (assign) MMTabBarButton *controlView; + +/** + * Tab bar view the tab bar button belongs to + */ +@property (readonly) MMTabBarView *tabBarView; + +#pragma mark Update images + +/** + * Update images + */ +- (void)updateImages; + +#pragma mark Additional Properties + +/** + * Tab style + */ +@property (strong) id style; + +/** + * Icon of receiver + */ +@property (strong) NSImage *icon; + +/** + * Large image of receiver + */ +@property (strong) NSImage *largeImage; + +/** + * Visibility of object count + */ @property (assign) BOOL showObjectCount; + +/** + * Current object count + */ @property (assign) NSInteger objectCount; -@property (retain) NSColor *objectCountColor; + +/** + * Color of object count + */ +@property (strong) NSColor *objectCountColor; + +/** + * Edited state + */ @property (assign) BOOL isEdited; + +/** + * Processing state + */ @property (assign) BOOL isProcessing; +/** + * Visibility of close button + */ @property (assign) BOOL hasCloseButton; + +/** + * Check if close button should be suppressed + */ @property (assign) BOOL suppressCloseButton; +/** + * Current tab state mask + */ @property (assign) MMTabStateMask tabState; -+ (NSColor *)defaultObjectCountColor; - -- (MMTabBarButton *)controlView; -- (void)setControlView:(MMTabBarButton *)aView; - -- (MMTabBarView *)tabBarView; - -- (void)updateImages; - #pragma mark Progress Indicator Support -- (MMProgressIndicator *)indicator; +/** + * Get progress indicator + */ +@property (readonly) MMProgressIndicator *indicator; #pragma mark Close Button Support -- (MMRolloverButton *)closeButton; -- (BOOL)shouldDisplayCloseButton; +/** + * The close button + */ +@property (readonly) MMRolloverButton *closeButton; + +/** + * Check if receiver should display close button + */ +@property (readonly) BOOL shouldDisplayCloseButton; + +/** + * Get close button image + * + * @param type Close button image type + * + * @return The image + */ - (NSImage *)closeButtonImageOfType:(MMCloseButtonImageType)type; #pragma mark Cell Values -- (NSAttributedString *)attributedStringValue; -- (NSAttributedString *)attributedObjectCountStringValue; +/** + * Attributed string value + */ +@property (readonly) NSAttributedString *attributedStringValue; + +/** + * Object count string value + */ +@property (readonly) NSAttributedString *attributedObjectCountStringValue; #pragma mark Determining Cell Size @@ -116,8 +152,8 @@ typedef enum MMTabStateMask : NSUInteger { - (NSRect)objectCounterRectForBounds:(NSRect)theRect; - (NSRect)closeButtonRectForBounds:(NSRect)theRect; -- (CGFloat)minimumWidthOfCell; -- (CGFloat)desiredWidthOfCell; +@property (readonly) CGFloat minimumWidthOfCell; +@property (readonly) CGFloat desiredWidthOfCell; #pragma mark Drawing @@ -131,11 +167,4 @@ typedef enum MMTabStateMask : NSUInteger { - (void)drawIndicatorWithFrame:(NSRect)frame inView:(NSView *)controlView; - (void)drawCloseButtonWithFrame:(NSRect)frame inView:(NSView *)controlView; -/* -#pragma mark Tracking Area Support - -- (void)addTrackingAreasForView:(NSView *)view inRect:(NSRect)cellFrame withUserInfo:(NSDictionary *)userInfo mouseLocation:(NSPoint)currentPoint; -- (void)mouseEntered:(NSEvent *)theEvent; -- (void)mouseExited:(NSEvent *)theEvent; -*/ @end diff --git a/MMTabBarView/MMTabBarView/MMTabBarButtonCell.m b/MMTabBarView/MMTabBarView/MMTabBarButtonCell.m index b326ccca..75a7a152 100644 --- a/MMTabBarView/MMTabBarView/MMTabBarButtonCell.m +++ b/MMTabBarView/MMTabBarView/MMTabBarButtonCell.m @@ -14,65 +14,24 @@ #import "NSView+MMTabBarViewExtensions.h" #import "NSCell+MMTabBarViewExtensions.h" -@interface MMTabBarButtonCell (/*Private*/) - -- (NSImage *)_closeButtonImageOfType:(MMCloseButtonImageType)type; - -- (CGFloat)_leftMargin; -- (CGFloat)_rightMargin; - -- (NSRect)_drawingRectForBounds:(NSRect)theRect; -- (NSRect)_titleRectForBounds:(NSRect)theRect; -- (NSRect)_iconRectForBounds:(NSRect)theRect; -- (NSRect)_largeImageRectForBounds:(NSRect)theRect; -- (NSRect)_indicatorRectForBounds:(NSRect)theRect; -- (NSSize)_objectCounterSize; -- (NSRect)_objectCounterRectForBounds:(NSRect)theRect; -- (NSSize)_closeButtonSizeForBounds:(NSRect)theRect; -- (NSRect)_closeButtonRectForBounds:(NSRect)theRect; - -- (CGFloat)_minimumWidthOfCell; -- (CGFloat)_desiredWidthOfCell; - -- (NSAttributedString *)_attributedStringValue; -- (NSAttributedString *)_attributedObjectCountStringValue; - -- (void)_updateSubButtons; -- (void)_updateCloseButtonImages; -- (void)_updateCloseButton; -- (void)_updateIndicator; - -- (void)_drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; -- (void)_drawBezelWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; -- (void)_drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; -- (void)_drawLargeImageWithFrame:(NSRect)frame inView:(NSView *)controlView; -- (void)_drawIconWithFrame:(NSRect)frame inView:(NSView *)controlView; -- (void)_drawTitleWithFrame:(NSRect)frame inView:(NSView *)controlView; -- (void)_drawObjectCounterWithFrame:(NSRect)frame inView:(NSView *)controlView; -- (void)_drawIndicatorWithFrame:(NSRect)frame inView:(NSView *)controlView; -- (void)_drawCloseButtonWithFrame:(NSRect)frame inView:(NSView *)controlView; - +@interface MMTabBarButtonCell () @end @implementation MMTabBarButtonCell - -@dynamic style; -@dynamic hasCloseButton; -@dynamic suppressCloseButton; -@synthesize icon = _icon; -@synthesize largeImage = _largeImage; -@synthesize showObjectCount = _showObjectCount; -@synthesize objectCount = _objectCount; -@synthesize objectCountColor = _objectCountColor; -@dynamic isEdited; -@synthesize isProcessing = _isProcessing; -@synthesize tabState = _tabState; +{ + id _style; + BOOL _isProcessing; + BOOL _isEdited; + BOOL _hasCloseButton; + BOOL _suppressCloseButton; + BOOL _closeButtonOver; +} + (NSColor *)defaultObjectCountColor { return [NSColor colorWithCalibratedWhite:0.3 alpha:0.45]; } -- (id)init { +- (instancetype)init { if ((self = [super init])) { _style = nil; @@ -81,7 +40,7 @@ - (id)init { _icon = nil; _largeImage = nil; _showObjectCount = NO; - _objectCountColor = [[NSColor colorWithCalibratedWhite:0.3 alpha:0.45] retain]; + _objectCountColor = [NSColor colorWithCalibratedWhite:0.3 alpha:0.45]; _isEdited = NO; _tabState = 0; @@ -92,15 +51,6 @@ - (id)init { return self; } -- (void)dealloc { - [_style release], _style = nil; - [_icon release], _icon = nil; - [_largeImage release], _largeImage = nil; - [_objectCountColor release], _objectCountColor = nil; - - [super dealloc]; -} - - (MMTabBarButton *)controlView { return (MMTabBarButton *)[super controlView]; } @@ -139,8 +89,8 @@ - (void)setStyle:(id)style { @synchronized (self) { - [_style release], _style = nil; - _style = [style retain]; + _style = nil; + _style = style; [self _updateSubButtons]; } @@ -515,10 +465,10 @@ - (id)copyWithZone:(NSZone *)zone { MMTabBarButtonCell *cellCopy = [super copyWithZone:zone]; if (cellCopy) { - cellCopy->_style = [_style retain]; - cellCopy->_icon = [_icon retain]; - cellCopy->_largeImage = [_largeImage retain]; - cellCopy->_objectCountColor = [_objectCountColor retain]; + cellCopy->_style = _style; + cellCopy->_icon = _icon; + cellCopy->_largeImage = _largeImage; + cellCopy->_objectCountColor = _objectCountColor; cellCopy->_tabState = _tabState; cellCopy->_showObjectCount = _showObjectCount; @@ -556,14 +506,14 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { } } -- (id)initWithCoder:(NSCoder *)aDecoder { +- (instancetype)initWithCoder:(NSCoder *)aDecoder { if ((self = [super initWithCoder:aDecoder])) { if ([aDecoder allowsKeyedCoding]) { - _style = [[aDecoder decodeObjectForKey:@"MMTabBarButtonCellStyle"] retain]; - _icon = [[aDecoder decodeObjectForKey:@"MMTabBarButtonCellIcon"] retain]; - _largeImage = [[aDecoder decodeObjectForKey:@"MMTabBarButtonCellLargeImage"] retain]; - _objectCountColor = [[aDecoder decodeObjectForKey:@"MMTabBarButtonCellLargeObjectCountColor"] retain]; + _style = [aDecoder decodeObjectForKey:@"MMTabBarButtonCellStyle"]; + _icon = [aDecoder decodeObjectForKey:@"MMTabBarButtonCellIcon"]; + _largeImage = [aDecoder decodeObjectForKey:@"MMTabBarButtonCellLargeImage"]; + _objectCountColor = [aDecoder decodeObjectForKey:@"MMTabBarButtonCellLargeObjectCountColor"]; _tabState = [aDecoder decodeIntegerForKey:@"MMTabBarButtonCellTabState"]; _showObjectCount = [aDecoder decodeBoolForKey:@"MMTabBarButtonCellShowObjectCount"]; @@ -587,7 +537,7 @@ - (NSAttributedString *)_attributedStringValue { NSMutableAttributedString *attrStr; NSString *contents = [self title]; - attrStr = [[[NSMutableAttributedString alloc] initWithString:contents] autorelease]; + attrStr = [[NSMutableAttributedString alloc] initWithString:contents]; NSRange range = NSMakeRange(0, [contents length]); [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0] range:range]; @@ -596,7 +546,7 @@ - (NSAttributedString *)_attributedStringValue { // Paragraph Style for Truncating Long Text static NSMutableParagraphStyle *truncatingTailParagraphStyle = nil; if (!truncatingTailParagraphStyle) { - truncatingTailParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; + truncatingTailParagraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; [truncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; [truncatingTailParagraphStyle setAlignment:NSCenterTextAlignment]; } @@ -614,7 +564,7 @@ - (NSAttributedString *)_attributedObjectCountStringValue { } NSString *contents = [NSString stringWithFormat:@"%lu", (unsigned long)[self objectCount]]; - return [[[NSMutableAttributedString alloc] initWithString:contents attributes:objectCountStringAttributes] autorelease]; + return [[NSMutableAttributedString alloc] initWithString:contents attributes:objectCountStringAttributes]; } #pragma mark > Sub Buttons @@ -848,7 +798,7 @@ - (NSRect)_largeImageRectForBounds:(NSRect)theRect { result.origin.y += (constrainedDrawingRect.size.height - scaledImageSize.height) / 2.0; } - return result; + return NSIntegralRect(result); } - (NSRect)_indicatorRectForBounds:(NSRect)theRect { @@ -869,7 +819,7 @@ - (NSRect)_indicatorRectForBounds:(NSRect)theRect { - (NSSize)_objectCounterSize { - if ([self showObjectCount] == 0) { + if (![self showObjectCount]) { return NSZeroSize; } @@ -1096,7 +1046,6 @@ - (void)_drawTitleWithFrame:(NSRect)frame inView:(NSView *)controlView { [NSGraphicsContext restoreGraphicsState]; - [shadow release]; } - (void)_drawObjectCounterWithFrame:(NSRect)frame inView:(NSView *)controlView { diff --git a/MMTabBarView/MMTabBarView/MMTabBarController.h b/MMTabBarView/MMTabBarView/MMTabBarController.h index ba0cfcf5..6ae6fa41 100644 --- a/MMTabBarView/MMTabBarView/MMTabBarController.h +++ b/MMTabBarView/MMTabBarView/MMTabBarController.h @@ -11,14 +11,10 @@ @class MMTabBarView, MMAttachedTabBarButton; @interface MMTabBarController : NSObject -{ - MMTabBarView *_tabBarView; - NSMenu *_overflowMenu; -} -- (id)initWithTabBarView:(MMTabBarView *)aTabBarView; +- (instancetype)initWithTabBarView:(MMTabBarView *)aTabBarView; -- (NSMenu *)overflowMenu; +@property (readonly) NSMenu *overflowMenu; - (void)layoutButtons; diff --git a/MMTabBarView/MMTabBarView/MMTabBarController.m b/MMTabBarView/MMTabBarView/MMTabBarController.m index b412836d..9052fdf7 100644 --- a/MMTabBarView/MMTabBarView/MMTabBarController.m +++ b/MMTabBarView/MMTabBarView/MMTabBarController.m @@ -14,14 +14,14 @@ #define MAX_OVERFLOW_MENUITEM_TITLE_LENGTH 60 -@interface MMTabBarController (Private) -- (NSArray *)_generateWidthsFromAttachedButtons:(NSArray *)buttons; -- (void)_setupAttachedButtons:(NSArray *)buttons withWidths:(NSArray *)widths; -- (NSInteger)_shrinkWidths:(NSMutableArray *)newWidths towardMinimum:(NSInteger)minimum withAvailableWidth:(CGFloat)availableWidth; -- (void)_addItemToOverflowMenu:(NSTabViewItem *)anItem withTitle:(NSString *)title; +@interface MMTabBarController() @end @implementation MMTabBarController +{ + __weak MMTabBarView *_tabBarView; + NSMenu *_overflowMenu; +} /*! @method initWithTabBarView: @@ -30,22 +30,13 @@ @implementation MMTabBarController @param A MMTabBarView. @returns A newly created MMTabBarController instance. */ -- (id)initWithTabBarView:(MMTabBarView *)aTabBarView { +- (instancetype)initWithTabBarView:(MMTabBarView *)aTabBarView { if ((self = [super init])) { _tabBarView = aTabBarView; } return self; } -- (void)dealloc { - - _tabBarView = nil; // non retained! - - [_overflowMenu release], _overflowMenu = nil; - - [super dealloc]; -} - /*! @method overflowMenu @abstract Returns current overflow menu or nil if there is none. @@ -72,7 +63,7 @@ - (void)layoutButtons { MMAttachedTabBarButton *draggedButton = [_tabBarView attachedTabBarButtonForDraggedItems]; if (draggedButton) { - NSMutableArray *mutable = [[attachedButtons mutableCopy] autorelease]; + NSMutableArray *mutable = [attachedButtons mutableCopy]; [mutable insertObject:draggedButton atIndex:[_tabBarView destinationIndexForDraggedItem]]; attachedButtons = mutable; @@ -407,7 +398,7 @@ - (void)_setupAttachedButtons:(NSArray *)buttons withWidths:(NSArray *)widths { NSUInteger buttonCount = [buttons count]; - [_overflowMenu release], _overflowMenu = nil; + _overflowMenu = nil; __block NSRect buttonRect = [_tabBarView genericButtonRect]; diff --git a/MMTabBarView/MMTabBarView/MMTabBarItem.h b/MMTabBarView/MMTabBarView/MMTabBarItem.h index e7445fec..b4a908cf 100644 --- a/MMTabBarView/MMTabBarView/MMTabBarItem.h +++ b/MMTabBarView/MMTabBarView/MMTabBarItem.h @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/29/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import @@ -12,14 +12,49 @@ @optional -@property (copy) NSString *title; -@property (retain) NSImage *icon; -@property (retain) NSImage *largeImage; -@property (assign) NSInteger objectCount; -@property (retain) NSColor *objectCountColor; +/** + * Title + */ +@property (copy) NSString *title; +/** + * Icon + */ +@property (strong) NSImage *icon; + +/** + * Large image + */ +@property (strong) NSImage *largeImage; + +/** + * Object count to display + */ +@property (assign) NSInteger objectCount; + +/** + * YES: show object count, NO: do not show + */ +@property (assign) BOOL showObjectCount; + +/** + * Color of object count badge + */ +@property (strong) NSColor *objectCountColor; + +/** + * Processing state + */ @property (assign) BOOL isProcessing; + +/** + * Edited state + */ @property (assign) BOOL isEdited; + +/** + * Returns YES if item has close button + */ @property (assign) BOOL hasCloseButton; @end diff --git a/MMTabBarView/MMTabBarView/MMTabBarView-Info.plist b/MMTabBarView/MMTabBarView/MMTabBarView-Info.plist index 423f0454..43670037 100644 --- a/MMTabBarView/MMTabBarView/MMTabBarView-Info.plist +++ b/MMTabBarView/MMTabBarView/MMTabBarView-Info.plist @@ -23,7 +23,7 @@ CFBundleVersion 1 NSHumanReadableCopyright - © 2012-2014 Michael Monscheuer. All rights reserved. + © 2012-2016 Michael Monscheuer. All rights reserved. NSPrincipalClass diff --git a/MMTabBarView/MMTabBarView/MMTabBarView.h b/MMTabBarView/MMTabBarView/MMTabBarView.h index 672c6d6e..a9941949 100644 --- a/MMTabBarView/MMTabBarView/MMTabBarView.h +++ b/MMTabBarView/MMTabBarView/MMTabBarView.h @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/19/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // /* @@ -38,7 +38,15 @@ static NSImage* _static##name##Image() \ return image; \ } -@class MMOverflowPopUpButton; +#define StaticImageWithFilename(name, filename) \ +static NSImage* _static##name##Image() \ +{ \ + static NSImage* image = nil; \ + if (!image) \ + image = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@#filename]]; \ + return image; \ +} + @class MMRolloverButton; @class MMTabBarViewler; @class MMTabBarButton; @@ -48,228 +56,535 @@ static NSImage* _static##name##Image() \ @protocol MMTabStyle; -typedef enum MMTabBarOrientation : NSUInteger { - MMTabBarHorizontalOrientation = 0, - MMTabBarVerticalOrientation -} MMTabBarOrientation; - -typedef enum MMTabBarTearOffStyle : NSUInteger { - MMTabBarTearOffAlphaWindow, - MMTabBarTearOffMiniwindow -} MMTabBarTearOffStyle; +/** + * Tab bar orientation + */ +typedef NS_ENUM(NSUInteger, MMTabBarOrientation){ +/** + * Horizontal orientation + */ +MMTabBarHorizontalOrientation = 0, +/** + * Vertical orientation + */ +MMTabBarVerticalOrientation +}; -typedef enum MMAttachedButtonsEnumerationOptions : NSUInteger { +/** + * Tear off style + */ +typedef NS_ENUM(NSUInteger, MMTabBarTearOffStyle){ +/** + * Show alpha window + */ +MMTabBarTearOffAlphaWindow, +/** + * Show mini window + */ +MMTabBarTearOffMiniwindow +}; - MMAttachedButtonsEnumerationNone = 0, - MMAttachedButtonsEnumerationUpdateTabStateMask = 1 << 1, - MMAttachedButtonsEnumerationUpdateButtonState = 1 << 2 -} MMAttachedButtonsEnumerationOptions; +/** + * Attached tab bar buttons enumeration options + */ +typedef NS_ENUM(NSUInteger, MMAttachedButtonsEnumerationOptions){ +/** + * No options + */ +MMAttachedButtonsEnumerationNone = 0, +/** + * Update tab state + */ +MMAttachedButtonsEnumerationUpdateTabStateMask = 1 << 1, +/** + * Update button state + */ +MMAttachedButtonsEnumerationUpdateButtonState = 1 << 2 +}; @protocol MMTabBarViewDelegate; -@interface MMTabBarView : NSView { - - // control basics - NSTabView *_tabView; // the tab view being navigated - MMOverflowPopUpButton *_overflowPopUpButton; // for too many tabs - MMRolloverButton *_addTabButton; - MMTabBarController *_controller; - - // Spring-loading. - NSTimer *_springTimer; - NSTabViewItem *_tabViewItemWithSpring; - - // configuration - id _style; - BOOL _onlyShowCloseOnHover; - BOOL _canCloseOnlyTab; - BOOL _disableTabClose; - BOOL _hideForSingleTab; - BOOL _showAddTabButton; - BOOL _sizeButtonsToFit; - BOOL _useOverflowMenu; - BOOL _alwaysShowActiveTab; - BOOL _allowsScrubbing; - NSInteger _resizeAreaCompensation; - MMTabBarOrientation _orientation; - BOOL _automaticallyAnimates; - MMTabBarTearOffStyle _tearOffStyle; - BOOL _allowsBackgroundTabClosing; - BOOL _selectsTabsOnMouseDown; - BOOL _resizeTabsToFitTotalWidth; - - // vertical tab resizing - BOOL _allowsResizing; - BOOL _isResizing; - - // button width - NSInteger _buttonMinWidth; - NSInteger _buttonMaxWidth; - NSInteger _buttonOptimumWidth; - - // animation - MMSlideButtonsAnimation *_slideButtonsAnimation; - - // animation for hide/show - NSViewAnimation *_hideShowTabBarAnimation; - BOOL _isHidden; - NSView *_partnerView; // gets resized when hide/show - NSInteger _tabBarWidth; // stored width of vertical tab bar - - // states - BOOL _isReorderingTabViewItems; - BOOL _needsUpdate; - - // drag and drop - NSUInteger _destinationIndexForDraggedItem; // NSNotFound = none - - // delegate - id _delegate; -} +@interface MMTabBarView : NSView -@property (retain) IBOutlet NSTabView *tabView; -@property (retain) IBOutlet NSView *partnerView; -@property (assign) IBOutlet id delegate; -@property (assign) NSUInteger destinationIndexForDraggedItem; +#pragma mark Basics + +/** + * Get bundle of class + * + * @return The bundle + */ ++ (NSBundle *)bundle; + +#pragma mark Outlets + +/** + * Tab view + */ +@property (strong) IBOutlet NSTabView *tabView; + +/** + * A partner view + */ +@property (strong) IBOutlet NSView *partnerView; + +/** + * Delegate + */ +@property (weak) IBOutlet id delegate; + +#pragma mark Working with View's current state + +/** + * Get available width for buttons + */ +@property (readonly) CGFloat availableWidthForButtons; + +/** + * Get available height for buttons + */ +@property (readonly) CGFloat availableHeightForButtons; + +/** + * Get generic button rect + * + * @return The button rect + */ +- (NSRect)genericButtonRect; + +/** + * Check if overflow button is currently visible + */ +@property (readonly) BOOL isOverflowButtonVisible; + +/** + * Get window's active state + */ +@property (readonly) BOOL isWindowActive; + +/** + * Check if in resize mode + */ @property (readonly) BOOL isResizing; + +/** + * Check if receiver needs update + */ @property (assign) BOOL needsUpdate; -@property (assign) BOOL resizeTabsToFitTotalWidth; -#pragma mark Control Characteristics +#pragma mark Drag & Drop Support -+ (NSBundle *)bundle; -- (CGFloat)availableWidthForButtons; -- (CGFloat)availableHeightForButtons; -- (NSRect)genericButtonRect; -- (BOOL)isWindowActive; +/** + * Check if detached dragging of tab view item is allowed + * + * @param anItem A Tab view item + * + * @return YES or NO + */ - (BOOL)allowsDetachedDraggingOfTabViewItem:(NSTabViewItem *)anItem; +/** + * Get destination index for dragged item + */ +@property (assign) NSUInteger destinationIndexForDraggedItem; + #pragma mark Style Class Registry +/** + * Register default tab style classes + */ + (void)registerDefaultTabStyleClasses; + +/** + * Register a tab style class + * + * @param aStyleClass A tab style class + */ + (void)registerTabStyleClass:(Class )aStyleClass; + +/** + * Unregister tab style class + * + * @param aStyleClass A tab style class + */ + (void)unregisterTabStyleClass:(Class )aStyleClass; + +/** + * Get registered tab style classes + * + * @return Array of all registered classes + */ + (NSArray *)registeredTabStyleClasses; + +/** + * Get registered class for specified tab style name + * + * @param name Name of a registered tab style + * + * @return The matching tab style class + */ + (Class )registeredClassForStyleName:(NSString *)name; #pragma mark Tab View Item Management -- (NSUInteger)numberOfTabViewItems; -- (NSUInteger)numberOfVisibleTabViewItems; -- (NSArray *)visibleTabViewItems; +/** + * Get number of tab view items + */ +@property (readonly) NSUInteger numberOfTabViewItems; + +/** + * Get number of visible tab view items + */ +@property (readonly) NSUInteger numberOfVisibleTabViewItems; + +/** + * Get array of visible tab view items + */ +@property (readonly) NSArray *visibleTabViewItems; + +/** + * Get index of specified tab view item + * + * @param anItem A tab view item + * + * @return The index into array of tab view items + */ - (NSUInteger)indexOfTabViewItem:(NSTabViewItem *)anItem; -- (NSTabViewItem *)selectedTabViewItem; + +/** + * Get selected tab view item + */ +@property (readonly) NSTabViewItem *selectedTabViewItem; + +/** + * Select specified tab view item + * + * @param anItem A tab view item + */ - (void)selectTabViewItem:(NSTabViewItem *)anItem; + +/** + * Move a tab view item to specified index + * + * @param anItem A tab view item + * @param index The destination index + */ - (void)moveTabViewItem:(NSTabViewItem *)anItem toIndex:(NSUInteger)index; + +/** + * Remove a tab view item + * + * @param anItem Tab view item to remove + */ - (void)removeTabViewItem:(NSTabViewItem *)anItem; -- (NSTabViewItem *)tabViewItemPinnedToOverflowButton; -- (void)setTabViewItemPinnedToOverflowButton:(NSTabViewItem *)item; +/** + * Tab view item currently pinned to overflow button + */ +@property (strong) NSTabViewItem *tabViewItemPinnedToOverflowButton; #pragma mark Attached Buttons Management -- (NSUInteger)numberOfAttachedButtons; -- (NSSet *)attachedButtons; -- (NSArray *)orderedAttachedButtons; +/** + * Get number of attached tab bar buttons + */ +@property (readonly) NSUInteger numberOfAttachedButtons; + +/** + * Get array of all attached tab bar buttons + */ +@property (readonly) NSSet *attachedButtons; + +/** + * Get ordered array of attached tab bar buttons + */ +@property (readonly) NSArray *orderedAttachedButtons; + +/** + * Get array of attached tab bar buttons sorted by using a comparator + * + * @param cmptr A comparator block + * + * @return The sorted array + */ - (NSArray *)sortedAttachedButtonsUsingComparator:(NSComparator)cmptr; + +/** + * INsert attached tab bar button for specified tab view item + * + * @param item A tab view item + * @param index Index to insert attached tab bar button at + */ - (void)insertAttachedButtonForTabViewItem:(NSTabViewItem *)item atIndex:(NSUInteger)index; + +/** + * Add attached tab bar button for specified tab view item + * + * @param tab view item to add attached tab bar button for + */ - (void)addAttachedButtonForTabViewItem:(NSTabViewItem *)item; + +/** + * Remove attached tab bar button + * + * @param aButton A tab bar button + */ - (void)removeAttachedButton:(MMAttachedTabBarButton *)aButton; + +/** + * Remove attached tab bar button and synchronize tab view items + * + * @param aButton A tab bar button + * @param syncTabViewItems YES: synchronize tab view items + */ - (void)removeAttachedButton:(MMAttachedTabBarButton *)aButton synchronizeTabViewItems:(BOOL)syncTabViewItems; + +/** + * Insert specified attached tab bar button at index + * + * @param aButton A tab bar button + * @param anIndex Destination index + */ - (void)insertAttachedButton:(MMAttachedTabBarButton *)aButton atTabItemIndex:(NSUInteger)anIndex; #pragma mark Find Attached Buttons -- (NSIndexSet *)viewIndexesOfAttachedButtons; +/** + * Get view indexes of attached buttons + */ +@property (readonly) NSIndexSet *viewIndexesOfAttachedButtons; -- (NSUInteger)viewIndexOfSelectedAttachedButton; +/** + * Get view index of selected attached button + */ +@property (readonly) NSUInteger viewIndexOfSelectedAttachedButton; -- (MMAttachedTabBarButton *)selectedAttachedButton; -- (MMAttachedTabBarButton *)lastAttachedButton; +/** + * Get selected attached tab bar button + */ +@property (readonly) MMAttachedTabBarButton *selectedAttachedButton; +/** + * Get last attached tab bar button + */ +@property (readonly) MMAttachedTabBarButton *lastAttachedButton; + +/** + * Get attached tab bar button at point + * + * @param aPoint A point in receiver's coos + * + * @return The matching attached tab bar button (or nil) + */ - (MMAttachedTabBarButton *)attachedButtonAtPoint:(NSPoint)aPoint; +/** + * Get attached tab bar button for specified tab view item + * + * @param anItem A tab view item + * + * @return Matching attached tab bar button (or nil) + */ - (MMAttachedTabBarButton *)attachedButtonForTabViewItem:(NSTabViewItem *)anItem; +/** + * Get index of specified attached tab bar button + * + * @param aButton A tab bar button + * + * @return Index of tab bar button + */ - (NSUInteger)indexOfAttachedButton:(MMAttachedTabBarButton *)aButton; #pragma mark Button State Management +/** + * Update tab state mask of specified attached tab bar button + * + * @param aButton An attached tab bar button + * @param index Button index + * @param prevButton Previous button + * @param nextButton Next Button + */ - (void)updateTabStateMaskOfAttachedButton:(MMAttachedTabBarButton *)aButton atIndex:(NSUInteger)index withPrevious:(MMAttachedTabBarButton *)prevButton next:(MMAttachedTabBarButton *)nextButton; + +/** + * Update tab state mask of specified attached tab bar button + * + * @param aButton An attached tab bar button + * @param index Button index + */ - (void)updateTabStateMaskOfAttachedButton:(MMAttachedTabBarButton *)aButton atIndex:(NSUInteger)index; + +/** + * Update tab state mask of all attached buttons + */ - (void)updateTabStateMaskOfAttachedButtons; #pragma mark Sending Messages to Attached Buttons +/** + * Enumerate attached tab bar buttons + * + * @param block Block to execute + */ - (void)enumerateAttachedButtonsUsingBlock:(void (^)(MMAttachedTabBarButton *aButton, NSUInteger idx, BOOL *stop))block; +/** + * Enumerate attached tab bar buttons with options + * + * @param opts Options (@see MMAttachedButtonsEnumerationOptions) + * @param block Block to execute + */ - (void)enumerateAttachedButtonsWithOptions:(MMAttachedButtonsEnumerationOptions)opts usingBlock:(void (^)(MMAttachedTabBarButton *aButton, NSUInteger idx, MMAttachedTabBarButton *previousButton, MMAttachedTabBarButton *nextButton, BOOL *stop))block; +/** + * Enumerate attached tab bar buttons in range with options + * + * @param buttons Array of attached tab bar buttons + * @param range Button index range + * @param opts Options (@see MMAttachedButtonsEnumerationOptions) + * @param block Block to execute + */ - (void)enumerateAttachedButtons:(NSArray *)buttons inRange:(NSRange)range withOptions:(MMAttachedButtonsEnumerationOptions)opts usingBlock:(void (^)(MMAttachedTabBarButton *aButton, NSUInteger idx, MMAttachedTabBarButton *previousButton, MMAttachedTabBarButton *nextButton, BOOL *stop))block; #pragma mark Find Tab Bar Buttons +/** + * Fin tab bar button at point + * + * @param point Point in receiver's coo system + * + * @return Matching tab bar button (or nil) + */ - (MMTabBarButton *)tabBarButtonAtPoint:(NSPoint)point; #pragma mark Control Configuration -- (id)style; -- (void)setStyle:(id )newStyle; -- (NSString *)styleName; +/** + * The tab style to use + */ +@property (strong) id style; + +/** + * Name of tab style + */ +@property (readonly) NSString *styleName; + +/** + * Set tab style by style name + * + * @param name Name of registered tab style + */ - (void)setStyleNamed:(NSString *)name; -- (MMTabBarOrientation)orientation; -- (void)setOrientation:(MMTabBarOrientation)value; -- (BOOL)onlyShowCloseOnHover; -- (void)setOnlyShowCloseOnHover:(BOOL)value; -- (BOOL)canCloseOnlyTab; -- (void)setCanCloseOnlyTab:(BOOL)value; -- (BOOL)disableTabClose; -- (void)setDisableTabClose:(BOOL)value; -- (BOOL)hideForSingleTab; -- (void)setHideForSingleTab:(BOOL)value; -- (BOOL)showAddTabButton; -- (void)setShowAddTabButton:(BOOL)value; -- (NSInteger)buttonMinWidth; -- (void)setButtonMinWidth:(NSInteger)value; -- (NSInteger)buttonMaxWidth; -- (void)setButtonMaxWidth:(NSInteger)value; -- (NSInteger)buttonOptimumWidth; -- (void)setButtonOptimumWidth:(NSInteger)value; -- (BOOL)sizeButtonsToFit; -- (void)setSizeButtonsToFit:(BOOL)value; -- (BOOL)useOverflowMenu; -- (void)setUseOverflowMenu:(BOOL)value; -- (BOOL)allowsBackgroundTabClosing; -- (void)setAllowsBackgroundTabClosing:(BOOL)value; -- (BOOL)allowsResizing; -- (void)setAllowsResizing:(BOOL)value; -- (BOOL)selectsTabsOnMouseDown; -- (void)setSelectsTabsOnMouseDown:(BOOL)value; -- (BOOL)automaticallyAnimates; -- (void)setAutomaticallyAnimates:(BOOL)value; -- (BOOL)alwaysShowActiveTab; -- (void)setAlwaysShowActiveTab:(BOOL)value; -- (BOOL)allowsScrubbing; -- (void)setAllowsScrubbing:(BOOL)value; -- (MMTabBarTearOffStyle)tearOffStyle; -- (void)setTearOffStyle:(MMTabBarTearOffStyle)tearOffStyle; +/** + * Reciever's layout orientation + */ +@property (assign) MMTabBarOrientation orientation; -#pragma mark Accessors +/** + * YES: only show close button on hover + */ +@property (assign) BOOL onlyShowCloseOnHover; -- (NSTabView *)tabView; -- (void)setTabView:(NSTabView *)view; -- (id)delegate; -- (void)setDelegate:(id)object; -- (CGFloat)heightOfTabBarButtons; +/** + * YES: can close last (single) tab available + */ +@property (assign) BOOL canCloseOnlyTab; + +/** + * Disable closing of tabs + */ +@property (assign) BOOL disableTabClose; + +/** + * Hide receiver if there is a single tab only + */ +@property (assign) BOOL hideForSingleTab; + +/** + * Visibilty of 'add' button + */ +@property (assign) BOOL showAddTabButton; + +/** + * Minimum width of tab bar buttons + */ +@property (assign) NSInteger buttonMinWidth; + +/** + * Minimum width of tab bar buttons + */ +@property (assign) NSInteger buttonMaxWidth; + +/** + * Optimum width of tab bar buttons + */ +@property (assign) NSInteger buttonOptimumWidth; + +/** + * Size tab bar buttons to fit + */ +@property (assign) BOOL sizeButtonsToFit; + +/** + * Should use of overflow menu + */ +@property (assign) BOOL useOverflowMenu; + +/** + * Allow background closing of tabs + */ +@property (assign) BOOL allowsBackgroundTabClosing; + +/** + * Allow resizing + */ +@property (assign) BOOL allowsResizing; + +/** + * Select tabs on mouse down event + */ +@property (assign) BOOL selectsTabsOnMouseDown; + +/** + * Automatically animates + */ +@property (assign) BOOL automaticallyAnimates; + +/** + * Assure that active tab is always visible + */ +@property (assign) BOOL alwaysShowActiveTab; + +/** + * Allow or disallow button scrubbing + */ +@property (assign) BOOL allowsScrubbing; + +/** + * Tear off style + */ +@property (assign) MMTabBarTearOffStyle tearOffStyle; + +/** + * Check if tabs should be resized to fit total width + */ +@property (assign) BOOL resizeTabsToFitTotalWidth; + +/** + * Check if receiver supports specified orientation + * + * @param orientation Orientation (@see MMTabBarOrientation) + * + * @return YES or NO + */ - (BOOL)supportsOrientation:(MMTabBarOrientation)orientation; -#pragma mark - -#pragma mark Visibility +#pragma mark Accessors -- (BOOL)isOverflowButtonVisible; +- (CGFloat)heightOfTabBarButtons; -#pragma mark - #pragma mark Resizing - (NSRect)dividerRect; @@ -336,7 +651,7 @@ typedef enum MMAttachedButtonsEnumerationOptions : NSUInteger { @optional - // Standard NSTabView delegate methods + // Additional NSTabView delegate methods - (BOOL)tabView:(NSTabView *)aTabView shouldCloseTabViewItem:(NSTabViewItem *)tabViewItem; - (void)tabView:(NSTabView *)aTabView willCloseTabViewItem:(NSTabViewItem *)tabViewItem; - (void)tabView:(NSTabView *)aTabView didCloseTabViewItem:(NSTabViewItem *)tabViewItem; diff --git a/MMTabBarView/MMTabBarView/MMTabBarView.m b/MMTabBarView/MMTabBarView/MMTabBarView.m index dcfb2489..88049542 100644 --- a/MMTabBarView/MMTabBarView/MMTabBarView.m +++ b/MMTabBarView/MMTabBarView/MMTabBarView.m @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/19/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // @@ -21,6 +21,7 @@ #import "MMLiveChatTabStyle.h" #import "MMCardTabStyle.h" #import "MMSafariTabStyle.h" +#import "MMYosemiteTabStyle.h" #import "MMTabDragAssistant.h" #import "MMTabBarController.h" #import "MMAttachedTabBarButton.h" @@ -31,87 +32,89 @@ #define DIVIDER_WIDTH 3 -@interface MMTabBarView (/*Private*/) +@interface MMTabBarView () +// reordering @property (assign) BOOL isReorderingTabViewItems; -- (void)_commonInit; - -// providing defaults -- (BOOL)_supportsOrientation:(MMTabBarOrientation)orientation; -- (CGFloat)_heightOfTabBarButtons; -- (CGFloat)_rightMargin; -- (CGFloat)_leftMargin; -- (CGFloat)_topMargin; -- (CGFloat)_bottomMargin; -- (NSSize)_addTabButtonSize; -- (NSRect)_addTabButtonRect; -- (NSSize)_overflowButtonSize; -- (NSRect)_overflowButtonRect; -- (void)_drawTabBarViewInRect:(NSRect)aRect; -- (void)_drawBezelInRect:(NSRect)rect; -- (void)_drawButtonBezelsInRect:(NSRect)rect; -- (void)_drawBezelOfButton:(MMAttachedTabBarButton *)button atIndex:(NSUInteger)index inButtons:(NSArray *)buttons indexOfSelectedButton:(NSUInteger)selIndex inRect:(NSRect)rect; -- (void)_drawBezelOfOverflowButton:(MMOverflowPopUpButton *)overflowButton inRect:(NSRect)rect; -- (void)_drawInteriorInRect:(NSRect)rect; - -// determine positions -- (void)_positionOverflowMenu; -- (void)_positionAddTabButton; -- (void)_checkWindowFrame; - -// convenience -- (void)_bindPropertiesOfAttachedButton:(MMAttachedTabBarButton *)aButton andTabViewItem:(NSTabViewItem *)item; -- (void)_unbindPropertiesOfAttachedButton:(MMAttachedTabBarButton *)aButton; - -// synchronize selection -- (void)_synchronizeSelection; - // resizing @property (assign) BOOL isResizing; -- (NSCursor *)_resizingMouseCursor; -- (void)_beginResizingWithMouseDownEvent:(NSEvent *)theEvent; - -// misc -- (BOOL)_shouldDisplayTabBar; +@property (readonly) NSCursor *resizingMouseCursor; // private actions -- (void)_overflowMenuAction:(id)sender; -- (void)_didClickTabButton:(id)sender; -- (void)_didClickCloseButton:(id)sender; - -// notification handlers -- (void)frameDidChange:(NSNotification *)notification; -- (void)windowDidMove:(NSNotification *)aNotification; - -// update buttons -- (void)_updateAddTabButton; -- (void)_updateOverflowPopUpButton; +- (IBAction)_overflowMenuAction:(id)sender; +- (IBAction)_didClickTabButton:(id)sender; +- (IBAction)_didClickCloseButton:(id)sender; @end @implementation MMTabBarView +{ + // control basics + NSTabView *_tabView; // the tab view being navigated + MMOverflowPopUpButton *_overflowPopUpButton; // for too many tabs + MMRolloverButton *_addTabButton; + MMTabBarController *_controller; + + // Spring-loading. + NSTimer *_springTimer; + NSTabViewItem *_tabViewItemWithSpring; + + // configuration + id _style; + BOOL _onlyShowCloseOnHover; + BOOL _canCloseOnlyTab; + BOOL _disableTabClose; + BOOL _hideForSingleTab; + BOOL _showAddTabButton; + BOOL _sizeButtonsToFit; + BOOL _useOverflowMenu; + BOOL _alwaysShowActiveTab; + BOOL _allowsScrubbing; + NSInteger _resizeAreaCompensation; + MMTabBarOrientation _orientation; + BOOL _automaticallyAnimates; + MMTabBarTearOffStyle _tearOffStyle; + BOOL _allowsBackgroundTabClosing; + BOOL _selectsTabsOnMouseDown; + + // vertical tab resizing + BOOL _allowsResizing; + + // button width + NSInteger _buttonMinWidth; + NSInteger _buttonMaxWidth; + NSInteger _buttonOptimumWidth; + + // animation + MMSlideButtonsAnimation *_slideButtonsAnimation; + + // animation for hide/show + NSViewAnimation *_hideShowTabBarAnimation; + BOOL _isHidden; + NSInteger _tabBarWidth; // stored width of vertical tab bar + + // states + BOOL _needsUpdate; -@dynamic tabView; -@synthesize partnerView = _partnerView; -@dynamic delegate; -@synthesize destinationIndexForDraggedItem = _destinationIndexForDraggedItem; -@synthesize isResizing = _isResizing; -@dynamic needsUpdate; -@synthesize resizeTabsToFitTotalWidth = _resizeTabsToFitTotalWidth; + // delegate + id _delegate; +} static NSMutableDictionary *registeredStyleClasses = nil; -+(void)initialize { - - if (registeredStyleClasses == nil) { - registeredStyleClasses = [[NSMutableDictionary dictionaryWithCapacity:10] retain]; - - [self registerDefaultTabStyleClasses]; ++ (void)initialize +{ + if (self == [MMTabBarView class]) { + if (registeredStyleClasses == nil) { + registeredStyleClasses = [NSMutableDictionary dictionaryWithCapacity:10]; + + [self registerDefaultTabStyleClasses]; + } } } -- (id)initWithFrame:(NSRect)frame { +- (instancetype)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization @@ -136,16 +139,15 @@ - (void)dealloc { // assure that pending animation will stop if (_slideButtonsAnimation) { [_slideButtonsAnimation stopAnimation]; - [_slideButtonsAnimation release], _slideButtonsAnimation = nil; + _slideButtonsAnimation = nil; } if (_hideShowTabBarAnimation) { [_hideShowTabBarAnimation stopAnimation]; - [_hideShowTabBarAnimation release], _hideShowTabBarAnimation = nil; + _hideShowTabBarAnimation = nil; } //Also unwind the spring, if it's wound. [_springTimer invalidate]; - [_springTimer release]; _springTimer = nil; //unbind all the items to prevent crashing //not sure if this is necessary or not @@ -155,16 +157,7 @@ - (void)dealloc { [self removeAttachedButton:aButton]; } - [_overflowPopUpButton release], _overflowPopUpButton = nil; - [_controller release], _controller = nil; - [_tabView release], _tabView = nil; - [_addTabButton release], _addTabButton = nil; - [_partnerView release], _partnerView = nil; - [_style release], _style = nil; - [self unregisterDraggedTypes]; - - [super dealloc]; } - (void)viewWillMoveToWindow:(NSWindow *)aWindow { @@ -172,12 +165,12 @@ - (void)viewWillMoveToWindow:(NSWindow *)aWindow { if (_hideShowTabBarAnimation) { [_hideShowTabBarAnimation stopAnimation]; - [_hideShowTabBarAnimation release]; _hideShowTabBarAnimation = nil; + _hideShowTabBarAnimation = nil; } if (_slideButtonsAnimation) { [_slideButtonsAnimation stopAnimation]; - [_slideButtonsAnimation release]; _slideButtonsAnimation = nil; + _slideButtonsAnimation = nil; } if ([self window]) { @@ -225,7 +218,7 @@ - (void)resetCursorRects { if ([self orientation] == MMTabBarVerticalOrientation) { - NSCursor *cursor = [self _resizingMouseCursor]; + NSCursor *cursor = [self resizingMouseCursor]; [self addCursorRect:[self dividerRect] cursor:cursor]; } } @@ -234,6 +227,14 @@ - (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent { return YES; } +- (NSSize)intrinsicContentSize +{ + if ([_style respondsToSelector:@selector(intrinsicContentSizeOfTabBarView:)]) + return [_style intrinsicContentSizeOfTabBarView:self]; + + return NSMakeSize(NSViewNoInstrinsicMetric, NSViewNoInstrinsicMetric); +} + #pragma mark - #pragma mark Characteristics @@ -354,6 +355,7 @@ + (void)registerDefaultTabStyleClasses { [self registerTabStyleClass:[MMCardTabStyle class]]; [self registerTabStyleClass:[MMLiveChatTabStyle class]]; [self registerTabStyleClass:[MMSafariTabStyle class]]; + [self registerTabStyleClass:[MMYosemiteTabStyle class]]; } + (void)registerTabStyleClass:(Class )aStyleClass { @@ -416,10 +418,8 @@ - (void)moveTabViewItem:(NSTabViewItem *)anItem toIndex:(NSUInteger)index { [self setIsReorderingTabViewItems:YES]; - [anItem retain]; [_tabView removeTabViewItem:anItem]; [_tabView insertTabViewItem:anItem atIndex:index]; - [anItem release]; // assure that item gets re-selected [_tabView selectTabViewItem:anItem]; @@ -567,7 +567,6 @@ - (void)insertAttachedButtonForTabViewItem:(NSTabViewItem *)item atIndex:(NSUInt // add button as subview [self addSubview:button]; - [button release]; // add tab item at specified index if ([[_tabView tabViewItems] indexOfObjectIdenticalTo:item] == NSNotFound) { @@ -849,8 +848,7 @@ - (MMTabBarButton *)tabBarButtonAtPoint:(NSPoint)point - (void)setStyle:(id )newStyle { if (_style != newStyle) { - [_style autorelease]; - _style = [newStyle retain]; + _style = newStyle; // assure that orientation is valid if (![self supportsOrientation:MMTabBarHorizontalOrientation] && _orientation == MMTabBarHorizontalOrientation) @@ -858,11 +856,15 @@ - (void)setStyle:(id )newStyle { if (![self supportsOrientation:MMTabBarVerticalOrientation] && _orientation == MMTabBarVerticalOrientation) [self setOrientation:MMTabBarHorizontalOrientation]; + // update buttons [self _updateAddTabButton]; [self _updateOverflowPopUpButton]; + // set style of attached buttons [[self attachedButtons] makeObjectsPerformSelector:@selector(setStyle:) withObject:_style]; + [self invalidateIntrinsicContentSize]; + [self update:NO]; } } @@ -879,7 +881,6 @@ - (void)setStyleNamed:(NSString *)name { id newStyle = [[(Class)styleClass alloc] init]; [self setStyle:newStyle]; - [newStyle release]; } - (MMTabBarOrientation)orientation { @@ -1092,10 +1093,10 @@ - (void)setTabView:(NSTabView *)view { return; if (_tabView) { - [_tabView release],_tabView = nil; + _tabView = nil; } - _tabView = [view retain]; + _tabView = view; // build buttons from existing tab view items for (NSTabViewItem *item in [_tabView tabViewItems]) { @@ -1106,7 +1107,7 @@ - (void)setTabView:(NSTabView *)view { } } --(CGFloat)heightOfTabBarButtons +- (CGFloat)heightOfTabBarButtons { if ([_style respondsToSelector:@selector(heightOfTabBarButtonsForTabBarView:)]) return [_style heightOfTabBarButtonsForTabBarView:self]; @@ -1303,7 +1304,7 @@ - (void)hideTabBar:(BOOL)hide animate:(BOOL)animate { // stop running animation if (_hideShowTabBarAnimation) { [_hideShowTabBarAnimation stopAnimation]; - [_hideShowTabBarAnimation release], _hideShowTabBarAnimation = nil; + _hideShowTabBarAnimation = nil; } // start animated update of partner view @@ -1587,7 +1588,6 @@ - (void)update:(BOOL)animate { [NSValue valueWithRect:[self addTabButtonRect]], NSViewAnimationEndFrameKey, nil]; [_slideButtonsAnimation addAnimationDictionary:addButtonAnimDict]; - [addButtonAnimDict release]; } else { [self _positionAddTabButton]; } @@ -1642,29 +1642,25 @@ - (BOOL)isDragging { #pragma mark - #pragma mark NSDraggingSource -- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context { - return NSDragOperationCopy; -} - -- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal { - - return [[MMTabDragAssistant sharedDragAssistant] draggingSourceOperationMaskForLocal:isLocal ofTabBarView:self]; +- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context +{ + return [[MMTabDragAssistant sharedDragAssistant] draggingSession:session sourceOperationMaskForDraggingContext:context ofTabBarView:self]; } -- (BOOL)ignoreModifierKeysWhileDragging { +- (BOOL)ignoreModifierKeysForDraggingSession:(NSDraggingSession *)session { return YES; } -- (void)draggedImage:(NSImage *)anImage beganAt:(NSPoint)screenPoint { - [[MMTabDragAssistant sharedDragAssistant] draggedImageBeganAt:screenPoint withTabBarView:self]; +- (void)draggingSession:(NSDraggingSession *)session willBeginAtPoint:(NSPoint)screenPoint { + [[MMTabDragAssistant sharedDragAssistant] draggingSession:session willBeginAtPoint:screenPoint withTabBarView:self]; } -- (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint { - [[MMTabDragAssistant sharedDragAssistant] draggedImageMovedTo:screenPoint]; +- (void)draggingSession:(NSDraggingSession *)session movedToPoint:(NSPoint)screenPoint { + [[MMTabDragAssistant sharedDragAssistant] draggingSession:session movedToPoint:screenPoint]; } -- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation { - [[MMTabDragAssistant sharedDragAssistant] draggedImageEndedAt:aPoint operation:operation]; +- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation { + [[MMTabDragAssistant sharedDragAssistant] draggingSession:session endedAtPoint:screenPoint operation:operation]; } #pragma mark - @@ -1711,18 +1707,18 @@ - (NSDragOperation)draggingUpdated:(id )sender { //If the user has dragged to a different tab, reset the timer. if (_tabViewItemWithSpring != [destinationButton tabViewItem]) { [_springTimer invalidate]; - [_springTimer release]; _springTimer = nil; + _springTimer = nil; _tabViewItemWithSpring = [destinationButton tabViewItem]; } if (!_springTimer) { //Finder's default delay time, as of Tiger, is 668 ms. If the user has never changed it, there's no setting in its defaults, so we default to that amount. - NSNumber *delayNumber = [(NSNumber *)CFPreferencesCopyAppValue((CFStringRef)@"SpringingDelayMilliseconds", (CFStringRef)@"com.apple.finder") autorelease]; + NSNumber *delayNumber = (NSNumber *)CFBridgingRelease(CFPreferencesCopyAppValue((CFStringRef)@"SpringingDelayMilliseconds", (CFStringRef)@"com.apple.finder")); NSTimeInterval delaySeconds = delayNumber ?[delayNumber doubleValue] / 1000.0 : 0.668; - _springTimer = [[NSTimer scheduledTimerWithTimeInterval:delaySeconds + _springTimer = [NSTimer scheduledTimerWithTimeInterval:delaySeconds target:self selector:@selector(fireSpring:) userInfo:sender - repeats:NO] retain]; + repeats:NO]; } return NSDragOperationCopy; } @@ -1732,7 +1728,7 @@ - (NSDragOperation)draggingUpdated:(id )sender { - (void)draggingExited:(id )sender { [_springTimer invalidate]; - [_springTimer release]; _springTimer = nil; + _springTimer = nil; [[MMTabDragAssistant sharedDragAssistant] draggingExitedTabBarView:self draggingInfo:sender]; } @@ -1949,7 +1945,7 @@ - (void)fireSpring:(NSTimer *)timer { _tabViewItemWithSpring = nil; [_springTimer invalidate]; - [_springTimer release]; _springTimer = nil; + _springTimer = nil; } } @@ -2012,7 +2008,7 @@ - (void)tabViewDidChangeNumberOfTabViewItems:(NSTabView *)aTabView { -(void)_finalizeAnimation:(NSAnimation *)animation { if (animation == _slideButtonsAnimation) { - [_slideButtonsAnimation release], _slideButtonsAnimation = nil; + _slideButtonsAnimation = nil; [self _positionAddTabButton]; @@ -2028,7 +2024,7 @@ -(void)_finalizeAnimation:(NSAnimation *)animation { if (!isHidden) [self setHidden:NO]; - [_hideShowTabBarAnimation release], _hideShowTabBarAnimation = nil; + _hideShowTabBarAnimation = nil; [self updateTrackingAreas]; //send the delegate messages @@ -2091,7 +2087,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder } } -- (id)initWithCoder:(NSCoder *)aDecoder +- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self) { @@ -2105,10 +2101,10 @@ - (id)initWithCoder:(NSCoder *)aDecoder [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(frameDidChange:) name:NSViewFrameDidChangeNotification object:self]; if ([aDecoder allowsKeyedCoding]) { - _tabView = [[aDecoder decodeObjectForKey:@"MMtabView"] retain]; - _overflowPopUpButton = [[aDecoder decodeObjectForKey:@"MMOverflowPopUpButton"] retain]; - _addTabButton = [[aDecoder decodeObjectForKey:@"MMaddTabButton"] retain]; - _style = [[aDecoder decodeObjectForKey:@"MMstyle"] retain]; + _tabView = [aDecoder decodeObjectForKey:@"MMtabView"]; + _overflowPopUpButton = [aDecoder decodeObjectForKey:@"MMOverflowPopUpButton"]; + _addTabButton = [aDecoder decodeObjectForKey:@"MMaddTabButton"]; + _style = [aDecoder decodeObjectForKey:@"MMstyle"]; _orientation = (MMTabBarOrientation)[aDecoder decodeIntegerForKey:@"MMorientation"]; _onlyShowCloseOnHover = [aDecoder decodeBoolForKey:@"MMonlyShowCloseOnHover"]; _canCloseOnlyTab = [aDecoder decodeBoolForKey:@"MMcanCloseOnlyTab"]; @@ -2123,7 +2119,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder _buttonMaxWidth = [aDecoder decodeIntegerForKey:@"MMbuttonMaxWidth"]; _buttonOptimumWidth = [aDecoder decodeIntegerForKey:@"MMbuttonOptimumWidth"]; _isHidden = [aDecoder decodeBoolForKey:@"MMisHidden"]; - _partnerView = [[aDecoder decodeObjectForKey:@"MMpartnerView"] retain]; + _partnerView = [aDecoder decodeObjectForKey:@"MMpartnerView"]; _useOverflowMenu = [aDecoder decodeBoolForKey:@"MMuseOverflowMenu"]; _automaticallyAnimates = [aDecoder decodeBoolForKey:@"MMautomaticallyAnimates"]; _alwaysShowActiveTab = [aDecoder decodeBoolForKey:@"MMalwaysShowActiveTab"]; @@ -2216,7 +2212,6 @@ - (void)_didClickCloseButton:(id)sender { return; } - [sender retain]; if (([self delegate]) && ([[self delegate] respondsToSelector:@selector(tabView:shouldCloseTabViewItem:)])) { if (![[self delegate] tabView:_tabView shouldCloseTabViewItem:tabViewItem]) { @@ -2228,15 +2223,12 @@ - (void)_didClickCloseButton:(id)sender { [[self delegate] tabView:_tabView willCloseTabViewItem:tabViewItem]; } - [tabViewItem retain]; [_tabView removeTabViewItem:tabViewItem]; if (([self delegate]) && ([[self delegate] respondsToSelector:@selector(tabView:didCloseTabViewItem:)])) { [[self delegate] tabView:_tabView didCloseTabViewItem:tabViewItem]; } - [tabViewItem release]; - [sender release]; } - (void)frameDidChange:(NSNotification *)notification { @@ -2256,8 +2248,6 @@ - (void)frameDidChange:(NSNotification *)notification { #pragma mark - #pragma mark Private Methods -@synthesize isReorderingTabViewItems = _isReorderingTabViewItems; - - (void)_commonInit { _controller = [[MMTabBarController alloc] initWithTabBarView:self]; @@ -2472,7 +2462,7 @@ - (void)_drawInteriorInRect:(NSRect)rect { labelRect.origin.y += 4.0; NSMutableAttributedString *attrStr; NSString *contents = @"MMTabBarView"; - attrStr = [[[NSMutableAttributedString alloc] initWithString:contents] autorelease]; + attrStr = [[NSMutableAttributedString alloc] initWithString:contents]; NSRange range = NSMakeRange(0, [contents length]); [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0] range:range]; NSMutableParagraphStyle *centeredParagraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; @@ -2481,7 +2471,6 @@ - (void)_drawInteriorInRect:(NSRect)rect { [attrStr addAttribute:NSParagraphStyleAttributeName value:centeredParagraphStyle range:range]; [attrStr drawInRect:labelRect]; - [centeredParagraphStyle release]; return; } } @@ -2653,7 +2642,7 @@ - (void)_synchronizeSelection { } } -- (NSCursor *)_resizingMouseCursor { +- (NSCursor *)resizingMouseCursor { if (NSWidth([self frame]) <= [self buttonMinWidth]) { return [NSCursor resizeRightCursor]; @@ -2678,7 +2667,7 @@ - (void)_beginResizingWithMouseDownEvent:(NSEvent *)theEvent { [self setIsResizing:YES]; - NSCursor *cursor = [self _resizingMouseCursor]; + NSCursor *cursor = [self resizingMouseCursor]; [cursor set]; while ((nextEvent = [[self window] nextEventMatchingMask:NSLeftMouseUpMask | NSLeftMouseDraggedMask untilDate:expiration inMode:NSEventTrackingRunLoopMode dequeue:YES]) != nil) { @@ -2696,7 +2685,7 @@ - (void)_beginResizingWithMouseDownEvent:(NSEvent *)theEvent { CGFloat resizeAmount = [nextEvent deltaX]; if ((currentPoint.x > frame.size.width && resizeAmount > 0) || (currentPoint.x < frame.size.width && resizeAmount < 0)) { - cursor = [self _resizingMouseCursor]; + cursor = [self resizingMouseCursor]; [cursor set]; NSRect partnerFrame = [_partnerView frame]; @@ -2751,7 +2740,7 @@ - (void)_updateAddTabButton { if (_addTabButton) { [_addTabButton removeFromSuperview]; - [_addTabButton release], _addTabButton = nil; + _addTabButton = nil; } // new tab button NSRect addTabButtonRect = [self addTabButtonRect]; diff --git a/MMTabBarView/MMTabBarView/MMTabDragAssistant.h b/MMTabBarView/MMTabBarView/MMTabDragAssistant.h index d28a4693..6f1cadfa 100644 --- a/MMTabBarView/MMTabBarView/MMTabDragAssistant.h +++ b/MMTabBarView/MMTabBarView/MMTabDragAssistant.h @@ -17,58 +17,33 @@ extern NSString *AttachedTabBarButtonUTI; -@interface MMTabDragAssistant : NSObject { - -@private - - NSPoint _currentMouseLocation; - - // standard drag & drop support - MMTabBarView *_sourceTabBar; - MMAttachedTabBarButton *_attachedTabBarButton; - - MMTabPasteboardItem *_pasteboardItem; - MMTabBarView *_destinationTabBar; - BOOL _isDragging; - - // sliding support - BOOL _isSliding; - - // Support for dragging into new windows - MMTabDragWindowController *_draggedTab; - MMTabDragWindowController *_draggedView; - NSSize _dragWindowOffset; - NSTimer *_fadeTimer; - BOOL _centersDragWindows; - MMTabBarTearOffStyle _currentTearOffStyle; - - // Animation - MMSlideButtonsAnimation *_slideButtonsAnimation; -} - -@property (retain) MMTabBarView *sourceTabBar; -@property (retain) MMAttachedTabBarButton *attachedTabBarButton; -@property (retain) MMTabPasteboardItem *pasteboardItem; -@property (retain) MMTabBarView *destinationTabBar; +@interface MMTabDragAssistant : NSObject + +// Creation/destruction ++ (instancetype)sharedDragAssistant; + +#pragma mark Properties + +@property (strong) MMTabBarView *sourceTabBar; +@property (strong) MMAttachedTabBarButton *attachedTabBarButton; +@property (strong) MMTabPasteboardItem *pasteboardItem; +@property (strong) MMTabBarView *destinationTabBar; @property (assign) BOOL isDragging; @property (assign) NSPoint currentMouseLocation; @property (assign) BOOL isSliding; -// Creation/destruction -+ (MMTabDragAssistant *)sharedDragAssistant; - #pragma mark Dragging Source Handling -- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal ofTabBarView:(MMTabBarView *)tabBarView; +- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context ofTabBarView:(MMTabBarView *)tabBarView; - (BOOL)shouldStartDraggingAttachedTabBarButton:(MMAttachedTabBarButton *)aButton ofTabBarView:(MMTabBarView *)tabBarView withMouseDownEvent:(NSEvent *)event; - (void)startDraggingAttachedTabBarButton:(MMAttachedTabBarButton *)aButton fromTabBarView:(MMTabBarView *)tabBarView withMouseDownEvent:(NSEvent *)event; -- (void)draggedImageBeganAt:(NSPoint)aPoint withTabBarView:(MMTabBarView *)tabBarView; -- (void)draggedImageMovedTo:(NSPoint)aPoint; -- (void)draggedImageEndedAt:(NSPoint)aPoint operation:(NSDragOperation)operation; +- (void)draggingSession:(NSDraggingSession *)session willBeginAtPoint:(NSPoint)screenPoint withTabBarView:(MMTabBarView *)tabBarView; +- (void)draggingSession:(NSDraggingSession *)session movedToPoint:(NSPoint)screenPoint; +- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation; #pragma mark Dragging Destination Handling diff --git a/MMTabBarView/MMTabBarView/MMTabDragAssistant.m b/MMTabBarView/MMTabBarView/MMTabDragAssistant.m index 1da0eec8..f9305c46 100644 --- a/MMTabBarView/MMTabBarView/MMTabDragAssistant.m +++ b/MMTabBarView/MMTabBarView/MMTabDragAssistant.m @@ -14,63 +14,34 @@ #import "MMSlideButtonsAnimation.h" #import "NSView+MMTabBarViewExtensions.h" -@interface MMTabBarView (SharedPrivate) - -@property (assign) BOOL isReorderingTabViewItems; - -@end - -@interface MMTabBarButton (SharedPrivate) - -- (NSRect)_indicatorRectForBounds:(NSRect)theRect; - -@end - -@interface MMTabDragAssistant (/*Private*/) - -- (NSUInteger)_destinationIndexForButton:(MMAttachedTabBarButton *)aButton atPoint:(NSPoint)aPoint inTabBarView:(MMTabBarView *)tabBarView; - -- (NSImage *)_imageForViewOfAttachedButton:(MMAttachedTabBarButton *)aButton forTabBarView:(MMTabBarView *)tabBarView styleMask:(NSUInteger *)outMask; -- (NSImage *)_miniwindowImageOfWindow:(NSWindow *)window; -- (void)_expandWindow:(NSWindow *)window atPoint:(NSPoint)point; - -- (void)_dragAttachedTabBarButton:(MMAttachedTabBarButton *)aButton ofTabBarView:(MMTabBarView *)tabBarView at:(NSPoint)buttonLocation event:(NSEvent *)theEvent source:(id)sourceObject; - -- (void)_slideBackTabBarButton:(MMAttachedTabBarButton *)aButton inTabBarView:(MMTabBarView *)tabBarView; - -- (NSUInteger)_moveAttachedTabBarButton:(MMAttachedTabBarButton *)aButton inTabBarView:(MMTabBarView *)tabBarView fromIndex:(NSUInteger)sourceIndex toIndex:(NSUInteger)destinationIndex; - -- (void)_draggingExitedTabBarView:(MMTabBarView *)tabBarView withPasteboardItem:(MMTabPasteboardItem *)pasteboardItem; - -- (MMTabPasteboardItem *)_tabPasteboardItemOfDraggingInfo:(id )draggingInfo; - -- (void)_beginDraggingWindowForPasteboardItem:(MMTabPasteboardItem *)pasteboardItem isSourceWindow:(BOOL)isSourceWindow; -- (void)_endDraggingWindowForPasteboardItem:(MMTabPasteboardItem *)pasteboardItem; - -- (void)_fadeInDragWindow:(NSTimer *)timer; -- (void)_fadeOutDragWindow:(NSTimer *)timer; +#import "MMTabBarView.Private.h" +#import "MMTabBarButton.Private.h" +@interface MMTabDragAssistant () @end NSString *AttachedTabBarButtonUTI = @"de.monscheuer.mmtabbarview.attachedbutton"; @implementation MMTabDragAssistant - -@synthesize sourceTabBar = _sourceTabBar; -@synthesize attachedTabBarButton = _attachedTabBarButton; -@synthesize pasteboardItem = _pasteboardItem; -@synthesize destinationTabBar = _destinationTabBar; -@synthesize isDragging = _isDragging; -@synthesize currentMouseLocation = _currentMouseLocation; - -@synthesize isSliding = _isSliding; +{ + // Support for dragging into new windows + MMTabDragWindowController *_draggedTab; + MMTabDragWindowController *_draggedView; + NSSize _dragWindowOffset; + NSTimer *_fadeTimer; + BOOL _centersDragWindows; + MMTabBarTearOffStyle _currentTearOffStyle; + + // Animation + MMSlideButtonsAnimation *_slideButtonsAnimation; +} static MMTabDragAssistant *sharedDragAssistant = nil; #pragma mark - #pragma mark Creation/Destruction -+ (MMTabDragAssistant *)sharedDragAssistant { ++ (instancetype)sharedDragAssistant { if (!sharedDragAssistant) { sharedDragAssistant = [[MMTabDragAssistant alloc] init]; } @@ -78,7 +49,7 @@ + (MMTabDragAssistant *)sharedDragAssistant { return sharedDragAssistant; } -- (id)init { +- (instancetype)init { if ((self = [super init])) { _destinationTabBar = nil; _isDragging = NO; @@ -91,23 +62,24 @@ - (id)init { } - (void)dealloc { + if (_slideButtonsAnimation) { [_slideButtonsAnimation stopAnimation]; - [_slideButtonsAnimation release], _slideButtonsAnimation = nil; + _slideButtonsAnimation = nil; } - - [_destinationTabBar release], _destinationTabBar = nil; - [_pasteboardItem release], _pasteboardItem = nil; - [super dealloc]; } #pragma mark - #pragma mark Dragging Source Handling -- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal ofTabBarView:(MMTabBarView *)tabBarView { +- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context ofTabBarView:(MMTabBarView *)tabBarView { + if (context == NSDraggingContextOutsideApplication) + return NSDragOperationNone; + else if (context == NSDraggingContextWithinApplication) + return NSDragOperationMove; - return(isLocal ? NSDragOperationMove : NSDragOperationNone); + return NSDragOperationNone; } - (BOOL)shouldStartDraggingAttachedTabBarButton:(MMAttachedTabBarButton *)aButton ofTabBarView:(MMTabBarView *)tabBarView withMouseDownEvent:(NSEvent *)event { @@ -124,9 +96,10 @@ - (void)startDraggingAttachedTabBarButton:(MMAttachedTabBarButton *)aButton from [self _dragAttachedTabBarButton:aButton ofTabBarView:tabBarView at:[aButton frame].origin event:event source:tabBarView]; } -- (void)draggedImageBeganAt:(NSPoint)aPoint withTabBarView:(MMTabBarView *)tabBarView { +- (void)draggingSession:(NSDraggingSession *)session willBeginAtPoint:(NSPoint)screenPoint withTabBarView:(MMTabBarView *)tabBarView { + if (_draggedTab) { - [[_draggedTab window] setFrameTopLeftPoint:aPoint]; + [[_draggedTab window] setFrameTopLeftPoint:screenPoint]; [[_draggedTab window] orderFront:nil]; if ([[tabBarView tabView] numberOfTabViewItems] == 1) { @@ -135,37 +108,35 @@ - (void)draggedImageBeganAt:(NSPoint)aPoint withTabBarView:(MMTabBarView *)tabBa } } -- (void)draggedImageMovedTo:(NSPoint)aPoint { +- (void)draggingSession:(NSDraggingSession *)session movedToPoint:(NSPoint)screenPoint { if (_draggedTab) { if (_centersDragWindows) { if ([_draggedTab isAnimating]) { return; } - //Ignore aPoint, as it seems to give wacky values NSRect frame = [[_draggedTab window] frame]; - frame.origin = [NSEvent mouseLocation]; + frame.origin = screenPoint; //[NSEvent mouseLocation]; frame.origin.x -= frame.size.width / 2; frame.origin.y -= frame.size.height / 2; [[_draggedTab window] setFrame:frame display:NO]; } else { - [[_draggedTab window] setFrameTopLeftPoint:aPoint]; + [[_draggedTab window] setFrameTopLeftPoint:screenPoint]; } if (_draggedView) { //move the view representation with the tab //the relative position of the dragged view window will be different //depending on the position of the tab bar relative to the controlled tab view - - aPoint.y -= [[_draggedTab window] frame].size.height; - aPoint.x -= _dragWindowOffset.width; - aPoint.y += _dragWindowOffset.height; - [[_draggedView window] setFrameTopLeftPoint:aPoint]; + screenPoint.y -= [[_draggedTab window] frame].size.height; + screenPoint.x -= _dragWindowOffset.width; + screenPoint.y += _dragWindowOffset.height; + [[_draggedView window] setFrameTopLeftPoint:screenPoint]; } } } -- (void)draggedImageEndedAt:(NSPoint)aPoint operation:(NSDragOperation)operation { +- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation { MMTabPasteboardItem *pasteboardItem = [self pasteboardItem]; @@ -180,7 +151,7 @@ - (void)draggedImageEndedAt:(NSPoint)aPoint operation:(NSDragOperation)operation if ([self destinationTabBar] == nil && sourceDelegate && [sourceDelegate respondsToSelector:@selector(tabView:newTabBarViewForDraggedTabViewItem:atPoint:)]) { - MMTabBarView *tabBarView = [sourceDelegate tabView:sourceTabView newTabBarViewForDraggedTabViewItem:[_attachedTabBarButton tabViewItem] atPoint:aPoint]; + MMTabBarView *tabBarView = [sourceDelegate tabView:sourceTabView newTabBarViewForDraggedTabViewItem:[_attachedTabBarButton tabViewItem] atPoint:screenPoint]; if (tabBarView) { @@ -403,13 +374,11 @@ - (void)finishDragOfPasteboardItem:(MMTabPasteboardItem *)pasteboardItem { if (_draggedTab) { [[_draggedTab window] orderOut:nil]; - [_draggedTab release]; _draggedTab = nil; } if (_draggedView) { [[_draggedView window] orderOut:nil]; - [_draggedView release]; _draggedView = nil; } @@ -463,7 +432,7 @@ - (void)_finalizeAnimation:(NSAnimation *)animation { i++; } - [_slideButtonsAnimation release], _slideButtonsAnimation = nil; + _slideButtonsAnimation = nil; } } @@ -620,7 +589,7 @@ - (NSImage *)_imageForViewOfAttachedButton:(MMAttachedTabBarButton *)aButton for } else { //the delegate doesn't give a custom image, so use an image of the view NSView *tabView = [[aButton tabViewItem] view]; - viewImage = [[[NSImage alloc] initWithSize:[tabView frame].size] autorelease]; + viewImage = [[NSImage alloc] initWithSize:[tabView frame].size]; [viewImage lockFocus]; [tabView drawRect:[tabView bounds]]; [viewImage unlockFocus]; @@ -635,7 +604,7 @@ - (NSImage *)_imageForViewOfAttachedButton:(MMAttachedTabBarButton *)aButton for - (NSImage *)_miniwindowImageOfWindow:(NSWindow *)window { NSRect rect = [window frame]; - NSImage *image = [[[NSImage alloc] initWithSize:rect.size] autorelease]; + NSImage *image = [[NSImage alloc] initWithSize:rect.size]; [image lockFocus]; rect.origin = NSZeroPoint; CGContextCopyWindowCaptureContentsToRect([[NSGraphicsContext currentContext] graphicsPort], *(CGRect *)&rect, [NSApp contextID], [window windowNumber], 0); @@ -662,17 +631,17 @@ - (void)_dragAttachedTabBarButton:(MMAttachedTabBarButton *)aButton ofTabBarView NSDate *expiration = [NSDate distantFuture]; BOOL continueDetached = NO; - // write to pasteboard - NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; + // create pasteboard item MMTabPasteboardItem *pasteboardItem = [[MMTabPasteboardItem alloc] init]; [pasteboardItem setSourceIndex:[tabBarView indexOfTabViewItem:[aButton tabViewItem]]]; [pasteboardItem setString:[aButton title] forType:AttachedTabBarButtonUTI]; - [pboard clearContents]; - [pboard writeObjects:[NSArray arrayWithObject:pasteboardItem]]; + + // create dragging item + NSDraggingItem *draggingItem = [[NSDraggingItem alloc] initWithPasteboardWriter:pasteboardItem]; + [self setSourceTabBar:tabBarView]; [self setAttachedTabBarButton:aButton]; [self setPasteboardItem:pasteboardItem]; - [pasteboardItem release]; // informal [[NSNotificationCenter defaultCenter] postNotificationName:MMTabDragDidBeginNotification object:pasteboardItem]; @@ -782,11 +751,8 @@ - (void)_dragAttachedTabBarButton:(MMAttachedTabBarButton *)aButton ofTabBarView [self setIsSliding:NO]; [aButton setIsInDraggedSlide:NO]; - [aButton retain]; - - [self _dragDetachedButton:aButton ofTabBarView:tabBarView withEvent:firstEvent pasteboard:pboard source:sourceObject]; + [self _dragDetachedButton:aButton ofTabBarView:tabBarView withEvent:firstEvent draggingItem:draggingItem source:sourceObject]; - [aButton release]; } else { [self setPasteboardItem:nil]; } @@ -797,7 +763,7 @@ - (void)_detachButton:(MMAttachedTabBarButton *)aButton fromTabBarView:(MMTabBar [tabBarView update]; } -- (void)_dragDetachedButton:(MMAttachedTabBarButton *)aButton ofTabBarView:(MMTabBarView *)tabBarView withEvent:(NSEvent *)theEvent pasteboard:(NSPasteboard *)pboard source:(id)source { +- (void)_dragDetachedButton:(MMAttachedTabBarButton *)aButton ofTabBarView:(MMTabBarView *)tabBarView withEvent:(NSEvent *)theEvent draggingItem:(NSDraggingItem *)draggingItem source:(id)source { [self setIsDragging:YES]; @@ -812,15 +778,18 @@ - (void)_dragDetachedButton:(MMAttachedTabBarButton *)aButton ofTabBarView:(MMTa _draggedTab = [[MMTabDragWindowController alloc] initWithImage:dragImage styleMask:NSBorderlessWindowMask tearOffStyle:_currentTearOffStyle]; NSPoint location = [aButton frame].origin; - - [tabBarView dragImage:[[[NSImage alloc] initWithSize:NSMakeSize(1, 1)] autorelease] at:location offset:NSZeroSize event:theEvent pasteboard:pboard source:source slideBack:NO]; + + NSImage *dummyImage = [[NSImage alloc] initWithSize:NSMakeSize(1, 1)]; + [draggingItem setDraggingFrame:NSMakeRect(location.x, location.y, 1, 1) contents:dummyImage]; + + [tabBarView beginDraggingSessionWithItems:[NSArray arrayWithObject:draggingItem] event:theEvent source:source]; } - (void)_slideBackTabBarButton:(MMAttachedTabBarButton *)aButton inTabBarView:(MMTabBarView *)tabBarView { if (_slideButtonsAnimation != nil) { [_slideButtonsAnimation stopAnimation]; - [_slideButtonsAnimation release], _slideButtonsAnimation = nil; + _slideButtonsAnimation = nil; } [aButton slideAnimationWillStart]; @@ -838,7 +807,7 @@ - (NSUInteger)_moveAttachedTabBarButton:(MMAttachedTabBarButton *)aButton inTabB if (_slideButtonsAnimation != nil) { [_slideButtonsAnimation stopAnimation]; - [_slideButtonsAnimation release], _slideButtonsAnimation = nil; + _slideButtonsAnimation = nil; } NSRange slidingRange; diff --git a/MMTabBarView/MMTabBarView/MMTabDragView.h b/MMTabBarView/MMTabBarView/MMTabDragView.h index 29ef06d7..be3c9192 100644 --- a/MMTabBarView/MMTabBarView/MMTabDragView.h +++ b/MMTabBarView/MMTabBarView/MMTabDragView.h @@ -8,14 +8,10 @@ #import -@interface MMTabDragView : NSView { - NSImage *_image; - NSImage *_alternateImage; - CGFloat _alpha; -} -- (void)setFadeValue:(CGFloat)value; -- (NSImage *)image; -- (void)setImage:(NSImage *)image; -- (NSImage *)alternateImage; -- (void)setAlternateImage:(NSImage *)image; +@interface MMTabDragView : NSView + +@property (assign) CGFloat alpha; +@property (strong) NSImage *image; +@property (strong) NSImage *alternateImage; + @end diff --git a/MMTabBarView/MMTabBarView/MMTabDragView.m b/MMTabBarView/MMTabBarView/MMTabDragView.m index 51449cfd..4aa7bac3 100644 --- a/MMTabBarView/MMTabBarView/MMTabDragView.m +++ b/MMTabBarView/MMTabBarView/MMTabDragView.m @@ -8,22 +8,15 @@ #import "MMTabDragView.h" - @implementation MMTabDragView -- (id)initWithFrame:(NSRect)frame { +- (instancetype)initWithFrame:(NSRect)frame { if ((self = [super initWithFrame:frame])) { _alpha = 1.0; } return self; } -- (void)dealloc { - [_image release]; - [_alternateImage release]; - [super dealloc]; -} - - (void)drawRect:(NSRect)rect { //1.0 fade means show the primary image //0.0 fade means show the secondary image @@ -37,26 +30,4 @@ - (void)drawRect:(NSRect)rect { [_alternateImage drawInRect:[self bounds] fromRect:srcRect operation:NSCompositeSourceOver fraction:alternateAlpha respectFlipped:YES hints:nil]; } -- (void)setFadeValue:(CGFloat)value { - _alpha = value; -} - -- (NSImage *)image { - return _image; -} - -- (void)setImage:(NSImage *)image { - [_image release]; - _image = [image retain]; -} - -- (NSImage *)alternateImage { - return _alternateImage; -} - -- (void)setAlternateImage:(NSImage *)image { - [_alternateImage release]; - _alternateImage = [image retain]; -} - @end diff --git a/MMTabBarView/MMTabBarView/MMTabDragWindow.h b/MMTabBarView/MMTabBarView/MMTabDragWindow.h index c248149d..266ca82c 100644 --- a/MMTabBarView/MMTabBarView/MMTabDragWindow.h +++ b/MMTabBarView/MMTabBarView/MMTabDragWindow.h @@ -10,11 +10,12 @@ @class MMTabDragView; -@interface MMTabDragWindow : NSWindow { - MMTabDragView *_dragView; -} -+ (MMTabDragWindow *)dragWindowWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask; +@interface MMTabDragWindow : NSWindow + ++ (instancetype)dragWindowWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask; + +- (instancetype)initWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask; + +@property (readonly) MMTabDragView *dragView; -- (id)initWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask; -- (MMTabDragView *)dragView; @end diff --git a/MMTabBarView/MMTabBarView/MMTabDragWindow.m b/MMTabBarView/MMTabBarView/MMTabDragWindow.m index d26286a8..7db41c06 100644 --- a/MMTabBarView/MMTabBarView/MMTabDragWindow.m +++ b/MMTabBarView/MMTabBarView/MMTabDragWindow.m @@ -10,16 +10,19 @@ #import "MMTabDragView.h" @implementation MMTabDragWindow +{ + MMTabDragView *_dragView; +} -+ (MMTabDragWindow *)dragWindowWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask { - return [[[MMTabDragWindow alloc] initWithImage:image styleMask:styleMask] autorelease]; ++ (instancetype)dragWindowWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask { + return [[MMTabDragWindow alloc] initWithImage:image styleMask:styleMask]; } -- (id)initWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask { +- (instancetype)initWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask { NSSize size = [image size]; if ((self = [super initWithContentRect:NSMakeRect(0, 0, size.width, size.height) styleMask:styleMask backing:NSBackingStoreBuffered defer:NO])) { - _dragView = [[[MMTabDragView alloc] initWithFrame:NSMakeRect(0, 0, size.width, size.height)] autorelease]; + _dragView = [[MMTabDragView alloc] initWithFrame:NSMakeRect(0, 0, size.width, size.height)]; [self setContentView:_dragView]; [self setLevel:NSStatusWindowLevel]; [self setIgnoresMouseEvents:YES]; diff --git a/MMTabBarView/MMTabBarView/MMTabDragWindowController.h b/MMTabBarView/MMTabBarView/MMTabDragWindowController.h index 157adc52..c5ef6e26 100644 --- a/MMTabBarView/MMTabBarView/MMTabDragWindowController.h +++ b/MMTabBarView/MMTabBarView/MMTabDragWindowController.h @@ -14,20 +14,16 @@ @class MMTabDragView; -@interface MMTabDragWindowController : NSWindowController { - MMTabBarTearOffStyle _tearOffStyle; - MMTabDragView *_view; - NSAnimation *_animation; - NSTimer *_timer; - - BOOL _showingAlternate; - NSRect _originalWindowFrame; -} -- (id)initWithImage:(NSImage *)image styleMask:(NSUInteger) styleMask tearOffStyle:(MMTabBarTearOffStyle)tearOffStyle; - -- (NSImage *)image; -- (NSImage *)alternateImage; -- (void)setAlternateImage:(NSImage *)image; -- (BOOL)isAnimating; +@interface MMTabDragWindowController : NSWindowController + +- (instancetype)initWithImage:(NSImage *)image styleMask:(NSUInteger) styleMask tearOffStyle:(MMTabBarTearOffStyle)tearOffStyle; + +@property (readonly) NSImage *image; + +@property (strong) NSImage *alternateImage; + +@property (readonly) BOOL isAnimating; + - (void)switchImages; + @end diff --git a/MMTabBarView/MMTabBarView/MMTabDragWindowController.m b/MMTabBarView/MMTabBarView/MMTabDragWindowController.m index 2c578fc7..66e5e465 100644 --- a/MMTabBarView/MMTabBarView/MMTabDragWindowController.m +++ b/MMTabBarView/MMTabBarView/MMTabDragWindowController.m @@ -11,11 +11,20 @@ #import "MMTabDragView.h" @implementation MMTabDragWindowController +{ + MMTabBarTearOffStyle _tearOffStyle; + MMTabDragView *_view; + NSAnimation *_animation; + NSTimer *_timer; + + BOOL _showingAlternate; + NSRect _originalWindowFrame; +} -- (id)initWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask tearOffStyle:(MMTabBarTearOffStyle)tearOffStyle { +- (instancetype)initWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask tearOffStyle:(MMTabBarTearOffStyle)tearOffStyle { MMTabDragWindow *window = [MMTabDragWindow dragWindowWithImage:image styleMask:styleMask]; if ((self = [super initWithWindow:window])) { - _view = [[window dragView] retain]; + _view = [window dragView]; _tearOffStyle = tearOffStyle; if (tearOffStyle == MMTabBarTearOffMiniwindow) { @@ -32,13 +41,6 @@ - (void)dealloc { if (_timer) { [_timer invalidate]; } - - if (_animation) { - [_animation release]; - } - - [_view release]; - [super dealloc]; } - (NSImage *)image { @@ -69,7 +71,6 @@ - (void)switchImages { //An animation already exists, get the current progress progress = 1.0f - [_animation currentProgress]; [_animation stopAnimation]; - [_animation release]; } //begin animating @@ -98,11 +99,11 @@ - (void)animateTimer:(NSTimer *)timer { frame.origin.x = mousePoint.x - (frame.size.width / 2); frame.origin.y = mousePoint.y - (frame.size.height / 2); - [_view setFadeValue:_showingAlternate ? 1.0f - animationValue : animationValue]; + [_view setAlpha:_showingAlternate ? 1.0f - animationValue : animationValue]; [[self window] setFrame:frame display:YES]; if (![_animation isAnimating]) { - [_animation release], _animation = nil; + _animation = nil; [timer invalidate]; _timer = nil; } diff --git a/MMTabBarView/MMTabBarView/MMTabPasteboardItem.h b/MMTabBarView/MMTabBarView/MMTabPasteboardItem.h index 4e6fa030..9ae45772 100644 --- a/MMTabBarView/MMTabBarView/MMTabPasteboardItem.h +++ b/MMTabBarView/MMTabBarView/MMTabPasteboardItem.h @@ -11,9 +11,7 @@ @class MMAttachedTabBarButton; @class MMTabBarView; -@interface MMTabPasteboardItem : NSPasteboardItem { - NSUInteger _sourceIndex; -} +@interface MMTabPasteboardItem : NSPasteboardItem @property (assign) NSUInteger sourceIndex; diff --git a/MMTabBarView/MMTabBarView/MMTabPasteboardItem.m b/MMTabBarView/MMTabBarView/MMTabPasteboardItem.m index 21ee3a9e..75815f0c 100644 --- a/MMTabBarView/MMTabBarView/MMTabPasteboardItem.m +++ b/MMTabBarView/MMTabBarView/MMTabPasteboardItem.m @@ -10,9 +10,7 @@ @implementation MMTabPasteboardItem -@synthesize sourceIndex = _sourceIndex; - -- (id)init { +- (instancetype)init { self = [super init]; if (self) { _sourceIndex = NSNotFound; diff --git a/MMTabBarView/MMTabBarView/MMTabStyle.h b/MMTabBarView/MMTabBarView/MMTabStyle.h index b31a5873..216ee682 100644 --- a/MMTabBarView/MMTabBarView/MMTabStyle.h +++ b/MMTabBarView/MMTabBarView/MMTabStyle.h @@ -17,72 +17,443 @@ @protocol MMTabStyle -// identity +#pragma mark Style name + +/** + * Name of style + * + * @return Style name + */ + (NSString *)name; -- (NSString *)name; + +/** + * Name of style + */ +@property (readonly) NSString *name; @optional -// tab view specific parameters +#pragma mark General + +/** + * Get intrinsic content size of tab bar + * + * @param tabBarView A tab bar view + * + * @return Intrinsic content size + */ +- (NSSize)intrinsicContentSizeOfTabBarView:(MMTabBarView *)tabBarView; + +/** + * Get height of tab bar buttons + * + * @param tabBarView A tab bar view + * + * @return The height of tab bar buttons + */ +- (CGFloat)heightOfTabBarButtonsForTabBarView:(MMTabBarView *)tabBarView; + +/** + * Check if tab style supports given orientation for specified tab bar view + * + * @param orientation An orientation + * @param tabBarView The tab bar view + * + * @return YES or NO + */ - (BOOL)supportsOrientation:(MMTabBarOrientation)orientation forTabBarView:(MMTabBarView *)tabBarView; + +#pragma mark Working with margins + +/** + * Get left margin for specified tab bar view + * + * @param tabBarView The tab bar view + * + * @return Margin value + */ - (CGFloat)leftMarginForTabBarView:(MMTabBarView *)tabBarView; + +/** + * Get right margin for specified tab bar view + * + * @param tabBarView The tab bar view + * + * @return Margin value + */ - (CGFloat)rightMarginForTabBarView:(MMTabBarView *)tabBarView; + +/** + * Get top margin for specified tab bar view + * + * @param tabBarView The tab bar view + * + * @return Margin value + */ - (CGFloat)topMarginForTabBarView:(MMTabBarView *)tabBarView; + +/** + * Get bottom margin for specified tab bar view + * + * @param tabBarView The tab bar view + * + * @return Margin value + */ - (CGFloat)bottomMarginForTabBarView:(MMTabBarView *)tabBarView; + +#pragma mark Working with 'add button' + +/** + * Get size of tab bar view's 'add button' + * + * @param tabBarView A tab bar view + * + * @return Size of 'add button' + */ - (NSSize)addTabButtonSizeForTabBarView:(MMTabBarView *)tabBarView; + +/** + * Get frame rect of tab bar view's 'add button' + * + * @param tabBarView A tab bar view + * + * @return Frame rect of 'add button' + */ - (NSRect)addTabButtonRectForTabBarView:(MMTabBarView *)tabBarView; + +/** + * Update 'add button' + * + * @param aButton The 'add button' + * @param tabBarView The tab bar view + */ +- (void)updateAddButton:(MMRolloverButton *)aButton ofTabBarView:(MMTabBarView *)tabBarView; + +#pragma mark Working with 'overflow button' + +/** + * Get size of tab bar view's 'overflow button' + * + * @param tabBarView A tab bar view + * + * @return Size of 'overflow button' + */ - (NSSize)overflowButtonSizeForTabBarView:(MMTabBarView *)tabBarView; + +/** + * Get frame rect of tab bar view's 'overflow button' + * + * @param tabBarView A tab bar view + * + * @return Frame rect of 'overflow button' + */ - (NSRect)overflowButtonRectForTabBarView:(MMTabBarView *)tabBarView; -- (CGFloat)heightOfTabBarButtonsForTabBarView:(MMTabBarView *)tabBarView; -- (void)updateAddButton:(MMRolloverButton *)aButton ofTabBarView:(MMTabBarView *)tabBarView; +/** + * Update 'overflow button' + * + * @param aButton The 'overflow button' + * @param tabBarView The tab bar view + */ - (void)updateOverflowPopUpButton:(MMOverflowPopUpButton *)aButton ofTabBarView:(MMTabBarView *)tabBarView; -// cell values +#pragma mark Working with tab bar button cells + +/** + * Get attributed string representing object count + * + * @param cell A tab bar button cell + * + * @return Object count (attributed string) + */ - (NSAttributedString *)attributedObjectCountStringValueForTabCell:(MMTabBarButtonCell *)cell; + +/** + * Get attributed string value + * + * @param cell A tab bar button cell + * + * @return Attributed string value + */ - (NSAttributedString *)attributedStringValueForTabCell:(MMTabBarButtonCell *)cell; -// Constraints +/** + * Minimum width of tab bar button cell + * + * @param cell A tab bar button cell + * + * @return Minimum width + */ - (CGFloat)minimumWidthOfTabCell:(MMTabBarButtonCell *)cell; + +/** + * Desired width of tab bar button cell + * + * @param cell A tab bar button cell + * + * @return Desired width + */ - (CGFloat)desiredWidthOfTabCell:(MMTabBarButtonCell *)cell; -// Update Buttons -- (BOOL)updateCloseButton:(MMRolloverButton *)closeButton ofTabCell:(MMTabBarButtonCell *)cell; // returning NO will hide the close button +/** + * Update close button + * + * @param closeButton A close button (@see MMRolloverButton) + * @param cell A tab bar button cell + * + * @return YES or NO, returning NO will hide the close button + */ +- (BOOL)updateCloseButton:(MMRolloverButton *)closeButton ofTabCell:(MMTabBarButtonCell *)cell; -// Providing Images +/** + * Get close button image + * + * @param type Button image type (@see MMCloseButtonImageType) + * @param cell A tab bar button cell + * + * @return The close button image + */ - (NSImage *)closeButtonImageOfType:(MMCloseButtonImageType)type forTabCell:(MMTabBarButtonCell *)cell; -// Determining Cell Size +#pragma mark Determining rects of tab bar button cell components + +/** + * Get drawing rect for bounds of tab bar button cell + * + * @param theRect Bounds rect + * @param cell Tab bar button cell + * + * @return A drawing rect + */ - (NSRect)drawingRectForBounds:(NSRect)theRect ofTabCell:(MMTabBarButtonCell *)cell; + +/** + * Get size of close button for bounds of tab bar button cell + * + * @param theRect Bounds rect + * @param cell A tab bar button cell + * + * @return Close button size + */ - (NSSize)closeButtonSizeForBounds:(NSRect)theRect ofTabCell:(MMTabBarButtonCell *)cell; + +/** + * Get rect of close button for bounds of tab bar button cell + * + * @param theRect Bounds rect + * @param cell A tab bar button cell + * + * @return Close button rect + */ - (NSRect)closeButtonRectForBounds:(NSRect)theRect ofTabCell:(MMTabBarButtonCell *)cell; +/** + * Get rect of title for bounds of tab bar button cell + * + * @param theRect Bounds rect + * @param cell A tab bar button cell + * + * @return Title rect + */ - (NSRect)titleRectForBounds:(NSRect)theRect ofTabCell:(MMTabBarButtonCell *)cell; + +/** + * Get rect of icon for bounds of tab bar button cell + * + * @param theRect Bounds rect + * @param cell A tab bar button cell + * + * @return Icon rect + */ - (NSRect)iconRectForBounds:(NSRect)theRect ofTabCell:(MMTabBarButtonCell *)cell; + +/** + * Get rect of large image for bounds of tab bar button cell + * + * @param theRect Bounds rect + * @param cell A tab bar button cell + * + * @return Large image rect + */ - (NSRect)largeImageRectForBounds:(NSRect)theRect ofTabCell:(MMTabBarButtonCell *)cell; + +/** + * Get rect of progress indicator for bounds of tab bar button cell + * + * @param theRect Bounds rect + * @param cell A tab bar button cell + * + * @return Progress indicator rect + */ - (NSRect)indicatorRectForBounds:(NSRect)theRect ofTabCell:(MMTabBarButtonCell *)cell; + +/** + * Get size of object counter for specified tab bar button cell + * + * @param cell A tab bar button cell + * + * @return Size of object counter + */ - (NSSize)objectCounterSizeOfTabCell:(MMTabBarButtonCell *)cell; + +/** + * Get rect of object counter for bounds of tab bar button cell + * + * @param theRect Bounds rect + * @param cell A tab bar button cell + * + * @return object counter rect + */ - (NSRect)objectCounterRectForBounds:(NSRect)theRect ofTabCell:(MMTabBarButtonCell *)cell; -// Drawing +#pragma mark Drawing the tab bar view + +/** + * Draw tab bar view + * + * @param tabBarView A tab bar view + * @param rect Drawing rect in tab bar view's coos + */ - (void)drawTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect; + +/** + * Draw bezel of tab bar view + * + * @param tabBarView A tab bar view + * @param rect Drawing rect in tab bar view's coos + */ - (void)drawBezelOfTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect; + +/** + * Draw button bezels of tab bar view + * + * @param tabBarView A tab bar view + * @param rect Drawing rect in tab bar view's coos + */ - (void)drawButtonBezelsOfTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect; + +/** + * Draw interior of tab bar view + * + * @param tabBarView A tab bar view + * @param rect Drawing rect in tab bar view's coos + */ +- (void)drawInteriorOfTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect; + +/** + * Draw bezel of tab bar button + * + * @param button A tab bar button + * @param index Index of tab bar button + * @param buttons Array of all buttons + * @param selIndex Index of selected button + * @param tabBarView Tab bar view to draw + * @param rect Drawing rect in tab bar view's coos + */ - (void)drawBezelOfButton:(MMAttachedTabBarButton *)button atIndex:(NSUInteger)index inButtons:(NSArray *)buttons indexOfSelectedButton:(NSUInteger)selIndex tabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect; + +/** + * Draw bezel of overflow button + * + * @param overflowButton An overflow button + * @param tabBarView Tab bar view to draw + * @param rect Drawing rect in tab bar view's coos + */ - (void)drawBezelOfOverflowButton:(MMOverflowPopUpButton *)overflowButton ofTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect; -- (void)drawInteriorOfTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect; +#pragma mark Drawing tab bar button cells + +/** + * Draw tab bar cell + * + * @param cell The tab bar button cell + * @param frame Frame of tab bar button cell + * @param controlView Cell's control view + */ - (void)drawTabBarCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)frame inView:(NSView *)controlView; + +/** + * Draw bezel of tab bar cell + * + * @param cell The tab bar button cell + * @param frame Frame of tab bar button cell + * @param controlView Cell's control view + */ - (void)drawBezelOfTabCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)frame inView:(NSView *)controlView; + +/** + * Draw interior of tab bar cell + * + * @param cell The tab bar button cell + * @param frame Frame of tab bar button cell + * @param controlView Cell's control view + */ - (void)drawInteriorOfTabCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)frame inView:(NSView *)controlView; + +/** + * Draw title of tab bar cell + * + * @param cell The tab bar button cell + * @param frame Frame of tab bar button cell + * @param controlView Cell's control view + */ - (void)drawTitleOfTabCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)frame inView:(NSView *)controlView; + +/** + * Draw icon of tab bar cell + * + * @param cell The tab bar button cell + * @param frame Frame of tab bar button cell + * @param controlView Cell's control view + */ - (void)drawIconOfTabCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)frame inView:(NSView *)controlView; + +/** + * Draw large image of tab bar cell + * + * @param cell The tab bar button cell + * @param frame Frame of tab bar button cell + * @param controlView Cell's control view + */ - (void)drawLargeImageOfTabCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)frame inView:(NSView *)controlView; + +/** + * Draw progress indicator of tab bar cell + * + * @param cell The tab bar button cell + * @param frame Frame of tab bar button cell + * @param controlView Cell's control view + */ - (void)drawIndicatorOfTabCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)frame inView:(NSView *)controlView; + +/** + * Draw object counter of tab bar cell + * + * @param cell The tab bar button cell + * @param frame Frame of tab bar button cell + * @param controlView Cell's control view + */ - (void)drawObjectCounterOfTabCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)frame inView:(NSView *)controlView; + +/** + * Draw close button of tab bar cell + * + * @param cell The tab bar button cell + * @param frame Frame of tab bar button cell + * @param controlView Cell's control view + */ - (void)drawCloseButtonOfTabCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)frame inView:(NSView *)controlView; -// Drag & Drop Support +#pragma mark Support Drag & Drop + +/** + * Get dragging rect for specified tab bar button + * + * @param aButton A tab bar button + * @param tabBarView A tab bar view + * + * @return The dragging rect + */ - (NSRect)draggingRectForTabButton:(MMAttachedTabBarButton *)aButton ofTabBarView:(MMTabBarView *)tabBarView; @end \ No newline at end of file diff --git a/MMTabBarView/MMTabBarView/NSAffineTransform+MMTabBarViewExtensions.h b/MMTabBarView/MMTabBarView/NSAffineTransform+MMTabBarViewExtensions.h index b02c31eb..6773db8d 100644 --- a/MMTabBarView/MMTabBarView/NSAffineTransform+MMTabBarViewExtensions.h +++ b/MMTabBarView/MMTabBarView/NSAffineTransform+MMTabBarViewExtensions.h @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/26/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import diff --git a/MMTabBarView/MMTabBarView/NSAffineTransform+MMTabBarViewExtensions.m b/MMTabBarView/MMTabBarView/NSAffineTransform+MMTabBarViewExtensions.m index f1a21918..f8b8da4b 100644 --- a/MMTabBarView/MMTabBarView/NSAffineTransform+MMTabBarViewExtensions.m +++ b/MMTabBarView/MMTabBarView/NSAffineTransform+MMTabBarViewExtensions.m @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/26/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import "NSAffineTransform+MMTabBarViewExtensions.h" diff --git a/MMTabBarView/MMTabBarView/NSBezierPath+MMTabBarViewExtensions.h b/MMTabBarView/MMTabBarView/NSBezierPath+MMTabBarViewExtensions.h index 25b15662..cdff4612 100644 --- a/MMTabBarView/MMTabBarView/NSBezierPath+MMTabBarViewExtensions.h +++ b/MMTabBarView/MMTabBarView/NSBezierPath+MMTabBarViewExtensions.h @@ -3,12 +3,13 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/26/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import -typedef enum MMBezierShapeCapMask : NSUInteger { +typedef NS_ENUM(NSUInteger, MMBezierShapeCapMask) +{ MMBezierShapeLeftCap = 0x0001, MMBezierShapeRightCap = 0x0002, @@ -16,7 +17,7 @@ typedef enum MMBezierShapeCapMask : NSUInteger { MMBezierShapeFlippedVertically = 0x1000, MMBezierShapeFillPath = 0x2000 -} MMBezierShapeCapMask; +}; @interface NSBezierPath (MMTabBarViewExtensions) diff --git a/MMTabBarView/MMTabBarView/NSBezierPath+MMTabBarViewExtensions.m b/MMTabBarView/MMTabBarView/NSBezierPath+MMTabBarViewExtensions.m index a495ae83..f7c930ec 100644 --- a/MMTabBarView/MMTabBarView/NSBezierPath+MMTabBarViewExtensions.m +++ b/MMTabBarView/MMTabBarView/NSBezierPath+MMTabBarViewExtensions.m @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/26/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import "NSBezierPath+MMTabBarViewExtensions.h" diff --git a/MMTabBarView/MMTabBarView/NSCell+MMTabBarViewExtensions.h b/MMTabBarView/MMTabBarView/NSCell+MMTabBarViewExtensions.h index 74c320be..351fafa7 100644 --- a/MMTabBarView/MMTabBarView/NSCell+MMTabBarViewExtensions.h +++ b/MMTabBarView/MMTabBarView/NSCell+MMTabBarViewExtensions.h @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/25/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import diff --git a/MMTabBarView/MMTabBarView/NSCell+MMTabBarViewExtensions.m b/MMTabBarView/MMTabBarView/NSCell+MMTabBarViewExtensions.m index 6ebef845..0934060e 100644 --- a/MMTabBarView/MMTabBarView/NSCell+MMTabBarViewExtensions.m +++ b/MMTabBarView/MMTabBarView/NSCell+MMTabBarViewExtensions.m @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/25/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import "NSCell+MMTabBarViewExtensions.h" diff --git a/MMTabBarView/MMTabBarView/NSString+MMTabBarViewExtensions.h b/MMTabBarView/MMTabBarView/NSString+MMTabBarViewExtensions.h index c956fc96..e0f2c529 100644 --- a/MMTabBarView/MMTabBarView/NSString+MMTabBarViewExtensions.h +++ b/MMTabBarView/MMTabBarView/NSString+MMTabBarViewExtensions.h @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/19/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import diff --git a/MMTabBarView/MMTabBarView/NSString+MMTabBarViewExtensions.m b/MMTabBarView/MMTabBarView/NSString+MMTabBarViewExtensions.m index f3000e53..2cdcc53e 100644 --- a/MMTabBarView/MMTabBarView/NSString+MMTabBarViewExtensions.m +++ b/MMTabBarView/MMTabBarView/NSString+MMTabBarViewExtensions.m @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/19/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import "NSString+MMTabBarViewExtensions.h" @@ -14,7 +14,7 @@ @implementation NSString (MMTabBarViewExtensions) - (NSString *)stringByTruncatingToLength:(NSUInteger)truncationLength { NSUInteger len = [self length]; if (len < truncationLength) - return [[self copy] autorelease]; + return [self copy]; // Unicode character 2026 is ellipsis return [[self substringToIndex:truncationLength - 10] stringByAppendingString:@"\u2026"]; diff --git a/MMTabBarView/MMTabBarView/NSTabViewItem+MMTabBarViewExtensions.h b/MMTabBarView/MMTabBarView/NSTabViewItem+MMTabBarViewExtensions.h index c1131142..a1b05e1a 100644 --- a/MMTabBarView/MMTabBarView/NSTabViewItem+MMTabBarViewExtensions.h +++ b/MMTabBarView/MMTabBarView/NSTabViewItem+MMTabBarViewExtensions.h @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/29/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import diff --git a/MMTabBarView/MMTabBarView/NSTabViewItem+MMTabBarViewExtensions.m b/MMTabBarView/MMTabBarView/NSTabViewItem+MMTabBarViewExtensions.m index 35eee5d0..698d32e1 100644 --- a/MMTabBarView/MMTabBarView/NSTabViewItem+MMTabBarViewExtensions.m +++ b/MMTabBarView/MMTabBarView/NSTabViewItem+MMTabBarViewExtensions.m @@ -3,7 +3,7 @@ // MMTabBarView // // Created by Michael Monscheuer on 9/29/12. -// Copyright (c) 2012 Michael Monscheuer. All rights reserved. +// Copyright (c) 2016 Michael Monscheuer. All rights reserved. // #import diff --git a/MMTabBarView/MMTabBarView/NSView+MMTabBarViewExtensions.m b/MMTabBarView/MMTabBarView/NSView+MMTabBarViewExtensions.m index 5d3bbe73..4e6f6f9f 100644 --- a/MMTabBarView/MMTabBarView/NSView+MMTabBarViewExtensions.m +++ b/MMTabBarView/MMTabBarView/NSView+MMTabBarViewExtensions.m @@ -96,7 +96,6 @@ - (void)orderFront { [subviews removeObjectIdenticalTo:self]; [subviews addObject:self]; [superview setSubviews:subviews]; - [subviews release]; } @end diff --git a/MMTabBarView/MMTabBarView/Styles/MMAdiumTabStyle.h b/MMTabBarView/MMTabBarView/Styles/MMAdiumTabStyle.h index 0a235c43..62f6a6e0 100644 --- a/MMTabBarView/MMTabBarView/Styles/MMAdiumTabStyle.h +++ b/MMTabBarView/MMTabBarView/Styles/MMAdiumTabStyle.h @@ -10,27 +10,8 @@ #import "MMTabStyle.h" @interface MMAdiumTabStyle : NSObject -{ - NSImage *_closeButton; - NSImage *_closeButtonDown; - NSImage *_closeButtonOver; - NSImage *_closeDirtyButton; - NSImage *_closeDirtyButtonDown; - NSImage *_closeDirtyButtonOver; - NSImage *_gradientImage; - BOOL _drawsUnified; - BOOL _drawsRight; -} - -- (void)loadImages; - -- (BOOL)drawsUnified; -- (void)setDrawsUnified:(BOOL)value; -- (BOOL)drawsRight; -- (void)setDrawsRight:(BOOL)value; - -- (void)encodeWithCoder:(NSCoder *)aCoder; -- (id)initWithCoder:(NSCoder *)aDecoder; +@property (assign) BOOL drawsUnified; +@property (assign) BOOL drawsRight; @end diff --git a/MMTabBarView/MMTabBarView/Styles/MMAdiumTabStyle.m b/MMTabBarView/MMTabBarView/Styles/MMAdiumTabStyle.m index 03c3d98a..c8dda5be 100644 --- a/MMTabBarView/MMTabBarView/Styles/MMAdiumTabStyle.m +++ b/MMTabBarView/MMTabBarView/Styles/MMAdiumTabStyle.m @@ -13,28 +13,25 @@ #import "NSView+MMTabBarViewExtensions.h" #import "NSCell+MMTabBarViewExtensions.h" #import "NSBezierPath+MMTabBarViewExtensions.h" +#import "MMTabBarButtonCell.Private.h" // #define Adium_CellPadding 2 #define Adium_MARGIN_X 4 #define kMMAdiumCounterPadding 3.0 -@interface MMTabBarButtonCell(SharedPrivates) - -- (void)_drawIconWithFrame:(NSRect)frame inView:(NSView *)controlView; -- (void)_drawCloseButtonWithFrame:(NSRect)frame inView:(NSView *)controlView; -- (void)_drawObjectCounterWithFrame:(NSRect)frame inView:(NSView *)controlView; - -@end - -@interface MMAdiumTabStyle (/*Private*/) - -- (void)_drawBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask usingStatesOfAttachedButton:(MMAttachedTabBarButton *)button ofTabBarView:(MMTabBarView *)tabBarView applyShadow:(BOOL)applyShadow drawRollovers:(BOOL)drawRollovers; - -- (void)_drawBezelWithFrame:(NSRect)frame usingStatesOfAttachedButton:(MMAttachedTabBarButton *)button ofTabBarView:(MMTabBarView *)tabBarView applyShadow:(BOOL)applyShadow drawRollovers:(BOOL)drawRollovers; - +@interface MMAdiumTabStyle () @end @implementation MMAdiumTabStyle +{ + NSImage *_closeButton; + NSImage *_closeButtonDown; + NSImage *_closeButtonOver; + NSImage *_closeDirtyButton; + NSImage *_closeDirtyButtonDown; + NSImage *_closeDirtyButtonOver; + NSImage *_gradientImage; +} + (NSString *)name { return @"Adium"; @@ -47,60 +44,15 @@ - (NSString *)name { #pragma mark - #pragma mark Creation/Destruction -- (id)init { +- (instancetype)init { if ((self = [super init])) { - [self loadImages]; + [self _loadImages]; _drawsUnified = NO; _drawsRight = NO; } return self; } -- (void)loadImages { - _closeButton = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front"]]; - _closeButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front_Pressed"]]; - _closeButtonOver = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front_Rollover"]]; - - _closeDirtyButton = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front"]]; - _closeDirtyButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front_Pressed"]]; - _closeDirtyButtonOver = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front_Rollover"]]; - - _gradientImage = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AdiumGradient"]]; -} - -- (void)dealloc { - [_closeButton release], _closeButton = nil; - [_closeButtonDown release], _closeButtonDown = nil; - [_closeButtonOver release], _closeButtonOver = nil; - - [_closeDirtyButton release], _closeDirtyButton = nil; - [_closeDirtyButtonDown release], _closeDirtyButtonDown = nil; - [_closeDirtyButtonOver release], _closeDirtyButtonOver = nil; - - [_gradientImage release], _gradientImage = nil; - - [super dealloc]; -} - -#pragma mark - -#pragma mark Drawing Style Accessors - -- (BOOL)drawsUnified { - return _drawsUnified; -} - -- (void)setDrawsUnified:(BOOL)value { - _drawsUnified = value; -} - -- (BOOL)drawsRight { - return _drawsRight; -} - -- (void)setDrawsRight:(BOOL)value { - _drawsRight = value; -} - #pragma mark - #pragma mark Tab View Specific @@ -433,7 +385,6 @@ - (void)drawBezelOfTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect { if ([tabBarView isWindowActive]) { NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.835 alpha:1.0] endingColor:[NSColor colorWithCalibratedWhite:0.843 alpha:1.0]]; [gradient drawInRect:rect angle:90.0]; - [gradient release]; } else { [[NSColor windowBackgroundColor] set]; NSRectFill(rect); @@ -521,7 +472,6 @@ - (void)drawBezelOfTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect { } } - [shadow release]; [NSGraphicsContext restoreGraphicsState]; } @@ -629,39 +579,19 @@ - (void)drawCloseButtonOfTabCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)fr } #pragma mark - -#pragma mark Archiving - -- (void)encodeWithCoder:(NSCoder *)aCoder { - if ([aCoder allowsKeyedCoding]) { - [aCoder encodeObject:_closeButton forKey:@"closeButton"]; - [aCoder encodeObject:_closeButtonDown forKey:@"closeButtonDown"]; - [aCoder encodeObject:_closeButtonOver forKey:@"closeButtonOver"]; - [aCoder encodeObject:_closeDirtyButton forKey:@"closeDirtyButton"]; - [aCoder encodeObject:_closeDirtyButtonDown forKey:@"closeDirtyButtonDown"]; - [aCoder encodeObject:_closeDirtyButtonOver forKey:@"closeDirtyButtonOver"]; - [aCoder encodeBool:_drawsUnified forKey:@"drawsUnified"]; - [aCoder encodeBool:_drawsRight forKey:@"drawsRight"]; - } -} +#pragma mark Private Methods -- (id)initWithCoder:(NSCoder *)aDecoder { - if ((self = [super init])) { - if ([aDecoder allowsKeyedCoding]) { - _closeButton = [[aDecoder decodeObjectForKey:@"closeButton"] retain]; - _closeButtonDown = [[aDecoder decodeObjectForKey:@"closeButtonDown"] retain]; - _closeButtonOver = [[aDecoder decodeObjectForKey:@"closeButtonOver"] retain]; - _closeDirtyButton = [[aDecoder decodeObjectForKey:@"closeDirtyButton"] retain]; - _closeDirtyButtonDown = [[aDecoder decodeObjectForKey:@"closeDirtyButtonDown"] retain]; - _closeDirtyButtonOver = [[aDecoder decodeObjectForKey:@"closeDirtyButtonOver"] retain]; - _drawsUnified = [aDecoder decodeBoolForKey:@"drawsUnified"]; - _drawsRight = [aDecoder decodeBoolForKey:@"drawsRight"]; - } - } - return self; -} +- (void)_loadImages { + _closeButton = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front"]]; + _closeButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front_Pressed"]]; + _closeButtonOver = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front_Rollover"]]; -#pragma mark - -#pragma mark Private Methods + _closeDirtyButton = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front"]]; + _closeDirtyButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front_Pressed"]]; + _closeDirtyButtonOver = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front_Rollover"]]; + + _gradientImage = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AdiumGradient"]]; +} - (void)_drawBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask usingStatesOfAttachedButton:(MMAttachedTabBarButton *)button ofTabBarView:(MMTabBarView *)tabBarView applyShadow:(BOOL)applyShadow drawRollovers:(BOOL)drawRollovers { @@ -697,7 +627,6 @@ - (void)_drawBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.835 alpha:1.0] endingColor:[NSColor colorWithCalibratedWhite:0.843 alpha:1.0]]; [gradient drawInRect:aRect angle:90.0]; - [gradient release]; } else { [[NSColor windowBackgroundColor] set]; NSRectFill(aRect); @@ -788,7 +717,6 @@ - (void)_drawBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.835 alpha:1.0] endingColor:[NSColor colorWithCalibratedWhite:0.843 alpha:1.0]]; [gradient drawInRect:aRect angle:90.0]; - [gradient release]; } else { [[NSColor windowBackgroundColor] set]; NSRectFill(aRect); @@ -803,7 +731,6 @@ - (void)_drawBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask } [gradient drawInRect:aRect angle:0.0]; - [gradient release]; } // frame @@ -846,7 +773,6 @@ - (void)_drawBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask } [NSGraphicsContext restoreGraphicsState]; - [shadow release]; } - (void)_drawBezelWithFrame:(NSRect)frame usingStatesOfAttachedButton:(MMAttachedTabBarButton *)button ofTabBarView:(MMTabBarView *)tabBarView applyShadow:(BOOL)applyShadow drawRollovers:(BOOL)drawRollovers @@ -903,7 +829,6 @@ - (void)_drawBezelWithFrame:(NSRect)frame usingStatesOfAttachedButton:(MMAttache } [NSGraphicsContext restoreGraphicsState]; - [shadow release]; } @end diff --git a/MMTabBarView/MMTabBarView/Styles/MMAquaTabStyle.h b/MMTabBarView/MMTabBarView/Styles/MMAquaTabStyle.h index 046f469a..7af3803c 100644 --- a/MMTabBarView/MMTabBarView/Styles/MMAquaTabStyle.h +++ b/MMTabBarView/MMTabBarView/Styles/MMAquaTabStyle.h @@ -9,24 +9,6 @@ #import #import "MMTabStyle.h" -@interface MMAquaTabStyle : NSObject { - NSImage *aquaTabBg; - NSImage *aquaTabBgDown; - NSImage *aquaTabBgDownGraphite; - NSImage *aquaTabBgDownNonKey; - NSImage *aquaDividerDown; - NSImage *aquaDivider; - NSImage *aquaCloseButton; - NSImage *aquaCloseButtonDown; - NSImage *aquaCloseButtonOver; - NSImage *aquaCloseDirtyButton; - NSImage *aquaCloseDirtyButtonDown; - NSImage *aquaCloseDirtyButtonOver; -} - -- (void)loadImages; - -- (void)encodeWithCoder:(NSCoder *)aCoder; -- (id)initWithCoder:(NSCoder *)aDecoder; +@interface MMAquaTabStyle : NSObject @end diff --git a/MMTabBarView/MMTabBarView/Styles/MMAquaTabStyle.m b/MMTabBarView/MMTabBarView/Styles/MMAquaTabStyle.m index 59d73d60..d181de17 100644 --- a/MMTabBarView/MMTabBarView/Styles/MMAquaTabStyle.m +++ b/MMTabBarView/MMTabBarView/Styles/MMAquaTabStyle.m @@ -12,6 +12,20 @@ #import "NSView+MMTabBarViewExtensions.h" @implementation MMAquaTabStyle +{ + NSImage *aquaTabBg; + NSImage *aquaTabBgDown; + NSImage *aquaTabBgDownGraphite; + NSImage *aquaTabBgDownNonKey; + NSImage *aquaDividerDown; + NSImage *aquaDivider; + NSImage *aquaCloseButton; + NSImage *aquaCloseButtonDown; + NSImage *aquaCloseButtonOver; + NSImage *aquaCloseDirtyButton; + NSImage *aquaCloseDirtyButtonDown; + NSImage *aquaCloseDirtyButtonOver; +} + (NSString *)name { return @"Aqua"; @@ -24,51 +38,13 @@ - (NSString *)name { #pragma mark - #pragma mark Creation/Destruction -- (id) init { +- (instancetype) init { if ((self = [super init])) { - [self loadImages]; + [self _loadImages]; } return self; } -- (void) loadImages { - // Aqua Tabs Images - aquaTabBg = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabsBackground"]]; - - aquaTabBgDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabsDown"]]; - - aquaTabBgDownGraphite = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabsDownGraphite"]]; - - aquaTabBgDownNonKey = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabsDownNonKey"]]; - - aquaDividerDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabsSeparatorDown"]]; - - aquaDivider = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabsSeparator"]]; - - aquaCloseButton = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front"]]; - aquaCloseButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front_Pressed"]]; - aquaCloseButtonOver = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front_Rollover"]]; - - aquaCloseDirtyButton = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front"]]; - aquaCloseDirtyButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front_Pressed"]]; - aquaCloseDirtyButtonOver = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front_Rollover"]]; -} - -- (void)dealloc { - [aquaTabBg release], aquaTabBg = nil; - [aquaTabBgDown release], aquaTabBgDown = nil; - [aquaDividerDown release], aquaDividerDown = nil; - [aquaDivider release], aquaDivider = nil; - [aquaCloseButton release], aquaCloseButton = nil; - [aquaCloseButtonDown release], aquaCloseButtonDown = nil; - [aquaCloseButtonOver release], aquaCloseButtonOver = nil; - [aquaCloseDirtyButton release], aquaCloseDirtyButton = nil; - [aquaCloseDirtyButtonDown release], aquaCloseDirtyButtonDown = nil; - [aquaCloseDirtyButtonOver release], aquaCloseDirtyButtonOver = nil; - - [super dealloc]; -} - #pragma mark - #pragma mark Tab View Specifics @@ -260,45 +236,29 @@ - (void)drawBezelOfOverflowButton:(MMOverflowPopUpButton *)overflowButton ofTabB } #pragma mark - -#pragma mark Archiving - -- (void)encodeWithCoder:(NSCoder *)aCoder { - //[super encodeWithCoder:aCoder]; - if ([aCoder allowsKeyedCoding]) { - [aCoder encodeObject:aquaTabBg forKey:@"aquaTabBg"]; - [aCoder encodeObject:aquaTabBgDown forKey:@"aquaTabBgDown"]; - [aCoder encodeObject:aquaTabBgDownGraphite forKey:@"aquaTabBgDownGraphite"]; - [aCoder encodeObject:aquaTabBgDownNonKey forKey:@"aquaTabBgDownNonKey"]; - [aCoder encodeObject:aquaDividerDown forKey:@"aquaDividerDown"]; - [aCoder encodeObject:aquaDivider forKey:@"aquaDivider"]; - [aCoder encodeObject:aquaCloseButton forKey:@"aquaCloseButton"]; - [aCoder encodeObject:aquaCloseButtonDown forKey:@"aquaCloseButtonDown"]; - [aCoder encodeObject:aquaCloseButtonOver forKey:@"aquaCloseButtonOver"]; - [aCoder encodeObject:aquaCloseDirtyButton forKey:@"aquaCloseDirtyButton"]; - [aCoder encodeObject:aquaCloseDirtyButtonDown forKey:@"aquaCloseDirtyButtonDown"]; - [aCoder encodeObject:aquaCloseDirtyButtonOver forKey:@"aquaCloseDirtyButtonOver"]; - } -} +#pragma mark Private Methods -- (id)initWithCoder:(NSCoder *)aDecoder { - //self = [super initWithCoder:aDecoder]; - //if (self) { - if ([aDecoder allowsKeyedCoding]) { - aquaTabBg = [[aDecoder decodeObjectForKey:@"aquaTabBg"] retain]; - aquaTabBgDown = [[aDecoder decodeObjectForKey:@"aquaTabBgDown"] retain]; - aquaTabBgDownGraphite = [[aDecoder decodeObjectForKey:@"aquaTabBgDownGraphite"] retain]; - aquaTabBgDownNonKey = [[aDecoder decodeObjectForKey:@"aquaTabBgDownNonKey"] retain]; - aquaDividerDown = [[aDecoder decodeObjectForKey:@"aquaDividerDown"] retain]; - aquaDivider = [[aDecoder decodeObjectForKey:@"aquaDivider"] retain]; - aquaCloseButton = [[aDecoder decodeObjectForKey:@"aquaCloseButton"] retain]; - aquaCloseButtonDown = [[aDecoder decodeObjectForKey:@"aquaCloseButtonDown"] retain]; - aquaCloseButtonOver = [[aDecoder decodeObjectForKey:@"aquaCloseButtonOver"] retain]; - aquaCloseDirtyButton = [[aDecoder decodeObjectForKey:@"aquaCloseDirtyButton"] retain]; - aquaCloseDirtyButtonDown = [[aDecoder decodeObjectForKey:@"aquaCloseDirtyButtonDown"] retain]; - aquaCloseDirtyButtonOver = [[aDecoder decodeObjectForKey:@"aquaCloseDirtyButtonOver"] retain]; - } - //} - return self; +- (void)_loadImages { + // Aqua Tabs Images + aquaTabBg = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabsBackground"]]; + + aquaTabBgDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabsDown"]]; + + aquaTabBgDownGraphite = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabsDownGraphite"]]; + + aquaTabBgDownNonKey = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabsDownNonKey"]]; + + aquaDividerDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabsSeparatorDown"]]; + + aquaDivider = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabsSeparator"]]; + + aquaCloseButton = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front"]]; + aquaCloseButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front_Pressed"]]; + aquaCloseButtonOver = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front_Rollover"]]; + + aquaCloseDirtyButton = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front"]]; + aquaCloseDirtyButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front_Pressed"]]; + aquaCloseDirtyButtonOver = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front_Rollover"]]; } @end diff --git a/MMTabBarView/MMTabBarView/Styles/MMCardTabStyle.h b/MMTabBarView/MMTabBarView/Styles/MMCardTabStyle.h index 1006e4f3..0cb5fec6 100644 --- a/MMTabBarView/MMTabBarView/Styles/MMCardTabStyle.h +++ b/MMTabBarView/MMTabBarView/Styles/MMCardTabStyle.h @@ -11,17 +11,6 @@ #import "NSBezierPath+MMTabBarViewExtensions.h" @interface MMCardTabStyle : NSObject -{ - NSImage *cardCloseButton; - NSImage *cardCloseButtonDown; - NSImage *cardCloseButtonOver; - NSImage *cardCloseDirtyButton; - NSImage *cardCloseDirtyButtonDown; - NSImage *cardCloseDirtyButtonOver; - - CGFloat _horizontalInset; - CGFloat _topMargin; -} @property (assign) CGFloat horizontalInset; @property (assign) CGFloat topMargin; diff --git a/MMTabBarView/MMTabBarView/Styles/MMCardTabStyle.m b/MMTabBarView/MMTabBarView/Styles/MMCardTabStyle.m index c4217c9d..f53da352 100644 --- a/MMTabBarView/MMTabBarView/Styles/MMCardTabStyle.m +++ b/MMTabBarView/MMTabBarView/Styles/MMCardTabStyle.m @@ -11,25 +11,20 @@ #import "MMAttachedTabBarButton.h" #import "NSView+MMTabBarViewExtensions.h" #import "NSBezierPath+MMTabBarViewExtensions.h" +#import "MMTabBarView.Private.h" -@interface MMTabBarView(SharedPrivates) - -- (void)_drawInteriorInRect:(NSRect)rect; -- (NSRect)_addTabButtonRect; -- (NSRect)_overflowButtonRect; - -@end - -@interface MMCardTabStyle (/*Private*/) - -- (void)_drawBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask usingStatesOfAttachedButton:(MMAttachedTabBarButton *)button ofTabBarView:(MMTabBarView *)tabBarView; - +@interface MMCardTabStyle () @end @implementation MMCardTabStyle - -@synthesize horizontalInset = _horizontalInset; -@synthesize topMargin = _topMargin; +{ + NSImage *cardCloseButton; + NSImage *cardCloseButtonDown; + NSImage *cardCloseButtonOver; + NSImage *cardCloseDirtyButton; + NSImage *cardCloseDirtyButtonDown; + NSImage *cardCloseDirtyButtonOver; +} + (NSString *)name { return @"Card"; @@ -42,7 +37,7 @@ - (NSString *)name { #pragma mark - #pragma mark Creation/Destruction -- (id) init { +- (instancetype) init { if ( (self = [super init]) ) { cardCloseButton = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front"]]; cardCloseButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front_Pressed"]]; @@ -57,17 +52,6 @@ - (id) init { return self; } -- (void)dealloc { - [cardCloseButton release], cardCloseButton = nil; - [cardCloseButtonDown release], cardCloseButtonDown = nil; - [cardCloseButtonOver release], cardCloseButtonOver = nil; - [cardCloseDirtyButton release], cardCloseDirtyButton = nil; - [cardCloseDirtyButtonDown release], cardCloseDirtyButtonDown = nil; - [cardCloseDirtyButtonOver release], cardCloseDirtyButtonOver = nil; - - [super dealloc]; -} - #pragma mark - #pragma mark Tab View Specific @@ -181,7 +165,6 @@ - (void)drawBezelOfTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect { if (gradient) { [gradient drawInRect:bounds angle:270]; - [gradient release]; } bounds = [tabBarView bounds]; @@ -271,7 +254,7 @@ - (void)_drawBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask if (gradient != nil) { [gradient drawInBezierPath:fillPath angle:90.0f]; - [gradient release], gradient = nil; + gradient = nil; } } else { [[NSColor windowBackgroundColor] set]; diff --git a/MMTabBarView/MMTabBarView/Styles/MMLiveChatTabStyle.h b/MMTabBarView/MMTabBarView/Styles/MMLiveChatTabStyle.h index f457abb7..5afb2a6b 100644 --- a/MMTabBarView/MMTabBarView/Styles/MMLiveChatTabStyle.h +++ b/MMTabBarView/MMTabBarView/Styles/MMLiveChatTabStyle.h @@ -10,18 +10,7 @@ #import "MMTabStyle.h" #import "NSBezierPath+MMTabBarViewExtensions.h" -@interface MMLiveChatTabStyle : NSObject { - NSImage *liveChatCloseButton; - NSImage *liveChatCloseButtonDown; - NSImage *liveChatCloseButtonOver; - NSImage *liveChatCloseDirtyButton; - NSImage *liveChatCloseDirtyButtonDown; - NSImage *liveChatCloseDirtyButtonOver; - - NSDictionary *_objectCountStringAttributes; - - CGFloat _leftMargin; -} +@interface MMLiveChatTabStyle : NSObject @property (assign) CGFloat leftMarginForTabBarView; diff --git a/MMTabBarView/MMTabBarView/Styles/MMLiveChatTabStyle.m b/MMTabBarView/MMTabBarView/Styles/MMLiveChatTabStyle.m index b7f206e8..57677339 100644 --- a/MMTabBarView/MMTabBarView/Styles/MMLiveChatTabStyle.m +++ b/MMTabBarView/MMTabBarView/Styles/MMLiveChatTabStyle.m @@ -13,15 +13,20 @@ #import "NSCell+MMTabBarViewExtensions.h" #import "NSBezierPath+MMTabBarViewExtensions.h" -@interface MMLiveChatTabStyle (/*Private*/) - -- (void)_drawBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask usingStatesOfAttachedButton:(MMAttachedTabBarButton *)button ofTabBarView:(MMTabBarView *)tabBarView; - +@interface MMLiveChatTabStyle () @end @implementation MMLiveChatTabStyle - -@synthesize leftMarginForTabBarView = _leftMargin; +{ + NSImage *liveChatCloseButton; + NSImage *liveChatCloseButtonDown; + NSImage *liveChatCloseButtonOver; + NSImage *liveChatCloseDirtyButton; + NSImage *liveChatCloseDirtyButtonDown; + NSImage *liveChatCloseDirtyButtonOver; + + NSDictionary *_objectCountStringAttributes; +} + (NSString *)name { return @"LiveChat"; @@ -34,7 +39,7 @@ - (NSString *)name { #pragma mark - #pragma mark Creation/Destruction -- (id) init { +- (instancetype) init { if ((self = [super init])) { liveChatCloseButton = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front"]]; liveChatCloseButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front_Pressed"]]; @@ -48,37 +53,24 @@ - (id) init { [[NSColor whiteColor] colorWithAlphaComponent:0.85], NSForegroundColorAttributeName, [[NSFontManager sharedFontManager] convertFont:[NSFont fontWithName:@"Lucida Grande" size:11.0] toHaveTrait:NSBoldFontMask], NSFontAttributeName, nil]; - _leftMargin = 5.0; + _leftMarginForTabBarView = 5.0; } return self; } -- (void)dealloc { - [liveChatCloseButton release], liveChatCloseButton = nil; - [liveChatCloseButtonDown release], liveChatCloseButtonDown = nil; - [liveChatCloseButtonOver release], liveChatCloseButtonOver = nil; - [liveChatCloseDirtyButton release], liveChatCloseDirtyButton = nil; - [liveChatCloseDirtyButtonDown release], liveChatCloseDirtyButtonDown = nil; - [liveChatCloseDirtyButtonOver release], liveChatCloseDirtyButtonOver = nil; - - [_objectCountStringAttributes release], _objectCountStringAttributes = nil; - - [super dealloc]; -} - #pragma mark - #pragma mark Tab View Specific - (CGFloat)leftMarginForTabBarView:(MMTabBarView *)tabBarView { if ([tabBarView orientation] == MMTabBarHorizontalOrientation) - return _leftMargin; + return _leftMarginForTabBarView; else return 0.0; } - (CGFloat)rightMarginForTabBarView:(MMTabBarView *)tabBarView { if ([tabBarView orientation] == MMTabBarHorizontalOrientation) - return _leftMargin; + return _leftMarginForTabBarView; else return 0.0; } @@ -334,13 +326,13 @@ -(NSRect)largeImageRectForBounds:(NSRect)theRect ofTabCell:(MMTabBarButtonCell * - (NSAttributedString *)attributedObjectCountStringValueForTabCell:(MMTabBarButtonCell *)cell { NSString *contents = [NSString stringWithFormat:@"%lu", (unsigned long)[cell objectCount]]; - return [[[NSMutableAttributedString alloc] initWithString:contents attributes:_objectCountStringAttributes] autorelease]; + return [[NSMutableAttributedString alloc] initWithString:contents attributes:_objectCountStringAttributes]; } - (NSAttributedString *)attributedStringValueForTabCell:(MMTabBarButtonCell *)cell { NSMutableAttributedString *attrStr; NSString * contents = [cell title]; - attrStr = [[[NSMutableAttributedString alloc] initWithString:contents] autorelease]; + attrStr = [[NSMutableAttributedString alloc] initWithString:contents]; NSRange range = NSMakeRange(0, [contents length]); [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0] range:range]; @@ -348,7 +340,7 @@ - (NSAttributedString *)attributedStringValueForTabCell:(MMTabBarButtonCell *)ce // Paragraph Style for Truncating Long Text static NSMutableParagraphStyle *TruncatingTailParagraphStyle = nil; if (!TruncatingTailParagraphStyle) { - TruncatingTailParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; + TruncatingTailParagraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; [TruncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; } [attrStr addAttribute:NSParagraphStyleAttributeName value:TruncatingTailParagraphStyle range:range]; @@ -369,7 +361,6 @@ - (void)drawBezelOfTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect { NSBezierPath *path = [NSBezierPath bezierPathWithRect:gradientRect]; NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.75 alpha:1.0] endingColor:[NSColor colorWithCalibratedWhite:0.75 alpha:0.0]]; [gradient drawInBezierPath:path angle:90.0]; - [gradient release]; } [[NSColor colorWithCalibratedWhite:0.576 alpha:1.0] set]; @@ -496,18 +487,6 @@ - (void)drawBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask [self _drawBezelInRect:aRect withCapMask:capMask usingStatesOfAttachedButton:button ofTabBarView:tabBarView]; } -#pragma mark - -#pragma mark Archiving - -- (void)encodeWithCoder:(NSCoder *)aCoder { - // ... do not encode anything -} - -- (id)initWithCoder:(NSCoder *)aDecoder { - // ... do not read anything - return [self init]; -} - #pragma mark - #pragma mark Private Methods @@ -542,7 +521,6 @@ - (void)_drawBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:startColor endingColor:endColor]; [gradient drawInBezierPath:fillPath angle:90.0]; - [gradient release]; NSBezierPath *outlinePath = outlinePath = [NSBezierPath bezierPathWithCardInRect:aRect radius:radius capMask:capMask]; diff --git a/MMTabBarView/MMTabBarView/Styles/MMMetalTabStyle.h b/MMTabBarView/MMTabBarView/Styles/MMMetalTabStyle.h index 9c7b9c65..105397e3 100644 --- a/MMTabBarView/MMTabBarView/Styles/MMMetalTabStyle.h +++ b/MMTabBarView/MMTabBarView/Styles/MMMetalTabStyle.h @@ -9,18 +9,6 @@ #import #import "MMTabStyle.h" -@interface MMMetalTabStyle : NSObject { - NSImage *metalCloseButton; - NSImage *metalCloseButtonDown; - NSImage *metalCloseButtonOver; - NSImage *metalCloseDirtyButton; - NSImage *metalCloseDirtyButtonDown; - NSImage *metalCloseDirtyButtonOver; - - NSDictionary *_objectCountStringAttributes; -} - -- (void)encodeWithCoder:(NSCoder *)aCoder; -- (id)initWithCoder:(NSCoder *)aDecoder; +@interface MMMetalTabStyle : NSObject @end diff --git a/MMTabBarView/MMTabBarView/Styles/MMMetalTabStyle.m b/MMTabBarView/MMTabBarView/Styles/MMMetalTabStyle.m index 1e6d8cda..d1902334 100644 --- a/MMTabBarView/MMTabBarView/Styles/MMMetalTabStyle.m +++ b/MMTabBarView/MMTabBarView/Styles/MMMetalTabStyle.m @@ -12,13 +12,21 @@ #import "NSView+MMTabBarViewExtensions.h" #import "NSBezierPath+MMTabBarViewExtensions.h" -@interface MMMetalTabStyle (/*Private*/) - -- (BOOL)_shouldDrawHorizontalTopBorderLineInView:(id)controlView; +@interface MMMetalTabStyle () @end @implementation MMMetalTabStyle +{ + NSImage *metalCloseButton; + NSImage *metalCloseButtonDown; + NSImage *metalCloseButtonOver; + NSImage *metalCloseDirtyButton; + NSImage *metalCloseDirtyButtonDown; + NSImage *metalCloseDirtyButtonOver; + + NSDictionary *_objectCountStringAttributes; +} StaticImage(TabNewMetal) StaticImage(TabNewMetalPressed) @@ -35,7 +43,7 @@ - (NSString *)name { #pragma mark - #pragma mark Creation/Destruction -- (id) init { +- (instancetype) init { if ((self = [super init])) { metalCloseButton = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"TabClose_Front"]]; metalCloseButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"TabClose_Front_Pressed"]]; @@ -52,19 +60,6 @@ - (id) init { return self; } -- (void)dealloc { - [metalCloseButton release], metalCloseButton = nil; - [metalCloseButtonDown release], metalCloseButtonDown = nil; - [metalCloseButtonOver release], metalCloseButtonOver = nil; - [metalCloseDirtyButton release], metalCloseDirtyButton = nil; - [metalCloseDirtyButtonDown release], metalCloseDirtyButtonDown = nil; - [metalCloseDirtyButtonOver release], metalCloseDirtyButtonOver = nil; - - [_objectCountStringAttributes release], _objectCountStringAttributes = nil; - - [super dealloc]; -} - #pragma mark - #pragma mark Tab View Specific @@ -156,13 +151,13 @@ - (NSImage *)closeButtonImageOfType:(MMCloseButtonImageType)type forTabCell:(MMT - (NSAttributedString *)attributedObjectCountStringValueForTabCell:(MMTabBarButtonCell *)cell { NSString *contents = [NSString stringWithFormat:@"%lu", (unsigned long)[cell objectCount]]; - return [[[NSMutableAttributedString alloc] initWithString:contents attributes:_objectCountStringAttributes] autorelease]; + return [[NSMutableAttributedString alloc] initWithString:contents attributes:_objectCountStringAttributes]; } - (NSAttributedString *)attributedStringValueForTabCell:(MMTabBarButtonCell *)cell { NSMutableAttributedString *attrStr; NSString *contents = [cell title]; - attrStr = [[[NSMutableAttributedString alloc] initWithString:contents] autorelease]; + attrStr = [[NSMutableAttributedString alloc] initWithString:contents]; NSRange range = NSMakeRange(0, [contents length]); // Add font attribute @@ -171,7 +166,7 @@ - (NSAttributedString *)attributedStringValueForTabCell:(MMTabBarButtonCell *)ce // Add shadow attribute NSShadow* shadow; - shadow = [[[NSShadow alloc] init] autorelease]; + shadow = [[NSShadow alloc] init]; CGFloat shadowAlpha; if (([cell state] == NSOnState) || [cell mouseHovered]) { shadowAlpha = 0.8; @@ -186,7 +181,7 @@ - (NSAttributedString *)attributedStringValueForTabCell:(MMTabBarButtonCell *)ce // Paragraph Style for Truncating Long Text static NSMutableParagraphStyle *TruncatingTailParagraphStyle = nil; if (!TruncatingTailParagraphStyle) { - TruncatingTailParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; + TruncatingTailParagraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; [TruncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; [TruncatingTailParagraphStyle setAlignment:NSCenterTextAlignment]; } @@ -347,36 +342,6 @@ - (void)drawBezelOfOverflowButton:(MMOverflowPopUpButton *)overflowButton ofTabB } } -#pragma mark - -#pragma mark Archiving - -- (void)encodeWithCoder:(NSCoder *)aCoder { - //[super encodeWithCoder:aCoder]; - if ([aCoder allowsKeyedCoding]) { - [aCoder encodeObject:metalCloseButton forKey:@"metalCloseButton"]; - [aCoder encodeObject:metalCloseButtonDown forKey:@"metalCloseButtonDown"]; - [aCoder encodeObject:metalCloseButtonOver forKey:@"metalCloseButtonOver"]; - [aCoder encodeObject:metalCloseDirtyButton forKey:@"metalCloseDirtyButton"]; - [aCoder encodeObject:metalCloseDirtyButtonDown forKey:@"metalCloseDirtyButtonDown"]; - [aCoder encodeObject:metalCloseDirtyButtonOver forKey:@"metalCloseDirtyButtonOver"]; - } -} - -- (id)initWithCoder:(NSCoder *)aDecoder { - // self = [super initWithCoder:aDecoder]; - //if (self) { - if ([aDecoder allowsKeyedCoding]) { - metalCloseButton = [[aDecoder decodeObjectForKey:@"metalCloseButton"] retain]; - metalCloseButtonDown = [[aDecoder decodeObjectForKey:@"metalCloseButtonDown"] retain]; - metalCloseButtonOver = [[aDecoder decodeObjectForKey:@"metalCloseButtonOver"] retain]; - metalCloseDirtyButton = [[aDecoder decodeObjectForKey:@"metalCloseDirtyButton"] retain]; - metalCloseDirtyButtonDown = [[aDecoder decodeObjectForKey:@"metalCloseDirtyButtonDown"] retain]; - metalCloseDirtyButtonOver = [[aDecoder decodeObjectForKey:@"metalCloseDirtyButtonOver"] retain]; - } - //} - return self; -} - #pragma mark - #pragma mark Private Methods diff --git a/MMTabBarView/MMTabBarView/Styles/MMUnifiedTabStyle.h b/MMTabBarView/MMTabBarView/Styles/MMUnifiedTabStyle.h index a922b8cd..7576a5d4 100644 --- a/MMTabBarView/MMTabBarView/Styles/MMUnifiedTabStyle.h +++ b/MMTabBarView/MMTabBarView/Styles/MMUnifiedTabStyle.h @@ -9,17 +9,7 @@ #import #import "MMTabStyle.h" -@interface MMUnifiedTabStyle : NSObject { - - NSImage *unifiedCloseButton; - NSImage *unifiedCloseButtonDown; - NSImage *unifiedCloseButtonOver; - NSImage *unifiedCloseDirtyButton; - NSImage *unifiedCloseDirtyButtonDown; - NSImage *unifiedCloseDirtyButtonOver; - - CGFloat _leftMargin; -} +@interface MMUnifiedTabStyle : NSObject @property (assign) CGFloat leftMarginForTabBarView; diff --git a/MMTabBarView/MMTabBarView/Styles/MMUnifiedTabStyle.m b/MMTabBarView/MMTabBarView/Styles/MMUnifiedTabStyle.m index d9c7894c..e92741f6 100644 --- a/MMTabBarView/MMTabBarView/Styles/MMUnifiedTabStyle.m +++ b/MMTabBarView/MMTabBarView/Styles/MMUnifiedTabStyle.m @@ -12,16 +12,18 @@ #import "NSView+MMTabBarViewExtensions.h" #import "NSBezierPath+MMTabBarViewExtensions.h" -@interface MMUnifiedTabStyle (/*Private*/) - -- (void)_drawCardBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask usingStatesOfAttachedButton:(MMAttachedTabBarButton *)button ofTabBarView:(MMTabBarView *)tabBarView; -- (void)_drawBoxBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask usingStatesOfAttachedButton:(MMAttachedTabBarButton *)button ofTabBarView:(MMTabBarView *)tabBarView; - +@interface MMUnifiedTabStyle () @end @implementation MMUnifiedTabStyle - -@synthesize leftMarginForTabBarView = _leftMargin; +{ + NSImage *unifiedCloseButton; + NSImage *unifiedCloseButtonDown; + NSImage *unifiedCloseButtonOver; + NSImage *unifiedCloseDirtyButton; + NSImage *unifiedCloseDirtyButtonDown; + NSImage *unifiedCloseDirtyButtonOver; +} + (NSString *)name { return @"Unified"; @@ -34,7 +36,7 @@ - (NSString *)name { #pragma mark - #pragma mark Creation/Destruction -- (id) init { +- (instancetype) init { if ((self = [super init])) { unifiedCloseButton = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front"]]; unifiedCloseButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabClose_Front_Pressed"]]; @@ -44,35 +46,24 @@ - (id) init { unifiedCloseDirtyButtonDown = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front_Pressed"]]; unifiedCloseDirtyButtonOver = [[NSImage alloc] initByReferencingFile:[[MMTabBarView bundle] pathForImageResource:@"AquaTabCloseDirty_Front_Rollover"]]; - _leftMargin = 0.0; + _leftMarginForTabBarView = 0.0; } return self; } -- (void)dealloc { - [unifiedCloseButton release], unifiedCloseButton = nil; - [unifiedCloseButtonDown release], unifiedCloseButtonDown = nil; - [unifiedCloseButtonOver release], unifiedCloseButtonOver = nil; - [unifiedCloseDirtyButton release], unifiedCloseDirtyButton = nil; - [unifiedCloseDirtyButtonDown release], unifiedCloseDirtyButtonDown = nil; - [unifiedCloseDirtyButtonOver release], unifiedCloseDirtyButtonOver = nil; - - [super dealloc]; -} - #pragma mark - #pragma mark Tab View Specific - (CGFloat)leftMarginForTabBarView:(MMTabBarView *)tabBarView { if ([tabBarView orientation] == MMTabBarHorizontalOrientation) - return _leftMargin; + return _leftMarginForTabBarView; else return 0.0f; } - (CGFloat)rightMarginForTabBarView:(MMTabBarView *)tabBarView { if ([tabBarView orientation] == MMTabBarHorizontalOrientation) - return _leftMargin; + return _leftMarginForTabBarView; else return 0.0f; } @@ -149,7 +140,6 @@ - (void)drawBezelOfTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect { } else { NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.835 alpha:1.0] endingColor:[NSColor colorWithCalibratedWhite:0.843 alpha:1.0]]; [gradient drawInRect:gradientRect angle:90.0]; - [gradient release]; } [[NSColor colorWithCalibratedWhite:0.576 alpha:1.0] set]; @@ -284,36 +274,6 @@ -(void)drawBezelOfOverflowButton:(MMOverflowPopUpButton *)overflowButton ofTabBa } } -#pragma mark - -#pragma mark Archiving - -- (void)encodeWithCoder:(NSCoder *)aCoder { - //[super encodeWithCoder:aCoder]; - if ([aCoder allowsKeyedCoding]) { - [aCoder encodeObject:unifiedCloseButton forKey:@"unifiedCloseButton"]; - [aCoder encodeObject:unifiedCloseButtonDown forKey:@"unifiedCloseButtonDown"]; - [aCoder encodeObject:unifiedCloseButtonOver forKey:@"unifiedCloseButtonOver"]; - [aCoder encodeObject:unifiedCloseDirtyButton forKey:@"unifiedCloseDirtyButton"]; - [aCoder encodeObject:unifiedCloseDirtyButtonDown forKey:@"unifiedCloseDirtyButtonDown"]; - [aCoder encodeObject:unifiedCloseDirtyButtonOver forKey:@"unifiedCloseDirtyButtonOver"]; - } -} - -- (id)initWithCoder:(NSCoder *)aDecoder { - // self = [super initWithCoder:aDecoder]; - //if (self) { - if ([aDecoder allowsKeyedCoding]) { - unifiedCloseButton = [[aDecoder decodeObjectForKey:@"unifiedCloseButton"] retain]; - unifiedCloseButtonDown = [[aDecoder decodeObjectForKey:@"unifiedCloseButtonDown"] retain]; - unifiedCloseButtonOver = [[aDecoder decodeObjectForKey:@"unifiedCloseButtonOver"] retain]; - unifiedCloseDirtyButton = [[aDecoder decodeObjectForKey:@"unifiedCloseDirtyButton"] retain]; - unifiedCloseDirtyButtonDown = [[aDecoder decodeObjectForKey:@"unifiedCloseDirtyButtonDown"] retain]; - unifiedCloseDirtyButtonOver = [[aDecoder decodeObjectForKey:@"unifiedCloseDirtyButtonOver"] retain]; - } - //} - return self; -} - #pragma mark - #pragma mark Private Methods @@ -332,13 +292,11 @@ - (void)_drawCardBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)cap NSColor *endColor = [NSColor colorWithDeviceWhite:0.663 alpha:1.000]; NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:startColor endingColor:endColor]; [gradient drawInBezierPath:fillPath angle:80.0]; - [gradient release]; } else if ([button mouseHovered]) { NSColor *startColor = [NSColor colorWithDeviceWhite:0.8 alpha:1.000]; NSColor *endColor = [NSColor colorWithDeviceWhite:0.8 alpha:1.000]; NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:startColor endingColor:endColor]; [gradient drawInBezierPath:fillPath angle:80.0]; - [gradient release]; } } else { @@ -349,7 +307,6 @@ - (void)_drawCardBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)cap [[NSGraphicsContext currentContext] setShouldAntialias:NO]; [gradient drawInBezierPath:fillPath angle:90.0]; [[NSGraphicsContext currentContext] setShouldAntialias:YES]; - [gradient release]; } } diff --git a/MMTabBarView/MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.h b/MMTabBarView/MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.h index d884778c..d382c6d5 100644 --- a/MMTabBarView/MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.h +++ b/MMTabBarView/MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.h @@ -9,10 +9,6 @@ #import #import "MMTabStyle.h" -@interface MMSafariTabStyle : NSObject { - - NSDictionary* _objectCountStringAttributes; - -} +@interface MMSafariTabStyle : NSObject @end diff --git a/MMTabBarView/MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.m b/MMTabBarView/MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.m index 6025b7a0..d27452b1 100644 --- a/MMTabBarView/MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.m +++ b/MMTabBarView/MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.m @@ -11,23 +11,13 @@ #import "MMTabBarView.h" #import "MMAttachedTabBarButton.h" #import "NSView+MMTabBarViewExtensions.h" - -@interface MMTabBarView(SharedPrivates) - -- (NSRect)_addTabButtonRect; -- (NSRect)_overflowButtonRect; - -@end - -@interface MMTabBarButtonCell(SharedPrivates) - -- (NSRect)_closeButtonRectForBounds:(NSRect)theRect; -- (CGFloat)_leftMargin; -- (CGFloat)_rightMargin; - -@end +#import "MMTabBarView.Private.h" +#import "MMTabBarButtonCell.Private.h" @implementation MMSafariTabStyle +{ + NSDictionary *_objectCountStringAttributes; +} StaticImage(SafariAWATClose) StaticImage(SafariAWATClosePressed) @@ -71,7 +61,7 @@ - (NSString *)name { #pragma mark - #pragma mark Creation/Destruction -- (id) init { +- (instancetype) init { if((self = [super init])) { _objectCountStringAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:[[NSFontManager sharedFontManager] convertFont:[NSFont fontWithName:@"Helvetica" size:11.0] toHaveTrait:NSBoldFontMask], NSFontAttributeName, [[NSColor whiteColor] colorWithAlphaComponent:0.85], NSForegroundColorAttributeName, @@ -80,12 +70,6 @@ - (id) init { return self; } -- (void)dealloc { - [_objectCountStringAttributes release], _objectCountStringAttributes = nil; - - [super dealloc]; -} - #pragma mark - #pragma mark Tab View Specific diff --git a/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front.png b/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front.png new file mode 100755 index 0000000000000000000000000000000000000000..4550e413c6ae4015b1fc79da8b0b8cd9fcb131b6 GIT binary patch literal 1233 zcmZ`(O>5LZ7*0W@uI)(+e)JHcf}oq(Wc%Tc*?_z07r3=-SJ^@jn@y%|G|7ZymQ7D$ z@lrt$6rtjw-lcf(FDN~T)I;$sJ*Wu9pU|1?wjIMZkdJxa=b7hy-sH{t-0aj~=5j_5 zgu$6qjsyN(lneXBGyMm_W$mqExTUiDeujaa10W zbCRABMNtdwC0I2kyL7rLN-Kl}5P){OEw}SB4wr#aC=@_W1*)2*h-|d#6En{G(bdi- zhx-^PvO*^y4)#U1ui3;cQj{bnbaZs;B+k;Yk{@+#QG9ufa5GB$&bSklCfH;q*et0=;5i?!f^?+{(p5<}_m zaYs6=GWLQHMG>Xxqg@IgOXKUuGWz(T1|Lil?uQO_YO=a?r7OV4()fj50(_7ou-3yl zCq{1FaA-pl7YePaXCh53V;6_>foUODSVG}KX>=m9aFPs{;E1*bqgL|~vIzIK=sQck z{gSy1xUdF#qBZ&@zzVjVrB%ZuNLO>pNLEp@x$&B+LPdf3yarMjt^$@RhsY#2tYPfx zi3^V{#k|~Q^7$@R18j=8sp^bu5~VY%XQ<}k{Og&?_j|YLFJXGdxLdn1WHmOg)IY6! zf3o=I=j*@w`(JjRRR%sc?9o$Eh#*S2r6|IEz9tg%&UtQ`Q_Vs;z= literal 0 HcmV?d00001 diff --git a/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front@2x.png b/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..ac32b0f82a82423b966ded8be342934dd394d726 GIT binary patch literal 1307 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&a=au%h`kcg59UmvUF{9L`nl>DSry^7odplSvNn+hu+GdHy)QK2F?C$HG5 z!d3~a!V1U+3F|8Y3;nDA{o-C@9zzrKDK}xwt{K19`Se z86_nJR{Hwo<>h+i#(Mch>H3D2mX`VkM*2oZx=P7{9O-#x!EwNQn0$BtH5OLR{C|l=&b@WD^hbJTrz6SKtYEsly5OvsnYPG&#iIxBO6iipcZJ*y)TY-f%L`p^60`eV}a^z5c^ zWv7o_tzUO>K4tOpxVtbi`vHfAMAid=*Hg9E{BfOH*}3uVL4$kmYBd_AZ(D{lpi<;HsXMd|v6mX?-X(Gs7c7{+3kj2o|M`E)8SrADBDCn&MGAmMZB3v?o0Sfkop_z?7Rta>C&iOg{ zMZpD$$*CZRfwdqBp{oX46N$?jBnc#qDalsFrAb+-$t6g!1&lLr+ILD!*GCez(Z{OV z2AC48eDhN>(<)sOOH%EO3=BAn#!X9#_Vv$HaVEj?C%kz0st-cAs*%$ZgTUT8@+3{~w;1`urcy`F~NbyYKs- z3*xF|?wUXAVdmP4tt<^6OrFh25o|DQJ9(*yNg%moZ#iRQ+Z{QkhNdZ(#97iZqGD!o zDSry^7odplSvNn+hu+GdHy)QK2F?C$HG5 z!d3~a!V1U+3F|8Y3;nDA{o-C@9zzrKDK}xwt{K19`Se z86_nJR{Hwo<>h+i#(Mch>H3D2mX`VkM*2oZx=P7{9O-#x!EwNQn0$BtH5OLR{C|l=&b@WD^hbJTrz}GamIaFf^Q;{gP$w+^+i~%%(LM_-P7FO=978;K zw@!8BYcddVxwu0)rs=T2qeIy%v~9cIe2~&JQJm9iE$}U&{_G6SpIZVpa{k#?|BUx- zo5rutHyYxvf8CgSTj+Is)+CkdI;Xi3bDpL?n4T!XXB40LX7#FF9NFsnpP!nq%+UhI zo!t82YC-=(n{qaThJ!Zgyv>I5c@mVF6Q9^#Thzab4P@-XqJG;K-l5D22@KzkU0uHM zfAi91s#VW9k1d$6mAB*ZkDPyt`vn@F8LnAg>33-}W97W*wfFa%6h4Sct^4)e;l0sq Y>4o~4%l-0}{|6PQp00i_>zopr0C3Rf&;S4c literal 0 HcmV?d00001 diff --git a/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front_Rollover.png b/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front_Rollover.png new file mode 100755 index 0000000000000000000000000000000000000000..78c3ab4272ad35ae67d522928f534cd9ba215e59 GIT binary patch literal 1367 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&Z81_llpi<;HsXMd|v6mX?-X(Gs7c7{+3kj2o|M`E)8SrADBDCn&MGAmMZB3v?o0Sfkop_z?7Rta>C&iOg{ zMZpD$$*CZRfwdqBp{oX46N$?jBnc#qDalsFrAb+-$t6g!1&lLr+ILD!*GCez(Z{OV z2AC48eDhN>(<)sOOH%EO3=B2kD_uMFnd5BbwwNYe&2Wa#-_DFRWF;CcV zCZ6H;MoX1TVi%;tvU4pACOnYxPd{+Euvgh}&h?DPx0*`tZT!lrdwS9T!=g=7CMB(Z cGXGf(qYX=Dr^LmM*`U(S)78&qol`;+01C6WxBvhE literal 0 HcmV?d00001 diff --git a/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front_Rollover@2x.png b/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabClose_Front_Rollover@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..a3223a1547d730477178e4358ba178c26784a200 GIT binary patch literal 1613 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&a=au%h`kcg59UmvUF{9L`nl>DSry^7odplSvNn+hu+GdHy)QK2F?C$HG5 z!d3~a!V1U+3F|8Y3;nDA{o-C@9zzrKDK}xwt{K19`Se z86_nJR{Hwo<>h+i#(Mch>H3D2mX`VkM*2oZx=P7{9O-#x!EwNQn0$BtH5OLR{C|l=&b@WD^hbJTrzf_%(d>)z1YMF=>%*;px(@6Qz0B@^;_d=ezuJIY-M6!H=$iBA@@( zy>D8Oq;w^7j-NU^ucW`{B%KWbTfbJtDkyAT;NQ?uE_W$G(VFwu-+i-v)Erq_ZO+TS zQ2O=z+xfK)k1K4PyluHGWcZ#JWSY(H)jRh1W9$Bx{qy_N3=O|X-qFtKI_zIKyZPNt zX4W74*UI=9#eQ7t+T3=C#q3>ziIm~-rI}G{cW$ujGEQ5|RHG$4OCjvevkm8N-I9%1 zAlk4&Kd=A#HNhg*72cZ!#157F%j^ti;QBK)l)-xCYdM8#9hSq_r<|9$vDXi(eZ{}!+Tl8q%iTs(*GYj!d~B! Yk6itme?xG!6R3>$boFyt=akR{00kl^fdBvi literal 0 HcmV?d00001 diff --git a/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabNew.png b/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabNew.png new file mode 100755 index 0000000000000000000000000000000000000000..d1c8a42bb89814f83b7f5fb486edca308645e120 GIT binary patch literal 1017 zcmbVLJ#W)M7&Zb`sL%}w(E*)Yi4T?7K09{eQ%sfkgIdC+N+Xexi+ydZ);?ojiQA2C zo%jPxY)FWSjR98v0vjU;sVj(~obv@kRU|CiclX}=Jn#4M=Ej4i#pOjo5SILPr_0wX z)pvP;|6jiu-Qvp)=JweZ-DV@46QLc^0Reu3cSx7u=-}xm(h`J=!?@RH{oo-AX(HiD zM=FzyqXnV0R%STdB@7J6PMlie$@>o?h$BmUtOrVv*<={6ALeB1aHAIG_mx-{!B~auTH?g1ey|B_niHT)S}jx{1co8Ox^5Wo9#9pi z$_jst8muGTKxzX_ACX(jqixi6ys0gIvcw@{8ItAEXe5m^iRL>pG)=SOP}LgOs1*k( z!(}ZkR%Q$iDZ)I?SWHt;G2#K;XO_r4orI8NK`=fko3{kqEs z>$dN-d*$cBkJHn&i%42s{q-VvdHnp6vVKiFYT56;eYv?TTv!l3UhVw!PrkmYhS7I7 KoVT4PN526<*EhQW literal 0 HcmV?d00001 diff --git a/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabNew@2x.png b/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabNew@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..5dfc389eab12c4324dddc22363ed91f2b2f3e498 GIT binary patch literal 1036 zcmbVL&ui0A91jkLj16{@Id*ttAj;MxFKN;yww5+&Tw$4|D_X?E(&TlGYw}|9X0zQC zJP3k_|A63CMA&W)MDXI#n|Spq=*5$R`O;r{7!wRh-h1Eo{d~T^AJ;do&&@2(Fbp$S zTQeGTy^wzAr|JL0VecwkE|O}CY~l{-+Yw^QE^Z@G^X+ZaK(@Pg?;|QO%v9HFwn)ob z*BtC~cB;cAen`;_Qz#{&?d%`|+GyJgitP8d?^xiuMfR3#30A11uD7-yq0Rk`rnA4} zs4iQ&1`3Hr34BCskodhI){-JS;MM3p74s|@sF0l^J9MgL)q##91Y}OiI0A$~Q8<{D z6$P#WQGg;Z&{xU8tR^d(m;4+kJ+wA*->6j|!&Fa$retO;=tj}k>w#wT{jLr&m* zKaFdk9g_z7Gb|dm=QS6?9on0RVq-GRZ zdc(P%tC{(n31KcP>72yNYCO8;A|4eFvu+R@XUDov;BcDbR zE^MScN;p~&YV|z9{vlzYM-IZ+5`TRBB!V!o#HYHac!^E=;pRz7c22fB{>hrSfe;vm1k1W%!23W| zpeif;HA=9IbOWgsFnL7oEe-Zj+i@qp_|6jhj3r2x2ZMn$&?K53$j~&+fpkTy3ddw`5M>AjMis)UQq@eosa4^I35|+2<(P-vC>yX@ZZ=HKEkiCfRMoZ3s@>Fe+cwl0 zwiRa#$3B_*4Y}V5*1Qyp?37?e(+;Ia(+=3~Q%18sO@O^)fO{VH!?;ka7Z)_n*CA>6 zf&^|#BQUBk3g<-NHvX0Q7#sXg)np!wT(rku?J`yI9xTLJ^YhJYd`Qe^CgsC%{_K2( z57yn5)9B=1dp|EO>I-OhclXyT@AcWstIFn0?X+fp`2Owoig0C7SbzWU#@_JDYB7wh L=9cqrWAF4gN>(=8 literal 0 HcmV?d00001 diff --git a/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabNewPressed@2x.png b/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/Images/YosemiteTabNewPressed@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..b5a87db681dcf3d89111598c0a1683e3254f53cd GIT binary patch literal 1037 zcmbVL&1=*^6b}?XD3l_IXir0WQE-z?vdM1J#=4siyI^YFU2u=hCez)}O(rH&H{Daw zlhA)bP`r2$556U0<}+(w`lx*b$UuD^BvJz8X#scz70 zk(P5?^Ki(yxeb?vF-0@X;!+m7-UcF|jXFW3v)}gKvLNtv_MYqrPHdoVusldmW3bZn z1{ZX0{i|%x`OGvEoe81o4`Vxne4i8mT z%{fG|KrIUCRz%#a5T)~D1{0-T62v6H5y%lcCaiVqF+=>xjM=9P+JbEAN^J6fr-RX{ULmG{CCkg1KxIGhln<0uw z&D2?X!uf%(+2xWAVW}vTL_sM-SQg5XDqB(+R#m8!q%p@y*lJOMR?$*a$u2@FRYcJ? z)Usj8vSBFV1Y3(z;zk}C`wggHiWO{25>LfyMuJ>|lP1Q!aR;n+F~MmU$G~VP;Hu+# zL6j@55U^=D^}4%R}=tTeMv?O#VnOH=TsWu1BX{lk-mo&6V`_R|ZO;*BZf%>HV)nLYcivo_&4-<-Su5tN>e|EK7;r_F literal 0 HcmV?d00001 diff --git a/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/MMYosemiteTabStyle.h b/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/MMYosemiteTabStyle.h new file mode 100755 index 00000000..82c698cb --- /dev/null +++ b/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/MMYosemiteTabStyle.h @@ -0,0 +1,18 @@ +// +// MMYosemiteTabStyle.h +// -------------------- +// +// Based on MMUnifiedTabStyle.h by Keith Blount +// Created by Ajin Man Tuladhar on 04/11/2014. +// Some clean up and adjustment by Michael Monscheuer on 03/16/2016 +// Copyright 2016 Ajin Man Tuladhar. All rights reserved. +// + +#import +#import "MMTabStyle.h" + +@interface MMYosemiteTabStyle : NSObject + +@property (assign) CGFloat leftMarginForTabBarView; + +@end diff --git a/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/MMYosemiteTabStyle.m b/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/MMYosemiteTabStyle.m new file mode 100755 index 00000000..49f17249 --- /dev/null +++ b/MMTabBarView/MMTabBarView/Styles/Yosemite Tab Style/MMYosemiteTabStyle.m @@ -0,0 +1,301 @@ +// +// MMYosemiteTabStyle.m +// -------------------- +// +// Based on MMUnifiedTabStyle.m by Keith Blount +// Created by Ajin Man Tuladhar on 04/11/2014. +// Copyright 2014 Ajin Man Tuladhar. All rights reserved. +// + +#import "MMYosemiteTabStyle.h" +#import "MMAttachedTabBarButton.h" +#import "MMTabBarView.h" +#import "NSView+MMTabBarViewExtensions.h" +#import "NSBezierPath+MMTabBarViewExtensions.h" + +@implementation MMYosemiteTabStyle + +StaticImage(YosemiteTabClose_Front) +StaticImage(YosemiteTabClose_Front_Pressed) +StaticImage(YosemiteTabClose_Front_Rollover) +StaticImageWithFilename(YosemiteTabCloseDirty_Front, AquaTabCloseDirty_Front) +StaticImageWithFilename(YosemiteTabCloseDirty_Front_Pressed, AquaTabCloseDirty_Front_Pressed) +StaticImageWithFilename(YosemiteTabCloseDirty_Front_Rollover, AquaTabCloseDirty_Front_Rollover) +StaticImage(YosemiteTabNew) +StaticImage(YosemiteTabNewPressed) + ++ (NSString *)name { + return @"Yosemite"; +} + +- (NSString *)name { + return [[self class] name]; +} + +#pragma mark - +#pragma mark Creation/Destruction + +- (id) init { + if ((self = [super init])) { + _leftMarginForTabBarView = -1.0f; + } + + return self; +} + +#pragma mark - +#pragma mark Tab View Specific + +- (NSSize)intrinsicContentSizeOfTabBarView:(MMTabBarView *)tabBarView +{ + return NSMakeSize(NSViewNoInstrinsicMetric, 25); +} + +- (CGFloat)leftMarginForTabBarView:(MMTabBarView *)tabBarView { + if ([tabBarView orientation] == MMTabBarHorizontalOrientation) + return -1.0f; + else + return 0.0f; +} + +- (CGFloat)rightMarginForTabBarView:(MMTabBarView *)tabBarView { + if ([tabBarView orientation] == MMTabBarHorizontalOrientation) + return -1.0f; + else + return 0.0f; +} + +- (CGFloat)topMarginForTabBarView:(MMTabBarView *)tabBarView { + if ([tabBarView orientation] == MMTabBarHorizontalOrientation) + return 0.0f; + + return 0.0f; +} + +- (CGFloat)heightOfTabBarButtonsForTabBarView:(MMTabBarView *)tabBarView { + return 25; +} + + +- (NSRect)addTabButtonRectForTabBarView:(MMTabBarView *)tabBarView { + NSRect window = [tabBarView frame]; + NSSize buttonSize = [tabBarView addTabButtonSize]; + NSRect rect = NSMakeRect(NSMaxX(window) - buttonSize.width - 5, 1, buttonSize.width, buttonSize.height); + return rect; +} + +- (NSSize)addTabButtonSizeForTabBarView:(MMTabBarView *)tabBarView { + return NSMakeSize(18,[tabBarView frame].size.height); +} + +- (BOOL)supportsOrientation:(MMTabBarOrientation)orientation forTabBarView:(MMTabBarView *)tabBarView { + + if (orientation != MMTabBarHorizontalOrientation) + return NO; + + return YES; +} + +#pragma mark - +#pragma mark Drag Support + +- (NSRect)draggingRectForTabButton:(MMAttachedTabBarButton *)aButton ofTabBarView:(MMTabBarView *)tabBarView { + + NSRect dragRect = [aButton stackingFrame]; + dragRect.size.width++; + return dragRect; + +} + +#pragma mark - +#pragma mark Add Tab Button + +- (void)updateAddButton:(MMRolloverButton *)aButton ofTabBarView:(MMTabBarView *)tabBarView { + + [aButton setImage:_staticYosemiteTabNewImage()]; + [aButton setAlternateImage:_staticYosemiteTabNewPressedImage()]; + [aButton setRolloverImage:_staticYosemiteTabNewImage()]; +} + +#pragma mark - +#pragma mark Providing Images + +- (NSImage *)closeButtonImageOfType:(MMCloseButtonImageType)type forTabCell:(MMTabBarButtonCell *)cell +{ + switch (type) { + case MMCloseButtonImageTypeStandard: + return _staticYosemiteTabClose_FrontImage(); + case MMCloseButtonImageTypeRollover: + return _staticYosemiteTabClose_Front_RolloverImage(); + case MMCloseButtonImageTypePressed: + return _staticYosemiteTabClose_Front_PressedImage(); + + case MMCloseButtonImageTypeDirty: + return _staticYosemiteTabCloseDirty_FrontImage(); + case MMCloseButtonImageTypeDirtyRollover: + return _staticYosemiteTabCloseDirty_Front_RolloverImage(); + case MMCloseButtonImageTypeDirtyPressed: + return _staticYosemiteTabCloseDirty_Front_PressedImage(); + + default: + break; + } + +} + +#pragma mark - +#pragma mark Drawing + +- (void)drawBezelOfTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect { + //Draw for our whole bounds; it'll be automatically clipped to fit the appropriate drawing area + rect = [tabBarView bounds]; + tabBarView.resizeTabsToFitTotalWidth= YES; + + NSRect gradientRect = rect; + + if (![tabBarView isWindowActive]) { + [[NSColor windowBackgroundColor] set]; + } else { + NSColor *startColor = [NSColor colorWithDeviceWhite:0.8 alpha:1.000]; + NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:startColor endingColor:startColor]; + [gradient drawInRect:gradientRect angle:90.0]; + } + + [[NSColor colorWithCalibratedRed:0.642 green:0.633 blue:0.642 alpha:1.000] set]; + [NSBezierPath strokeLineFromPoint:NSMakePoint(NSMinX(rect), NSMinY(rect) + 0.5) + toPoint:NSMakePoint(NSMaxX(rect), NSMinY(rect) + 0.5)]; + + [NSBezierPath strokeLineFromPoint:NSMakePoint(NSMinX(rect), NSMaxY(rect) - 0.5) + toPoint:NSMakePoint(NSMaxX(rect), NSMaxY(rect) - 0.5)]; +} + + +-(void)drawBezelOfTabCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)frame inView:(NSView *)controlView +{ + MMTabBarView *tabBarView = [controlView enclosingTabBarView]; + MMAttachedTabBarButton *button = (MMAttachedTabBarButton *)controlView; + + BOOL overflowMode = [button isOverflowButton]; + if ([button isSliding]) + overflowMode = NO; + + NSRect aRect = NSZeroRect; + if (overflowMode) { + aRect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.width +1, frame.size.height); + } else { + aRect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); + } + + aRect.origin.y += 1; + aRect.size.height -= 2; + + if (overflowMode) { + [self _drawCardBezelInRect:aRect withCapMask:MMBezierShapeLeftCap|MMBezierShapeFlippedVertically usingStatesOfAttachedButton:button ofTabBarView:tabBarView]; + } else { + [self _drawCardBezelInRect:aRect withCapMask:MMBezierShapeAllCaps|MMBezierShapeFlippedVertically usingStatesOfAttachedButton:button ofTabBarView:tabBarView]; + } +} + +-(void)drawBezelOfOverflowButton:(MMOverflowPopUpButton *)overflowButton ofTabBarView:(MMTabBarView *)tabBarView inRect:(NSRect)rect { + + MMAttachedTabBarButton *lastAttachedButton = [tabBarView lastAttachedButton]; + if ([lastAttachedButton isSliding]) + return; + + NSWindow *window = [tabBarView window]; + NSToolbar *toolbar = [window toolbar]; + + NSRect frame = [overflowButton frame]; + + if (toolbar && [toolbar isVisible]) { + + NSRect aRect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); + aRect.size.width += 5.0; + aRect.origin.y += 1; + aRect.size.height -= 2; + + [self _drawCardBezelInRect:aRect withCapMask:MMBezierShapeRightCap|MMBezierShapeFlippedVertically usingStatesOfAttachedButton:lastAttachedButton ofTabBarView:tabBarView]; + + } else { + NSRect aRect = NSMakeRect(frame.origin.x, frame.origin.y+0.5, frame.size.width-0.5f, frame.size.height-1.0); + aRect.size.width += 5.0; + + [self _drawBoxBezelInRect:aRect withCapMask:MMBezierShapeRightCap|MMBezierShapeFlippedVertically usingStatesOfAttachedButton:lastAttachedButton ofTabBarView:tabBarView]; + + if ([tabBarView showAddTabButton]) { + + NSColor *lineColor = [NSColor colorWithCalibratedWhite:0.576 alpha:1.0]; + [lineColor set]; + [NSBezierPath strokeLineFromPoint:NSMakePoint(NSMaxX(aRect)+.5, NSMinY(aRect)) toPoint:NSMakePoint(NSMaxX(aRect)+0.5, NSMaxY(aRect))]; + + [[[NSColor whiteColor] colorWithAlphaComponent:0.5] set]; + [NSBezierPath strokeLineFromPoint:NSMakePoint(NSMaxX(aRect)+1.5f, NSMinY(aRect)+1.0) toPoint:NSMakePoint(NSMaxX(aRect)+1.5f, NSMaxY(aRect)-1.0)]; + } + } +} + +#pragma mark - +#pragma mark Private Methods + +- (void)_drawCardBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask usingStatesOfAttachedButton:(MMAttachedTabBarButton *)button ofTabBarView:(MMTabBarView *)tabBarView { + + NSColor *lineColor = [NSColor colorWithCalibratedWhite:0.576 alpha:1.0]; + CGFloat radius = 0.0f; + + NSBezierPath *fillPath = [NSBezierPath bezierPathWithCardInRect:aRect radius:radius capMask:capMask|MMBezierShapeFillPath]; + + if ([tabBarView isWindowActive]) { + if ([button state] == NSOnState) { + NSColor *startColor = [NSColor colorWithDeviceWhite:0.875 alpha:1.000]; + NSColor *endColor = [NSColor colorWithDeviceWhite:0.902 alpha:1.000]; + NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:startColor endingColor:endColor]; + [[NSGraphicsContext currentContext] setShouldAntialias:NO]; + [gradient drawInBezierPath:fillPath angle:90.0]; + [[NSGraphicsContext currentContext] setShouldAntialias:YES]; + } else { + NSColor *startColor = [NSColor colorWithDeviceWhite:0.8 alpha:1.000]; + NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:startColor endingColor:startColor]; + [gradient drawInBezierPath:fillPath angle:80.0]; + } + } else { + + if ([button state] == NSOnState) { + NSColor *startColor = [NSColor colorWithDeviceWhite:0.875 alpha:1.000]; + NSColor *endColor = [NSColor colorWithDeviceWhite:0.902 alpha:1.000]; + NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:startColor endingColor:endColor]; + [[NSGraphicsContext currentContext] setShouldAntialias:NO]; + [gradient drawInBezierPath:fillPath angle:90.0]; + [[NSGraphicsContext currentContext] setShouldAntialias:YES]; + } + } + + NSBezierPath *bezier = [NSBezierPath bezierPath]; + [lineColor set]; + + BOOL shouldDisplayLeftDivider = [button shouldDisplayLeftDivider]; + if (shouldDisplayLeftDivider) { + //draw the tab divider + [bezier moveToPoint:NSMakePoint(NSMinX(aRect), NSMinY(aRect))]; + [bezier lineToPoint:NSMakePoint(NSMinX(aRect), NSMaxY(aRect))]; + } + + [bezier moveToPoint:NSMakePoint(NSMaxX(aRect), NSMinY(aRect))]; + [bezier lineToPoint:NSMakePoint(NSMaxX(aRect), NSMaxY(aRect))]; + [bezier stroke]; +} + +- (void)_drawBoxBezelInRect:(NSRect)aRect withCapMask:(MMBezierShapeCapMask)capMask usingStatesOfAttachedButton:(MMAttachedTabBarButton *)button ofTabBarView:(MMTabBarView *)tabBarView { + + capMask &= ~MMBezierShapeFillPath; + + // fill + if ([button state] == NSOnState) { + [[NSColor colorWithCalibratedWhite:0.0 alpha:0.2] set]; + NSRectFillUsingOperation(aRect, NSCompositeSourceAtop); + } else if ([button mouseHovered]) { + [[NSColor colorWithCalibratedWhite:0.0 alpha:0.1] set]; + NSRectFillUsingOperation(aRect, NSCompositeSourceAtop); + } +} + +@end diff --git a/default.xcworkspace/xcshareddata/default.xccheckout b/default.xcworkspace/xcshareddata/default.xccheckout index 1a334e89..eb53a1c9 100644 --- a/default.xcworkspace/xcshareddata/default.xccheckout +++ b/default.xcworkspace/xcshareddata/default.xccheckout @@ -10,31 +10,29 @@ default IDESourceControlProjectOriginsDictionary - B63C0D76-7988-44C3-920F-0F0E40F98A62 - https://github.com/MiMo42/MMTabBarView.git + f5e4fa30-5e63-140c-9cbd-ce57b7db7bff + https://github.com/mindersw/MMTabBarView IDESourceControlProjectPath - default.xcworkspace + trunk/default.xcworkspace IDESourceControlProjectRelativeInstallPathDictionary - B63C0D76-7988-44C3-920F-0F0E40F98A62 - .. + f5e4fa30-5e63-140c-9cbd-ce57b7db7bff + ../.. - IDESourceControlProjectURL - https://github.com/MiMo42/MMTabBarView.git IDESourceControlProjectVersion - 110 + 111 IDESourceControlProjectWCCIdentifier - B63C0D76-7988-44C3-920F-0F0E40F98A62 + f5e4fa30-5e63-140c-9cbd-ce57b7db7bff IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey - public.vcs.git + public.vcs.subversion IDESourceControlWCCIdentifierKey - B63C0D76-7988-44C3-920F-0F0E40F98A62 + f5e4fa30-5e63-140c-9cbd-ce57b7db7bff IDESourceControlWCCName - MMTabBarView + MMTabBarView-MSW%20fork