Stored parents in the various tControls. This is neccessary for making tRelayout on all controls.
This commit is contained in:
parent
399f18f3ad
commit
8868ad3b53
|
@ -5,6 +5,7 @@
|
|||
NSMutableArray *children;
|
||||
NSView *sv;
|
||||
BOOL vertical;
|
||||
id<tControl> parent;
|
||||
}
|
||||
|
||||
- (id)tInitVertical:(BOOL)vert
|
||||
|
@ -14,6 +15,7 @@
|
|||
self->children = [NSMutableArray new];
|
||||
self->sv = nil;
|
||||
self->vertical = vert;
|
||||
self->parent = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -21,19 +23,20 @@
|
|||
- (void)tAddControl:(id<tControl>)c stretchy:(BOOL)s
|
||||
{
|
||||
if (self->sv != nil)
|
||||
[c tAddToView:self->sv];
|
||||
[c tSetParent:self->parent addToView:self->sv];
|
||||
[self->children addObject:c];
|
||||
// TODO mark as needing relayout
|
||||
}
|
||||
|
||||
- (void)tAddToView:(NSView *)v
|
||||
- (void)tSetParent:(id<tControl>)p addToView:(NSView *)v
|
||||
{
|
||||
self->parent = p;
|
||||
self->sv = v;
|
||||
[self->children enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
||||
id<tControl> c;
|
||||
|
||||
c = (id<tControl>) obj;
|
||||
[c tAddToView:self->sv];
|
||||
[c tSetParent:self->parent addToView:self->sv];
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
@implementation tButton {
|
||||
NSButton *b;
|
||||
id<tControl> parent;
|
||||
}
|
||||
|
||||
- (id)tInitWithText:(NSString *)text
|
||||
|
@ -16,12 +17,15 @@
|
|||
[self->b setBezelStyle:NSRoundedBezelStyle];
|
||||
[self->b setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]];
|
||||
[self->b setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||
|
||||
self->parent = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)tAddToView:(NSView *)v
|
||||
- (void)tSetParent:(id<tControl>)p addToView:(NSView *)v
|
||||
{
|
||||
self->parent = p;
|
||||
[v addSubview:self->b];
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
@protocol tControl
|
||||
@required
|
||||
- (void)tAddToView:(NSView *)v;
|
||||
- (void)tSetParent:(id<tControl>)p addToView:(NSView *)v;
|
||||
- (void)tFillAutoLayoutHorz:(NSMutableArray *)horz
|
||||
vert:(NSMutableArray *)vert
|
||||
extra:(NSMutableArray *)extra
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
@implementation tSpinbox {
|
||||
NSTextField *t;
|
||||
NSStepper *s;
|
||||
id<tControl> parent;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
|
@ -25,12 +26,15 @@
|
|||
[self->s setValueWraps:NO];
|
||||
[self->s setAutorepeat:YES];
|
||||
[self->s setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||
|
||||
self->parent = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)tAddToView:(NSView *)v
|
||||
- (void)tSetParent:(id<tControl>)p addToView:(NSView *)v
|
||||
{
|
||||
self->parent = p;
|
||||
[v addSubview:self->t];
|
||||
[v addSubview:self->s];
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
- (void)tSetControl:(id<tControl>)cc
|
||||
{
|
||||
self->c = cc;
|
||||
[self->c tAddToView:[self->w contentView]];
|
||||
[self->c tSetParent:self addToView:[self->w contentView]];
|
||||
[self tRelayout];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue