slow progress in getting things to work

This commit is contained in:
Bill Currie 2010-09-20 03:06:35 +09:00
parent a229f20525
commit 7f5a68023b
7 changed files with 80 additions and 70 deletions

View file

@ -32,7 +32,8 @@ tile
Adjust the size for the pop up scale menu Adjust the size for the pop up scale menu
================= =================
*/ -tile */
-tile
{ {
NSRect scrollerframe; NSRect scrollerframe;
NSRect buttonframe, buttonframe2; NSRect buttonframe, buttonframe2;
@ -44,7 +45,7 @@ Adjust the size for the pop up scale menu
scrollerframe =[_horizScroller frame]; scrollerframe =[_horizScroller frame];
newframe.origin.y = scrollerframe.origin.y; newframe.origin.y = scrollerframe.origin.y;
newframe.origin.x = scrollerframe.size.width - buttonframe.size.width; newframe.origin.x = scrollerframe.origin.x + scrollerframe.size.width - buttonframe.size.width;
newframe.size.width = buttonframe.size.width; newframe.size.width = buttonframe.size.width;
newframe.size.height = scrollerframe.size.height; newframe.size.height = scrollerframe.size.height;
scrollerframe.size.width -= newframe.size.width; scrollerframe.size.width -= newframe.size.width;

View file

@ -55,10 +55,10 @@ void XYlineto (vec3_t pt);
-setDrawMode:(drawmode_t) mode; -setDrawMode:(drawmode_t) mode;
-newSuperBounds; -newSuperBounds;
-newRealBounds:(NSRect *) nb; -newRealBounds:(NSRect) nb;
-addToScrollRange: (float) x:(float) y; -addToScrollRange: (float) x:(float) y;
-setOrigin:(NSPoint *) pt scale:(float) sc; -setOrigin:(NSPoint) pt scale:(float) sc;
-centerOn:(vec3_t) org; -centerOn:(vec3_t) org;

View file

@ -49,6 +49,7 @@ initWithFrame:
[scalebutton_i addItemWithTitle:@"100%"]; [scalebutton_i addItemWithTitle:@"100%"];
[scalebutton_i addItemWithTitle:@"200%"]; [scalebutton_i addItemWithTitle:@"200%"];
[scalebutton_i addItemWithTitle:@"300%"]; [scalebutton_i addItemWithTitle:@"300%"];
[scalebutton_i sizeToFit];
[scalebutton_i selectItemAtIndex:4]; [scalebutton_i selectItemAtIndex:4];
@ -63,15 +64,16 @@ initWithFrame:
[gridbutton_i addItemWithTitle:@"grid 16"]; [gridbutton_i addItemWithTitle:@"grid 16"];
[gridbutton_i addItemWithTitle:@"grid 32"]; [gridbutton_i addItemWithTitle:@"grid 32"];
[gridbutton_i addItemWithTitle:@"grid 64"]; [gridbutton_i addItemWithTitle:@"grid 64"];
[gridbutton_i sizeToFit];
[gridbutton_i selectItemAtIndex:4]; [gridbutton_i selectItemAtIndex:4];
// initialize the scroll view // initialize the scroll view
scrollview_i =[[PopScrollView alloc] scrollview_i = [[PopScrollView alloc] initWithFrame: frameRect
initWithFrame: frameRect button1: scalebutton_i button2:gridbutton_i]; button1: scalebutton_i
button2: gridbutton_i];
[scrollview_i setLineScroll:64]; [scrollview_i setLineScroll:64];
[scrollview_i setAutoresizingMask:(NSViewWidthSizable | [scrollview_i setAutoresizingMask:(NSViewWidthSizable |
NSViewHeightSizable)]; NSViewHeightSizable)];
// link objects together // link objects together
[scrollview_i setDocumentView:self]; [scrollview_i setDocumentView:self];
@ -85,10 +87,9 @@ initWithFrame:
} }
-setModeRadio:m -setModeRadio:m
{ // this should be set from IB, but {
// because I toss myself in a // this should be set from IB, but because I toss myself in a
// popscrollview // popscrollview the connection gets lost
// the connection gets lost
mode_radio_i = m; mode_radio_i = m;
[mode_radio_i setTarget:self]; [mode_radio_i setTarget:self];
[mode_radio_i setAction: @selector (drawMode:)]; [mode_radio_i setAction: @selector (drawMode:)];
@ -119,20 +120,20 @@ initWithFrame:
/* /*
v v
*/ */
-setOrigin:(NSPoint *) -setOrigin:(NSPoint)pt scale:(float) sc
pt scale:(float) sc
{ {
NSRect sframe; NSRect sframe;
NSRect newbounds; NSRect newbounds;
NSClipView *cv = (NSClipView *) _super_view;
// //
// calculate the area visible in the cliprect // calculate the area visible in the cliprect
// //
scale = sc; scale = sc;
sframe =[[self superview] frame]; sframe = [_super_view frame];
newbounds =[[self superview] frame]; newbounds = [_super_view frame];
newbounds.origin = *pt; newbounds.origin = pt;
newbounds.size.width /= scale; newbounds.size.width /= scale;
newbounds.size.height /= scale; newbounds.size.height /= scale;
sframe.size.width /= scale; sframe.size.width /= scale;
@ -151,18 +152,19 @@ pt scale:(float) sc
// //
// size this view // size this view
// //
[self setBoundsSize:newbounds.size]; [self setFrameSize:newbounds.size];
[self setBoundsOrigin:newbounds.origin]; [self setFrameOrigin:newbounds.origin];
// XXX[self moveTo: newbounds.origin.x : newbounds.origin.y]; // XXX[self moveTo: newbounds.origin.x : newbounds.origin.y];
// //
// scroll and scale the clip view // scroll and scale the clip view
// //
[[self superview] setBoundsSize:sframe.size]; [cv setBoundsSize:sframe.size];
[[self superview] setBoundsOrigin:*pt]; [cv scrollToPoint:pt];
// XXX[quakeed_i reenableDisplay]; // XXX[quakeed_i reenableDisplay];
[scrollview_i display]; [scrollview_i display];
[[_super_view superview] reflectScrolledClipView: cv];
return self; return self;
} }
@ -183,7 +185,7 @@ pt scale:(float) sc
sbounds.origin.x += delta.x; sbounds.origin.x += delta.x;
sbounds.origin.y += delta.y; sbounds.origin.y += delta.y;
[self setOrigin: &sbounds.origin scale:scale]; [self setOrigin: sbounds.origin scale:scale];
return self; return self;
} }
@ -199,7 +201,7 @@ When superview is resized
NSRect r; NSRect r;
r =[[self superview] bounds]; r =[[self superview] bounds];
[self newRealBounds:&r]; [self newRealBounds:r];
return self; return self;
} }
@ -213,17 +215,23 @@ Should only change the scroll bars, not cause any redraws.
If realbounds has shrunk, nothing will change. If realbounds has shrunk, nothing will change.
=================== ===================
*/ */
-newRealBounds:(NSRect *) nb -newRealBounds:(NSRect) nb
{ {
NSRect sbounds; NSRect sbounds;
realbounds = *nb; realbounds = nb;
Sys_Printf ("realbounds: %g %g %g %g\n",
realbounds.origin.x, realbounds.origin.y,
realbounds.size.width, realbounds.size.height);
// //
// calculate the area visible in the cliprect // calculate the area visible in the cliprect
// //
sbounds =[[self superview] bounds]; sbounds = [[self superview] bounds];
sbounds = NSUnionRect (*nb, sbounds); Sys_Printf ("sbounds: %g %g %g %g\n",
sbounds.origin.x, sbounds.origin.y,
sbounds.size.width, sbounds.size.height);
sbounds = NSUnionRect (nb, sbounds);
// //
// size this view // size this view
@ -231,16 +239,16 @@ If realbounds has shrunk, nothing will change.
// XXX[quakeed_i disableDisplay]; // XXX[quakeed_i disableDisplay];
[self setPostsBoundsChangedNotifications:NO]; [self setPostsBoundsChangedNotifications:NO];
[self setBoundsSize:sbounds.size]; [self setFrameSize:sbounds.size];
[self setBoundsOrigin:sbounds.origin]; [self setFrameOrigin:sbounds.origin];
// XXX[self moveTo: sbounds.origin.x : sbounds.origin.y]; // XXX[self moveTo: sbounds.origin.x : sbounds.origin.y];
[self setPostsBoundsChangedNotifications:YES]; [self setPostsBoundsChangedNotifications:YES];
[scrollview_i reflectScrolledClipView:[scrollview_i contentView]]; [scrollview_i reflectScrolledClipView:[scrollview_i contentView]];
// XXX[quakeed_i reenableDisplay]; // XXX[quakeed_i reenableDisplay];
[[scrollview_i horizontalScroller] display]; //[[scrollview_i horizontalScroller] display];
[[scrollview_i verticalScroller] display]; //[[scrollview_i verticalScroller] display];
return self; return self;
} }
@ -276,7 +284,7 @@ Called when the scaler popup on the window is used
visrect.origin.x -= sframe.size.width / 2 / nscale; visrect.origin.x -= sframe.size.width / 2 / nscale;
visrect.origin.y -= sframe.size.height / 2 / nscale; visrect.origin.y -= sframe.size.height / 2 / nscale;
[self setOrigin: &visrect.origin scale:nscale]; [self setOrigin: visrect.origin scale:nscale];
return self; return self;
} }
@ -317,7 +325,7 @@ zoomIn
new.x = constant->x - ofs.x / 2; new.x = constant->x - ofs.x / 2;
new.y = constant->y - ofs.y / 2; new.y = constant->y - ofs.y / 2;
[self setOrigin: &new scale:scale * 2]; [self setOrigin: new scale:scale * 2];
return self; return self;
} }
@ -358,7 +366,7 @@ zoomOut
new.x = constant->x - ofs.x * 2; new.x = constant->x - ofs.x * 2;
new.y = constant->y - ofs.y * 2; new.y = constant->y - ofs.y * 2;
[self setOrigin: &new scale:scale / 2]; [self setOrigin: new scale:scale / 2];
return self; return self;
} }
@ -444,7 +452,7 @@ superviewChanged
*/ */
-superviewChanged -superviewChanged
{ {
[self newRealBounds:&realbounds]; [self newRealBounds:realbounds];
return self; return self;
} }
@ -705,7 +713,7 @@ drawWire
newrect.size.width += 2 * gridsize; newrect.size.width += 2 * gridsize;
newrect.size.height += 2 * gridsize; newrect.size.height += 2 * gridsize;
if (!NSEqualRects (newrect, realbounds)) if (!NSEqualRects (newrect, realbounds))
[self newRealBounds:&newrect]; [self newRealBounds:newrect];
return self; return self;
} }
@ -788,7 +796,7 @@ NSRect xy_draw_rect;
-drawRect: (NSRect) rects -drawRect: (NSRect) rects
{ {
static float drawtime; // static to shut up compiler warning float drawtime = 0;
if (timedrawing) if (timedrawing)
drawtime = Sys_DoubleTime (); drawtime = Sys_DoubleTime ();
@ -932,7 +940,7 @@ ScrollCallback (float dx, float dy)
oldreletive.x -= dx; oldreletive.x -= dx;
oldreletive.y -= dy; oldreletive.y -= dy;
[xyview_i setOrigin: &neworg scale:scale]; [xyview_i setOrigin: neworg scale:scale];
} }
-scrollDragFrom:(NSEvent *) theEvent -scrollDragFrom:(NSEvent *) theEvent

View file

@ -8,8 +8,8 @@ initWithFrame: button:
Initizes a scroll view with a button at it's lower right corner Initizes a scroll view with a button at it's lower right corner
==================== ====================
*/ */
- initWithFrame:(NSRect) - initWithFrame:(NSRect) frameRect button1:b1
frameRect button1:b1 { {
[super initWithFrame:frameRect]; [super initWithFrame:frameRect];
[self addSubview:b1]; [self addSubview:b1];
@ -29,7 +29,8 @@ tile
Adjust the size for the pop up scale menu Adjust the size for the pop up scale menu
================= =================
*/ -tile */
-tile
{ {
NSRect scrollerframe; NSRect scrollerframe;
@ -39,6 +40,7 @@ Adjust the size for the pop up scale menu
scrollerframe.size.width = 0; scrollerframe.size.width = 0;
[_horizScroller setFrame:scrollerframe]; [_horizScroller setFrame:scrollerframe];
[_horizScroller setHidden:YES];
return self; return self;
} }

View file

@ -41,8 +41,7 @@ extern float zplanedir;
-setXYOrigin:(NSPoint *) pt; -setXYOrigin:(NSPoint *) pt;
-setOrigin:(NSPoint *) -setOrigin:(NSPoint) pt scale:(float) sc;
pt scale:(float) sc;
@end @end
#endif // ZView_h #endif // ZView_h

View file

@ -52,16 +52,15 @@ initWithFrame:
[zscalebutton_i addItemWithTitle:@"300%"]; [zscalebutton_i addItemWithTitle:@"300%"];
[zscalebutton_i selectItemAtIndex:4]; [zscalebutton_i selectItemAtIndex:4];
// initialize the scroll view // initialize the scroll view
zscrollview_i =[[ZScrollView alloc] zscrollview_i =[[ZScrollView alloc] initWithFrame: frameRect
initWithFrame: frameRect button1:zscalebutton_i]; button1: zscalebutton_i];
[zscrollview_i setAutoresizingMask:NSViewWidthSizable | [zscrollview_i setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable]; NSViewHeightSizable];
[zscrollview_i setDocumentView:self]; [zscrollview_i setDocumentView:self];
// [_super_view setDrawOrigin: 0 : 0]; //[_super_view setBoundsOrigin: NSMakePoint (0, 0)];
minheight = 0; minheight = 0;
maxheight = 64; maxheight = 64;
@ -71,7 +70,7 @@ initWithFrame:
[self newRealBounds]; [self newRealBounds];
[self setOrigin: &pt scale:1]; [self setOrigin: pt scale:1];
return zscrollview_i; return zscrollview_i;
} }
@ -93,8 +92,7 @@ initWithFrame:
setOrigin:scale: setOrigin:scale:
=================== ===================
*/ */
-setOrigin:(NSPoint *) -setOrigin:(NSPoint) pt scale:(float) sc
pt scale:(float) sc
{ {
NSRect sframe; NSRect sframe;
NSRect newbounds; NSRect newbounds;
@ -104,9 +102,9 @@ pt scale:(float) sc
// //
scale = sc; scale = sc;
sframe =[_super_view frame]; sframe =[self frame];
newbounds =[_super_view frame]; newbounds =[self frame];
newbounds.origin = *pt; newbounds.origin = pt;
newbounds.size.width /= scale; newbounds.size.width /= scale;
newbounds.size.height /= scale; newbounds.size.height /= scale;
@ -130,7 +128,8 @@ pt scale:(float) sc
// size this view // size this view
// //
[self setBoundsSize:newbounds.size]; [self setBoundsSize:newbounds.size];
// XXX[self setDrawOrigin: -newbounds.size.width/2 : newbounds.origin.y]; [self setBoundsOrigin: NSMakePoint (-newbounds.size.width/2,
newbounds.origin.y)];
// XXX[self moveTo: -newbounds.size.width/2 : newbounds.origin.y]; // XXX[self moveTo: -newbounds.size.width/2 : newbounds.origin.y];
// //
@ -169,15 +168,15 @@ 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 =[_super_view bounds]; visrect =[self bounds];
sframe =[_super_view frame]; sframe =[self frame];
visrect.origin.x += visrect.size.width / 2; visrect.origin.x += visrect.size.width / 2;
visrect.origin.y += visrect.size.height / 2; visrect.origin.y += visrect.size.height / 2;
visrect.origin.x -= sframe.size.width / 2 / nscale; visrect.origin.x -= sframe.size.width / 2 / nscale;
visrect.origin.y -= sframe.size.height / 2 / nscale; visrect.origin.y -= sframe.size.height / 2 / nscale;
[self setOrigin: &visrect.origin scale:nscale]; [self setOrigin: visrect.origin scale:nscale];
return self; return self;
} }
@ -242,6 +241,7 @@ If realbounds has shrunk, nothing will change.
{ {
NSRect sbounds; NSRect sbounds;
float vistop, visbottom; float vistop, visbottom;
NSClipView *cv = (NSClipView *) _super_view;
if (minheight == oldminheight && maxheight == oldmaxheight) if (minheight == oldminheight && maxheight == oldmaxheight)
return self; return self;
@ -274,18 +274,18 @@ If realbounds has shrunk, nothing will change.
// size this view // size this view
// //
// XXX[quakeed_i disableDisplay]; // 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]; // XXX[self suspendNotifyAncestorWhenFrameChanged:YES];
[self setBoundsSize:sbounds.size]; [self setFrameSize:sbounds.size];
[self setBoundsOrigin: NSMakePoint (-sbounds.size.width / 2, [self setFrameOrigin: NSMakePoint (-sbounds.size.width / 2,
sbounds.origin.y)]; sbounds.origin.y)];
// XXX[self moveTo: -sbounds.size.width/2 : sbounds.origin.y]; [cv scrollToPoint: NSMakePoint (-sbounds.size.width/2, sbounds.origin.y)];
// XXX[self suspendNotifyAncestorWhenFrameChanged:NO]; // XXX[self suspendNotifyAncestorWhenFrameChanged:NO];
// XXX[[_super_view _super_view] reflectScroll: _super_view]; [[_super_view superview] reflectScrolledClipView: cv];
// XXX[quakeed_i reenableDisplay]; // XXX[quakeed_i reenableDisplay];
// XXX[[[[self _super_view] _super_view] vertScroller] display]; [[zscrollview_i verticalScroller] display];
return self; return self;
} }
@ -320,7 +320,7 @@ Rect is in global world (unscaled) coordinates
left = _bounds.origin.x; left = _bounds.origin.x;
right = 24; right = 24;
//Sys_Printf ("gridsize: %d left: %d right: %d\n", gridsize, left, right);
bottom = rect.origin.y - 1; bottom = rect.origin.y - 1;
top = rect.origin.y + rect.size.height + 2; top = rect.origin.y + rect.size.height + 2;
@ -441,14 +441,14 @@ drawSelf
-drawRect: (NSRect) rects -drawRect: (NSRect) rects
{ {
NSRect visRect; //NSRect visRect;
//Sys_Printf("ZView:drawRect\n");
minheight = 999999; minheight = 999999;
maxheight = -999999; maxheight = -999999;
// allways draw the entire bar // allways draw the entire bar
visRect =[self visibleRect]; //visRect =[self visibleRect];
rects = visRect; rects = [self bounds];
// erase window // erase window
NSEraseRect (rects); NSEraseRect (rects);
@ -612,7 +612,7 @@ ZScrollCallback (float dy)
scale =[zview_i currentScale]; scale =[zview_i currentScale];
oldreletive.y -= dy; oldreletive.y -= dy;
[zview_i setOrigin: &neworg scale:scale]; [zview_i setOrigin: neworg scale:scale];
} }
-scrollDragFrom:(NSEvent *) theEvent -scrollDragFrom:(NSEvent *) theEvent