Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How to make scrolling window with scroll bar on right side? (Windows PC)

Author
Message
Mark Garrett
Reviewed AGK on Steam
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location: California, US
Posted: 22nd Aug 2017 20:57
Would like it's dimensions be 500 width X 2000 height

Have not found any possible solution. But it would be good for my game which is almost finished.

It would be to display the top 500 scores.
.
Jambo B
15
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 22nd Aug 2017 21:20
Hi Bubba,

What about this:

Have a sprite on the right-hand side of the screen which represents the scrollbar.
When the scrollbar is dragged, it moves up and down the screen.
Set up an array of texts (perhaps 15 of them) which will be used to display the data you want to show.
Initially, if the scrollbar is at the top, texts 1-10 (for example) display the first ten items.
As the scrollbar moves down, the texts move up.
When the top text moves up off the top of the screen, because the scrollbar has moved down, it is hidden and marked as inactive.
When the bottom text moves down off the bottom of the screen, because the scrollbar has moved up, it is hidden and marked as inactive.
When there is room for another text at the bottom of the screen (because the user has scrolled down far enough), one of the hidden, inactive texts is reused and placed at the bottom position.
When there is room for another text at the top of the screen (because the user has scrolled up far enough), one of the hidden, inactive texts is reused and placed at the top position.

When scrolling, you'd have to work out how far to move each text up or down. You could take the position of the scrollbar as a percentage. When it's at the top, item 1 is displayed; when it's at the bottom, item 500 is displayed. A bit of maths will let you calculate which item should be at the top of the list based on the scrollbar's Y position.

Just a thought!

James
Mark Garrett
Reviewed AGK on Steam
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location: California, US
Posted: 23rd Aug 2017 00:17 Edited at: 23rd Aug 2017 00:20
Quite a concept! I'll give it a try

Maybe that's how Microsoft does it (come to think of it)
.
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 23rd Aug 2017 10:17
I have an example of a scrolling window app made with AGK. The version I made was a bit more complex as I added draggable/resizable panels to it too to try and make a starting template for proper desktop apps.

The scrolling part is easy. If I get some time later tonight I will break it up so that it's just the scrollable window part. It has scrollbars on the right and bottom that resize/disappear depending on the size of the content.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 23rd Aug 2017 21:41 Edited at: 23rd Aug 2017 21:42
Here's my example for horizontal and vertical scroll bars. When I was working on my project I was using percentages for positioning everything instead of VirtualResolution(1024, 768) so had to convert it. In this example I've got two global variables xContentSize# and yContentSize#, these should contain the overall size of the scene that you want to pan around.

If you press the space key while it's running it will randomly change the values of those two variables and resize the scroll bars as well as reposition the 4 sprites showing the corners of the scene.

You will need to play around with the maximum scroll bar size as well as how far they can move (trackSize) because at the moment the trackSize is the window size so they overlap at the bottom right corner.

After uploading it I noticed that when you resize the window the bars don't remain at the edge of the screen. I didn't have this problem when I was working with percentages, but adding SetDisplayAspect(-1) fixed this (that may cause you problems with the rest of your game/app though)

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-09-30 07:12:16
Your offset time is: 2024-09-30 07:12:16