How to create scrollable window?

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: 57
Joined: Mon Jul 27, 2020 9:08 pm

How to create scrollable window?

Post by Andrey01 »

I want to create a scrollable dialog window that would contain some amount of editboxes aligning vertically and setting values of parameters with static texts above them describing what they set. As there will be enough lots of editboxes I need it to be scrollable. I know how to add a scrollbar, but how to do the window to be scrolled?
CuteAlien
Admin
Posts: 9647
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to create scrollable window?

Post by CuteAlien »

What I would try (no guarantees, I didn't test):

Use one big statictext element as parent for all elements which can be scrolled.
Put the scrollbar beside it.
Handle the EGET_SCROLL_BAR_CHANGED event and move the position of the statictext based on that.
If clipping all works correct then by moving the statictext everything outside it's visible area should be clipped away.
If you want to control the visible area some more then you can put a second statictext behind the scrolling one as parent - and then everything outside that one is clipped.

Alternatively you can write a new gui element which handles it. That could work like listbox does and update the scrolling in the draw call (see CGUIListBox.cpp for how it works). But probably overkill unless you need many of those.
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
Andrey01
Posts: 57
Joined: Mon Jul 27, 2020 9:08 pm

Re: How to create scrollable window?

Post by Andrey01 »

Hmm, when I try to add an editbox as a child of a static text, it seems to be clipped away I suppose because of it is outside of that rectangle. Is it possible to disable clipping away of its child elements?
CuteAlien
Admin
Posts: 9647
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to create scrollable window?

Post by CuteAlien »

That clipping is what makes the scrolling work. Because then moving the parent element will hide stuff. You want stuff clipped for this case.

Otherwise you can call setNotClipped for elements.
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
chronologicaldot
Competition winner
Posts: 685
Joined: Mon Sep 10, 2012 8:51 am

Re: How to create scrollable window?

Post by chronologicaldot »

I have a GUIScrollPane in IrrExtensions that makes it easy. You can even set it to automatically add vertical and horizontal scrollbars.
https://github.com/chronologicaldot/Irr ... rollPane.h
https://github.com/chronologicaldot/Irr ... llPane.cpp

Here's the thread for comments and reports: http://irrlicht.sourceforge.net/forum/v ... =9&t=52246
Andrey01
Posts: 57
Joined: Mon Jul 27, 2020 9:08 pm

Re: How to create scrollable window?

Post by Andrey01 »

Thanks everyone!
Post Reply