mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 15:30:47 +00:00
Fixed drawing of subviews to tile decently.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3572 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a16328ebd0
commit
5c31c8bd0e
1 changed files with 70 additions and 58 deletions
|
@ -267,10 +267,7 @@ RETURN_LABEL:
|
||||||
|
|
||||||
- (void)adjustSubviews
|
- (void)adjustSubviews
|
||||||
{
|
{
|
||||||
NSRect fr=[self frame];
|
NSRect fr = [self frame];
|
||||||
NSSize newSize;
|
|
||||||
NSPoint newPoint;
|
|
||||||
float total=0.;
|
|
||||||
|
|
||||||
NSLog (@"XRSplitView adjustSubviews");
|
NSLog (@"XRSplitView adjustSubviews");
|
||||||
if(delegate && [delegate respondsToSelector:@selector(splitView:resizeSubviewsWithOldSize:)])
|
if(delegate && [delegate respondsToSelector:@selector(splitView:resizeSubviewsWithOldSize:)])
|
||||||
|
@ -279,62 +276,77 @@ NSLog (@"XRSplitView adjustSubviews");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* split the area up evenly */
|
{ /* split the area up evenly */
|
||||||
NSArray *subs=[self subviews];
|
NSArray *subs = [self subviews];
|
||||||
int i, div, count=[subs count];
|
unsigned count = [subs count];
|
||||||
id v;
|
NSView *views[count];
|
||||||
int w,h;
|
NSRect frames[count];
|
||||||
NSRect r, bd=[self bounds];
|
NSRect bd = [self bounds];
|
||||||
|
float thickness = [self dividerThickness];
|
||||||
|
NSSize newSize;
|
||||||
|
NSPoint newPoint;
|
||||||
|
unsigned i;
|
||||||
|
NSRect r;
|
||||||
|
float oldTotal;
|
||||||
|
float newTotal;
|
||||||
|
float scale;
|
||||||
|
float running;
|
||||||
|
|
||||||
div=(int)([self dividerThickness]*(count-1));
|
[subs getObjects: views];
|
||||||
w=(int)ceil((NSWidth(bd)-div)/count);
|
if ([self isVertical])
|
||||||
h=(int)ceil((NSHeight(bd)-div)/count);
|
{
|
||||||
for(i=0;i<count;i++)
|
newTotal = NSHeight(bd) - thickness*(count-1);
|
||||||
{
|
oldTotal = 0.0;
|
||||||
v=[subs objectAtIndex:i];
|
for (i = 0; i < count; i++)
|
||||||
r = [v frame];
|
{
|
||||||
/* bounds check */
|
frames[i] = [views[i] frame];
|
||||||
if([self isVertical])
|
oldTotal += NSHeight(frames[i]);
|
||||||
{
|
}
|
||||||
newSize=NSMakeSize(NSWidth(bd), h);
|
scale = newTotal/oldTotal;
|
||||||
/* make sure nothing spills over */
|
running = 0.0;
|
||||||
while((total+newSize.height)>(NSHeight(bd)-div))
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
newSize.height-=1.;
|
float newHeight;
|
||||||
}
|
|
||||||
total+=newSize.height;
|
|
||||||
|
|
||||||
newPoint=NSMakePoint(0,(float)ceil(i ?
|
r = [views[i] frame];
|
||||||
(i*([self dividerThickness]+h)) : 0));
|
newHeight = NSHeight(frames[i]) * scale;
|
||||||
if(newSize.height<1) newSize.height=1.;
|
if (i == count - 1)
|
||||||
if(newPoint.y<1) newPoint.y=1.;
|
newHeight = floor(newHeight);
|
||||||
}
|
else
|
||||||
else
|
newHeight = ceil(newHeight);
|
||||||
{
|
newSize = NSMakeSize(NSWidth(bd), newHeight);
|
||||||
newSize=NSMakeSize(w, NSHeight(bd));
|
newPoint = NSMakePoint(0.0, running);
|
||||||
/* make sure nothing spills over */
|
running += newHeight + thickness;
|
||||||
while((total+newSize.width)>(NSWidth(bd)-div))
|
[views[i] setFrameSize: newSize];
|
||||||
{
|
[views[i] setFrameOrigin: newPoint];
|
||||||
newSize.width-=1.;
|
}
|
||||||
}
|
}
|
||||||
total+=newSize.width;
|
else
|
||||||
|
{
|
||||||
|
newTotal = NSWidth(bd) - thickness*(count-1);
|
||||||
|
oldTotal = 0.0;
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
oldTotal += NSWidth([views[i] frame]);
|
||||||
|
}
|
||||||
|
scale = newTotal/oldTotal;
|
||||||
|
running = 0.0;
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
float newWidth;
|
||||||
|
|
||||||
newPoint=NSMakePoint((float)ceil(i ?
|
r = [views[i] frame];
|
||||||
(i*([self dividerThickness]+w)) : 0), 0);
|
newWidth = NSWidth(r) * scale;
|
||||||
if(newSize.width<1) newSize.width=1.;
|
if (i == count - 1)
|
||||||
if(newPoint.x<1) newPoint.x=1.;
|
newWidth = floor(newWidth);
|
||||||
}
|
else
|
||||||
[v setFrameSize: newSize];
|
newWidth = ceil(newWidth);
|
||||||
[v setFrameOrigin: newPoint];
|
newSize = NSMakeSize(newWidth, NSHeight(bd));
|
||||||
|
newPoint = NSMakePoint(running, 0.0);
|
||||||
if(!i == 0) // Fix me FAR
|
running += newWidth + thickness;
|
||||||
{
|
[views[i] setFrameSize: newSize];
|
||||||
[v setFrameOrigin:NSMakePoint(0, bounds.size.height - ([v bounds].size.height -
|
[views[i] setFrameOrigin: newPoint];
|
||||||
[self dividerThickness] - 20))];
|
}
|
||||||
//NSLog (@"XRSplitView: bounds.size.height %f, [v bounds].size.height %f ", //bounds.size.height, [v bounds].size.height);
|
}
|
||||||
//NSLog (@"XRSplitView: newPoint %f ", newPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
postNotificationName:NSSplitViewDidResizeSubviewsNotification object:self];
|
postNotificationName:NSSplitViewDidResizeSubviewsNotification object:self];
|
||||||
|
@ -366,7 +378,7 @@ if(!i == 0) // Fix me FAR
|
||||||
|
|
||||||
- (void)setDividerThickNess:(float)newWidth
|
- (void)setDividerThickNess:(float)newWidth
|
||||||
{
|
{
|
||||||
dividerWidth=newWidth;
|
dividerWidth=ceil(newWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float)draggedBarWidth //defaults to 8
|
- (float)draggedBarWidth //defaults to 8
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue