[Drawkit] two views, different layers?
James Maxwell
jbmaxwell at rubato-music.com
Mon Jul 28 00:44:18 PDT 2008
Hey Graham,
On 27-Jul-08, at 5:32 PM, Graham Cox wrote:
> Hi James,
>
> What you're describing is possible but you'll have to do quite a bit
> of work, somewhere. The visibility of a layer is a property of the
> layer, and the view just renders everything in the drawing by asking
> each layer to draw itself - if the layer is hidden, it won't be drawn.
Yeah, this is kind of what my understand was...
>
>
> A (somewhat fiddly) way to do it: The view is passed to the layer's -
> drawRect:inView: method, so if you subclass the layer and override
> that method, you could skip the drawing for specific views, just
> calling super's implementation to draw the content. It's not that
> clean because it means the layer has to have knowledge of the view,
> so a cleaner solution would be to devise some sort of protocol
> whereby the layer can ask the view "should I draw"? and the view
> will say yes or no.
Okay, this seems workable to me. I'll poke around with that tomorrow,
maybe.
>
>
> To make it more awkward still, the scroll position of each view is a
> property of the scrollview that contains it, and there's no
> synchronisation - you'd have to figure out a way to keep all the
> views scrolled to the same position. Not impossible, but definitely
> awkward.
Actually scrolling is not too huge a deal. I have a "play cursor" kind
of object I've made, which uses the autosrolling feature to scroll the
views, as required. If the play cursor is drawn at the same position
in both views, then the autoscrolling should take care of the rest...
I suppose this would be possible with two drawings, as well... I'm not
sure. I still have some things to consider with this design. Two
drawings may actually be simpler. I'm also considering just a toggling
of layers, so that these two "drawings" are actually just layers on
the same drawing, which never appear simultaneously. That could work
as well. I don't suppose it's possible to set a layer's alpha channel,
is it?
thanks,
J.
>
>
> I can think of other solutions that could also be made to work -
> like having a custom view controller that managed two views which
> were embedded in the same scrollview - but it's not going to be all
> that trivial.
>
> cheers, Graham
>
>
> On 28 Jul 2008, at 7:03 am, James Maxwell wrote:
>
>> Hey All,
>>
>> I've got a rather strange requirement for the app I'm working on. I
>> want two views, which appear to be different, but which are closely
>> related in content. They should remain synchronized, in the sense
>> that they should autoscroll together (among other things, to do
>> with music, specifically). I was planning on using two drawings,
>> but this seems like it might be a real hassle... So, I'm wondering
>> whether it's possible to have two views on the same drawing, with
>> view A having a certain layer hidden, and view B having only the
>> hidden layer from view A visible? Make sense? Strange, I know...
>> but is it possible?
>>
>> cheers,
>>
>> J.
>>
>>
>> _______________________________________________
>> Drawkit mailing list
>> Drawkit at lists.apptree.net
>> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
More information about the Drawkit
mailing list