window resize problem (NSMinX(windowFrame), NSMaxY(windowFrame)
window resize problem (NSMinX(windowFrame), NSMaxY(windowFrame)
- Subject: window resize problem (NSMinX(windowFrame), NSMaxY(windowFrame)
- From: Rhon Fitzwater <email@hidden>
- Date: Mon, 14 Jun 2004 14:49:39 -0400
Hi,
I still have not been able to get this to work right. Maybe to shed
some more light for you, I am basically using Apple's
RoundTransparentWindow example
(
http://developer.apple.com/samplecode/RoundTransparentWindow/
RoundTransparentWindow.html) modified. I changed the two images, it now
uses just one (rectangular colored image).
What I added to the example:
Added code:
-when the mouse enters the window the alpha setting of the window is
set to 1.0
-when the mouse exits the window the alpha setting of the window is set
to 0.2
What I have working now, is the setting of the alpha setting on
mouseentered and mouseexited. What I want to get working is when the
mouse enters the window, the window will resize to 300 x 85. Then when
the mouse exits, i want the window to resize back to 170 x 85. I dont
want the window to move around though. I want it to stay in the same
place. With what I have working now, the window resizes properly, but
it moves to the bottom(about 2 inches up) left side of the screen. I
dont believe the newWindowFrame = NSMakeRect(NSMinX(windowFrame),
NSMaxY(windowFrame), 170, 85); code is working properly, using
(NSMinX(windowFrame), NSMaxY(windowFrame) the resize should keep the
window in the same position, but it is not.
Can someone please shed some light on this for me?
Thanks,
-rhon
SOME CODE
------------------
//mouse entered exited window code below
- (void)viewDidMoveToWindow {
[self addTrackingRect:[self frame] owner:self user
Data:nil
assumeInside:YES];
[super viewDidMoveToWindow];
}
static float windowAlphaIncrement = 0.15;
static float windowAlphaCurrentIncrement;
static float windowAlphaMin = 0.2;
static float windowAlphaMax = 1.0;
static float windowAlphaFadeRate = 1.0 / 15.0;
- (void)changeTransparency:(NSTimer *)timer
{
float alpha = [[self window] alphaValue];
BOOL reschedule = NO;
alpha += windowAlphaCurrentIncrement;
// Reschedule timer if we haven't reached desired value
if (windowAlphaCurrentIncrement > 0)
{
if (alpha < windowAlphaMax)
reschedule = YES;
else
alpha = windowAlphaMax;
}
else
{
if (alpha > windowAlphaMin)
reschedule = YES;
else
alpha = windowAlphaMin;
}
if (reschedule)
[NSTimer scheduledTimerWithTimeInterval:windowAlphaFadeRate
target:self selector:@selector(changeTransparency:) userInfo:nil
repeats:NO];
[[self window] setAlphaValue:alpha];
}
- (void)resizeTheWindowLarge:(id)sender;
{
NSRect windowFrame;
NSRect newWindowFrame;
windowFrame = [self frame];
newWindowFrame = NSMakeRect(NSMinX(windowFrame), NSMaxY(windowFrame),
300, 85);
NSLog(@"Supposed to resize");
[[self window] setFrame:newWindowFrame display:YES animate:YES];
}
- (void)resizeTheWindowSmall:(id)sender;
{
NSRect windowFrame;
NSRect newWindowFrame;
windowFrame = [self frame];
newWindowFrame = NSMakeRect(NSMinX(windowFrame), NSMaxY(windowFrame),
170, 85);
NSLog(@"Supposed to resize");
[[self window] setFrame:newWindowFrame display:YES animate:YES];
}
- (void)mouseEntered:(NSEvent *)event {
NSLog(@"Mouse Entered");
//bring alpha back to 1
windowAlphaCurrentIncrement = windowAlphaIncrement;
[NSTimer scheduledTimerWithTimeInterval:windowAlphaFadeRate
target:self selector:@selector(changeTransparency:) userInfo:nil
repeats:NO];
//resize window to large view
[self resizeTheWindowLarge:nil];
}
- (void)mouseExited:(NSEvent *)event {
NSLog(@"Mouse Exited");
windowAlphaCurrentIncrement = -windowAlphaIncrement;
[NSTimer scheduledTimerWithTimeInterval:windowAlphaFadeRate
target:self selector:@selector(changeTransparency:) userInfo:nil
repeats:NO];
[self resizeTheWindowSmall:nil];
}
//end of mouse entered or exited window code
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.