[Y-devel] State of the Widgets
Chris Amshey ychris at amshey.net
Fri Feb 27 07:57:20 GMT 2004
Hello, List!
Having been poking around in the guts of the code and implementing
a slider, I've seen a lot more of how things actually work, and
I have some ideas about where we need to go. This may already be
where we're going, but it's not written down yet, so bear with me
while I wax dissertative. :)
The issue at point, is widget behaviour, the control of which is being
discussed in several different threads, about ideas like a 'ui layer'
or a 'behaviour module'; I'm not really convinced of the need or wisdow
to seperate 'ui' from theme, but there might be benefits... however,
whoever is controlling ui issues, needs to be tightly integrated with
theme even if they aren't part of theme.
More to the point (and diving into the practical core), I think
theme-module needs to provide an API to determine what is happening to
a widget. Currently, a widget is 'hit' if a mouseclick hits anywhere
in its bounding box, which is fine for rectangular buttons. It's
acceptable but not quite so nice for checkboxes. It becomes far less
acceptable for sliders and scrollbars, and will be a problem with
non-rectangular themes. That is, if we have a round button, clicking
inside the bounding box does not mean we hit the button.
There are several ways to solve this; the one I think is implied by
Mark's paper is that the moveable bit on the scrollbar and the slider
and so on would be subwidgets of the main widget, and that shrinks the
bounding box, making the range of erroneous targeting smaller (but
this is not how checkbox was implemented). This method is simple
enough, but I don't like it. I hate it when I don't like simplicity,
but it's got too much functional cost.
In the case that we have a round, elliptical, crescent-shaped,
what-have-you widget (and, with the RGBA mapping built in, the api
begs for themes with variously shaped widgets), then there is going to
be a serious issue with missing the button. Also, if you care to
imagine a very minimalist look where the slider on a slider widget or
a scrollbar is a single-pixel line... we don't want to ask the user to
literally hit that line on the pixel (though this can be resolved by a
transparent bitmap, at some waste of processing the useless pixels).
What we want, then, is an API where Y::theme or Y-ui-module can ask
theme if a pointer operation succeeds for any given point. This API
may or may not pass in guidelines for determining that (ie, we might
'hit' strictly on a pixel-hit, we might hit within 3 pixels, we might
hit only if we hit near the center of a widget - ie, -not- hitting
part of a widget's 'look' that is meant to be a drop-shadow or
glowing-halo or what-have-you.)
There is no way (that I see) for anybody but theme-module to make this
decision, because -only- theme-module knows pixel-for-pixel where a
widget 'really' is (especially if widgets pad themselves instead of
layouts padding widgets, which is a related problem: if widgets pad
themselves, Y::widget-classes do not even know where the bounding box
really is.)
In any case, my proposal for a solution is very simply an API along
the lines of, 'bool themeInWidget(widget *self, int x, int y)',
modified for compatibility of calling convention with whatever Mark's
doing to the theme API right now. This should, I think, be called from
whoever's really making the action decisions, whether that's where
it is now or in a UI module.
Right, then, let me catch my breath now... okay, thoughts, anyone? Is
anyone still awake this far along? Am I making sense here?
--Chris
More information about the Y-devel mailing list
2026 © www.Y-Windows.Org - All Rights Reserved