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;
|
-(int) gridsize;
|
||||||
-(float) snapToGrid:(float) f;
|
-(float) snapToGrid:(float) f;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NSView(XYView)
|
||||||
|
-(void) setFrame:(NSRect) frame bounds:(NSRect) bounds scale:(NSSize) scale;
|
||||||
@end
|
@end
|
||||||
#endif // XYView_h
|
#endif // XYView_h
|
||||||
|
|
|
@ -16,6 +16,34 @@ id scrollview_i, gridbutton_i, scalebutton_i;
|
||||||
vec3_t xy_viewnormal; // v_forward for xy view
|
vec3_t xy_viewnormal; // v_forward for xy view
|
||||||
float xy_viewdist; // clip behind this plane
|
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
|
@implementation XYView
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
|
@ -141,31 +169,11 @@ initWithFrame:
|
||||||
sframe.size.height *= scale;
|
sframe.size.height *= scale;
|
||||||
|
|
||||||
// redisplay everything
|
// redisplay everything
|
||||||
//[self setPostsFrameChangedNotifications:NO];
|
|
||||||
//[self setPostsBoundsChangedNotifications:NO];
|
|
||||||
|
|
||||||
// size this view
|
// size this view
|
||||||
[self setFrame: sframe];
|
[self setFrame:sframe bounds:bounds scale:NSMakeSize (scale, scale)];
|
||||||
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 setPostsFrameChangedNotifications:YES];
|
// scroll the clip view
|
||||||
//[self setPostsBoundsChangedNotifications:YES];
|
|
||||||
|
|
||||||
// scroll and scale the clip view
|
|
||||||
pt.x *= scale;
|
pt.x *= scale;
|
||||||
pt.y *= scale;
|
pt.y *= scale;
|
||||||
[cv setBoundsOrigin:pt];
|
[cv setBoundsOrigin:pt];
|
||||||
|
@ -231,6 +239,7 @@ If realbounds has shrunk, nothing will change.
|
||||||
bounds.origin.y /= scale;
|
bounds.origin.y /= scale;
|
||||||
bounds.size.width /= scale;
|
bounds.size.width /= scale;
|
||||||
bounds.size.height /= scale;
|
bounds.size.height /= scale;
|
||||||
|
|
||||||
bounds = NSUnionRect (realbounds, bounds);
|
bounds = NSUnionRect (realbounds, bounds);
|
||||||
sframe = bounds;
|
sframe = bounds;
|
||||||
sframe.origin.x *= scale;
|
sframe.origin.x *= scale;
|
||||||
|
@ -239,20 +248,7 @@ If realbounds has shrunk, nothing will change.
|
||||||
sframe.size.height *= scale;
|
sframe.size.height *= scale;
|
||||||
|
|
||||||
// size this view
|
// size this view
|
||||||
//[self setPostsFrameChangedNotifications:NO];
|
[self setFrame:sframe bounds:bounds scale:NSMakeSize (scale, scale)];
|
||||||
//[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];
|
|
||||||
|
|
||||||
[scrollview_i reflectScrolledClipView:[scrollview_i contentView]];
|
[scrollview_i reflectScrolledClipView:[scrollview_i contentView]];
|
||||||
return self;
|
return self;
|
||||||
|
@ -1230,8 +1226,7 @@ mouseDown
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
// check eye
|
// check eye
|
||||||
if ([cameraview_i XYmouseDown: &pt flags:[theEvent
|
if ([cameraview_i XYmouseDown: &pt flags:[theEvent modifierFlags]])
|
||||||
modifierFlags]])
|
|
||||||
return self; // camera move
|
return self; // camera move
|
||||||
|
|
||||||
// check z post
|
// check z post
|
||||||
|
|
|
@ -60,12 +60,12 @@ initWithFrame:
|
||||||
|
|
||||||
[zscrollview_i setDocumentView:self];
|
[zscrollview_i setDocumentView:self];
|
||||||
|
|
||||||
//[_super_view setBoundsOrigin: NSMakePoint (0, 0)];
|
[_super_view setBoundsOrigin: NSMakePoint (0, 0)];
|
||||||
|
|
||||||
minheight = 0;
|
minheight = 0;
|
||||||
maxheight = 64;
|
maxheight = 64;
|
||||||
|
|
||||||
pt.x = -_bounds.size.width;
|
pt.x = -[_super_view bounds].size.width / 2;
|
||||||
pt.y = -128;
|
pt.y = -128;
|
||||||
|
|
||||||
[self newRealBounds];
|
[self newRealBounds];
|
||||||
|
@ -95,52 +95,36 @@ setOrigin:scale:
|
||||||
-setOrigin:(NSPoint) pt scale:(float) sc
|
-setOrigin:(NSPoint) pt scale:(float) sc
|
||||||
{
|
{
|
||||||
NSRect sframe;
|
NSRect sframe;
|
||||||
NSRect newbounds;
|
NSRect bounds;
|
||||||
|
NSRect size;
|
||||||
|
|
||||||
//
|
|
||||||
// calculate the area visible in the cliprect
|
// calculate the area visible in the cliprect
|
||||||
//
|
|
||||||
scale = sc;
|
scale = sc;
|
||||||
|
|
||||||
sframe =[self frame];
|
bounds =[_super_view bounds];
|
||||||
newbounds =[self frame];
|
bounds.origin = pt;
|
||||||
newbounds.origin = pt;
|
bounds.size.width /= 1;
|
||||||
newbounds.size.width /= scale;
|
bounds.size.height /= scale;
|
||||||
newbounds.size.height /= scale;
|
|
||||||
|
|
||||||
//
|
size = NSMakeRect (0, oldminheight, 1, oldmaxheight - oldminheight);
|
||||||
// union with the realbounds
|
// union with the realbounds
|
||||||
//
|
bounds = NSUnionRect (size, bounds);
|
||||||
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
|
// redisplay everything
|
||||||
//
|
bounds.origin = NSMakePoint (-bounds.size.width/2, bounds.origin.y);
|
||||||
// XXX[quakeed_i disableDisplay];
|
sframe = bounds;
|
||||||
|
sframe.origin.x *= 1;
|
||||||
|
sframe.origin.y *= scale;
|
||||||
|
sframe.size.width *= 1;
|
||||||
|
sframe.size.height *= scale;
|
||||||
|
|
||||||
//
|
|
||||||
// size this view
|
// size this view
|
||||||
//
|
[self setFrame:sframe bounds:bounds scale:NSMakeSize (1, scale)];
|
||||||
[self setBoundsSize:newbounds.size];
|
|
||||||
[self setBoundsOrigin: NSMakePoint (-newbounds.size.width/2,
|
|
||||||
newbounds.origin.y)];
|
|
||||||
// XXX[self moveTo: -newbounds.size.width/2 : newbounds.origin.y];
|
|
||||||
|
|
||||||
//
|
|
||||||
// scroll and scale the clip view
|
// scroll and scale the clip view
|
||||||
//
|
pt.x *= 1;
|
||||||
// XXX[_super_view setDrawSize
|
pt.y *= scale;
|
||||||
// XXX : sframe.size.width/scale
|
[_super_view setBoundsOrigin: pt];
|
||||||
// XXX : sframe.size.height/scale];
|
|
||||||
// XXX[_super_view setDrawOrigin: pt->x : pt->y];
|
|
||||||
|
|
||||||
// XXX[quakeed_i reenableDisplay];
|
|
||||||
[zscrollview_i display];
|
[zscrollview_i display];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -157,7 +141,8 @@ Called when the scaler popup on the window is used
|
||||||
-scaleMenuTarget:sender
|
-scaleMenuTarget:sender
|
||||||
{
|
{
|
||||||
char const *item;
|
char const *item;
|
||||||
NSRect visrect, sframe;
|
NSRect rect;
|
||||||
|
NSPoint mid, org, orig;
|
||||||
float nscale;
|
float nscale;
|
||||||
|
|
||||||
item =[[sender titleOfSelectedItem] cString];
|
item =[[sender titleOfSelectedItem] cString];
|
||||||
|
@ -168,15 +153,17 @@ Called when the scaler popup on the window is used
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// keep the center of the view constant
|
// keep the center of the view constant
|
||||||
visrect =[self bounds];
|
rect =[_super_view bounds];
|
||||||
sframe =[self frame];
|
mid.x = rect.size.width / 2;
|
||||||
visrect.origin.x += visrect.size.width / 2;
|
mid.y = rect.size.height / 2;
|
||||||
visrect.origin.y += visrect.size.height / 2;
|
|
||||||
|
|
||||||
visrect.origin.x -= sframe.size.width / 2 / nscale;
|
org.x = (rect.origin.x + mid.x) / 1;
|
||||||
visrect.origin.y -= sframe.size.height / 2 / nscale;
|
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;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -239,8 +226,10 @@ If realbounds has shrunk, nothing will change.
|
||||||
*/
|
*/
|
||||||
-newRealBounds
|
-newRealBounds
|
||||||
{
|
{
|
||||||
NSRect sbounds;
|
NSRect bounds;
|
||||||
float vistop, visbottom;
|
NSRect sframe;
|
||||||
|
NSRect size;
|
||||||
|
|
||||||
NSClipView *cv = (NSClipView *) _super_view;
|
NSClipView *cv = (NSClipView *) _super_view;
|
||||||
|
|
||||||
if (minheight == oldminheight && maxheight == oldmaxheight)
|
if (minheight == oldminheight && maxheight == oldmaxheight)
|
||||||
|
@ -252,38 +241,23 @@ If realbounds has shrunk, nothing will change.
|
||||||
minheight -= 16;
|
minheight -= 16;
|
||||||
maxheight += 16;
|
maxheight += 16;
|
||||||
|
|
||||||
//
|
|
||||||
// calculate the area visible in the cliprect
|
// calculate the area visible in the cliprect
|
||||||
//
|
bounds =[cv bounds];
|
||||||
sbounds =[_super_view bounds];
|
bounds.size.width /= 1;
|
||||||
visbottom = sbounds.origin.y;
|
bounds.size.height /= scale;
|
||||||
vistop = visbottom + sbounds.size.height;
|
|
||||||
|
|
||||||
if (vistop > maxheight)
|
size = NSMakeRect (0, minheight, 1, maxheight - minheight);
|
||||||
maxheight = vistop;
|
|
||||||
if (visbottom < minheight)
|
|
||||||
minheight = visbottom;
|
|
||||||
if (minheight == _bounds.origin.y
|
|
||||||
&& maxheight - minheight == _bounds.size.height)
|
|
||||||
return self;
|
|
||||||
|
|
||||||
sbounds.origin.y = minheight;
|
bounds = NSUnionRect (size, bounds);
|
||||||
sbounds.size.height = maxheight - minheight;
|
|
||||||
|
sframe = bounds;
|
||||||
|
sframe.size.width *= 1;
|
||||||
|
sframe.size.height *= scale;
|
||||||
|
|
||||||
//
|
|
||||||
// size this view
|
// size this view
|
||||||
//
|
[self setFrame:sframe bounds:bounds scale:NSMakeSize (1, scale)];
|
||||||
// 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];
|
[[_super_view superview] reflectScrolledClipView: cv];
|
||||||
|
|
||||||
[[zscrollview_i verticalScroller] display];
|
[[zscrollview_i verticalScroller] display];
|
||||||
|
|
||||||
|
@ -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 ();
|
NopSound ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue