nagyistoce / maccode

Automatically exported from code.google.com/p/maccode
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

ugly behavior when tearing off last tab in PSMTabBarControl #25

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run sample app
2. Change tear-off option to Miniwindow
3. Close all tabs but one and then tear it off

What is the expected output? What do you see instead?
I expect the same behavior as that which is experienced when tearing off a tab 
when multiple 
tabs exist.  Instead, the window immediately closes and there is no DND image.

What version of the product are you using? On what operating system?
I pulled the tip today, 8/5/2008.  Leopard.

Please provide any additional information below.

Original issue reported on code.google.com by keithmal...@gmail.com on 6 Aug 2008 at 12:05

GoogleCodeExporter commented 9 years ago
Index: PSMTabBarControl.h
===================================================================
--- PSMTabBarControl.h  (revision 263)
+++ PSMTabBarControl.h  (working copy)
@@ -212,6 +212,7 @@
 //Tear-off tabs methods
 - (NSImage *)tabView:(NSTabView *)aTabView imageForTabViewItem:(NSTabViewItem *)tabViewItem 
offset:(NSSize *)offset styleMask:(unsigned int *)styleMask;
 - (PSMTabBarControl *)tabView:(NSTabView *)aTabView newTabBarForDraggedTabViewItem:(NSTabViewItem 
*)tabViewItem atPoint:(NSPoint)point;
+- (BOOL)tabView:(NSTabView *)aTabView 
shouldSpeciallyTreatDraggingOfLastTabViewItem:(NSTabViewItem 
*)tabViewItem;
 - (void)tabView:(NSTabView *)aTabView closeWindowForLastTabViewItem:(NSTabViewItem *)tabViewItem;

 //Overflow menu validation
Index: PSMTabDragAssistant.m
===================================================================
--- PSMTabDragAssistant.m   (revision 263)
+++ PSMTabDragAssistant.m   (working copy)
@@ -299,7 +299,9 @@
        //set the window's alpha mask to zero if the last tab is being dragged
        //don't fade out the old window if the delegate doesn't respond to the new tab bar method, just to 
be safe
        if ([[[self sourceTabBar] tabView] numberOfTabViewItems] == 1 && [self sourceTabBar] == control &&
-               [[[self sourceTabBar] delegate] 
respondsToSelector:@selector(tabView:newTabBarForDraggedTabViewItem:atPoint:)]) 
{
+               [[[self sourceTabBar] delegate] 
respondsToSelector:@selector(tabView:newTabBarForDraggedTabViewItem:atPoint:)] 
&&
+               (![[[self sourceTabBar] delegate] 
respondsToSelector:@selector(tabView:shouldSpeciallyTreatDraggingOfLastTabViewIt
em:)] ||
+               [[[self sourceTabBar] delegate] tabView:[[self sourceTabBar] tabView] 
shouldSpeciallyTreatDraggingOfLastTabViewItem:[[[[self sourceTabBar] tabView] 
tabViewItems] lastObject]])) {
            [[[self sourceTabBar] window] setAlphaValue:0.0];

            if ([_sourceTabBar tearOffStyle] == PSMTabBarTearOffAlphaWindow) {
@@ -500,7 +502,9 @@
        [[_draggedTab window] setFrameTopLeftPoint:aPoint];
        [[_draggedTab window] orderFront:nil];

-       if ([[[self sourceTabBar] tabView] numberOfTabViewItems] == 1) {
+       if ([[[self sourceTabBar] tabView] numberOfTabViewItems] == 1 &&
+               (![[[self sourceTabBar] delegate] 
respondsToSelector:@selector(tabView:shouldSpeciallyTreatDraggingOfLastTabViewIt
em:)] ||
+               [[[self sourceTabBar] delegate] tabView:[[self sourceTabBar] tabView] 
shouldSpeciallyTreatDraggingOfLastTabViewItem:[[[[self sourceTabBar] tabView] 
tabViewItems] lastObject]])) {
            [self draggingExitedTabBar:[self sourceTabBar]];
            [[_draggedTab window] setAlphaValue:0.0];
        }

Original comment by keithmal...@gmail.com on 6 Aug 2008 at 12:08

GoogleCodeExporter commented 9 years ago
This will make it behave like Safari: the source window will hide during drag 
and the miniwindow will appear

308c308,309
<               #warning fix me - what should we do when the last tab is dragged as a 
miniwindow?
---
>               [_draggedTab switchImages];
>               _centersDragWindows = YES;
505c506,508
<           [[_draggedTab window] setAlphaValue:0.0];
---
>           if ([_sourceTabBar tearOffStyle] == PSMTabBarTearOffAlphaWindow) {
>               [[_draggedTab window] setAlphaValue:0.0];
>           }

Original comment by lruc...@mac.com on 11 Jan 2011 at 12:59