HyperNext Studio

HyperNext Studio => General => Topic started by: tools-n-stuff on October 26, 2010, 02:29:40 PM

Title: Centering cards
Post by: tools-n-stuff on October 26, 2010, 02:29:40 PM
I guess the title says it all, but i was wondering if there wasn't a way of having the cards display in the center of the screen?
Title: Re: Centering cards
Post by: Malkom on October 26, 2010, 04:19:07 PM
Quote from: "tools-n-stuff"
I guess the title says it all, but i was wondering if there wasn't a way of having the cards display in the center of the screen?

Use the following command and place it in the Card's script although it can be placed in a button etc:-


Code: [Select]
@ to center card 1
CardSetCenter(1)
Title: Re: Centering cards
Post by: tools-n-stuff on October 26, 2010, 06:52:54 PM
Cool, thanks Malkom
Title: Re: Centering cards
Post by: carlk on January 04, 2011, 03:35:05 AM
I don't recall where in my reading I found that using a parameter of zero in this command will center the current card.  Anyway, I put this command into the beginning the script for each of my cards....

CardSetCenter(0)

And it works except for one annoying behavior.  First the card is displayed at its default location (upper left corner of the screen) and then it jumps to the center position.

I understand that a card needs to appear before its script can run, so I'm wondering ... is there a way to get each card centered yet avoid this jumping?

Thanks,
Carl
Title: Re: Centering cards
Post by: Malkom on January 04, 2011, 06:51:51 AM
Quote from: "carlk"
I don't recall where in my reading I found that using a parameter of zero in this command will center the current card.  Anyway, I put this command into the beginning the script for each of my cards....

CardSetCenter(0)

And it works except for one annoying behavior.  First the card is displayed at its default location (upper left corner of the screen) and then it jumps to the center position.

I understand that a card needs to appear before its script can run, so I'm wondering ... is there a way to get each card centered yet avoid this jumping?

Thanks,
Carl

Yes, placing the command inside the card to be centered has this annoying delay.

However, if you place the CardSetCenter command in the StartUp section of the MainCode section then it will center your card before it opens and loads.

Code: [Select]
@ center card 2
CardSetCenter(2)

By the way, this works fine on Macintosh but there is a bug on Windows XP - the card's top remains unchanged so it would need calculating manually using the ScreenHeightFN, CardHeightFN functions and then calling the CardSetTop command.
Title: Re: Centering cards
Post by: carlk on January 05, 2011, 08:26:18 AM
In a stack of many cards, such as I now have, it's inconvenient to put individual card centering commands into the Startup script of the MainCode for each card.  Also, if the stack will add cards during use, as mine does, the new cards wouldn't be included in the programmed centering code.  So here's what I came up with to center all cards in the stack...

Code: [Select]
@ use in Startup script of MainCode to center all cards in stack before opening home card
Local numCards,x
Put TotalCardsFN into numCards
For x=1 to numCards step 1
     CardSetCenter(x)
EndFor
Title: Re: Centering cards
Post by: carlk on January 05, 2011, 08:32:52 AM
I forgot to add to my previous posting that, as a Mac user, this works fine for me.  I presume Windows XP users could incorporate some additional code into what I provided that would calculate the new location of the card's top and call the CardSetTop command.

Carl
Title: Re: Centering cards
Post by: Malkom on January 06, 2011, 01:34:31 PM
Quote from: "carlk"
In a stack of many cards, such as I now have, it's inconvenient to put individual card centering commands into the Startup script of the MainCode for each card.  Also, if the stack will add cards during use, as mine does, the new cards wouldn't be included in the programmed centering code.  So here's what I came up with to center all cards in the stack...

Code: [Select]
@ use in Startup script of MainCode to center all cards in stack before opening home card
Local numCards,x
Put TotalCardsFN into numCards
For x=1 to numCards step 1
     CardSetCenter(x)
EndFor

Thats a good idea and thank you for the code example.