Agui positing
jonny2027

Hi All,

Me agian. I was just wondering if anyone could tell me how i can position a button from Agui? Currently it just sits in the top left of my screen and i cannot see any options to position it.

Thanks

Jonathan

jmasterx

Call widget->setLocation(x,y);

If you want it centered you can do:
widget->alignToParent(agui::ALIGN_MIDDLE_CENTER);

There are layouts you can use too that will auto relocate and auto resize when the screen size changes.

However, note that, Agui does not take into consideration Allegro Transforms. If you scale the screen to be resolution independent, Agui will not respond to your mouse as you would expect.

Mark Oates
jmasterx said:

However, note that, Agui does not take into consideration Allegro Transforms. If you scale the screen to be resolution independent, Agui will not respond to your mouse as you would expect.

My GUI does. 8-)

jmasterx

What do you use to apply the transformation to the mouse? I can easily implement it if I have that.

Thanks

Mark Oates

As it is now, Widgets do not respond directly to mouse events, they are "pre-processed" first. There are some al_invert_transform and al_transform_coordinates in there. The mouse positions and displacements are modified to native coordinate space and sent into the widget's update function for collision testing.

Also, widgets can have their own transform, too. Any widget can be scaled and/or rotated, and that transformation can have transformations prior to it while still doing mouse collisions correctly.

jmasterx

That's cool :)

Agui is backend independent so I always need to abstract away the underlying API in anything I add. I might look into the implementations of some of those allegro functions and use that. The user will be responsible for supplying me some kind of transform.

I could enforce that the backend handles this but I'm not sure that's the best idea...

jonny2027

Thanks for the information. I will give it a shot. Just out of interest what is your GUI Mark.

Thanks

Jonathan

Mark Oates

It's not finished yet. It's still in infinite beta loop. ;)

jmasterx

I just added support for Transformations!

You can get it in SVN.

It's as easy to use as Allegro's transformations:

Here is a test example I used in my game:

#SelectExpand
1 //render the scene 2 if(m_needsRedraw && al_is_event_queue_empty(queue)) 3 { 4 5 6 m_g.begin(); 7 agui::Transform t; 8 t.rotate(-0.2); 9 t.translate(-50,30); 10 t.scale(0.2f,0.2f); 11 m_currentScene->getGui().setUseTransform(true); 12 m_currentScene->getGui().setTransform(t); 13 m_currentScene->render(); 14 al_set_target_backbuffer(al_get_current_display()); 15 ALLEGRO_TRANSFORM transform; 16 al_identity_transform(&transform); 17 al_rotate_transform(&transform, -0.2); 18 al_translate_transform(&transform,-50,30); 19 al_scale_transform(&transform,0.2f,0.2f); 20 al_use_transform(&transform); 21 m_g.end(); 22 23 m_needsRedraw = false; 24 }

One thing though, to use it, you will need to render your game using the method where you render everything to a separate bitmap then blit that to the backbuffer. This is because Agui uses clipping rectangles and those don't like to be transformed it seems :P

Thread #611775. Printed from Allegro.cc