AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Animated Splash Screens
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Tue Jun 13, 2006 1:52 pm    Post subject: Animated Splash Screens Reply with quote

In a recent post, Ricardo111 wanted to show an animation while a long process was running.
I proposed to animate text instead and my script seemed to please.
So I worked a bit more on it, to allow to easily add other animations (a kind of splash screen framework), while being #Includable in other scripts (you can keep only one animation to make this file lighter - beware of dependencies!).
The result can be downloaded: AnimatedSplashScreens.ahk.
I also added a demo code with a little GUI.
It is a bit light on the comments but I hope its usage will be clear.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Wed Jun 14, 2006 12:58 pm    Post subject: Reply with quote

Dear PhiLho, Smile

Nice Work! Very Happy
My favorite is RandomZoom!

Regards, Smile

PS: I am getting this error (when A_Index reaches 75, I guess). Please look into it.
_________________
URLGet - Internet Explorer based Downloader
Back to top
View user's profile Send private message Send e-mail
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Wed Jun 14, 2006 1:22 pm    Post subject: Reply with quote

Argh! I think we have reached a limit of AutoHotkey, which isn't designed for such silly use. ^_^'
I cannot see a workaround, as you have to declare the font before affecting it to a control. I suppose AHK stores each created font in an array of limited siz, and never release them. (Perhaps it could release the previous font when assigning a new?)
Alas, we cannot create the different font sizes in advance and reuse them, because there is no way to reference them.
So, we are stuck.
Thanks for reporting the problem.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
MisterW



Joined: 20 Jul 2005
Posts: 65

PostPosted: Thu Jun 15, 2006 12:28 am    Post subject: Reply with quote

I ran into this error recently. Writing some simple presentation software in ahk (a BIT like Powerpoint) I set the mouse wheel to dynamically changing the font size and after a while I get the same error message. I checked the source code and ahk only allocates room for MAX_GUI_FONTS which is set at 100. It does check to see whether a font already exists before allocating a new one.

here are some suggestions:

* Keep a table of fonts in use(displaying data on screen) and override those that aren't as need be

* Enabling an option for the programmer to set:

#GuiResources low|med|high|unlimited

where low is the default, med is more and high is really high.

* bump the font number up to 1000. (not a solution - you just run into the problem later)
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Thu Jun 15, 2006 12:47 am    Post subject: Reply with quote

Interesting ideas; thanks.

I could use clarification on what strategies require more than 100 fonts, and how many fonts would be sufficient (maybe an unlimited number is required). As mentioned above, since fonts are cached, a script would need to access more than 100 unique fonts to trigger this error. Accessing 70 fonts 10 times each wouldn't be enough to trigger it.

When I say "font" above, I really mean a combination of typeface + size + style, so that might explain why the limit is reached more easily.

Thanks.
Back to top
View user's profile Send private message Send e-mail
MisterW



Joined: 20 Jul 2005
Posts: 65

PostPosted: Thu Jun 15, 2006 1:30 am    Post subject: Reply with quote

Here is a sample of the code I'm using that requires potentially many combinations of font/size/weight/color? etc.

It is intended to be a presentation engine for displaying song words on a projector screen but is really just exploring the potential of ahk for such a job.

As you can see at any one time I only really need just one font being displayed but require the ability to choose among many. If you run the code and scroll the mousewheel or rightclick and change the font you'll get the idea.

For the purposes of this application you might not hit the size issue. I did because I was testing different fonts at different sizes to see how they looked. It would be nice to have flexibility to ignore arbritary limitations if possible by using a setting in the code such #GuiResources unlimited.

Certainly animation of text is another situation where numerous font combinations is needed - if my code develops a little further that may be a possible feature.


Code:

#SingleInstance Force

Colors=Red,Green,Blue,Yellow,Black,White
AvailableFonts=Arial,Tahoma,Verdana,Courier New,Times

loop, parse, Colors, `,
{
   Menu, FGColor, Add, %A_LoopField%, FGColorMenuHandler
   Menu, BGColor, Add, %A_LoopField%, BGColorMenuHandler
}

loop, parse, AvailableFonts, `,
{
   Menu, FontMenu, Add, %A_LoopField%, FontMenuHandler
}

Menu, TextAlignMenu, Add, Right, TextAlignMenu
Menu, TextAlignMenu, Add, Left, TextAlignMenu
Menu, TextAlignMenu, Add, Center, TextAlignMenu

Menu, ContextMenu, Add, Background Color, :BGColor
Menu, ContextMenu, Add, Foreground Color, :FGColor
Menu, ContextMenu, Add, Font, :FontMenu
Menu, ContextMenu, Add, Align, :TextAlignMenu

Menu, FileMenu, Add, &Exit, FileMenuHandler

Menu, MenuBar, Add, &File, :FileMenu

Gui, Menu, MenuBar

Text=Here is the first line of Text to show`nand this is the second one much like the first`nThe third is also quite similar and`nIs now followed by the fourth line which ends here.

WindowTitle=SmartSong
WinWidth=%A_ScreenWidth%;800
WinHeight=%A_ScreenHeight%;600
TextWidth := WinWidth
TextHeight := WinHeight
Font=Verdana
FontWeight=1000
FontSizer = 24
FontSize := FontSizer
Gui +ToolWindow
Gui, color, white
Gui, Font, s%FontSize% w%FontWeight%, %Font%
Gui, Add, Text,x0 y0 w%TextWidth% h%TextHeight% vPageText,%Text%
Gui, Show, w%WinWidth% h%WinHeight%, %WindowTitle%

return

WheelUp::
ifWinActive, %WindowTitle%
{
   FontSizer++
   if FontSizer > 72
      FontSizer = 72
   else
      Gui, Font, s%FontSizer%

   GuiControl, Font, PageText
} else {
   Send, {WheelUp}
}
return

WheelDown::
ifWinActive, %WindowTitle%
{
   FontSizer--
   if FontSizer < 8
      FontSizer = 8
   else
      Gui, Font, s%FontSizer%

   GuiControl, Font, PageText
} else {
   Send, {WheelDown}
}
return

GuiContextMenu:
Menu, ContextMenu, Show, %A_GuiX%, %A_GuiY%
return

ContextMenuHandler:
msgbox, You selected %A_ThisMenuItem%
return

FileMenuHandler:
ExitApp
return

FontMenuHandler:
Gui, Font,,%A_ThisMenuItem%
GuiControl,Font,PageText
return

BGColorMenuHandler:
Gui, Color, %A_ThisMenuItem%
return

FGColorMenuHandler:
Gui, Font, c%A_ThisMenuItem%
GuiControl, Font, PageText
return

TextAlignMenu:
GuiControl,+%A_ThisMenuItem%,PageText
return

GuiClose:
ExitApp
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Thu Jun 15, 2006 3:26 am    Post subject: Reply with quote

Thanks for the example (more are welcome from anyone). The limit of 100 fonts was chosen to conserve memory and also because it was more fonts than I expected anyone would ever use in a single script. That limit can be increased, but it would help to know if there is any practical, real-world need for it (you mentioned a theoretical/testing script, which although it would be nice to support, probably isn't a high priority).

Anyway, I've made a note to see what can be done about it. Furthermore, I expect that font management will be streamlined a bit sometime down the road.

Thanks.
Back to top
View user's profile Send private message Send e-mail
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Thu Jun 15, 2006 9:54 am    Post subject: Reply with quote

OK, I have put a log of the used fonts, just by adding FileAppend %ASS_size%`n, FontSizeList.txt after the Gui Font command. A little C:\PrgCmdLine\Unix\sort.exe -u FontSizeList.txt | wc shows that I reached 99 distinct font sizes. Looking at these, I saw negative font values, and values beyond the maximum. And indeed, it goes ugly sometime.
I improved my algorithm a bit, and now it uses 41 fonts as expected (any value between 8 and 4Cool. So, it should no more crash, unless you change the initial font size to something big (above 107 or 106).
I uploaded the improved script.

Chris, a suggestion on a better font use. It may not solve the base problem, but it may ease the use of fonts, and perhaps help controlling what is used.

Currently, when we want to change a font, and go back to a previous one, we have to redeclare most of it:
Gui Font, s16 cBlack, Broadway
Gui Add, Text, , This is
Gui Font, s16 cRed italic, Broadway
Gui Add, Text, x+5, just
Gui Font, s16 cBlack norm, Broadway
Gui Add, Text, x+5, an example
Gui Show

Actually, it isn't really necessary to do full declaration, as one font inherits from the previous one:
Gui Font, s16 cBlack, Broadway
Gui Add, Text, , This is
Gui Font, cRed italic
Gui Add, Text, x+5, just
Gui Font, cBlack norm
Gui Add, Text, x+5, an example
Gui Show

But it would be nice to be able to create a font object and refers to it:
Gui Font, s16 cBlack vblackFont, Broadway
Gui Font, s16 cRed italic vredFont, Broadway

Gui Add, Text, fblackFont, This is
Gui Add, Text, fredFont x+5, just
Gui Add, Text, fblackFont x+5, an example

I am not sure here if fonts declared this way still inherit from the previous one or not. I suppose they should, to avoid surprises...

Declaring alternative fonts may be tricky, but we could use something like:
Gui Font, s%size% w800 cLime vf%size%, Arial
Gui Font, rf%size%, Helvetica
(r as reference...)

BTW, when I write:
gui, font,, MS sans serif
gui, font,, Arial
gui, font,, Verdana ; Preferred font

does AHK create three fonts (if all fonts are available) or only the latest fitting one?

Back to my idea, I don't know if it is useful (widely used) enough to be worth implementing. It shouldn't generate too much code, anyway. What do you think of it?
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 4511
Location: Belgrade

PostPosted: Thu Jun 15, 2006 9:59 am    Post subject: Reply with quote

Hej PhilLo.

This is very cool.

After visiting your site, I guess you can't control yourself when graphics is in question Cool

Maybe you should create OpenGL extension to AHK Smile

And then release another, even better looking splashscreen framework Razz
_________________
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Thu Jun 15, 2006 10:52 am    Post subject: Reply with quote

Curiously enough, I haven't studied yet OpenGL nor DirectX, mostly because of lack of time.
Note that it is fun to play with constraints, it reminds me when I was trying to make good looking screens with alphanumeric terminals, including a wait icon displaying successively / - \ | (big animation! Smile).
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 4511
Location: Belgrade

PostPosted: Thu Jun 15, 2006 11:12 am    Post subject: Reply with quote

Yeah, I know what you mean (especialy that about time)

Anyway, look what some cool people did with OpenGl
http://www.novell.com/linux/xglrelease/

Then, go, and download Live CD and I garantee that you will not be able to beleive what you see. Smile
_________________
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Fri Jun 16, 2006 12:05 am    Post subject: Reply with quote

PhiLho wrote:
But it would be nice to be able to create a font object and refer to it
My impression is that most people do not switch fonts that often in GUI design (and perhaps even less often do they use more than one or two typefaces). Therefore, the benefit/cost ratio seems unfavorable. However, contrary opinions are welcome.

One of the costs of adding new features is hidden: it's the documentation complexity. For example, even if a new feature were easy to implement and very small in code size, documenting it would make the GUI feature seem more complex and harder to learn/remember. On the other hand, a feature may well have enough compelling benefits to justify these costs.

Quote:
when I write:
gui, font,, MS sans serif
gui, font,, Arial
gui, font,, Verdana ; Preferred font

does AHK create three fonts (if all fonts are available) or only the latest fitting one?
It will create all three (if they exist). However, this is an implementation detail that might be optimized in the future. As someone mentioned above, code could be added to do "garbage collection" to delete unused fonts each time a GUI window is destroyed.
Back to top
View user's profile Send private message Send e-mail
1991



Joined: 20 Jan 2006
Posts: 29
Location: Colorado, USA

PostPosted: Tue Jun 27, 2006 11:26 pm    Post subject: Reply with quote

argh!
Why didn't I find this earlier?!? Mad >pathetic 5-year old stomp<

for my loading animation, I used an image-changing loop on a fullscreen gui, and a dropping effect.

see My Google site
Code:

Loop
{
sleep,100
pic++
if pic=37
break
guicontrol,,Static1, loading_animation\%pic%.bmp
}
sleep,1000

current:=(a_screenheight-67)/2
;the super- cool animated drop (so i'm being slightly sarcastic)
loop, 33
{
x:=50-a_index
sleep,%x%
y:=a_index-4
current:=current+y
guicontrol, move, Static1,% " x" (a_screenwidth-185)/2 " y" current
}
Back to top
View user's profile Send private message
Thalon



Joined: 12 Jul 2005
Posts: 633

PostPosted: Wed Jun 28, 2006 6:25 am    Post subject: Reply with quote

I can't access the script...
Neither per direct click nor via "Save target as.."

Sad
Thalon
_________________
AHK-Icon-Changer
AHK-IRC
deutsches Forum
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Wed Jun 28, 2006 6:45 am    Post subject: Reply with quote

Dear Thalon, Smile

You wrote:
I can't access the script...
Neither per direct click nor via "Save target as.."


There are some difficulties right now @ autohotkey.net. See this post.

Here is my copy of the script : ( Redundant - Edited out )

Regards, Smile
_________________
URLGet - Internet Explorer based Downloader


Last edited by SKAN on Sat Jul 01, 2006 8:46 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group