Highlighting parts of complex widgets in themes
Karl Vogel
karl.vogel at seagha.com
Wed Dec 17 14:05:51 GMT 2003
Since I like the gnome Simple theme that much and I couldn't find it for
KDE, I
thought I'd have a look at implementing it.
The thinice engine (the gtk engine used in the simple theme) has
highlighting of
the buttons if you move over them. For normal widgets (e.g. buttons) this
can be
achieved by installing an event filter that listens for Enter and Leave
events.
(like it's also done in the Plastik theme)
However, this doesn't work for complex widgets like the scrollbar, as it is
composed of smaller Primitive Elements (arrow up, down, slider). The enter
and
leave event is for the entire scrollbar, so that alone can't be used as you
would highlight the entire widget, while only the Primitive Element should
be
highlight.
I currently implemented this by installing an eventfilter on the scrollbar
that
also listens for mouse move events and then records the current mouse
position
within the widget. Then I issue a repaint and in the drawing code of the
Primitive Element, I check if the recorded mouse position is within the
element.
In order to receive the mouse move events, I had to enable mouse tracking on
the
widget, which I actived in the polish method of the style.
While this works, I'm wondering if there isn't a better way to do this.. as
this
feels kind of hackish and would mock things up if the application changes
the
tracking state.
-- Karl
More information about the kde-core-devel
mailing list