Added labels to make sure those don't need minimum width constraints. They don't.
This commit is contained in:
parent
1cdc7d3eb3
commit
f185ca71c6
|
@ -0,0 +1,61 @@
|
||||||
|
// 31 july 2015
|
||||||
|
#import "osxaltest.h"
|
||||||
|
|
||||||
|
@implementation tLabel {
|
||||||
|
NSTextField *t;
|
||||||
|
id<tControl> parent;
|
||||||
|
NSLayoutPriority horzpri, vertpri;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)init
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
self->t = [[NSTextField alloc] initWithFrame:NSZeroRect];
|
||||||
|
[self->t setStringValue:@"Label"];
|
||||||
|
[self->t setEditable:NO];
|
||||||
|
[self->t setSelectable:NO];
|
||||||
|
[self->t setDrawsBackground:NO];
|
||||||
|
[self->t setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]];
|
||||||
|
[self->t setBordered:NO];
|
||||||
|
[self->t setBezelStyle:NSTextFieldSquareBezel];
|
||||||
|
[self->t setBezeled:NO];
|
||||||
|
[[self->t cell] setLineBreakMode:NSLineBreakByClipping];
|
||||||
|
[[self->t cell] setScrollable:YES];
|
||||||
|
[self->t setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||||
|
|
||||||
|
self->parent = nil;
|
||||||
|
|
||||||
|
self->horzpri = [self->t contentHuggingPriorityForOrientation:NSLayoutConstraintOrientationHorizontal];
|
||||||
|
self->vertpri = [self->t contentHuggingPriorityForOrientation:NSLayoutConstraintOrientationVertical];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)tSetParent:(id<tControl>)p addToView:(NSView *)v relayout:(BOOL)relayout
|
||||||
|
{
|
||||||
|
self->parent = p;
|
||||||
|
[v addSubview:self->t];
|
||||||
|
if (relayout)
|
||||||
|
[self tRelayout];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)tFillAutoLayout:(tAutoLayoutParams *)p
|
||||||
|
{
|
||||||
|
// reset the hugging priority
|
||||||
|
[self->t setContentHuggingPriority:self->horzpri forOrientation:NSLayoutConstraintOrientationHorizontal];
|
||||||
|
[self->t setContentHuggingPriority:self->vertpri forOrientation:NSLayoutConstraintOrientationVertical];
|
||||||
|
p->view = self->t;
|
||||||
|
p->attachLeft = YES;
|
||||||
|
p->attachTop = YES;
|
||||||
|
p->attachRight = YES;
|
||||||
|
p->attachBottom = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)tRelayout
|
||||||
|
{
|
||||||
|
if (self->parent != nil)
|
||||||
|
[self->parent tRelayout];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -18,6 +18,7 @@ BOOL firstvert = YES;
|
||||||
tButton *button;
|
tButton *button;
|
||||||
tSpinbox *spinbox;
|
tSpinbox *spinbox;
|
||||||
tEntry *entry;
|
tEntry *entry;
|
||||||
|
tLabel *label;
|
||||||
|
|
||||||
mainwin = [[tWindow alloc] init];
|
mainwin = [[tWindow alloc] init];
|
||||||
[mainwin tSetMargined:spaced];
|
[mainwin tSetMargined:spaced];
|
||||||
|
@ -69,6 +70,11 @@ BOOL firstvert = YES;
|
||||||
[hbox tAddControl:entry stretchy:YES];
|
[hbox tAddControl:entry stretchy:YES];
|
||||||
[box tAddControl:hbox stretchy:NO];
|
[box tAddControl:hbox stretchy:NO];
|
||||||
|
|
||||||
|
hbox = [[tBox alloc] tInitVertical:!firstvert spaced:spaced];
|
||||||
|
label = [[tLabel alloc] init];
|
||||||
|
[hbox tAddControl:label stretchy:NO];
|
||||||
|
[box tAddControl:hbox stretchy:NO];
|
||||||
|
|
||||||
[mainwin tShow];
|
[mainwin tShow];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,9 @@ struct tAutoLayoutParams {
|
||||||
@interface tEntry : NSObject<tControl>
|
@interface tEntry : NSObject<tControl>
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface tLabel : NSObject<tControl>
|
||||||
|
@end
|
||||||
|
|
||||||
@interface tSpinbox : NSObject<tControl>
|
@interface tSpinbox : NSObject<tControl>
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
{
|
{
|
||||||
[self->w cascadeTopLeftFromPoint:NSMakePoint(20, 20)];
|
[self->w cascadeTopLeftFromPoint:NSMakePoint(20, 20)];
|
||||||
[self->w makeKeyAndOrderFront:self];
|
[self->w makeKeyAndOrderFront:self];
|
||||||
// [[self->w contentView] tIsAmbiguous:0];
|
[[self->w contentView] tIsAmbiguous:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)tRelayout
|
- (void)tRelayout
|
||||||
|
|
Loading…
Reference in New Issue