Scrollbar, a lot of questions

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

hurricane
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Nov 28, 2008 11:59

Scrollbar, a lot of questions

Postby hurricane » Tue Dec 16, 2008 10:08

Hi all guys,

i am working with CEGUI::Scrollbar but i have a question:

can i set min and max value? default is 0.0 --> 1.0, can i modify it ...i don't find right "set" method...

EDIT: i read now document-size and page-size....but i need a range also negative...for example from -1.0 to 1.0, i need convert by hand???

thx a lot and sorry for "noob question"
Last edited by hurricane on Tue Dec 16, 2008 11:11, edited 1 time in total.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Dec 16, 2008 10:49

Hi,

yes, you'll need to apply an appropriate offset in order to get negative values.

Since the scrollbar is meant to represent some position within some other entity (the document), in that context a negative position does not make sense. Obviously if you're using the scrollbar as an alternative to a slider, then the whole document/page/position abstraction does not really apply, so I know where you're coming from ;)

CE.

hurricane
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Nov 28, 2008 11:59

Postby hurricane » Tue Dec 16, 2008 11:10

thx CE,

i have another question that i write here:

i need a particular behavior for my scrollbar. When the user press the scrollbar and move it (CEGUI::Scrollbar::EventScrollPositionChanged) i need that this event is fired while the mouse is not released (CEGUI::Scrollbar::EventMouseButtonUp).

i try do:

Code: Select all

wmgr.getWindow("Root/camera/position_x")->subscribeEvent(
   CEGUI::Scrollbar::EventScrollPositionChanged,
   Event::Subscriber(&gui::handleScrollbar,this));


and the handler function:

Code: Select all

bool gui::handleScrollbar(const CEGUI::EventArgs& args){

  Window* window = static_cast<Window*>(static_cast<const WindowEventArgs&>(args).window);

  while(!window->isEventPresent(CEGUI::Scrollbar::EventMouseButtonUp)){
   // here my functions...
   // here i need a CEGUI::System::doEvents(); ????
  }

  return true;

}


but the applicition is blocked.. i think the System can't fire events...

any solution?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Dec 16, 2008 11:36

Hi,

isEventPresent does not do what you think it does ;)

The easiest solution is to use the built-in auto-repeat features. On the scrollbar call:

Code: Select all

scrollbar->setMouseAutoRepeatEnabled( true );

or set the "MouseButtonDownAutoRepeat" property to "True". If you want all scrollbars to have this enabled, you can add a property initialiser to the scrollbar definition in the looknfeel file.

Note however, that depending on the looknfeel (basically proportional thumb, or not) and how you have the document size, page size, and such things set you can get into a "flicking" situation - where the thumb jumps past the point where mouse is held, then back again (because the mouse is now on the other side of the thumb, the next auto-repeat 'click' causes the thumb to jump back in the opposite direction, and so on).

CE.

hurricane
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Nov 28, 2008 11:59

Postby hurricane » Tue Dec 16, 2008 12:03

CrazyEddie wrote:Hi,

isEventPresent does not do what you think it does ;)

The easiest solution is to use the built-in auto-repeat features. On the scrollbar call:

Code: Select all

scrollbar->setMouseAutoRepeatEnabled( true );

or set the "MouseButtonDownAutoRepeat" property to "True". If you want all scrollbars to have this enabled, you can add a property initialiser to the scrollbar definition in the looknfeel file.

Note however, that depending on the looknfeel (basically proportional thumb, or not) and how you have the document size, page size, and such things set you can get into a "flicking" situation - where the thumb jumps past the point where mouse is held, then back again (because the mouse is now on the other side of the thumb, the next auto-repeat 'click' causes the thumb to jump back in the opposite direction, and so on).

CE.


CE, thanks for reply but i don't resolve my problem.

i added "setMouseAutoRepeatEnabled( true );" to my scrollbar but nothing changed...when i press mouse button on the "middle selector" of scrollbar and if i move it the event is fired but i want that this event is repeated while mouse isn't release...this not happens

also thanks, Martin

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Dec 16, 2008 13:46

Hmm, sorry. I got the wrong end of the stick :? Scrap that then :)

Firstly, you can't ever sit in a loop within an event handler, especially not if you're waiting on some external event - all inputs are injected by you don't forget, so if you're sitting in a loop waiting for something to happen, you'll just hang.

I think basically what you need to do is:

Subscribe to Scrollbar::EventThumbTrackStarted and Scrollbar::EventThumbTrackEnded - these will inform you when the user 'grabs' and 'releases' the scrollbar thumb. Within the assigned handlers for these, you'll need to set and clear some state that will enable you to do something elsewhere depending upon whether the particular state is set.

Then either within your main loop, or perhaps in a Window::EventWindowUpdated handler, check the previously mentioned state and react according to whether the user current has the thumb 'grabbed'.

I think maybe that sounds vastly more complex than it really is:

Code: Select all

bool gui::thumbGrabbedHandler(const CEGUI::EventArgs& args)
{
    mUserHasGrabbedThumb = true;

    return true;
}

bool gui::thumbReleasedHandler(const CEGUI::EventArgs& args)
{
    mUserHasGrabbedThumb = false;

    return true;
}

bool gui::scrollbarUpdateHandler(const CEGUI::EventArgs& args)
{
    if (mUserHasGrabbedThumb)
    {
        // TODO: Something useful!
    }

    return true;
}


Obviously that does not cater for >1 scrollbar, though that's easy to add yourself, I just wanted to show the basic concept (or at least one approach to it).

CE

hurricane
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Nov 28, 2008 11:59

Postby hurricane » Tue Dec 16, 2008 15:00

hi CE,

all now is more clear but how subscribe Window::EventWindowUpdated event?

with:

Code: Select all

   wmgr.getWindow("myScrollbar")->subscribeEvent(
      CEGUI::Window::EventWindowUpdated,
      Event::Subscriber(&gui::scrollbarUpdateHandler,this));


the event don't fire! must i fire it by hand in my main loop?

ps: the other two events work fine.

EDIT: i find the problem: i didn't inject time pulse. also thx Ce, i resolved!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Dec 17, 2008 09:47

Cool. I'm glad you got it working :D


Return to “Help”

Who is online

Users browsing this forum: Baidu [Spider] and 23 guests