[Drawkit] DKKnob

V1ru8 info at v1ru8.net
Mon Jun 15 06:42:19 PDT 2009


Thank you for the short introduction! But I still think I'm doing  
something wrong. My subclass of DKKnob overwrites the  
fillColourForKnobType method. But that method gets never called with  
the type kDKHotspotKnobType. And even if I allwasy return "blackColor"  
the hotspot is still yellow (yes I mean the one on DKImageShape).

Maybe if you redesign the DKKnob customization part some time. The  
idea of a class for every knob sounds nice. With a abstract factory  
patter I think that would be a nice idea.

Thomas

On 15.06.2009, at 02:36, Graham Cox wrote:

>
> On 14/06/2009, at 10:30 PM, V1ru8 wrote:
>
>> I'm trying to customize the Knobs. So I subclass DKKnob and  
>> implements some of the methods. Like fillColourForKnobType: and  
>> knobPathAtPoint:ofType:angle:userInfo:. That let me change the  
>> color and geometry of a few knobs (the ones to rotate and the ones  
>> to resize (only geometry). But I can't change the geometry nor  
>> change the color of the yellow one in the middle (to move the  
>> content). How can I change them? How can I change the color of the  
>> resize knobs?
>> For me it looks like the API to change the knobs isn't very  
>> consistent. Because when I see a method like "-  
>> (NSColor*)fillColourForKnobType:(DKKnobType) knobType" I assume  
>> that I can change the color of all knobs with it. Or is there  
>> something I should now about the knob system which brings a bit  
>> more clarity in?
>
>
> DKKnob abstracts the "type" of a knob from its appearance. This is  
> done to permit customising of the appearance easily, but it may seem  
> confusing at first.
>
> The knob types are enumerated in DKCommonTypes.h. The knob type for  
> the yellow content positioning knob (as used in DKImageShape - I  
> assume that's what you're using) is kDKHotspotKnobType, because that  
> functionality is implemented using hotspots. The knob type is there  
> to tell the system *how* the knob is being used, and DKKnob's job is  
> to represent that visually on screen.
>
> The method -fillColourForKnobType: does allow you to change the fill  
> colour used for all knobs of a given type, provided that the type  
> does use a fill and you know the type.
>
> The types are used as follows:
>
> 	kDKControlPointKnobType		- used for off-path control point son  
> bezier paths (default is a light blue square)
> 	kDKOnPathKnobType		- on-path points on bezier and other paths,  
> orange circle
> 	kDKBoundingRectKnobType		- corners and mid-points of shapes,  
> stroked and filled square*
> 	kDKRotationKnobType		- rotation knob on shapes, white-outlined  
> purple circle
> 	kDKCentreTargetKnobType		- origin target of shapes, light blue  
> cross inside a circle
> 	kDKHotspotKnobType		- hotspots, yellow square
> 	kDKOffPathKnobType		- not currently used
>
> * shape knobs take their fill colour from the layer's selection  
> highlight colour, to reinforce the use of this colour when selecting  
> shapes. Therefore altering this colour at the level of DKKnob won't  
> have any visible effect. Also, certain object states like layer and  
> object locking can also modify the colours used to draw different  
> knobs.
>
> In hindsight it might have been better to implement each knob type  
> as a separate knob class, rather than bundling it all into DKKnob,  
> and in future it might evolve that way.
>
> --Graham
>
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net



More information about the Drawkit mailing list