mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 00:00:48 +00:00
polish behavior of tool tips and reduce meory footprint.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23777 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
dadd5a0230
commit
0e6b15b3e9
3 changed files with 132 additions and 106 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2006-10-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSToolTips.h: Remove some ivars
|
||||||
|
* Source/GSToolTips.m: Move ivars to be static variables for common
|
||||||
|
use by all tool tips. Cancel an in-progress tooltip when a new one
|
||||||
|
starts.
|
||||||
|
|
||||||
2006-10-04 Richard Frith-Macdonald <rfm@gnu.org>
|
2006-10-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSToolTips.h: create tool tip wondow fully on screen
|
* Source/GSToolTips.h: create tool tip wondow fully on screen
|
||||||
|
|
|
@ -36,10 +36,6 @@
|
||||||
{
|
{
|
||||||
NSView *view;
|
NSView *view;
|
||||||
NSTrackingRectTag toolTipTag;
|
NSTrackingRectTag toolTipTag;
|
||||||
NSTimer *timer;
|
|
||||||
NSWindow *window;
|
|
||||||
NSSize offset;
|
|
||||||
BOOL restoreMouseMoved;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destroy object handling tips for aView.
|
/** Destroy object handling tips for aView.
|
||||||
|
|
|
@ -96,6 +96,10 @@ typedef struct NSView_struct
|
||||||
@implementation GSToolTips
|
@implementation GSToolTips
|
||||||
|
|
||||||
static NSMapTable *viewsMap = 0;
|
static NSMapTable *viewsMap = 0;
|
||||||
|
static NSTimer *timer;
|
||||||
|
static NSWindow *window;
|
||||||
|
static NSSize offset;
|
||||||
|
static BOOL restoreMouseMoved;
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
|
@ -192,11 +196,18 @@ static NSMapTable *viewsMap = 0;
|
||||||
|
|
||||||
- (void) mouseEntered: (NSEvent *)theEvent
|
- (void) mouseEntered: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
if (timer == nil)
|
GSTTProvider *provider;
|
||||||
{
|
|
||||||
GSTTProvider *provider = (GSTTProvider*)[theEvent userData];
|
|
||||||
NSString *toolTipString;
|
NSString *toolTipString;
|
||||||
|
|
||||||
|
if (timer != nil)
|
||||||
|
{
|
||||||
|
/* Moved from one tooltip view to another, so reset the timer.
|
||||||
|
*/
|
||||||
|
[timer invalidate];
|
||||||
|
timer = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
provider = (GSTTProvider*)[theEvent userData];
|
||||||
if ([[provider object] respondsToSelector:
|
if ([[provider object] respondsToSelector:
|
||||||
@selector(view:stringForToolTip:point:userData:)] == YES)
|
@selector(view:stringForToolTip:point:userData:)] == YES)
|
||||||
{
|
{
|
||||||
|
@ -225,7 +236,6 @@ static NSMapTable *viewsMap = 0;
|
||||||
[[view window] setAcceptsMouseMovedEvents: YES];
|
[[view window] setAcceptsMouseMovedEvents: YES];
|
||||||
}
|
}
|
||||||
[NSWindow _setToolTipVisible: self];
|
[NSWindow _setToolTipVisible: self];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) mouseExited: (NSEvent *)theEvent
|
- (void) mouseExited: (NSEvent *)theEvent
|
||||||
|
@ -439,6 +449,13 @@ static NSMapTable *viewsMap = 0;
|
||||||
- (void) _timedOut: (NSTimer *)aTimer
|
- (void) _timedOut: (NSTimer *)aTimer
|
||||||
{
|
{
|
||||||
NSString *toolTipString = [aTimer userInfo];
|
NSString *toolTipString = [aTimer userInfo];
|
||||||
|
NSAttributedString *toolTipText = nil;
|
||||||
|
NSSize textSize;
|
||||||
|
NSPoint mouseLocation = [NSEvent mouseLocation];
|
||||||
|
NSRect visible;
|
||||||
|
NSRect rect;
|
||||||
|
NSColor *color;
|
||||||
|
NSMutableDictionary *attributes;
|
||||||
|
|
||||||
if (timer != nil)
|
if (timer != nil)
|
||||||
{
|
{
|
||||||
|
@ -449,15 +466,22 @@ static NSMapTable *viewsMap = 0;
|
||||||
timer = nil;
|
timer = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window == nil)
|
if (window != nil)
|
||||||
{
|
{
|
||||||
NSAttributedString *toolTipText = nil;
|
/* Moved from one tooltip view to another ... so stop displaying
|
||||||
NSSize textSize;
|
* the old tool tip before we start the new one.
|
||||||
NSPoint mouseLocation = [NSEvent mouseLocation];
|
* This is similar to the case in -mouseEntered: where we cancel
|
||||||
NSRect visible;
|
* the timer for one tooltip view because we have entered another
|
||||||
NSRect rect;
|
* one.
|
||||||
NSColor *color;
|
* To think about ... if we entered a tooltip rectangle without
|
||||||
NSMutableDictionary *attributes;
|
* having left the previous one, then when we leave this rectangle
|
||||||
|
* we are probably back in the other one and should really restart
|
||||||
|
* the timer for the original view. However, this is a rare case
|
||||||
|
* so it's probably better to ignore it than add a lot of code to
|
||||||
|
* keep track of all entry and exit.
|
||||||
|
*/
|
||||||
|
[self _endDisplay];
|
||||||
|
}
|
||||||
|
|
||||||
attributes = [NSMutableDictionary dictionary];
|
attributes = [NSMutableDictionary dictionary];
|
||||||
[attributes setObject: [NSFont toolTipsFontOfSize: 10.0]
|
[attributes setObject: [NSFont toolTipsFontOfSize: 10.0]
|
||||||
|
@ -520,7 +544,6 @@ static NSMapTable *viewsMap = 0;
|
||||||
|
|
||||||
[self _drawText: toolTipText];
|
[self _drawText: toolTipText];
|
||||||
RELEASE(toolTipText);
|
RELEASE(toolTipText);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue