Added tEntry as a test of the tSpinbox bug. THAT works fine.

This commit is contained in:
Pietro Gagliardi 2015-08-03 11:14:05 -04:00
parent 38c10ed990
commit 06257b19a5
4 changed files with 70 additions and 0 deletions

View File

@ -55,6 +55,7 @@
}
// TODO spaced
// TODO custom minimum width for non-stretchy controls
- (void)tFillAutoLayout:(tAutoLayoutParams *)p
{
NSMutableDictionary *views;

58
redo/osxaltest/entry.m Normal file
View File

@ -0,0 +1,58 @@
// 31 july 2015
#import "osxaltest.h"
@implementation tEntry {
NSTextField *t;
id<tControl> parent;
NSLayoutPriority horzpri, vertpri;
}
- (id)init
{
self = [super init];
if (self) {
self->t = [[NSTextField alloc] initWithFrame:NSZeroRect];
[self->t setSelectable:YES];
[self->t setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]];
[self->t setBordered:NO];
[self->t setBezelStyle:NSTextFieldSquareBezel];
[self->t setBezeled:YES];
[[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

View File

@ -17,6 +17,7 @@ BOOL firstvert = YES;
tBox *box, *hbox;
tButton *button;
tSpinbox *spinbox;
tEntry *entry;
mainwin = [[tWindow alloc] init];
[mainwin tSetMargined:spaced];
@ -61,6 +62,13 @@ BOOL firstvert = YES;
[hbox tAddControl:spinbox stretchy:YES];
[box tAddControl:hbox stretchy:NO];
hbox = [[tBox alloc] tInitVertical:!firstvert];
entry = [[tEntry alloc] init];
[hbox tAddControl:entry stretchy:NO];
entry = [[tEntry alloc] init];
[hbox tAddControl:entry stretchy:YES];
[box tAddControl:hbox stretchy:NO];
[mainwin tShow];
}

View File

@ -36,6 +36,9 @@ struct tAutoLayoutParams {
- (id)tInitWithText:(NSString *)text;
@end
@interface tEntry : NSObject<tControl>
@end
@interface tSpinbox : NSObject<tControl>
@end