mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Add methods to handle orientation in NSStackView.
This commit is contained in:
parent
8814229de5
commit
47d48a1659
3 changed files with 103 additions and 6 deletions
2
MISSING
2
MISSING
|
@ -15,7 +15,7 @@ MISSING HEADERS ( * = difficult, - = quick, + = placeholder, x = won't do )
|
|||
> NSGlyphInfo.h -
|
||||
> NSItemProvider.h +
|
||||
> NSMenuToolbarItem.h -
|
||||
> NSOpenGLLayer.h +
|
||||
> NSOpenGLLayer.h x - header only
|
||||
> NSTableCellView.h *
|
||||
> NSTableRowView.h *
|
||||
> NSTableViewRowAction.h *
|
||||
|
|
|
@ -299,7 +299,7 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
@"string", @"NS.relative",
|
||||
@"canPropagateSelectedChildViewControllerTitle",
|
||||
@"NSTabViewControllerCanPropagateSelectedChildViewControllerTitle",
|
||||
@"rowAlignment", @"NSGrid_alignment",
|
||||
@"rowAlignment", @"NSGrid_alignment", // NSGridView
|
||||
@"rowSpacing", @"NSGrid_rowSpacing",
|
||||
@"columnSpacing", @"NSGrid_columnSpacing",
|
||||
@"hidden", @"NSGrid_hidden",
|
||||
|
@ -317,6 +317,10 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
@"contentView", @"NSGrid_content",
|
||||
@"row", @"NSGrid_owningRow",
|
||||
@"column", @"NSGrid_owningColumn",
|
||||
@"beginningViews", @"NSStackViewBeginningContainer", // NSStackView
|
||||
@"middleViews", @"NSStackViewMiddleContainer",
|
||||
@"endViews", @"NSStackViewEndContainer",
|
||||
@"orientation", @"NSStackViewOrientation",
|
||||
nil];
|
||||
RETAIN(XmlKeyMapTable);
|
||||
|
||||
|
@ -365,6 +369,7 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
// decoding the integer flag masks...
|
||||
XmlKeyToDecoderSelectorMap =
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"decodeOrientationForElement:", @"NSStackViewOrientation",
|
||||
@"decodeXPlacementForElement:", @"NSGrid_xPlacement",
|
||||
@"decodeYPlacementForElement:", @"NSGrid_yPlacement",
|
||||
@"decodeRowAlignmentForElement:", @"NSGrid_alignment",
|
||||
|
@ -3044,6 +3049,26 @@ didStartElement: (NSString*)elementName
|
|||
return [self _decodePlacementForObject: obj];
|
||||
}
|
||||
|
||||
- (id) _decodeOrientationForObject: (id)obj
|
||||
{
|
||||
NSLayoutConstraintOrientation orientation = 0L;
|
||||
if ([obj isEqualToString: @"vertical"])
|
||||
{
|
||||
orientation = NSLayoutConstraintOrientationVertical;
|
||||
}
|
||||
else if ([obj isEqualToString: @"horizontal"])
|
||||
{
|
||||
orientation = NSLayoutConstraintOrientationHorizontal;
|
||||
}
|
||||
return [NSNumber numberWithInteger: orientation];
|
||||
}
|
||||
|
||||
- (id) decodeOrientationForElement: (GSXibElement *)element
|
||||
{
|
||||
id obj = [element attributeForKey: @"orientation"];
|
||||
return [self _decodeOrientationForObject: obj];
|
||||
}
|
||||
|
||||
- (id) decodeRowAlignmentForElement: (GSXibElement *)element
|
||||
{
|
||||
id obj = [element attributeForKey: @"rowAlignment"];
|
||||
|
|
|
@ -71,6 +71,78 @@
|
|||
|
||||
- (void) _refreshView
|
||||
{
|
||||
if (_orientation == NSUserInterfaceLayoutOrientationHorizontal)
|
||||
{
|
||||
if (_beginningContainer != nil) // if one exists, they all do...
|
||||
{
|
||||
NSSize s = [self frame].size;
|
||||
CGFloat w = s.width / 3.0; // three sections, always.
|
||||
CGFloat h = s.height; // since we are horiz. the height is the height of the view
|
||||
NSUInteger i = 0;
|
||||
CGFloat y = 0.0;
|
||||
CGFloat x = 0.0;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
NSRect f;
|
||||
|
||||
x = w * (CGFloat)i;
|
||||
f = NSMakeRect(x,y,w,h);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
[_beginningContainer setFrame: f];
|
||||
[self addSubview: _beginningContainer];
|
||||
}
|
||||
if (i == 1)
|
||||
{
|
||||
[_middleContainer setFrame: f];
|
||||
[self addSubview: _middleContainer];
|
||||
}
|
||||
if (i == 2)
|
||||
{
|
||||
[_endContainer setFrame: f];
|
||||
[self addSubview: _endContainer];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_beginningContainer != nil) // if one exists, they all do...
|
||||
{
|
||||
NSSize s = [self frame].size;
|
||||
CGFloat w = s.width; // since vert... w is constant...
|
||||
CGFloat h = s.height / 3.0; // 3 sections
|
||||
NSUInteger i = 0;
|
||||
CGFloat y = 0.0;
|
||||
CGFloat x = 0.0;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
NSRect f;
|
||||
|
||||
x = h * (CGFloat)i;
|
||||
f = NSMakeRect(x,y,w,h);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
[_beginningContainer setFrame: f];
|
||||
[self addSubview: _beginningContainer];
|
||||
}
|
||||
if (i == 1)
|
||||
{
|
||||
[_middleContainer setFrame: f];
|
||||
[self addSubview: _middleContainer];
|
||||
}
|
||||
if (i == 2)
|
||||
{
|
||||
[_endContainer setFrame: f];
|
||||
[self addSubview: _endContainer];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Properties
|
||||
|
@ -184,10 +256,10 @@
|
|||
_customSpacingMap = RETAIN([NSMapTable weakToWeakObjectsMapTable]);
|
||||
_visiblePriorityMap = RETAIN([NSMapTable weakToWeakObjectsMapTable]);
|
||||
|
||||
// Gravity...
|
||||
_beginningContainer = [[NSStackViewContainer alloc] init];
|
||||
_middleContainer = [[NSStackViewContainer alloc] init];
|
||||
_endContainer = [[NSStackViewContainer alloc] init];
|
||||
// Gravity... not used by default.
|
||||
_beginningContainer = nil; // [[NSStackViewContainer alloc] init];
|
||||
_middleContainer = nil; // [[NSStackViewContainer alloc] init];
|
||||
_endContainer = nil; // [[NSStackViewContainer alloc] init];
|
||||
|
||||
[self _refreshView];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue