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.
IndexProgramming Questions & HelpOther Libraries › Dynamic Navigation + ControlP5
Page Index Toggle Pages: 1
Dynamic Navigation + ControlP5 (Read 1723 times)
Dynamic Navigation + ControlP5
Sep 27th, 2007, 3:25pm
 
Hello!
I've been working on a GUI for a university assignment for a while now, I thought I was getting close, but I seem to have hit a wall and I have no idea what to do.  I'd appreciate all the help you can offer me, as I'm stumped ( though it is late, I could just be having a small mental block ).

I'll explain what I'm making first :

I'm making a visualisation creation tool.  Allowing people to easially create simple visuals that will happily dance to music.  I need a nice GUI so that it's simple and easy to use ( though, really, I'm the only one that needs to be able to use it ... the more trouble I have with this GUI, the less I care about how it looks ).

I've been developing each of the parts in isolation, I've got my audio analysis working fine, I've got my 3d, additive blending, simple motionblur stuff working, and the GUI is the other thing I'm working on at the moment and it's causing me problems...

So, what do I want to do exactly ?
I want 4 menus :

- Add
- Remove
- Edit
- Load / Save

Each of these I want to have subcategories.  Now, using ControlP5, a MultiList is perfect!
I've got my mainmenu which contains my list, the list is broken into 4 buttons ( add, remove, edit, load/save ).  This part I have no problem with.  Within the "add" menu is the only item I've got at the moment, a simple 3d sphere.  When the user clicks on 'sphere' a new controlP5 tab opens called "sphere".

"sphere" has 6 items in it :
a textfield : "object_name"
4 sliders : "object_x", "object_y", "object_z", and "diameter"

and a button called 'save_sphere'

'save_sphere' updates the sphere with it's newly entered elements, and removes the sphere tab.

That all works fine, the FIRST time.
the SECOND time I do the exact same thing ( add->sphere, save_sphere ) I've noticed that it's running save_sphere TWICE.  The THIRD time, it's running it THREE times...and so on.  This is causing weird errors and is giving me a mega headache.

Now, I can only think that sphere is not being removed properly.  ( using : controlP5.remove("sphere"); - even removing all the other elements as well )  But I can't see how to fix it.

Basically I'm just asking for any advice you lovely people can offer.  If you know of a better way to do this, please let me know.  I'd just like to get this GUI out of the way, so I can move on to the stuff that actually matters in this assignment!

Thanks in advance everyone, any help you can give would be very much appreciated.
Re: Dynamic Navigation + ControlP5
Reply #1 - Sep 27th, 2007, 4:14pm
 
Isn't that just typical ?
I fixed it.

Instead of using the usual ControlP5 button method( make a function with the button name ), I assigned the buttons an id, and used the controlEvent function to listen for that ID number.  From there I am able to remove sphere properly.  I assume it just didn't like being removed from within itself.

hah.
Thankyou everyone!
Re: Dynamic Navigation + ControlP5
Reply #2 - Sep 27th, 2007, 6:25pm
 
hey tom,
thanks for getting into the "multilist testing", so now i kind of know what needs to be added and changed.
hope you didnt have too much trouble in the end and you are back on track with your actual assignment. drop me a line if you make it available online.
best,
andi
Re: Dynamic Navigation + ControlP5
Reply #3 - Sep 28th, 2007, 5:19pm
 
I too am looking at the MultiList as a more elegant solution, BUT i'm wondering, tom, did you figure out a good way to add and remove elements from the multilist on the fly? i was reading in your other thread that you were trying to get that to work, and i would benefit from this too--i'm trying to use multilist to create a sort of contextual menu for a rollover...

i'm building a sorting tool based on the traer physics library, using multiple criteria that correspond to different magnets that you can turn on and off..since there are about 8 categories for sorting, but each one only corresponds with one physics attractor, its really only useful to see the values for the corresponding attractors that you currently have enabled, i'm currently drawing a little menu showing the values when you roll over one of the items, but it seems like a multilist would be an even better solution with its awesome built in hit detection.

cheers!

Re: Dynamic Navigation + ControlP5
Reply #4 - Sep 28th, 2007, 5:31pm
 
another question,
and this one might be dumb, but is there a list of the methods for MultiList somewhere online? i can't find it in the documentation, and so i'm just basing my implementation off of the examples.

thanks a bunch!
seth
Re: Dynamic Navigation + ControlP5
Reply #5 - Sep 29th, 2007, 1:00am
 
Hi Seth,
No, I couldn't figure out a way to *remove* elements, but I can add them. ( For removing, I'm just re-naming the button to "-remove-".  It Is possible to remove them, however the next button you add to that sub menu will appear a space below ( rather than up at the position it should be ).  It is possible to hard-set the location of the buttons, so I suppose you could move all of them up yourself which wouldn't be amazingly hard to do ( and I may do in future versions ),  but for now, no, as far as I could see, there was no way to remove buttons properly.

As for adding them, that was easy, you just need a unique button name for the menu you wish to add.  So :

Code:

MultiListButton editB;
MultiList l;

l = gui.addMultiList("myList",10,40,130,15);
editB = l.add("test2",3);
editB.setLabel("Edit");


then to create a new button within 'edit' you just type editB = l.add("buttonname",idthinggy);

That's how I'm doing it anyway.

As for a list of methods, there isn't any online, but from what I've discovered :

remove()
updateLocation(float x, float y);
add(String theName, int theValue);
close();
open();

and MultiListButton :

remove();
updateLocation(x,y); ( this is what I was using to relocate the buttons after removal )
add();

I think that's about it.  Though I'm sure I'm missing a bit.

I've got a version of my menu online, it's an old one and I've since fixed quite a few of the bugs contained within (like the -remove- bug, that was a problem with my ArrayList that was holding the Spheres ), just make sure you read the blog entry so you don't break it Wink

I do think the most needed feature of the MultiList would be when an element is removed from the menu, all the other elements in that list move up to fill in the gap.  Shouldn't be too hard to do, just go through and update the location for all sub buttons after that one x(width of the buttons) places.  Suppose I could hard-code it myself.  I might try it tonight.

http://www.tenfiftyfour.com/aAVis/?p=18
Re: Dynamic Navigation + ControlP5
Reply #6 - Oct 2nd, 2007, 12:12am
 
Hi Tom,
thanks a bunch, thats really helpful to see what you've discovered.
your implementation is really sweet too. but i can see we will both benefit from the ability to just remove an item. do you think it would be too intensive to just recreate the menu?
Re: Dynamic Navigation + ControlP5
Reply #7 - Oct 2nd, 2007, 1:12am
 
sethotron wrote on Oct 2nd, 2007, 12:12am:
Hi Tom,
thanks a bunch, thats really helpful to see what you've discovered.
your implementation is really sweet too. but i can see we will both benefit from the ability to just remove an item. do you think it would be too intensive to just recreate the menu


Ironically that's exactly what I've done.
I found you have to remove the buttons first. once all the buttons have been removed, you can remove the list, and recreate it.  Works a treat!

I've found as soon as I post something here, I figure out a solution.
Re: Dynamic Navigation + ControlP5
Reply #8 - Oct 2nd, 2007, 1:25am
 
hi,
thanks for helping to find out some of the limitations of the multilist. i am currently finishing the documentation and examples but you can download a current version with remove capabilities for multilists at www.sojamo.de/controlP5. please see the multilist example and documentation for details.
best,
andi

Re: Dynamic Navigation + ControlP5
Reply #9 - Oct 2nd, 2007, 1:34am
 
sojamo wrote on Oct 2nd, 2007, 1:25am:
hi,
thanks for helping to find out some of the limitations of the multilist. i am currently finishing the documentation and examples but you can download a current version with remove capabilities for multilists at www.sojamo.de/controlP5. please see the multilist example and documentation for details.
best,
andi



Awesome! Thankyou! I will try it out right now!

edit : k, old code is broken now
getting the following error :

Uncaught error fetching image:
java.lang.NullPointerException
     at sun.awt.image.URLImageSource.getConnection(Unknown Source)

so, now I've got to figure out how to fix it. Though Im not calling any images ... You calling something in the library

Yeah, the whole library is borked.  I took a peek inside the .jar file and noticed you're missing one of the .gif files you had in there before.  Could you still be referencing it somewhere

synt24.gif it was called.
Re: Dynamic Navigation + ControlP5
Reply #10 - Oct 2nd, 2007, 2:06am
 
Yeah, it's missing that file.

By Adding synt24.gif to the .jar file in the right spot it works perfectly now Cheesy, you might want to update the version you've got on the website.
Re: Dynamic Navigation + ControlP5
Reply #11 - Oct 2nd, 2007, 3:52am
 
thanks, fixed.
Page Index Toggle Pages: 1