mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-12-01 00:21:50 +00:00
Get scaling working in the Z view as well.
This commit is contained in:
parent
d4d8c50c85
commit
b2eb4020d5
3 changed files with 91 additions and 118 deletions
|
@ -69,5 +69,9 @@ void XYlineto (vec3_t pt);
|
|||
-(int) gridsize;
|
||||
-(float) snapToGrid:(float) f;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSView(XYView)
|
||||
-(void) setFrame:(NSRect) frame bounds:(NSRect) bounds scale:(NSSize) scale;
|
||||
@end
|
||||
#endif // XYView_h
|
||||
|
|
|
@ -16,6 +16,34 @@ id scrollview_i, gridbutton_i, scalebutton_i;
|
|||
vec3_t xy_viewnormal; // v_forward for xy view
|
||||
float xy_viewdist; // clip behind this plane
|
||||
|
||||
@implementation NSView(XYView)
|
||||
-(void) setFrame:(NSRect) frame bounds:(NSRect) bounds scale:(NSSize) scale
|
||||
{
|
||||
// XXX[quakeed_i disableDisplay];
|
||||
//[self setPostsFrameChangedNotifications:NO];
|
||||
//[self setPostsBoundsChangedNotifications:NO];
|
||||
[self setFrame: frame];
|
||||
if (_boundsMatrix) {
|
||||
//FIXME workaround for a bug (?) in GNUstep
|
||||
NSAffineTransformStruct t = [_boundsMatrix transformStruct];
|
||||
t.m11 = t.m22 = 1;
|
||||
t.m12 = t.m21 = 0;
|
||||
[_boundsMatrix setTransformStruct: t];
|
||||
}
|
||||
[self setBounds: bounds];
|
||||
if (_boundsMatrix) {
|
||||
//FIXME workaround for a bug (?) in GNUstep
|
||||
NSAffineTransformStruct t = [_boundsMatrix transformStruct];
|
||||
t.tX *= scale.width;
|
||||
t.tY *= scale.height;
|
||||
[_boundsMatrix setTransformStruct: t];
|
||||
}
|
||||
//[self setPostsFrameChangedNotifications:YES];
|
||||
//[self setPostsBoundsChangedNotifications:YES];
|
||||
// XXX[quakeed_i reenableDisplay];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation XYView
|
||||
/*
|
||||
==================
|
||||
|
@ -141,31 +169,11 @@ initWithFrame:
|
|||
sframe.size.height *= scale;
|
||||
|
||||
// redisplay everything
|
||||
//[self setPostsFrameChangedNotifications:NO];
|
||||
//[self setPostsBoundsChangedNotifications:NO];
|
||||
|
||||
// size this view
|
||||
[self setFrame: sframe];
|
||||
if (_boundsMatrix) {
|
||||
//FIXME workaround for a bug (?) in GNUstep
|
||||
NSAffineTransformStruct t = [_boundsMatrix transformStruct];
|
||||
t.m11 = t.m22 = 1;
|
||||
t.m12 = t.m21 = 0;
|
||||
[_boundsMatrix setTransformStruct: t];
|
||||
}
|
||||
[self setBounds: bounds];
|
||||
if (_boundsMatrix) {
|
||||
//FIXME workaround for a bug (?) in GNUstep
|
||||
NSAffineTransformStruct t = [_boundsMatrix transformStruct];
|
||||
t.tX *= scale;
|
||||
t.tY *= scale;
|
||||
[_boundsMatrix setTransformStruct: t];
|
||||
}
|
||||
[self setFrame:sframe bounds:bounds scale:NSMakeSize (scale, scale)];
|
||||
|
||||
//[self setPostsFrameChangedNotifications:YES];
|
||||
//[self setPostsBoundsChangedNotifications:YES];
|
||||
|
||||
// scroll and scale the clip view
|
||||
// scroll the clip view
|
||||
pt.x *= scale;
|
||||
pt.y *= scale;
|
||||
[cv setBoundsOrigin:pt];
|
||||
|
@ -231,6 +239,7 @@ If realbounds has shrunk, nothing will change.
|
|||
bounds.origin.y /= scale;
|
||||
bounds.size.width /= scale;
|
||||
bounds.size.height /= scale;
|
||||
|
||||
bounds = NSUnionRect (realbounds, bounds);
|
||||
sframe = bounds;
|
||||
sframe.origin.x *= scale;
|
||||
|
@ -239,20 +248,7 @@ If realbounds has shrunk, nothing will change.
|
|||
sframe.size.height *= scale;
|
||||
|
||||
// size this view
|
||||
//[self setPostsFrameChangedNotifications:NO];
|
||||
//[self setPostsBoundsChangedNotifications:NO];
|
||||
|
||||
[self setFrame: sframe];
|
||||
if (_boundsMatrix) {
|
||||
//FIXME workaround for a bug in GNUstep
|
||||
NSAffineTransformStruct t = [_boundsMatrix transformStruct];
|
||||
t.m11 = t.m22 = 1;
|
||||
[_boundsMatrix setTransformStruct: t];
|
||||
}
|
||||
[self setBounds: bounds];
|
||||
|
||||
//[self setPostsBoundsChangedNotifications:YES];
|
||||
//[self setPostsFrameChangedNotifications:YES];
|
||||
[self setFrame:sframe bounds:bounds scale:NSMakeSize (scale, scale)];
|
||||
|
||||
[scrollview_i reflectScrolledClipView:[scrollview_i contentView]];
|
||||
return self;
|
||||
|
@ -1230,8 +1226,7 @@ mouseDown
|
|||
return self;
|
||||
}
|
||||
// check eye
|
||||
if ([cameraview_i XYmouseDown: &pt flags:[theEvent
|
||||
modifierFlags]])
|
||||
if ([cameraview_i XYmouseDown: &pt flags:[theEvent modifierFlags]])
|
||||
return self; // camera move
|
||||
|
||||
// check z post
|
||||
|
|
|
@ -60,12 +60,12 @@ initWithFrame:
|
|||
|
||||
[zscrollview_i setDocumentView:self];
|
||||
|
||||
//[_super_view setBoundsOrigin: NSMakePoint (0, 0)];
|
||||
[_super_view setBoundsOrigin: NSMakePoint (0, 0)];
|
||||
|
||||
minheight = 0;
|
||||
maxheight = 64;
|
||||
|
||||
pt.x = -_bounds.size.width;
|
||||
pt.x = -[_super_view bounds].size.width / 2;
|
||||
pt.y = -128;
|
||||
|
||||
[self newRealBounds];
|
||||
|
@ -95,52 +95,36 @@ setOrigin:scale:
|
|||
-setOrigin:(NSPoint) pt scale:(float) sc
|
||||
{
|
||||
NSRect sframe;
|
||||
NSRect newbounds;
|
||||
NSRect bounds;
|
||||
NSRect size;
|
||||
|
||||
//
|
||||
// calculate the area visible in the cliprect
|
||||
//
|
||||
// calculate the area visible in the cliprect
|
||||
scale = sc;
|
||||
|
||||
sframe =[self frame];
|
||||
newbounds =[self frame];
|
||||
newbounds.origin = pt;
|
||||
newbounds.size.width /= scale;
|
||||
newbounds.size.height /= scale;
|
||||
bounds =[_super_view bounds];
|
||||
bounds.origin = pt;
|
||||
bounds.size.width /= 1;
|
||||
bounds.size.height /= scale;
|
||||
|
||||
//
|
||||
// union with the realbounds
|
||||
//
|
||||
if (newbounds.origin.y > oldminheight) {
|
||||
newbounds.size.height += newbounds.origin.y - oldminheight;
|
||||
newbounds.origin.y = oldminheight;
|
||||
}
|
||||
if (newbounds.origin.y + newbounds.size.height < oldmaxheight) {
|
||||
newbounds.size.height += oldmaxheight
|
||||
- (newbounds.origin.y + newbounds.size.height);
|
||||
}
|
||||
//
|
||||
// redisplay everything
|
||||
//
|
||||
// XXX[quakeed_i disableDisplay];
|
||||
size = NSMakeRect (0, oldminheight, 1, oldmaxheight - oldminheight);
|
||||
// union with the realbounds
|
||||
bounds = NSUnionRect (size, bounds);
|
||||
// redisplay everything
|
||||
bounds.origin = NSMakePoint (-bounds.size.width/2, bounds.origin.y);
|
||||
sframe = bounds;
|
||||
sframe.origin.x *= 1;
|
||||
sframe.origin.y *= scale;
|
||||
sframe.size.width *= 1;
|
||||
sframe.size.height *= scale;
|
||||
|
||||
//
|
||||
// size this view
|
||||
//
|
||||
[self setBoundsSize:newbounds.size];
|
||||
[self setBoundsOrigin: NSMakePoint (-newbounds.size.width/2,
|
||||
newbounds.origin.y)];
|
||||
// XXX[self moveTo: -newbounds.size.width/2 : newbounds.origin.y];
|
||||
// size this view
|
||||
[self setFrame:sframe bounds:bounds scale:NSMakeSize (1, scale)];
|
||||
|
||||
//
|
||||
// scroll and scale the clip view
|
||||
//
|
||||
// XXX[_super_view setDrawSize
|
||||
// XXX : sframe.size.width/scale
|
||||
// XXX : sframe.size.height/scale];
|
||||
// XXX[_super_view setDrawOrigin: pt->x : pt->y];
|
||||
// scroll and scale the clip view
|
||||
pt.x *= 1;
|
||||
pt.y *= scale;
|
||||
[_super_view setBoundsOrigin: pt];
|
||||
|
||||
// XXX[quakeed_i reenableDisplay];
|
||||
[zscrollview_i display];
|
||||
|
||||
return self;
|
||||
|
@ -157,7 +141,8 @@ Called when the scaler popup on the window is used
|
|||
-scaleMenuTarget:sender
|
||||
{
|
||||
char const *item;
|
||||
NSRect visrect, sframe;
|
||||
NSRect rect;
|
||||
NSPoint mid, org, orig;
|
||||
float nscale;
|
||||
|
||||
item =[[sender titleOfSelectedItem] cString];
|
||||
|
@ -168,15 +153,17 @@ Called when the scaler popup on the window is used
|
|||
return NULL;
|
||||
|
||||
// keep the center of the view constant
|
||||
visrect =[self bounds];
|
||||
sframe =[self frame];
|
||||
visrect.origin.x += visrect.size.width / 2;
|
||||
visrect.origin.y += visrect.size.height / 2;
|
||||
rect =[_super_view bounds];
|
||||
mid.x = rect.size.width / 2;
|
||||
mid.y = rect.size.height / 2;
|
||||
|
||||
visrect.origin.x -= sframe.size.width / 2 / nscale;
|
||||
visrect.origin.y -= sframe.size.height / 2 / nscale;
|
||||
org.x = (rect.origin.x + mid.x) / 1;
|
||||
org.y = (rect.origin.y + mid.y) / scale;
|
||||
|
||||
[self setOrigin: visrect.origin scale:nscale];
|
||||
orig.x = org.x - mid.x / 1;
|
||||
orig.y = org.y - mid.y / nscale;
|
||||
|
||||
[self setOrigin: orig scale:nscale];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -239,8 +226,10 @@ If realbounds has shrunk, nothing will change.
|
|||
*/
|
||||
-newRealBounds
|
||||
{
|
||||
NSRect sbounds;
|
||||
float vistop, visbottom;
|
||||
NSRect bounds;
|
||||
NSRect sframe;
|
||||
NSRect size;
|
||||
|
||||
NSClipView *cv = (NSClipView *) _super_view;
|
||||
|
||||
if (minheight == oldminheight && maxheight == oldmaxheight)
|
||||
|
@ -252,39 +241,24 @@ If realbounds has shrunk, nothing will change.
|
|||
minheight -= 16;
|
||||
maxheight += 16;
|
||||
|
||||
//
|
||||
// calculate the area visible in the cliprect
|
||||
//
|
||||
sbounds =[_super_view bounds];
|
||||
visbottom = sbounds.origin.y;
|
||||
vistop = visbottom + sbounds.size.height;
|
||||
// calculate the area visible in the cliprect
|
||||
bounds =[cv bounds];
|
||||
bounds.size.width /= 1;
|
||||
bounds.size.height /= scale;
|
||||
|
||||
if (vistop > maxheight)
|
||||
maxheight = vistop;
|
||||
if (visbottom < minheight)
|
||||
minheight = visbottom;
|
||||
if (minheight == _bounds.origin.y
|
||||
&& maxheight - minheight == _bounds.size.height)
|
||||
return self;
|
||||
size = NSMakeRect (0, minheight, 1, maxheight - minheight);
|
||||
|
||||
sbounds.origin.y = minheight;
|
||||
sbounds.size.height = maxheight - minheight;
|
||||
bounds = NSUnionRect (size, bounds);
|
||||
|
||||
sframe = bounds;
|
||||
sframe.size.width *= 1;
|
||||
sframe.size.height *= scale;
|
||||
|
||||
// size this view
|
||||
[self setFrame:sframe bounds:bounds scale:NSMakeSize (1, scale)];
|
||||
|
||||
//
|
||||
// size this view
|
||||
//
|
||||
// XXX[quakeed_i disableDisplay];
|
||||
//Sys_Printf ("sbounds: %g %g %g %g\n", -sbounds.size.width / 2, sbounds.origin.y, sbounds.size.width, sbounds.size.height);
|
||||
// XXX[self suspendNotifyAncestorWhenFrameChanged:YES];
|
||||
[self setFrameSize:sbounds.size];
|
||||
[self setFrameOrigin: NSMakePoint (-sbounds.size.width / 2,
|
||||
sbounds.origin.y)];
|
||||
[cv scrollToPoint: NSMakePoint (-sbounds.size.width/2, sbounds.origin.y)];
|
||||
// XXX[self suspendNotifyAncestorWhenFrameChanged:NO];
|
||||
[[_super_view superview] reflectScrolledClipView: cv];
|
||||
|
||||
// XXX[quakeed_i reenableDisplay];
|
||||
|
||||
[[zscrollview_i verticalScroller] display];
|
||||
|
||||
return self;
|
||||
|
@ -735,7 +709,7 @@ mouseDown
|
|||
|
||||
}
|
||||
|
||||
Sys_Printf ("bad flags for click %x\n", flags);
|
||||
Sys_Printf ("bad flags for click %x %g %g\n", flags, pt.x, pt.y);
|
||||
NopSound ();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue