Page 1 of 1

Moving windows automatically

Posted: Tue Aug 26, 2008 12:49
by SalvoFa
Hi all,

I'd like to add some nice effects when a window I need to move and change window dimensions without the user interaction.
For example a "for" cycle in which I smoothly move the window around the screen.

Is it possible?

Posted: Tue Aug 26, 2008 23:07
by daves
Very possible. In my own application I created a class called RoboticWindow. I use this class to create specific effects including the kind of effect that you describe. CEGUI does not have any direct support for this kind of dynamic, but CEGUI provides all the flexibility you need to create a higher level class that performs the dynamic coloring (or more generally texturing), sizing, positioning operations that you might envision.

Really the kind of effect that you describe is easily achieved using setArea along with a timer that allows you to modify the area (which includes both size and position) according to some simple mathematical formula.

Posted: Wed Aug 27, 2008 08:43
by SalvoFa
Thank you!
Ok for the setArea...but how can I use the timer?
Are there any examples?

Posted: Wed Aug 27, 2008 12:05
by daves
I'm referring to a simple application level timer. For example in my application I have an AppTimerManager that accepts registration requests from multiple AppTimerClients. In my main rendering loop (perhaps 40 or 50 times each second) the AppTimerManager will run through the list of AppTimerClients and invoke an "update" method for each. This gives the client a chance to perform a periodic task.

The way my "RoboticWindow" class works is that each active instance of a RoboticWindow will register as an AppTimerClient. It will then begin to receive "wakeup calls" (40 or 50 times per second) through the "update" method invocation. The RoboticWindow will then perform some "prescribed" dynamic which may include a sizing operation over time (e.g. start at 50x50 pixels and grow to 100x100 pixels in size within 2 seconds), a positoning operation, a "flashing operation", a "fading operation", etc. Once the prescribed operation is complete the RoboticWindow will unregister for timing events .. its job is done. The cegui window is now in its "final resting state". The only "state" information that the RoboticWindow needs to keep track of are "the prescribed action" and "the time since the prescribed operation began". This state information is enough for it to compute the current values for size, position, color, etc with each wakeup call.

Posted: Mon Sep 01, 2008 07:25
by SalvoFa
Thank you again!
I will search for some example of this doesn't seem to be hard to implement.