creating a horizontal slider - problems

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
SupSuper
Just popping in
Just popping in
Posts: 17
Joined: Mon Feb 07, 2005 16:17
Location: Portugal
Contact:

creating a horizontal slider - problems

Postby SupSuper » Thu Mar 10, 2005 22:18

no, this isn't a thread on how to create one, i've figured that out myself ;)

rather, this is one to see if any of you can figure out what's wrong with the code for one. basically, i've changed all the TaharezLook's Slider code so it would work horizontally, instead of vertically. however, when i drag the thumb left/right, it moves up/down (though it snaps back to place when i let it go), and i can't find out why! i've kept looking and looking but can't find out why, GAH! :x
i've attached the code so you can have a look and see if you can find the problem.

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

Re: creating a horizontal slider - problems

Postby CrazyEddie » Fri Mar 11, 2005 09:23

I'll have a look and get back to you a bit later on :)

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

Re: creating a horizontal slider - problems

Postby CrazyEddie » Fri Mar 11, 2005 14:34

Okay :)

Two small mistakes...

In the updateThumb method:

Code: Select all

d_thumb->setPosition(Point(0, absoluteToRelativeX_impl(this, slideExtent - (fltVal * (slideExtent / posExtent)))));


becomes:

Code: Select all

d_thumb->setPosition(Point(absoluteToRelativeX_impl(this, (fltVal * (slideExtent / posExtent))), 0));

The main issue was you had the x and y co-ords round the wrong way ;) The other change was to remove the inversion that is required for vertical bars with 0 at the bottom.

In the getValueFromThumb method

Code: Select all

return d_maxValue - (d_thumb->getAbsoluteXPosition() / (slideExtent / posExtent));


Becomes:

Code: Select all

return (d_thumb->getAbsoluteXPosition() / (slideExtent / posExtent));

Required to remove the inversion mentioned above.

HTH

CE.

User avatar
SupSuper
Just popping in
Just popping in
Posts: 17
Joined: Mon Feb 07, 2005 16:17
Location: Portugal
Contact:

Re: creating a horizontal slider - problems

Postby SupSuper » Fri Mar 11, 2005 15:23

thanks, it works now :)


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 2 guests