GUI transition [SOLVED]

Discussion and support for general JUCE issues

GUI transition [SOLVED]

Postby billythekid » Wed May 23, 2012 4:06 pm

Hi all,

I am working on a little demo iOS app. Until now, I have just been using a tabbed component to flick between 2 gui components that each take up almost the entire workspace when active. I would like to replace the tabbed component with something a bit more fitting for the platform . . .

In an ideal world:
* It would be nice to switch between them with a swipe gesture
* It would be nice to animate the transition

Can anyone suggest where I need to begin looking, or if there is some example juce code about that would allow me to do this.

Thanks!
Last edited by billythekid on Wed May 30, 2012 2:51 pm, edited 1 time in total.
billythekid
JUCE UberWeenie
 
Posts: 145
Joined: Wed Sep 29, 2010 4:33 pm
Location: South east England

Re: GUI transition

Postby billythekid » Wed May 23, 2012 6:35 pm

As a side note, I remember seeing a 3rd party component posted by Haydxn on the forum ages ago. I think it allowed you to graphically navigate a value tree. A demo was posted where you could search your way through an intojucer project or something like that. This had some sliding transitions in it. I made a mental bookmark that it might come in handy later, but for all my searching of the forum, I can no longer find it :( Any help would be great!
billythekid
JUCE UberWeenie
 
Posts: 145
Joined: Wed Sep 29, 2010 4:33 pm
Location: South east England

Re: GUI transition

Postby sonic59 » Wed May 23, 2012 11:34 pm

It would be nice to switch between them with a swipe gesture


Juce doesn't have any gestures code itself so you would have to roll your own code.

It would be nice to animate the transition


ComponentAnimator class.
The Juce demo has a couple animation demos. There is path/image animation by position, rotation and size in the Graphics demo. There is also a bouncing balls in the Multitheaded demo.
sonic59
JUCE UberWeenie
 
Posts: 224
Joined: Tue Mar 09, 2010 5:51 pm

Re: GUI transition

Postby symfonysid » Thu May 24, 2012 1:45 pm

Here's the Haydxn code you mentioned:

http://rawmaterialsoftware.com/viewtopic.php?f=6&t=6877

It's using the ComponentAnimator... I've been using Haydxn's code on iOS for transitioning between nested settings screens. If you want to start these transitions when the user swipes, the easiest way to do detect a swipe is to use the following methods in the MouseEvent in mouseDrag():

getDistanceFromDragStartX()
getDistanceFromDragStartY()
User avatar
symfonysid
JUCE Obsessive
 
Posts: 81
Joined: Tue Sep 23, 2008 5:06 pm

Re: GUI transition

Postby billythekid » Fri May 25, 2012 8:33 am

Excelent info folks! Thanks.
billythekid
JUCE UberWeenie
 
Posts: 145
Joined: Wed Sep 29, 2010 4:33 pm
Location: South east England

Re: GUI transition

Postby billythekid » Mon May 28, 2012 3:37 pm

Ok. Got this working OK. However, I cant get the swipes feeling as responsive as they do in some other APPs when running it on the device. I'm using code like the following at the moment

Code: Select all
void  cTestBodyComponent::mouseUp (const MouseEvent &e)
{
        if(e.getLengthOfMousePress()<800)
        {
            if(e.getDistanceFromDragStartX() > getWidth()/4) //SWITCH LEFT
            if(e.getDistanceFromDragStartX() < -getWidth()/4) //SWITCH RIGHT
        }
}


It would be nice to use mouseDrag rather than mouseUp to improve responsiveness, but when I do this, subsequent components receive the same drag event and immediately get switched past. Is there some way to reset the event at the point where the component gets switched?

i.e. . . .
Code: Select all
if(e.getDistanceFromDragStartX() > getWidth()/4)
{
    e.resetTheEvent()
    //SWITCH LEFT
}
billythekid
JUCE UberWeenie
 
Posts: 145
Joined: Wed Sep 29, 2010 4:33 pm
Location: South east England

Re: GUI transition

Postby billythekid » Wed May 30, 2012 2:50 pm

Solved . . . TADA . . .

Code: Select all
void  cTestBodyComponent::mouseDrag(const MouseEvent &e)
{
    const int DRAG_DIST_THRESHOLD = 50; //px
    const int DRAG_TIMEOUT = 500; //ms
   

    if (mouseDownInThisComponent && //mouse event must have started here
        (e.getLengthOfMousePress() < DRAG_TIMEOUT) && //swipe must be fast enough
        (abs(e.getDistanceFromDragStartX()) > DRAG_DIST_THRESHOLD) ) //swipe must be long enough
    {
        if( e.getDistanceFromDragStartX() > 0)
            //transition left
       
        if(e.getDistanceFromDragStartX() < 0)
            //transition right   
       
        mouseDownInThisComponent = false;
    }
}
       


void cTestBodyComponent::mouseDown (const MouseEvent &e)
{
    mouseDownInThisComponent = true;   
}
billythekid
JUCE UberWeenie
 
Posts: 145
Joined: Wed Sep 29, 2010 4:33 pm
Location: South east England

Re: GUI transition [SOLVED]

Postby sonic59 » Wed May 30, 2012 3:19 pm

Great!
Are you using the OpenGL renderer or CoreGraphics Renderer?
Wondering if iOS devices have the power to have smooth/responsive animations with just the CPU renderer.
sonic59
JUCE UberWeenie
 
Posts: 224
Joined: Tue Mar 09, 2010 5:51 pm

Re: GUI transition [SOLVED]

Postby billythekid » Wed May 30, 2012 4:38 pm

Just using the CoreGraphics renderer. I didn't even realise the OpenGL renderer was working on iOS (not built the juce demo in many months). Anyway, I have a component that takes up most of the screen with a couple of test buttons, a massive label component containing a digit, and a background image. Now that have cropped and scaled the background image object in the component constructor and just use the drawImageAt (rather than drawImage) method in the draw() function, everything seems to run very smoothly and responsively. I'm very impressed at how simple this was to do in the end! :mrgreen: Juce rocks (but we all knew that anyway).
billythekid
JUCE UberWeenie
 
Posts: 145
Joined: Wed Sep 29, 2010 4:33 pm
Location: South east England


Return to General JUCE discussion

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Google Feedfetcher, haydxn and 1 guest

cron