mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:00:48 +00:00
Add -_didInvalidateLayout method that is called whenever any layout information has been invalidated. Use it in NSLayoutManager to resize text views.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15915 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b03bce8c51
commit
f5851fc4f4
4 changed files with 58 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2003-02-09 18:02 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
|
* Headers/gnustep/gui/GSLayoutManager_internal.h,
|
||||||
|
Source/GSLayoutManager.m, Source/NSLayoutManager.m: Add
|
||||||
|
-_didInvalidateLayout method that is called whenever layout has
|
||||||
|
been invalidated. Use it in NSLayoutManager to resize text views.
|
||||||
|
|
||||||
2003-02-09 15:23 Alexander Malmberg <alexander@malmberg.org>
|
2003-02-09 15:23 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
* Source/NSTextView_actions.m: Fix several movement actions (used
|
* Source/NSTextView_actions.m: Fix several movement actions (used
|
||||||
|
|
|
@ -164,6 +164,19 @@ typedef struct GSLayoutManager_textcontainer_s
|
||||||
BOOL started, complete;
|
BOOL started, complete;
|
||||||
unsigned int pos, length;
|
unsigned int pos, length;
|
||||||
|
|
||||||
|
/*
|
||||||
|
This should be set to YES whenever any layout information for this text
|
||||||
|
container has been invalidated. It is reset to NO in -_didInvalidateLayout.
|
||||||
|
All methods called externally that invalidate layout (directly or
|
||||||
|
indirectly) should call -_didInvalidateLayout at some safe point after
|
||||||
|
all invalidation is done.
|
||||||
|
|
||||||
|
In GSLayoutManager, -_didInvalidateLayout only resets the flags. However,
|
||||||
|
subclasses might need to actually do something. NSLayoutManager needs to
|
||||||
|
tell its NSTextView:s to resize.
|
||||||
|
*/
|
||||||
|
BOOL was_invalidated;
|
||||||
|
|
||||||
linefrag_t *linefrags;
|
linefrag_t *linefrags;
|
||||||
int num_linefrags;
|
int num_linefrags;
|
||||||
} textcontainer_t;
|
} textcontainer_t;
|
||||||
|
@ -198,6 +211,8 @@ typedef struct GSLayoutManager_textcontainer_s
|
||||||
-(void) _doLayout; /* TODO: this is just a hack until proper incremental layout is done */
|
-(void) _doLayout; /* TODO: this is just a hack until proper incremental layout is done */
|
||||||
-(void) _doLayoutToGlyph: (unsigned int)glyphIndex;
|
-(void) _doLayoutToGlyph: (unsigned int)glyphIndex;
|
||||||
-(void) _doLayoutToContainer: (int)cindex;
|
-(void) _doLayoutToContainer: (int)cindex;
|
||||||
|
|
||||||
|
-(void) _didInvalidateLayout;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1295,6 +1295,7 @@ it should still be safe. might lose opportunities to merge runs, though.
|
||||||
tc->linefrags = NULL;
|
tc->linefrags = NULL;
|
||||||
tc->num_linefrags = 0;
|
tc->num_linefrags = 0;
|
||||||
tc->pos = tc->length = 0;
|
tc->pos = tc->length = 0;
|
||||||
|
tc->was_invalidated = YES;
|
||||||
}
|
}
|
||||||
for (i = idx - 1, tc = textcontainers + idx - 1; i >= 0; i--, tc--)
|
for (i = idx - 1, tc = textcontainers + idx - 1; i >= 0; i--, tc--)
|
||||||
{
|
{
|
||||||
|
@ -1368,6 +1369,18 @@ it should still be safe. might lose opportunities to merge runs, though.
|
||||||
[self _doLayout];
|
[self _doLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-(void) _didInvalidateLayout
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
textcontainer_t *tc;
|
||||||
|
|
||||||
|
for (tc = textcontainers, i = 0; i < num_textcontainers; i++, tc++)
|
||||||
|
{
|
||||||
|
tc->was_invalidated = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -1380,6 +1393,7 @@ it should still be safe. might lose opportunities to merge runs, though.
|
||||||
{
|
{
|
||||||
[self _invalidateLayoutFromContainer: 0];
|
[self _invalidateLayoutFromContainer: 0];
|
||||||
#if 0
|
#if 0
|
||||||
|
/* TODO: need to bring this up to date and fix it */
|
||||||
unsigned int from_glyph = glyphs->glyph_length;
|
unsigned int from_glyph = glyphs->glyph_length;
|
||||||
int i, j;
|
int i, j;
|
||||||
textcontainer_t *tc;
|
textcontainer_t *tc;
|
||||||
|
@ -1926,6 +1940,8 @@ forStartOfGlyphRange: (NSRange)glyphRange
|
||||||
textcontainers[i].textContainer = [aTextContainer retain];
|
textcontainers[i].textContainer = [aTextContainer retain];
|
||||||
|
|
||||||
[aTextContainer setLayoutManager: self];
|
[aTextContainer setLayoutManager: self];
|
||||||
|
|
||||||
|
[self _didInvalidateLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) removeTextContainerAtIndex: (unsigned int)index
|
- (void) removeTextContainerAtIndex: (unsigned int)index
|
||||||
|
@ -1949,6 +1965,8 @@ forStartOfGlyphRange: (NSRange)glyphRange
|
||||||
free(textcontainers);
|
free(textcontainers);
|
||||||
textcontainers = NULL;
|
textcontainers = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[self _didInvalidateLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) textContainerChangedGeometry: (NSTextContainer *)aContainer
|
- (void) textContainerChangedGeometry: (NSTextContainer *)aContainer
|
||||||
|
@ -1963,6 +1981,7 @@ forStartOfGlyphRange: (NSRange)glyphRange
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
[self _invalidateLayoutFromContainer: i];
|
[self _invalidateLayoutFromContainer: i];
|
||||||
|
[self _didInvalidateLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2069,6 +2088,7 @@ See [NSTextView -setTextContainer:] for more information about these calls.
|
||||||
{
|
{
|
||||||
[tc->textContainer setLayoutManager: self];
|
[tc->textContainer setLayoutManager: self];
|
||||||
}
|
}
|
||||||
|
[self _didInvalidateLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2125,6 +2145,7 @@ See [NSTextView -setTextContainer:] for more information about these calls.
|
||||||
return;
|
return;
|
||||||
usesScreenFonts = flag;
|
usesScreenFonts = flag;
|
||||||
[self _invalidateEverything];
|
[self _invalidateEverything];
|
||||||
|
[self _didInvalidateLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSFont *) substituteFontForFont: (NSFont *)originalFont
|
- (NSFont *) substituteFontForFont: (NSFont *)originalFont
|
||||||
|
@ -2161,6 +2182,7 @@ See [NSTextView -setTextContainer:] for more information about these calls.
|
||||||
|
|
||||||
showsInvisibleCharacters = flag;
|
showsInvisibleCharacters = flag;
|
||||||
[self _invalidateEverything];
|
[self _invalidateEverything];
|
||||||
|
[self _didInvalidateLayout];
|
||||||
}
|
}
|
||||||
- (BOOL) showsInvisibleCharacters
|
- (BOOL) showsInvisibleCharacters
|
||||||
{
|
{
|
||||||
|
@ -2174,6 +2196,7 @@ See [NSTextView -setTextContainer:] for more information about these calls.
|
||||||
return;
|
return;
|
||||||
showsControlCharacters = flag;
|
showsControlCharacters = flag;
|
||||||
[self _invalidateEverything];
|
[self _invalidateEverything];
|
||||||
|
[self _didInvalidateLayout];
|
||||||
}
|
}
|
||||||
- (BOOL) showsControlCharacters
|
- (BOOL) showsControlCharacters
|
||||||
{
|
{
|
||||||
|
@ -2209,6 +2232,8 @@ See [NSTextView -setTextContainer:] for more information about these calls.
|
||||||
[self invalidateLayoutForCharacterRange: r
|
[self invalidateLayoutForCharacterRange: r
|
||||||
isSoft: YES
|
isSoft: YES
|
||||||
actualCharacterRange: NULL];
|
actualCharacterRange: NULL];
|
||||||
|
|
||||||
|
[self _didInvalidateLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1450,9 +1450,6 @@ TODO: not really clear what these should do
|
||||||
changeInLength: (int)lengthChange
|
changeInLength: (int)lengthChange
|
||||||
invalidatedRange: (NSRange)invalidatedRange
|
invalidatedRange: (NSRange)invalidatedRange
|
||||||
{
|
{
|
||||||
unsigned int g;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
[super textStorage: aTextStorage
|
[super textStorage: aTextStorage
|
||||||
edited: mask
|
edited: mask
|
||||||
range: range
|
range: range
|
||||||
|
@ -1490,22 +1487,31 @@ TODO: not really clear what these should do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-(void) _didInvalidateLayout
|
||||||
|
{
|
||||||
|
unsigned int g;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* Invalidate display from the first glyph not laid out (which will
|
/* Invalidate display from the first glyph not laid out (which will
|
||||||
generally be the first glyph to have been invalidated). */
|
generally be the first glyph to have been invalidated). */
|
||||||
g = layout_glyph;
|
g = layout_glyph;
|
||||||
|
|
||||||
|
[super _didInvalidateLayout];
|
||||||
|
|
||||||
for (i = 0; i < num_textcontainers; i++)
|
for (i = 0; i < num_textcontainers; i++)
|
||||||
{
|
{
|
||||||
if (textcontainers[i].complete &&
|
if (textcontainers[i].complete &&
|
||||||
g < textcontainers[i].pos + textcontainers[i].length)
|
g < textcontainers[i].pos + textcontainers[i].length)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
[[textcontainers[i].textContainer textView] sizeToFit]; /* TODO? */
|
[[textcontainers[i].textContainer textView] sizeToFit];
|
||||||
[[textcontainers[i].textContainer textView] setNeedsDisplay: YES];
|
[[textcontainers[i].textContainer textView] setNeedsDisplay: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue