mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 06:00:44 +00:00
Fix for 5253. positional determination of splitview orientation and order.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@18087 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f0561498e9
commit
c1d9ea7597
3 changed files with 112 additions and 2 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2003-11-15 16:53 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormViewWithContectViewEditor.m: Added methods
|
||||
_shouldBeVertical and _sortByPosition:isVertical: and
|
||||
enhanced the groupSelectionInSplitView method to allow
|
||||
positional orientation of the splitview. The user should
|
||||
now expect the splitview to be built based on the relative
|
||||
position of the views in the window being edited. This fix
|
||||
addresses Report/Bug #5253.
|
||||
|
||||
2003-11-12 00:27 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormViewEditor.m: Removed extra RELEASE which was causing
|
||||
|
|
|
@ -841,6 +841,100 @@
|
|||
#define MAX(A,B) ((A)>(B)?(A):(B))
|
||||
#define MIN(A,B) ((A)<(B)?(A):(B))
|
||||
|
||||
int _sortViews(id view1, id view2, void *context)
|
||||
{
|
||||
BOOL isVertical = *((BOOL *)context);
|
||||
int order = NSOrderedSame;
|
||||
NSRect rect1 = [[view1 editedObject] frame];
|
||||
NSRect rect2 = [[view2 editedObject] frame];
|
||||
|
||||
if(!isVertical)
|
||||
{
|
||||
float y1 = rect1.origin.y;
|
||||
float y2 = rect2.origin.y;
|
||||
|
||||
if(y1 == y2)
|
||||
order = NSOrderedSame;
|
||||
else
|
||||
order = (y1 > y2)?NSOrderedAscending:NSOrderedDescending;
|
||||
}
|
||||
else
|
||||
{
|
||||
float x1 = rect1.origin.x;
|
||||
float x2 = rect2.origin.x;
|
||||
|
||||
if(x1 == x2)
|
||||
order = NSOrderedSame;
|
||||
else
|
||||
order = (x1 < x2)?NSOrderedAscending:NSOrderedDescending;
|
||||
}
|
||||
|
||||
return order;
|
||||
}
|
||||
|
||||
- (NSArray *) _sortByPosition: (NSArray *)subviews
|
||||
isVertical: (BOOL)isVertical
|
||||
{
|
||||
NSMutableArray *array = [subviews mutableCopy];
|
||||
NSMutableArray *result = [array sortedArrayUsingFunction: _sortViews
|
||||
context: &isVertical];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL) _shouldBeVertical: (NSArray *)subviews
|
||||
{
|
||||
BOOL vertical = NO;
|
||||
NSEnumerator *enumerator = [subviews objectEnumerator];
|
||||
GormViewEditor *editor = nil;
|
||||
NSRect prevRect = NSZeroRect;
|
||||
NSRect currRect = NSZeroRect;
|
||||
int count = 0;
|
||||
|
||||
// iterate over the list of views...
|
||||
while((editor = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSView *subview = [editor editedObject];
|
||||
currRect = [subview frame];
|
||||
|
||||
if(!NSEqualRects(prevRect,NSZeroRect))
|
||||
{
|
||||
float
|
||||
x1 = prevRect.origin.x, // pull these for convenience.
|
||||
x2 = currRect.origin.x,
|
||||
y1 = prevRect.origin.y,
|
||||
y2 = currRect.origin.y,
|
||||
h1 = prevRect.size.height,
|
||||
h2 = currRect.size.height,
|
||||
w1 = prevRect.size.width,
|
||||
w2 = currRect.size.width;
|
||||
|
||||
if((x1 < x2 || x1 > x2) && ((y2 >= y1 && y2 <= (y1 + h1)) ||
|
||||
(y2 <= y1 && y2 >= (y1 - h1))))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
if((y1 < y2 || y1 > y2) && ((x2 >= x1 && x2 <= (x1 + w1)) ||
|
||||
(x2 <= x1 && x2 >= (x1 - w1))))
|
||||
{
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
prevRect = currRect;
|
||||
}
|
||||
|
||||
NSLog(@"The vote is %d",count);
|
||||
|
||||
if(count >= 0)
|
||||
vertical = YES;
|
||||
else
|
||||
vertical = NO;
|
||||
|
||||
// return the result...
|
||||
return vertical;
|
||||
}
|
||||
|
||||
- (void) groupSelectionInSplitView
|
||||
{
|
||||
NSEnumerator *enumerator = nil;
|
||||
|
@ -849,6 +943,8 @@
|
|||
NSRect rect = NSZeroRect;
|
||||
GormViewEditor *editor = nil;
|
||||
NSView *superview = nil;
|
||||
NSArray *sortedviews = nil;
|
||||
BOOL vertical = NO;
|
||||
|
||||
if ([selection count] < 2)
|
||||
{
|
||||
|
@ -872,8 +968,12 @@
|
|||
|
||||
[superview addSubview: splitView];
|
||||
|
||||
// positionally determine orientation
|
||||
vertical = [self _shouldBeVertical: selection];
|
||||
sortedviews = [self _sortByPosition: selection isVertical: vertical];
|
||||
[splitView setVertical: vertical];
|
||||
|
||||
enumerator = [selection objectEnumerator];
|
||||
enumerator = [sortedviews objectEnumerator];
|
||||
|
||||
editor = [document editorForObject: splitView
|
||||
inEditor: self
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
styleMask: NSBorderlessWindowMask
|
||||
backing: NSBackingStoreBuffered
|
||||
defer: YES];
|
||||
|
||||
|
||||
[win setMenu: self];
|
||||
[win setLevel: NSSubmenuWindowLevel];
|
||||
// [win setWorksWhenModal: NO];
|
||||
|
|
Loading…
Reference in a new issue