Page 1 of 1

move camera with scroller

Posted: Mon Oct 24, 2005 12:07
by pabloa
It appears in demo 4, I am trying to copy it in my project. the scrollbar is made, but the problem is asociate it the event. I copy the method to move the camera horizontally

Code: Select all

/*************************************************************************
   Method that moves the camera horizontally
*************************************************************************/
bool CEGUIOgre_FrameListener::horzMoveHandler(const CEGUI::EventArgs& e)
{
   using namespace CEGUI;

   static float lastPos = 0;

   Scrollbar* sb = (Scrollbar*)((const WindowEventArgs&)e).window;

   mRotY = 0;
   mRotX = sb->getScrollPosition() - lastPos;
   lastPos = sb->getScrollPosition();

   moveCamera();

   return true;
}


but dont run I dont undertand how asociatte event to scroller, slicer, etc... Could somebody help me?

Re: move camera with scroller

Posted: Mon Oct 24, 2005 13:23
by madlion
Did you subscribe a event to call this method?

Re: move camera with scroller

Posted: Mon Oct 24, 2005 17:54
by martignasse
I dont undertand how asociatte event to scroller, slicer, etc... Could somebody help me?


event system is a core cegui fonctionnality, you have to understand it.

Basicly, you tel to the event system that a button event react by a callback to a fonction :

Code: Select all

 YourButton->subscribeEvent(PushButton::EventClicked, Event::Subscriber( Namespace::YourFonction, this));


For more info, you should look in the FAQ at the question "What is the correct way to subscribe for an event?" ;)

and in the API Reference in the CEGUI:EventSet class reference, the subscribeEvent fonction is the three before the end.

Hope it help.

Re: move camera with scroller

Posted: Mon Oct 24, 2005 19:21
by madlion
martignasse wrote:
I dont undertand how asociatte event to scroller, slicer, etc... Could somebody help me?


Ups... next time i should read it more carefully. :roll:

Re: move camera with scroller

Posted: Tue Oct 25, 2005 18:15
by martignasse
no problem,

for myself, it's not easy to found info in the API reference.

it's comming, slowly... ;)

Re: move camera with scroller

Posted: Thu Nov 10, 2005 11:52
by pabloa
OK ! I did it. how can the "scrollbar's Button" appear in the middle of the scrollbar. I want to be able move it rigth and left.

Re: move camera with scroller

Posted: Thu Nov 10, 2005 12:56
by martignasse
OK ! I did it. how can the "scrollbar's Button" appear in the middle of the scrollbar. I want to be able move it rigth and left.
you should do something like making the midle value of you'r slider the default value.

for example, you want you'r slider control camera from -10 to 10, so you'r middle value is 0.
But because the slider widget can manage only positive value, you have to translate (with some helper fonctions) to 0 |-| 20 and make you'r middle value 10.

finely yourslider->setCurrentValue(10.0f) and the thumb will be in the middle.