[Drawkit] DKKnob
Graham Cox
graham.cox at bigpond.com
Sun Jun 14 17:36:00 PDT 2009
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
More information about the Drawkit
mailing list