How to change size of button?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Andrey01
Posts: 62
Joined: Mon Jul 27, 2020 9:08 pm

How to change size of button?

Post by Andrey01 »

I try to change current size of a button accessing via 'AbsoluteRect', but that doesn`t change. How to change then?
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: How to change size of button?

Post by Seven »

the gui elements are positioned relative to their parent so you have to use setRelativePosition() which then gets updated with updateAbsoutePosition();
Andrey01
Posts: 62
Joined: Mon Jul 27, 2020 9:08 pm

Re: How to change size of button?

Post by Andrey01 »

Thanks, It gets kinda worked, but I have other question: why are the coords of the upper left/lower right corners 's32' type? That is, is it impossible to move e.g. upper left corner to left (negative direction)? Or maybe do the gui elements use some specific coordinate system? And also, the coords can not be fractional.
CuteAlien
Admin
Posts: 9846
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to change size of button?

Post by CuteAlien »

Why would it be impossible? s32 is a signed type, so it can be negative.
Coordinates are pixels, that's why they are not fractional.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: How to change size of button?

Post by Seven »

i have never had an issue with moving gui elements around.
(i consider my gui use to be fairly extreme - see video to see my irrlicht gui in action)
so i might be able to help with nay other questions you have regarding it. we will see :)

https://youtu.be/gmqWs9u-XiQ


GUI Coordinates are in screen space and the rootguielement is at recti(0,0,screenSizeX,ScreenSizeY)
children are then placed relative to their parents.
since gui elements are screen aligned, it makes sense to me that they use whole numbers instead of fractions.
the method I use to scale elements is to store the scale, relative to the parent, in the element and then update accordingly.
there is a scale method already in the base gui though that you can use. I just personally wanted to create my own system.
Post Reply