Skip to content
This repository was archived by the owner on Nov 19, 2019. It is now read-only.

Commit ef43cd5

Browse files
author
Michael Ehrmann
committed
[FIX] fixing incremental cell state updates
1 parent 2213f62 commit ef43cd5

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

Source/PSMTabBarControl.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,6 @@ - (void)tabView:(NSTabView *)aTabView didSelectTabViewItem:(NSTabViewItem *)tabV
20032003
[self update];
20042004
} else {
20052005
[_controller setSelectedCell:thisCell];
2006-
[self update];
20072006
}
20082007
}
20092008

Source/PSMTabBarController.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,18 @@ - (void)setSelectedCell:(PSMTabBarCell *)cell {
9292
}
9393

9494
[nextCell setState:NSOffState];
95-
[nextCell setTabState:PSMTab_PositionMiddleMask];
95+
[nextCell setTabState:[nextCell tabState] & ~(PSMTab_SelectedMask)];
9696

9797
if(lastCell && lastCell != [_control lastVisibleTab]) {
98-
[lastCell setTabState:~[lastCell tabState] & PSMTab_RightIsSelectedMask];
98+
[lastCell setTabState:[lastCell tabState] & (~PSMTab_RightIsSelectedMask)];
9999
}
100100

101101
if((nextCell = [enumerator nextObject])) {
102-
[nextCell setTabState:~[lastCell tabState] & PSMTab_LeftIsSelectedMask];
102+
[nextCell setTabState:[nextCell tabState] & (~PSMTab_LeftIsSelectedMask)];
103103
}
104104

105105
[cell setState:NSOnState];
106-
[cell setTabState:PSMTab_SelectedMask];
106+
[cell setTabState:[cell tabState] | PSMTab_SelectedMask];
107107

108108
if(![cell isInOverflowMenu]) {
109109
NSUInteger cellIndex = [cells indexOfObject:cell];

Source/PSMTabDragAssistant.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ - (void)distributePlaceholdersInTabBarControl:(PSMTabBarControl *)tabBarControl
778778
// called upon first drag - must distribute placeholders
779779
[self distributePlaceholdersInTabBarControl:tabBarControl];
780780

781-
NSArray *cells = [tabBarControl cells];
781+
NSArray *cells = [[tabBarControl cells] copy];
782782

783783
// replace dragged cell with a placeholder, and clean up surrounding cells
784784
NSUInteger cellIndex = [cells indexOfObject:cell];
@@ -789,9 +789,14 @@ - (void)distributePlaceholdersInTabBarControl:(PSMTabBarControl *)tabBarControl
789789
[tabBarControl removeCellAtIndex:(cellIndex + 1)];
790790
[tabBarControl removeCellAtIndex:(cellIndex - 1)];
791791

792+
// if cell was selected cell, update selection direction markers of surrounding cells
792793
if((NSInteger)cellIndex - 2 >= 0) {
793794
pc = [cells objectAtIndex:cellIndex - 2];
794-
[pc setTabState:~[pc tabState] & PSMTab_RightIsSelectedMask];
795+
[pc setTabState:[pc tabState] & (~PSMTab_RightIsSelectedMask)];
796+
}
797+
if((NSInteger)cellIndex + 2 < cells.count) {
798+
pc = [cells objectAtIndex:cellIndex + 2];
799+
[pc setTabState:[pc tabState] & (~PSMTab_LeftIsSelectedMask)];
795800
}
796801
}
797802
}

0 commit comments

Comments
 (0)