Finally made a start on the vertical scrollbar. There’s a single vertical scrollbar floating around in the demo which shows the progress so far. I’ve got a gutter and a grip implemented. The gutter is represented by the new “ScrollbarVertical” gadget, creating an instance of which will provide a scrollbar without up/down buttons. There’s also a header file for a “ScrollbarVerticalComplex” gadget, which will be a gadget that contains a ScrollbarVertical and the up/down buttons.
The gadget behaves as you’d expect - click and drag the grip, or click the gutter to make the grip jump its own height up or down the gutter. I’d initially built it so that the grip jumped straight to the stylus location when the gutter was clicked, but I checked out the behaviour of Windows and realised that the usual way of handling this was to move by a single grip height.
At the moment I’m just getting the UI built, so it doesn’t interact with any other gadgets yet. The current plan is to have the scrollbar interact with an object that inherits from a new “ScrollableBase” class, which is basically an interface representing the features of a scrollable box. However, it’s just occurred to me that this won’t be a good solution if I want the scrollbar to double up as a slider gadget (gahh, I should have thought of this before - it throws all the class names out). It might be better if the scrollbar fired a scroll event in its event handler instead.
It’s interesting to note that the Woopsi framework is actually doing most of the work for me now. Putting the scrollbar together has just been a case of knitting together existing functionality.
In other Woopsi news, I’ve tidied up the TextBox’s click() and release() functions a little.
Replaced the “target” ScrollableBase idea with a simple EventHandler structure instead. There’s a new scroll event defined in the EventHandler enum, and the scrollbar just sends a scroll event to its event handler when the grip is dragged or the gutter is clicked. It sends the scroll distance as the x and y event arguments.
I’ve also sorted out the scrollbar colours.