Am 08.09.2010 23:32, schrieb Clemens:
On Thu, 09 Sep 2010 09:14:31 +1200, <superstippi@xxxxxx> wrote:@@ -294,10 +294,14 @@ if ((text && fText && !strcmp(text, fText)) || (!text && !fText)) return; + float oldWidth = StringWidth(fText); + free(fText); fText = text ? strdup(text) : NULL; - InvalidateLayout(); + if (oldWidth != StringWidth(fText)) + InvalidateLayout(); + Invalidate();just curious, isn't it the normal case that the text has changed when calling SetText? and then StringWidth is quit expensive because it ask the app server for the string width? Especially if you call it twice. Maybe you want to check if the string is the same? because otherwise it is very likely that the width has changed to. Is it right that in general every glyph has a different width?
I haven't actually tested what is more expensive. I do have a use-case where the string with stays the same, even when the string changes. The string actually changing at all is already tested at the beginning of the function. I suppose calling InvalidateLayout() unchecked is more expensive than using StringWidth() twice, that's why I made the change, but like I said, I haven't actually tested it.
Best regards, -Stephan