This commit is contained in:
stridey%gmail.com 2006-10-28 06:41:55 +00:00
Родитель 8765897166
Коммит 2904e513df
1 изменённых файлов: 29 добавлений и 16 удалений

Просмотреть файл

@ -58,7 +58,7 @@
-(void)unregisterTabButtonsForTracking;
-(void)initOverflow;
-(NSRect)tabsRect;
-(BOOL)isMouseInside;
-(BrowserTabViewItem *)tabViewItemUnderMouse;
-(NSString*)view:(NSView*)view stringForToolTip:(NSToolTipTag)tag point:(NSPoint)point userData:(void*)userData;
-(NSButton*)newScrollButton:(NSButton*)button;
-(void)setLeftMostVisibleTabIndex:(int)index;
@ -230,7 +230,7 @@ static const int kOverflowButtonMargin = 1;
return nil;
}
// returns the tab at the specified point
// returns the tab at the specified point (in tab bar view coordinates)
-(TabButtonCell*)buttonAtPoint:(NSPoint)clickPoint
{
BrowserTabViewItem *tab = nil;
@ -413,16 +413,24 @@ static const int kOverflowButtonMargin = 1;
- (void)handleWindowIsKey:(NSWindow *)inWindow
{
// set tab bar dirty because the location of the mouse is inside the tab bar
if ([self isMouseInside])
[self setNeedsDisplay:YES];
// the mouse isn't tracked when the window isn't key, so update the tab hover
// state manually if the mouse is in a tab
BrowserTabViewItem *tab = [self tabViewItemUnderMouse];
if (tab) {
[mTabView refreshTab:tab];
[[tab tabButtonCell] updateHoverState:YES];
}
}
- (void)handleWindowResignKey:(NSWindow *)inWindow
{
// set tab bar dirty when the mouse is inside because the window does not respond to mouse hovering events when it is not key
if ([self isMouseInside])
[self setNeedsDisplay:YES];
// the mouse isn't tracked when the window isn't key, so update the tab hover
// state manually if the mouse is in a tab
BrowserTabViewItem *tab = [self tabViewItemUnderMouse];
if (tab) {
[mTabView refreshTab:tab];
[[tab tabButtonCell] updateHoverState:NO];
}
}
// returns the height the tab bar should be if drawn
@ -432,12 +440,24 @@ static const int kOverflowButtonMargin = 1;
return kTabBarDefaultHeight;
}
// finds the tab under the given point (in window coordinates), if any
-(BrowserTabViewItem *)tabViewItemAtPoint:(NSPoint)location
{
TabButtonCell *button = [self buttonAtPoint:[self convertPoint:location fromView:nil]];
NSPoint mousePointInView = [self convertPoint:location fromView:nil];
// Don't bother checking each tab's frame if the point isn't in the tab bar
if (!NSMouseInRect(mousePointInView, [self bounds], NO))
return nil;
TabButtonCell *button = [self buttonAtPoint:mousePointInView];
return (button) ? [button tabViewItem] : nil;
}
// finds the tab currently under the mouse, if any
-(BrowserTabViewItem *)tabViewItemUnderMouse
{
NSPoint mousePointInWindow = [[self window] convertScreenToBase:[NSEvent mouseLocation]];
return [self tabViewItemAtPoint:mousePointInWindow];
}
-(void)layoutButtons
{
int numberOfTabs = [mTabView numberOfTabViewItems];
@ -595,13 +615,6 @@ static const int kOverflowButtonMargin = 1;
return rect;
}
-(BOOL)isMouseInside
{
NSPoint mousePointInWindow = [[self window] convertScreenToBase:[NSEvent mouseLocation]];
NSPoint mousePointInView = [[self superview] convertPoint:mousePointInWindow fromView:nil];
return NSMouseInRect(mousePointInView, [self frame], NO);
}
-(BOOL)isVisible
{
return mVisible;