We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentLibraries,  Tool Development › Standard UI Class for Processing
Pages: 1 2 3 
? Standard UI Class for Processing (Read 9203 times)
? Standard UI Class for Processing
May 14th, 2005, 4:32pm
 
Admins: Feel free to move this somewhere, I thought it merited discussion but couldn't find another suitable section.

I was wondering if it was worth building a default/standard set of UI components that could be used within processing. i.e. A class of objects; buttons, sliders, check boxes, drop down lists, (?text areas) that could be used in a processing program to make it easier to develop certain types of applets.

I wanted to know what people would want out of such as a class, ideas about the features each object would have, and how it would be integrated into current programs.

I won't go into too much detail about how useful buttons and sliders and menus would be, but certainly I've wanted to stick a button quickly on my applet but had to write a rough class for it - it'd be easier to have standard featureful set of objects that could be easily included in to a program.

I know for full interactive features the mouse events (mousePressed() and mouseReleased()) will need to be passed to the class, (unless theres a way to intercept these values) and also a call in draw() are needed to give the best funtionality. That would be the minimum set of requirements for each object.

How would objects be styled? What would the default font be? What elements would be most useful? What would a stardard set of keywords be for methods? etc.
Please discuss.
Re: ? Standard UI Class for Processing
Reply #1 - May 14th, 2005, 6:10pm
 
I think this should be a Library. I agree it would be a very important addition to the software.

Bredan Berg wrote such a library for version 68,69. Maybe a discussion of the merits of this project could help us know how to move forward.
http://www.thbbpt.net/interfascia/
Re: ? Standard UI Class for Processing
Reply #2 - May 14th, 2005, 11:12pm
 
i've recently been working on gui classes for a project.  not finished and i have a hard time making it into a library.  but if it works out i'm happy to share.
pardon ugly test applet - the classes are flexible (colours, sizes, fonts etc).
www.fredrikolofsson.com/temp/testgui/
Re: ? Standard UI Class for Processing
Reply #3 - May 15th, 2005, 2:19am
 
I very much like what I see with the Interfascia project. I don't have an old version of processing to test it with (it was looking to take BApplet). I'll try and get an old version and test it soon.

I can't say much about your project redfrik, I'm not a fan of the colours =) and I don't know how you've put it together. If you're willing to share then I'd like to take a look.

A few things that caught my eye about Interfacia:
Firstly the use of the GUIController, from what I gather its a collection class used to store references to all the GUI elements and also allows a single target/object to pass mouse events to.

The second and mildly suprising part was in the mousePressed() and mouseReleased() sections of his demo. (http://www.thbbpt.net/interfascia/examples/)

Code:
void loop() {
...

// tell the GUI controller to update all components
[b]controller.update (mouseX, mouseY);[/b]

...
}

void mousePressed () {
[b]controller.mousePressed (mouseX, mouseY);[/b]
}

void mouseReleased () {
[b]controller.mouseReleased (mouseX, mouseY);[/b]
}


For all these actions he passed the mouse position to them. You could argue that you don't need to, however when workin on my sliders (http://mkv25.net/?item_id=101) I released that if you adjust the transform coordinate this does not affect the mouseX and mouseY values, so you have to adjust these before checking the bounding box for a hit - this is a good feature I think.

The last idea I want to mention at this stage is styles. I think a separate object/class should be created that holds the default style, colours, widths and fonts, that can be applied across a range of elements. E.g. A default GUIStyle class would be attached to GUIController with basic grey/blue components - but could be overriden/replaced by the user to give custom set of colours across all GUI elements inside the GUIController object.

I am just about to send an email off to Brendan Berg asking if the source to Iterfascia is available and pointing him to this post to see if we can learn any more.
Re: ? Standard UI Class for Processing
Reply #4 - May 15th, 2005, 6:52am
 
Quote:
I know for full interactive features the mouse events (mousePressed() and mouseReleased()) will need to be passed to the class, (unless theres a way to intercept these values) and also a call in draw() are needed to give the best funtionality. That would be the minimum set of requirements for each object.


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 Sad )

Code:

int x=0;
Test tester;

void setup()
{
size(200,200);
background(0xFF808080);
tester=new Test();
}

void draw()
{
line(x,0,x,height);
x++;
if (x>width)
x=0;
}

public class Test
{
public Test()
{
registerPre(this);
registerDraw(this);
}

public void pre()
{
background(0xFF808080);
}

public void draw()
{
println(millis());
}
}


now, what this does is setup initializes a class, which registers its two methods to run before and after draw() (the main one, not the classe's) is called, to test it you can comment out the line in setup() that initializes the tester varialbe, and instead of drawing a moving line it will draw a rect that slowly get's begger to the right.

hope this helps!
Re: ? Standard UI Class for Processing
Reply #5 - May 15th, 2005, 4:30pm
 
ok, i clean up the demo interface code a little and put it online.  hope this will explain how it works - comments very welcome.  i rather hold on to the classes a little longer as drastic changes might happen.  also i'd like to put them into a library but time is limited atm.
www.fredrikolofsson.com/temp/testgui/
Re: ? Standard UI Class for Processing
Reply #6 - May 16th, 2005, 9:46pm
 
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 Sad )


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?

Re: ? Standard UI Class for Processing
Reply #7 - May 16th, 2005, 10:23pm
 
it's all already there ...

from <processing-folder>/libraries/howto.txt :

Quote:
public void mouseEvent(MouseEvent e)
called when a mouse event occurs in the parent applet

public void keyEvent(KeyEvent e)
called when a key event occurs in the parent applet


so:

Code:
foo ff;

void setup()
{
size( 200, 200 );
ff = new foo();
}

void draw()
{

}

public class foo
{
foo()
{
registerKeyEvent( this );
registerMouseEvent( this );
}

public void keyEvent(KeyEvent e)
{
println( "KE: " + e.toString() );
}

public void mouseEvent(MouseEvent e)
{
println( "ME: " + e.toString() );
}
}


should get you started ..

F
Re: ? Standard UI Class for Processing
Reply #8 - May 16th, 2005, 10:55pm
 
also from that howto, why we'd like to discourage using the name "PGui" rather than something of your own:

NAMING

Libraries should not be prefixed with "P" the way that the core
Processing classes are, i.e. it's tempting to prefix everything
that way to identify it with processing, but we'd like to reserve
that naming for "official" things that are inside processing.core.

Similarly, please don't using processing.* as the prefix for your
library. We'd like to keep that name space clear for official
things as well.
Re: ? Standard UI Class for Processing
Reply #9 - May 17th, 2005, 12:29am
 
a couple things, the thing i found out (about the p5 classes being able to register methods) allows updating of the event without any code in the draw loop.

ie: instead of the code you provided you could do this:
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() {
...
// notice the lack of any gui.* functions here
// the functions you would normally call for the
// update() function can be assigned to pre() (which
// is called before the main draw() loop) in the
// class and the functions for the draw() function
// could be assigned to a draw that gets registered
// in the class (which )is called after the
// main draw loop
}


also, fry, the mouseEvent and keyEvent things i had already found, only i am unable to extract any meaningful data from that, except for the use of toString() (and i dont think it would be very good to parse that during runtime Wink )

if you know how to get the information out of the events passed to those functions, i would be grateful if you would help us with that.
Re: ? Standard UI Class for Processing
Reply #10 - May 17th, 2005, 12:50am
 
try:
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/event/KeyEvent.html

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/event/MouseEvent.html

F

( F as in fjen not fry .. Smiley )
Re: ? Standard UI Class for Processing
Reply #11 - May 17th, 2005, 2:35am
 
ah, thank you, i think that was what i was looking for.
i didn't know that there was a reference for java online...

any ways, thanks, this will help in aproject im working on.
Re: ? Standard UI Class for Processing
Reply #12 - May 17th, 2005, 2:15pm
 
fjen wrote on May 16th, 2005, 10:23pm:
it's all already there ...

from <processing-folder>/libraries/howto.txt :


Brilliant, thanks ^ for pointing that out. I've just read through the Java 2 APi notes on MouseEvent() as well.

Quote:
also from that howto, why we'd like to discourage using the name "PGui" rather than something of your own.


Not a problem, I'll refer to it as GUI or MyGUI until I've dicussed more of the requirements and figured out how it will operate.
Re: ? Standard UI Class for Processing
Reply #13 - May 27th, 2005, 6:16am
 
Whoa...

Nice to hear that there's an interest in such a library. I haven't been able to do much work on Interfascia while I've been at school, but I may have more free time now that I'm home. I'd like to continue work on the project, and if anyone has suggestions or even wants to help, that would be great!

Just send me a message at robot (at) thbbpt (dot) net

Thanks,
Brendan
Re: ? Standard UI Class for Processing
Reply #14 - May 27th, 2005, 6:35am
 
Also, I fixed the email problem. My hosting service migrated my account to a new server and that address didn't get copied. I didn't find out about it until the 16th.

Sorry
Pages: 1 2 3