Tuesday, October 12, 2004

GUI solution found..

.. I'll create my own.

After having done some SDL-libraries research, I've taken the decision to create my own, simple GUI for pixelate. The most tasty GUI of the things I looked at was a thing called Guichan, which seems like the thing I would want but I've found I'm too lazy to read online documentation. Instead, I'll create a minimalistic GUI system featuring only mouse interaction. I'm hoping to come up with code in the style

GUI gui;
gui.addWidget(new WColor(i,r[i],g[i],b[i]), 50, 50, 10, 10);
gui.addWidget(new WMyQuitButton(), 100, 100, 10, 10);
gui.draw();
...
while(pop_event(&e)) {
switch(e->type) {
case EVENT_MOUSEDOWN:
if(!gui.handleMouseDown(e->x, e->y)) {
// do other handling if GUI doesn't..
}
case EVENT_MOUSEUP:
...
case EVENT_MOUSEMOTION:
(and mouse down => mousedrag)
...
}
}
...
gui.markForRedraw(r); // mark the widgets in this
// rectangle - tell the gui that they need to be redrawn
gui.redraw(); // draw anything that wants to be redrawn
// the gui keeps track of which widgets wants to be
// redrawn, in the form of a bool per widget (bool
// needsRedraw) for example if a button wants to
// change appearance
...
gui.hide(ptrWidget); // does NOT clear draw surface beneath
gui.show(ptrWidget); // only a bool per Widget; does not
// change 'find'-tree-structure

class WMyQuitButton : public Widget {
void handleMouseDown(int localX, intlocalY);
void handleMouseDrag(int localX, int localY);
void handleMouseUp(int localX, int localY);
void draw(int xmin,ymin,xmax,ymax); // inclusive
// a widget might
};


That's hopefully, I'll see where it ends. After this GUI system is up and running, maybe I can continue the actual pixelate project.

0 Comments:

Post a Comment

<< Home