Re: Text system glitch - lines across text view
Re: Text system glitch - lines across text view
- Subject: Re: Text system glitch - lines across text view
- From: Andrew Hughes <email@hidden>
- Date: Wed, 28 Dec 2011 12:41:44 -0600
Ross,
Thanks for chiming in. Yeah, I know it's a pretty vague problem and it's
hard for me to give enough detail on the implementation. I was just hoping
somebody had seen this type of problem before.
I did neglect to write in the layout managers in the diagram. Oops. It
definitely should have looked like this. I hadn't touched this code in a
while and was diving back in so I forgot.
NSTextView > NSTextContainer
NSTextView > NSTextContainer > NSLayoutManager >
NSTextStorage
NSTextView > NSTextContainer
NSTextView > NSTextContainer
NSView > NSTextView > NSTextContainer > NSLayoutManager >
NSTextStorage
NSTextView > NSTextContainer
NSTextView > NSTextContainer
NSTextView > NSTextContainer > NSLayoutManager >
NSTextStorage
NSTextView > NSTextContainer
The whole thing's a little non-standard because I want to be able to view
multiple NSTextStorages in the same view and present them as if they are
part of the same document while keeping the data storage separate.
Of course, shortly after I posted this, I think I fixed the lines problem
(which had to do with setting the text view as opaque and drawing it's
background in the drawRect instead of allowing the superview to do it). Not
sure if this is just a workaround for a deeper problem in the way I am
updating views or if this is really a legitimate solution, but it seems to
work. Sadly, I've thought I fixed this bug before and it's cropped back up
again, so we'll see.
The other issue, which is apparently unrelated, is the "doubling" of the
text, where it appears to be drawn twice and looks "bold" compared to the
rest of the text, is still there. It is almost surely cause by some problem
in the background-foreground pagination interaction because it doesn't
happen when I test the program paginating foreground only.
Thanks again. Happy holidays.
Andrew
Thanks for the reminders on turning background layout off and using the
"peformSelector" hook to avoid threading issues. I was aware of those
problems when I wrote the code, but it's worth going back and checking to
make sure that it's actually being done in all cases.
On Wed, Dec 28, 2011 at 10:07 AM, Ross Carter <email@hidden> wrote:
> On Dec 25, 2011, at 4:22 PM, Andrew Hughes wrote:
>
> > NSTextView > NSTextContainer
> > NSTextView > NSTextContainer > NSTextStorage
> > NSTextView > NSTextContainer
> >
> > NSView -> NSTextView > NSTextContainer
> > NSTextView > NSTextContainer > NSTextStorage
> >
> > NSTextView > NSTextContainer
> > NSTextView > NSTextContainer > NSTextStorage
> > NSTextView > NSTextContainer
> > NSTextView > NSTextContainer
> > NSTextView > NSTextContainer
> >
> > The list of visible NSTextViews needed can get quite large, so as an
> > optimization the pagination algorithm starts at the currently being
> edited
> > NSTextStorage-Container-View and does that in the foreground before
> laying
> > out the rest of the system on a separate thread in the background (they
> are
> > hidden while being pushed to a separate thread).
>
> Andrew, since nobody else has chimed in, I'll offer a couple of thoughts
> although I have no idea what the precise problem is.
>
> Your description of the layout hierarchy is incomplete and, as I interpret
> it, incorrect. You neglect the NSLayoutManager, which is the object that
> actually draws the text when the NSTextView -drawRect: method fires.
> Because you have an issue with text drawing, I think you need to know
> exactly what is happening with your layout managers. Layout managers are a
> bit on the heavy side as text objects go. Do you have a separate layout
> manager for every text view? Or a single layout manager for each
> NSTextStorage?
>
> Text containers have no relationship with NSTextStorage (your diagram
> shows a NSTextContainer positioned between a NSTextView and a
> NSTextStorage). They must be associated with a NSLayoutManager and
> optionally (usually) with a NSTextView.
>
> Your diagram makes me think that you have multiple textView/textContainer
> pairs associated with a single NSTextStorage. If that is correct, did you
> add those text containers to the NSLayoutManager and allow it to handle
> flowing the text through the containers?
>
> Finally, did you turn off background layout for each layout manager while
> it is being used on the background thread, and did you wrap messages that
> might affect layout in -performSelector:withObject:afterDelay:?
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden