* Source/GSLayoutManager.m (-usedRectForTextContainer:): Add extra

line rect when needed.
	* Source/NSTextView.m (sizeToFit): Don't add extra line rect, as
	it is now already included.
	* Source/NSStringDrawing.m (cache_lookup): Remove hack for empty string.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@40346 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2017-02-17 19:44:25 +00:00
parent f5ce3badde
commit a33b4c5073
4 changed files with 27 additions and 20 deletions

View file

@ -1,3 +1,11 @@
2017-02-17 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSLayoutManager.m (-usedRectForTextContainer:): Add extra
line rect when needed.
* Source/NSTextView.m (sizeToFit): Don't add extra line rect, as
it is now already included.
* Source/NSStringDrawing.m (cache_lookup): Remove hack for empty string.
2017-02-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSStringDrawing.m: Use shared drawing code.

View file

@ -2601,7 +2601,14 @@ forStartOfGlyphRange: (NSRange)glyphRange
}
if (tc->usedRectValid)
return tc->usedRect;
{
used = tc->usedRect;
if (tc->textContainer == extra_textcontainer)
{
used = NSUnionRect(used, extra_used_rect);
}
return used;
}
if (tc->num_linefrags)
{
@ -2626,9 +2633,15 @@ forStartOfGlyphRange: (NSRange)glyphRange
used = NSMakeRect(x0, y0, x1 - x0, y1 - y0);
}
else
used = NSZeroRect;
{
used = NSZeroRect;
}
tc->usedRect = used;
tc->usedRectValid = YES;
if (tc->textContainer == extra_textcontainer)
{
used = NSUnionRect(used, extra_used_rect);
}
return used;
}

View file

@ -285,17 +285,9 @@ static cache_t *cache_lookup(BOOL hasSize, NSSize size, BOOL useScreenFonts)
[c->textContainer setContainerSize: NSMakeSize(LARGE_SIZE, LARGE_SIZE)];
}
[c->layoutManager setUsesScreenFonts: useScreenFonts];
if ([c->textStorage length] == 0)
{
// FIXME: We should use attributes from the original data
CGFloat h = [[NSFont userFontOfSize: 0] defaultLineHeightForFont];
c->usedRect = NSMakeRect(0.0, 0.0, 0.0, h);
}
else
{
c->usedRect = [c->layoutManager usedRectForTextContainer: c->textContainer];
}
// Layout the whole container
[c->layoutManager glyphRangeForTextContainer: c->textContainer];
c->usedRect = [c->layoutManager usedRectForTextContainer: c->textContainer];
}
return c;

View file

@ -1933,13 +1933,7 @@ incorrectly. */
if (_tf.is_horizontally_resizable || _tf.is_vertically_resizable)
{
NSRect r = [_layoutManager usedRectForTextContainer: _textContainer];
NSSize s2;
if (_textContainer == [_layoutManager extraLineFragmentTextContainer])
{
r = NSUnionRect(r, [_layoutManager extraLineFragmentUsedRect]);
}
s2 = NSMakeSize(NSMaxX(r), NSMaxY(r));
NSSize s2 = NSMakeSize(NSMaxX(r), NSMaxY(r));
if (_tf.is_horizontally_resizable)
size.width = s2.width + 2 * _textContainerInset.width;