On 27/09/10 12:44, Patrick Shirkey wrote:
On Sun, September 26, 2010 1:35 pm, pete
shorthose wrote:
another possibility that was briefly discussed for use with
phat was that of a composite widget with different layers that
could be drawn separately, one on top of the other. eg render an SVG
or pixmap as a background on the first pass, then draw something
with cairo (a value indicator..) on top.
Well I have found that this will only work with recent gtk (it may have
been fixed by now) if the widget is not being updated often. There was a
memory bug in wither the font or vector functions when drawing text on
top
of a dynamically rendered and frequently updated layer.
There are ways around this but they require a bit of flexibility and I
didn't have the time when I was working on my code to figure it out. One
of the methods would have just minimised the bug but not actually fixed
it. That required redrawing only the parts of the widget that need to be
updated.
i've not seen this myself. if you shoot me the code i'd be happy to have
a look.
there are
obvious limits to what you can achieve with this kind of
thing,
Like what exactly? Pretty much only what the mind can think of. Anything
you can achieve in inkscape or gimp will be possible with cairo. That is
much more than most widgets will ever need.
limits to what you can achieve with a composite widget, not cairo alone.
when you mix methods you
gain the advantages and disadvantages of both at once.
but you
could get some complex effects on a knob while still
maintaining procedural control over the size, colour and shape of the
vector elements. (tick marks around the knob, value indicator size
and colour etc). IIRC we discarded the idea due to it's complexity.
we wanted a generally configurable knob and the vector elements would
need anything from extensive widget options right up to a full blown
markup language to describe them (not a problem for app specific
widgets).
Drawing with cairo is pretty easy once you get the hang of it. It helps
if
you have some working knowledge of gimp or inkscape so you can visualise
the steps required to create the effects. Do you have examples of the
kind
of visuals were you interested in creating
sorry, i wasn't very clear. we were thinking about a themeable combo
knob. with pixmaps that's easy. supply
a pixmap animation that can look like what ever you want. for cairo..
how do you do that since the design
is in code?. there is no file format containing a design specification
nor an interpretor to load it. note i'm not
talking about a native cairo knob that respects themes here. i'm talking
about the combo widget.
IIUC, you can write your own function to load a pixmap defined in a
specific folder or xml etc... Then just draw it in the background layer of
the widget. I did something similar with a custom mouse cursor in python
recently. The code is about 5 lines in the end. I can post it if you are
interested.
tbh, i think that the best way to handle knob themes
may well be to
sidestep the issue entirely. provide a plugin
API, and have the widget load plugins that do all the drawing. then
interested parties can do what ever the
hell they like provided they write the code and ship the plugin
themselves. a gtk theme author might then just specify a
plugin if they cared about how the knobs looked with the the rest of
their widgets. similar to the way theme
engines work but for a 3rd party widget library. ship some sensible
defaults/examples and leave people to it.
The way they handle this in ex. cocoa is expand the borders of the image.
I'm not sure if they provide complete support in for a circular image or
an image with a gradient though.
I haven't seen this in cairo but it is certainly possible to write a
custom widget for that purpose if the need arose.
The trade off is how much time you want to spend on it I guess.
--
Patrick Shirkey
Boost Hardware Ltd.