Fixed non-wrapping uiMultlineEntries.
This commit is contained in:
parent
07cd03452d
commit
6c6843dac6
|
@ -18,6 +18,7 @@ This README is being written.<br>
|
||||||
** Removed `uiControlVerifyDestroy()`; that is now part of `uiFreeControl()` itself.
|
** Removed `uiControlVerifyDestroy()`; that is now part of `uiFreeControl()` itself.
|
||||||
** Added `uiPi`, a constant for π. This is provided for C and C++ programmers, where there is no standard named constant for π; bindings authors shouldn't need to worry about this.
|
** Added `uiPi`, a constant for π. This is provided for C and C++ programmers, where there is no standard named constant for π; bindings authors shouldn't need to worry about this.
|
||||||
** Fixed uiMultilineEntry not properly having line breaks on Windows.
|
** Fixed uiMultilineEntry not properly having line breaks on Windows.
|
||||||
|
** Added `uiNewNonWrappingMultilineEntry()`, which creates a uiMultilineEntry that scrolls horizontally instead of wrapping lines. (This is not documented as being changeable after the fact on Windows, hence it's a creation-time choice.)
|
||||||
|
|
||||||
## Runtime Requirements
|
## Runtime Requirements
|
||||||
|
|
||||||
|
|
|
@ -150,9 +150,8 @@ void singleChildConstraintsSetMargined(struct singleChildConstraints *c, int mar
|
||||||
[c->bottomConstraintEqual setConstant:margin];
|
[c->bottomConstraintEqual setConstant:margin];
|
||||||
}
|
}
|
||||||
|
|
||||||
// from http://blog.bjhomer.com/2014/08/nsscrollview-and-autolayout.html because (as pointed out there) Apple's official guide is really only for iOS
|
// based on http://blog.bjhomer.com/2014/08/nsscrollview-and-autolayout.html because (as pointed out there) Apple's official guide is really only for iOS
|
||||||
// TODO this doesn't quite work with NSTextView; it *mostly* works
|
void scrollViewConstraintsEstablish(struct scrollViewConstraints *c, NSScrollView *sv, BOOL hscroll, BOOL vscroll, NSString *desc)
|
||||||
void scrollViewConstraintsEstablish(struct scrollViewConstraints *c, NSScrollView *sv, NSString *desc)
|
|
||||||
{
|
{
|
||||||
NSView *cv, *dv;
|
NSView *cv, *dv;
|
||||||
|
|
||||||
|
@ -176,6 +175,7 @@ void scrollViewConstraintsEstablish(struct scrollViewConstraints *c, NSScrollVie
|
||||||
[sv addConstraint:c->documentTop];
|
[sv addConstraint:c->documentTop];
|
||||||
[c->documentTop retain];
|
[c->documentTop retain];
|
||||||
|
|
||||||
|
if (!hscroll) {
|
||||||
c->documentTrailing = mkConstraint(dv, NSLayoutAttributeTrailing,
|
c->documentTrailing = mkConstraint(dv, NSLayoutAttributeTrailing,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
cv, NSLayoutAttributeTrailing,
|
cv, NSLayoutAttributeTrailing,
|
||||||
|
@ -183,8 +183,9 @@ void scrollViewConstraintsEstablish(struct scrollViewConstraints *c, NSScrollVie
|
||||||
[desc stringByAppendingString:@"document trailing constraint"]);
|
[desc stringByAppendingString:@"document trailing constraint"]);
|
||||||
[sv addConstraint:c->documentTrailing];
|
[sv addConstraint:c->documentTrailing];
|
||||||
[c->documentTrailing retain];
|
[c->documentTrailing retain];
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
if (!vscroll) {
|
||||||
c->documentBottom = mkConstraint(dv, NSLayoutAttributeBottom,
|
c->documentBottom = mkConstraint(dv, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
sv, NSLayoutAttributeBottom,
|
sv, NSLayoutAttributeBottom,
|
||||||
|
@ -192,7 +193,7 @@ void scrollViewConstraintsEstablish(struct scrollViewConstraints *c, NSScrollVie
|
||||||
[desc stringByAppendingString:@"document bottom constraint"]);
|
[desc stringByAppendingString:@"document bottom constraint"]);
|
||||||
[sv addConstraint:c->documentBottom];
|
[sv addConstraint:c->documentBottom];
|
||||||
[c->documentBottom retain];
|
[c->documentBottom retain];
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollViewConstraintsRemove(struct scrollViewConstraints *c, NSScrollView *sv)
|
void scrollViewConstraintsRemove(struct scrollViewConstraints *c, NSScrollView *sv)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// 8 december 2015
|
// 8 december 2015
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
|
// TODO you actually have to click on parts with a line in them in order to start editing; clicking below the last line doesn't give focus
|
||||||
|
|
||||||
// NSTextView has no intrinsic content size by default, which wreaks havoc on a pure-Auto Layout system
|
// NSTextView has no intrinsic content size by default, which wreaks havoc on a pure-Auto Layout system
|
||||||
// we'll have to take over to get it to work
|
// we'll have to take over to get it to work
|
||||||
// see also http://stackoverflow.com/questions/24210153/nstextview-not-properly-resizing-with-auto-layout and http://stackoverflow.com/questions/11237622/using-autolayout-with-expanding-nstextviews
|
// see also http://stackoverflow.com/questions/24210153/nstextview-not-properly-resizing-with-auto-layout and http://stackoverflow.com/questions/11237622/using-autolayout-with-expanding-nstextviews
|
||||||
|
@ -149,6 +151,12 @@ static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
|
||||||
disableAutocorrect(e->tv);
|
disableAutocorrect(e->tv);
|
||||||
// this option is complex; just set it to the Interface Builder default
|
// this option is complex; just set it to the Interface Builder default
|
||||||
[[e->tv layoutManager] setAllowsNonContiguousLayout:YES];
|
[[e->tv layoutManager] setAllowsNonContiguousLayout:YES];
|
||||||
|
if (hscroll) {
|
||||||
|
// TODO this is a giant mess
|
||||||
|
[e->tv setHorizontallyResizable:YES];
|
||||||
|
[[e->tv textContainer] setWidthTracksTextView:NO];
|
||||||
|
[[e->tv textContainer] setContainerSize:NSMakeSize(CGFLOAT_MAX, CGFLOAT_MAX)];
|
||||||
|
}
|
||||||
// don't use uiDarwinSetControlFont() directly; we have to do a little extra work to set the font
|
// don't use uiDarwinSetControlFont() directly; we have to do a little extra work to set the font
|
||||||
font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]];
|
font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]];
|
||||||
[e->tv setTypingAttributes:[NSDictionary
|
[e->tv setTypingAttributes:[NSDictionary
|
||||||
|
@ -160,7 +168,7 @@ static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
|
||||||
|
|
||||||
[e->sv setDocumentView:e->tv];
|
[e->sv setDocumentView:e->tv];
|
||||||
[e->tv setTranslatesAutoresizingMaskIntoConstraints:NO];
|
[e->tv setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||||
scrollViewConstraintsEstablish(&(e->constraints), e->sv, @"uiMultilineEntry");
|
scrollViewConstraintsEstablish(&(e->constraints), e->sv, hscroll, YES, @"uiMultilineEntry");
|
||||||
// needed to allow horizontal shrinking
|
// needed to allow horizontal shrinking
|
||||||
// TODO what about vertical text?
|
// TODO what about vertical text?
|
||||||
[e->tv setContentCompressionResistancePriority:NSLayoutPriorityDefaultLow forOrientation:NSLayoutConstraintOrientationHorizontal];
|
[e->tv setContentCompressionResistancePriority:NSLayoutPriorityDefaultLow forOrientation:NSLayoutConstraintOrientationHorizontal];
|
||||||
|
|
|
@ -80,7 +80,7 @@ struct scrollViewConstraints {
|
||||||
NSLayoutConstraint *documentWidth;
|
NSLayoutConstraint *documentWidth;
|
||||||
NSLayoutConstraint *documentHeight;
|
NSLayoutConstraint *documentHeight;
|
||||||
};
|
};
|
||||||
extern void scrollViewConstraintsEstablish(struct scrollViewConstraints *c, NSScrollView *sv, NSString *desc);
|
extern void scrollViewConstraintsEstablish(struct scrollViewConstraints *c, NSScrollView *sv, BOOL hscroll, BOOL vscroll, NSString *desc);
|
||||||
extern void scrollViewConstraintsRemove(struct scrollViewConstraints *c, NSScrollView *sv);
|
extern void scrollViewConstraintsRemove(struct scrollViewConstraints *c, NSScrollView *sv);
|
||||||
|
|
||||||
// map.m
|
// map.m
|
||||||
|
|
Loading…
Reference in New Issue