Re: Problem adding subview to NSScroller subclass
Re: Problem adding subview to NSScroller subclass
- Subject: Re: Problem adding subview to NSScroller subclass
- From: Gideon King <email@hidden>
- Date: Sun, 08 Jul 2012 13:38:47 +1000
From memory I think the drawing problems only happened when I was trying to use overlay scrollers.
With my own scroller implementation, I wondered what was going on, and I see that the backtrace is totally different when I am using overlay scrollers:
frame #0: 0x0000000100463304 NovaMind5`-[NMPresentableScroller drawRect:] + 148 at NMPresentableScroller.m:90
frame #1: 0x00007fff838870b2 AppKit`-[NSSurface displayIfNeeded] + 266
frame #2: 0x00007fff839a9d0d AppKit`-[NSView _recursiveSyncAndDisplayViewBackingSurfacesIfNeeded:] + 212
frame #3: 0x00007fff87e2f0b6 CoreFoundation`__NSArrayEnumerate + 582
frame #4: 0x00007fff839a9df6 AppKit`-[NSView _recursiveSyncAndDisplayViewBackingSurfacesIfNeeded:] + 445
frame #5: 0x00007fff87e2f0b6 CoreFoundation`__NSArrayEnumerate + 582
frame #6: 0x00007fff839a9df6 AppKit`-[NSView _recursiveSyncAndDisplayViewBackingSurfacesIfNeeded:] + 445
frame #7: 0x00007fff87e2f0b6 CoreFoundation`__NSArrayEnumerate + 582
frame #8: 0x00007fff839a9df6 AppKit`-[NSView _recursiveSyncAndDisplayViewBackingSurfacesIfNeeded:] + 445
frame #9: 0x00007fff87e2f0b6 CoreFoundation`__NSArrayEnumerate + 582
frame #10: 0x00007fff839a9df6 AppKit`-[NSView _recursiveSyncAndDisplayViewBackingSurfacesIfNeeded:] + 445
frame #11: 0x00007fff87e2f0b6 CoreFoundation`__NSArrayEnumerate + 582
frame #12: 0x00007fff839a9df6 AppKit`-[NSView _recursiveSyncAndDisplayViewBackingSurfacesIfNeeded:] + 445
frame #13: 0x00007fff87e2f0b6 CoreFoundation`__NSArrayEnumerate + 582
frame #14: 0x00007fff839a9df6 AppKit`-[NSView _recursiveSyncAndDisplayViewBackingSurfacesIfNeeded:] + 445
frame #15: 0x00007fff83a20683 AppKit`-[NSView _recursiveSyncDisplayAndFlushViewBackingSurfacesIfNeeded] + 96
frame #16: 0x00007fff83970c8a AppKit`-[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 1168
frame #17: 0x00007fff8393b993 AppKit`-[NSView displayIfNeeded] + 1830
versus normal drawing:
frame #0: 0x0000000100463304 NovaMind5`-[NMPresentableScroller drawRect:] + 148 at NMPresentableScroller.m:90
frame #1: 0x00007fff83979e20 AppKit`-[NSView _drawRect:clip:] + 4437
frame #2: 0x00007fff83976c93 AppKit`-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 3058
frame #3: 0x00007fff83977724 AppKit`-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5763
frame #4: 0x00007fff83977724 AppKit`-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5763
frame #5: 0x00007fff83977724 AppKit`-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5763
frame #6: 0x00007fff83977724 AppKit`-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5763
frame #7: 0x00007fff83977724 AppKit`-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5763
frame #8: 0x00007fff83977724 AppKit`-[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 5763
frame #9: 0x00007fff83975e23 AppKit`-[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 314
frame #10: 0x00007fff83971a3d AppKit`-[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 4675
frame #11: 0x00007fff8393b993 AppKit`-[NSView displayIfNeeded] + 1830
So I wondered what would happen if I used setWantsLayer:YES on my accessory view, and low and behold it is now drawn on my 10.7+ style overlay views! Yay!
It doesn't auto-hide, and it only actually works when the scrollers are shown, so I'm not sure that it's going to be that useful anyway. I thought the auto-hiding might be done through the opacity of a backing layer on the view, but there is apparently no layer on this view (!). I logged setAlphaValue: and it wasn't called, so am not sure where the opacity is coming from.
If I can get it to auto-hide with the scroller, and make the scrollers stay visible when the control is in use (it's sometimes a popup button, and sometimes a text field), then it may work out well. Otherwise, I may just have to stick with using either always visible scrollers, or find another location for my zoom controls.
At least I
Regards
Gideon
On 08/07/2012, at 12:21 PM, Graham Cox <email@hidden> wrote:
>
> On 08/07/2012, at 12:13 PM, Gideon King wrote:
>
>> Yes, I was using that type of code before too, but it didn't work with the new scrollbar styles (drawing artifacts on resize, not automatically hiding), which is what prompted me to look at subclassing the scroller itself instead. Unfortunately it still only works with the legacy style scrollers and not overlays as per my previous message.
>
>
> That's right. If you do anything to modify the position of the scrollers, it will revert to the legacy scrollbars. That's the way NSScroller works now. AFAIK, you can't have it both ways - add a placard and have overlay scrollers. That's why I moved my placard elsewhere. That said I never experienced drawing artefacts or other problems, it just used the old scrollbars.
>
> --Graham
>
>
_______________________________________________
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