From 5f2fd0477a15ea6972692e8305deb26979128d2d Mon Sep 17 00:00:00 2001 From: Alexander Malmberg Date: Tue, 18 Feb 2003 20:26:49 +0000 Subject: [PATCH] Add basic interface that lets the typesetter access soft-invalidated layout information. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16003 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 2 +- Headers/gnustep/gui/GSLayoutManager.h | 13 +++++ Source/GSLayoutManager.m | 81 +++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 41151f4cf..b99bd99a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ * Headers/gnustep/gui/GSLayoutManager.h, Source/GSLayoutManager.m: Add basic interface that lets the typesetter access soft-invalidated - glyph information. + layout information. * Source/GSHorizontalTypesetter.m (-layoutLineNewParagraph:): Use the soft-invalidated information to avoid rebuilding the layout diff --git a/Headers/gnustep/gui/GSLayoutManager.h b/Headers/gnustep/gui/GSLayoutManager.h index 26f3b5b4e..5b24be4d7 100644 --- a/Headers/gnustep/gui/GSLayoutManager.h +++ b/Headers/gnustep/gui/GSLayoutManager.h @@ -317,6 +317,19 @@ just the union of all the line frag rects?) */ - (void) getFirstUnlaidCharacterIndex: (unsigned int *)charIndex glyphIndex: (unsigned int *)glyphIndex; + +/* +Basic (and experimental) methods that let the typesetter use soft-invalidated +layout information. +*/ +-(void) _softInvalidateUseLineFrags: (int)num + withShift: (NSSize)shift + inTextContainer: (NSTextContainer *)textContainer; +-(NSRect) _softInvalidateLineFragRect: (int)index + nextGlyph: (unsigned int *)next_glyph + inTextContainer: (NSTextContainer *)textContainer; +-(unsigned int) _softInvalidateFirstGlyphInTextContainer: (NSTextContainer *)textContainer; + @end #endif diff --git a/Source/GSLayoutManager.m b/Source/GSLayoutManager.m index b377fa9f5..d036d5345 100644 --- a/Source/GSLayoutManager.m +++ b/Source/GSLayoutManager.m @@ -2267,6 +2267,87 @@ forStartOfGlyphRange: (NSRange)glyphRange } +-(void) _softInvalidateUseLineFrags: (int)num + withShift: (NSSize)shift + inTextContainer: (NSTextContainer *)textContainer +{ + int i; + textcontainer_t *tc; + linefrag_t *lf; + for (i = 0, tc = textcontainers; i < num_textcontainers; i++, tc++) + if (tc->textContainer == textContainer) + break; + if (i == num_textcontainers) + { + NSLog(@"(%s): does not own text container", __PRETTY_FUNCTION__); + return; + } + + for (i = 0, lf = &tc->linefrags[tc->num_linefrags]; i < num; i++, lf++) + { + lf->rect.origin.x += shift.width; + lf->rect.origin.y += shift.height; + lf->used_rect.origin.x += shift.width; + lf->used_rect.origin.y += shift.height; + tc->length += lf->length; + } + tc->num_soft -= num; + tc->num_linefrags += num; + + layout_glyph = tc->pos + tc->length; + /* + We must have layouts beyond all the soft-invalidated line frags, + so comparing with glyphs->glyph_length is ok. + */ + if (layout_glyph == glyphs->glyph_length) + layout_char = glyphs->char_length; + else + layout_char = [self characterIndexForGlyphAtIndex: layout_glyph]; /* TODO? */ +} + +-(NSRect) _softInvalidateLineFragRect: (int)index + nextGlyph: (unsigned int *)next_glyph + inTextContainer: (NSTextContainer *)textContainer +{ + int i; + textcontainer_t *tc; + linefrag_t *lf; + for (i = 0, tc = textcontainers; i < num_textcontainers; i++, tc++) + if (tc->textContainer == textContainer) + break; + if (i == num_textcontainers) + { + NSLog(@"(%s): does not own text container", __PRETTY_FUNCTION__); + return NSZeroRect; + } + + if (index >= tc->num_soft) + return NSZeroRect; + + lf = &tc->linefrags[tc->num_linefrags + index]; + *next_glyph = lf->pos + lf->length; + return lf->rect; +} + +-(unsigned int) _softInvalidateFirstGlyphInTextContainer: (NSTextContainer *)textContainer +{ + int i; + textcontainer_t *tc; + for (i = 0, tc = textcontainers; i < num_textcontainers; i++, tc++) + if (tc->textContainer == textContainer) + break; + if (i == num_textcontainers) + { + NSLog(@"(%s): does not own text container", __PRETTY_FUNCTION__); + return (unsigned int)-1; + } + if (tc->num_soft) + return tc->linefrags[tc->num_linefrags].pos; + else + return (unsigned int)-1; +} + + @end