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 & HelpPrograms › Popup Windows
Page Index Toggle Pages: 1
Popup Windows (Read 843 times)
Popup Windows
Jun 3rd, 2007, 10:37pm
 
Hi all,

I'm working on a drawing application that's intended to have several popup windows in which I can configure the brushes.

You can find a rough sketch of the drawing tool here.

I've created a Window object which, upon creation, initiates a bunch of gui elements (using the fantastic controlP5 library) and draws a rect() as a frame.

After I've done setting the necessary parameters I want the Window to disappear again. Unfortunately I've run into two problems with that:

1. Obviously the rect() is drawn to the stage, but I don't want it to. It should disappear, revealing whatever it covered before. The only way I can think of around this, is to save and reload the underlying pixels after the window is gone But that feels a wrong thing to do

2. It's a snap to create a button with controlP5:
Code:

controlP5.addButton("button",10,100,160,80,20);

Unfortunately once it's created I can't seem to get rid of it again. It will constantly draw on top of everything else. Is there a way to delete created buttons/radios/sliders again? I stumbled upon remove() in the documentation, but I don't seems to get it to work. Andi?

True, I could use a controlP5 controller window for my popups, but I'd rather try without, because it wouldn't fit the overall look and feel of the application.

cheers,
Greg


Re: Popup Windows
Reply #1 - Jun 3rd, 2007, 11:10pm
 
Hi Dek,

Have you tried the fill()'s alpha ?
Re: Popup Windows
Reply #2 - Jun 3rd, 2007, 11:28pm
 
jaylfk,

Not sure if I understand what you mean. I don't want the background to shine through while the window is displayed. And even if it does, the rect() still alters the pixels under it.
Or am I completely missing your point?
Re: Popup Windows
Reply #3 - Jun 3rd, 2007, 11:46pm
 
Can you show a sample of your code ?

It would be easier to see if we are talking about the same thing or not Smiley

Edit : sorry i've just realized that you've posted some already Cheesy
Re: Popup Windows
Reply #4 - Jun 4th, 2007, 1:25pm
 
Ok, so I've decided the save/load-pixels-option works well enough, even though I still think it's not the cleanest way to go.

Basically what I do is create a window-object and before drawing anything to the stage I create a PImage with the pixels that are going to be covered:

Code:

PImage backgroundPixels = createImage(windowWidth, windowHeight, RGB);
windowPixels = get(windowXpos, windowYpos, windowWidth, windowHeight);


and then after I've killed the window-object, I can "restore" the pixels to their original values.

Code:

image(backgroundPixels, windowXpos, windowYpos);


One down, one to go. Now how can I get rid of the controlP5 elements?
I did try:

Code:

controlP5.remove(Controller closeWindow); // closeWindow is one of the buttons


but it gives me a syntax error (missing right parenthesis)? Or maybe I haven't figured out correctly how to adress a specific controller?
Re: Popup Windows
Reply #5 - Jun 4th, 2007, 5:28pm
 
hi dek,
there are 2 ways to get rid of a controller. the first one is to remove it.
in your case, you created a button with
Code:

controlP5.addButton("button",10,100,160,80,20);

to remove the same, you would write
Code:

controlP5.remove(controlP5.controller("button"));


the second option is to hide the controller, you still keep an instance of the controller but you just make it invisible with
Code:

controlP5.controller("button").hide();

you can check the status of the controller's visibility with
Code:

controlP5.controller("button").isVisible();

which will return true or false.

to make a controller visible again use,
Code:

controlP5.controller("button").show();


hope  that helps,
andi

Re: Popup Windows
Reply #6 - Jun 5th, 2007, 12:47am
 
Andi,

Yeah this does the trick. Vielen Dank. That's one fantastic library you've put together! Looking forward to the final release.

One slight problem remains though. As intended I want to create popup-windows. For that purpose I add controllers as needed to controlP5, from within the popup-window class. It should be possible to create a button, that once pressed, deletes the window-object and removes() all controllers within the window.
But I can't get the controller event for these elements to work inside the class.

Code:

void closeWindow() {
// delete window object
controlP5.remove(controlP5.controller("closeWindow"));
}


This only seems to register if I write it outside of the class. Any idea what the problem might be?

cheers,
Greg
Re: Popup Windows
Reply #7 - Jun 5th, 2007, 7:03pm
 
it does indeed only register methods for your initial sketch class. controlP5 is using reflection to determine the existence of methods, but only with a reference to the initial sketch class. will consider listeners or something to get around this.

andi
Re: Popup Windows
Reply #8 - Jun 5th, 2007, 8:09pm
 
Ok, thanks for the info. Luckily I'll still be able to achive what I want, even if it's not the most elegant way to write the code.

cheers,
Greg
Page Index Toggle Pages: 1