Skip to content
This repository was archived by the owner on Nov 15, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
build
*.mode1v3
*.pbxuser
project.xcworkspace
xcuserdata
.svn
4 changes: 2 additions & 2 deletions DMTabBar/DMTabBar/DMTabBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ - (void) setTabBarItems:(NSArray *)newTabBarItems {
[self.tabBarItems enumerateObjectsUsingBlock:^(DMTabBarItem * tabBarItem, NSUInteger idx, BOOL *stop) {
NSButton *itemButton = tabBarItem.tabBarItemButton;
itemButton.frame = NSMakeRect(0.0f, 0.0f, kDMTabBarItemWidth, NSHeight(self.bounds));
itemButton.state = (itemIndex == selectedItemIndex ? NSOnState : NSOffState);
itemButton.state = (itemIndex == selectedItemIndex ? NSControlStateValueOn : NSControlStateValueOff);
itemButton.action = @selector(selectTabBarItem:);
itemButton.target = self;
[self addSubview:itemButton];
Expand All @@ -164,7 +164,7 @@ - (void) setSelectedTabBarItem:(DMTabBarItem *)newSelectedTabBarItem {

__block NSUInteger buttonIndex = 0;
[self.tabBarItems enumerateObjectsUsingBlock:^(DMTabBarItem* tabBarItem, NSUInteger idx, BOOL *stop) {
tabBarItem.state = (buttonIndex == selectedItemIndex ? NSOnState : NSOffState);
tabBarItem.state = (buttonIndex == selectedItemIndex ? NSControlStateValueOn : NSControlStateValueOff);
++buttonIndex;
}];
}
Expand Down
10 changes: 5 additions & 5 deletions DMTabBar/DMTabBar/DMTabBarItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

@interface DMTabBarItem : NSButtonCell { }

@property (nonatomic,assign) BOOL enabled; // YES or NO to enable or disable the item
@property (getter=isEnabled) BOOL enabled; // YES or NO to enable or disable the item
@property (nonatomic,strong) NSImage* icon; // That's the image of the item
@property (nonatomic,strong) NSString* toolTip; // Tool tip message
@property (nonatomic,strong) NSString* keyEquivalent; // Shortcut key equivalent
@property (nonatomic,assign) NSUInteger keyEquivalentModifierMask; // Shortcut modifier key (keyEquivalentModifierMask+keyEquivalent = event)
@property (nonatomic,assign) NSUInteger tag; // Tag of the item
@property (nonatomic,assign) NSInteger state; // Current state (NSOnState = selected)
@property (copy) NSString *keyEquivalent; // Shortcut key equivalent
@property NSEventModifierFlags keyEquivalentModifierMask; // Shortcut modifier key (keyEquivalentModifierMask+keyEquivalent = event)
@property NSInteger tag; // Tag of the item
@property NSControlStateValue state; // Current state (NSOnState = selected)

// Internal use
// We'll use a customized NSButton (+NSButtonCell) and apply it inside the bar for each item.
Expand Down
20 changes: 10 additions & 10 deletions DMTabBar/DMTabBar/DMTabBarItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ - (id)initWithIcon:(NSImage *) iconImage tag:(NSUInteger) itemTag {
self = [super init];
if (self) {
// Create associated NSButton to place inside the bar (it's customized by DMTabBarButtonCell with a special gradient for selected state)
tabBarItemButton = [[NSButton alloc] initWithFrame:NSZeroRect];
tabBarItemButton = [[NSButton alloc] initWithFrame:NSZeroRect];
tabBarItemButton.cell = [[DMTabBarButtonCell alloc] init];
tabBarItemButton.image = iconImage;
[tabBarItemButton setEnabled:YES];
tabBarItemButton.enabled = YES;
tabBarItemButton.tag = itemTag;
[tabBarItemButton sendActionOn:NSLeftMouseDownMask];
[tabBarItemButton sendActionOn:NSEventMaskLeftMouseDown];
}
return self;
}
Expand All @@ -70,11 +70,11 @@ - (NSImage *) icon {
return tabBarItemButton.image;
}

- (void) setTag:(NSUInteger)newTag {
- (void) setTag:(NSInteger)newTag {
tabBarItemButton.tag = newTag;
}

- (NSUInteger) tag {
- (NSInteger) tag {
return tabBarItemButton.tag;
}

Expand All @@ -86,11 +86,11 @@ - (NSString *) toolTip {
return tabBarItemButton.toolTip;
}

- (void) setKeyEquivalentModifierMask:(NSUInteger)newKeyEquivalentModifierMask {
tabBarItemButton.keyEquivalentModifierMask = newKeyEquivalentModifierMask;
- (void) setKeyEquivalentModifierMask:(NSEventModifierFlags)newKeyEquivalentModifierMask {
tabBarItemButton.keyEquivalentModifierMask = newKeyEquivalentModifierMask;
}

- (NSUInteger) keyEquivalentModifierMask {
- (NSEventModifierFlags) keyEquivalentModifierMask {
return tabBarItemButton.keyEquivalentModifierMask;
}

Expand Down Expand Up @@ -120,7 +120,7 @@ @implementation DMTabBarButtonCell
- (id)init {
self = [super init];
if (self) {
self.bezelStyle = NSTexturedRoundedBezelStyle;
self.bezelStyle = NSBezelStyleToolbar;
}
return self;
}
Expand All @@ -130,7 +130,7 @@ - (NSInteger) nextState {
}

- (void) drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView {
if (self.state == NSOnState) {
if (self.state == NSControlStateValueOn) {
// If selected we need to draw the border new background for selection (otherwise we will use default back color)
// Save current context
[[NSGraphicsContext currentContext] saveGraphicsState];
Expand Down