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