mythmon wrote on May 15th, 2005, 6:52am:i think i may have figured that out...
i found out that normal classes (even processing classes!) can register events like a library would, so you could register an even to run every frame, or one for mouseEvent (though i haven't been able to get any information out of that one yet
)
Thats very good news for creating a seamless interface for creating GUI objects... less lines of codes for the end user to put into their app.
I suppose Ben or Casey might be able to help pluck the mouse event events out for us to use.
If we could register those invents inside the GUIController class then
I could imagine creating interface elments as follows:
Code:PGui gui;
color c_red = color(255, 0, 0);
...
void setup() {
gui = new PGui(c_text, c_button, c_highlight, c_dark, ...);
// Method 1
gui.addButton(x, y, "text");
gui.addScrollBar(x, y, width, height, minVal, maxVal);
// Method 2
PGuiButton textButton = PGuiButton(x, y, "text");
gui.add(textButton);
}
void draw() {
gui.update();
...
gui.draw();
}
The constructor for PGui would take all the values for the style and font specifications, or maybe just a hue value.
The user would add buttons and scrollbars etc. via methods in PGui. PGui would be a collection class of similar objects
A call to gui.update() would update all the values in the PGui controller based on mouse events, and a call to gui.draw() would draw the elements to the screen.
I'm not sure about the best method for accessing properties and values of objects inside of the Gui controller. Feedback welcome. Any ideas how you'd like to see such a class implemented?