It is currently 01 Jan 2010, 07:55

Welcome
Welcome to the SDB Engine Forum!
You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!


Post a new topicPost a reply Page 1 of 1   [ 8 posts ]
Author Message
 Post subject: ... set default color
PostPosted: 22 Aug 2008, 20:49 

Joined: 27 May 2008, 19:38
Posts: 67
Location: Dresden / Germany
Is there an easy way to easily set the default (background) color of a gadget? E.g. I altered a label with this:
Code:
scui.Set("myLabel", { Bevel = { Colors = { Fill1 = { r = 250, g = 0, b = 0 } } } }, 1 )

Now, can I easily switch back to the default color?

Thanks in advance! :-)

_________________
CD32 + SX1; AmiKit (WinUAE) + OS3.9


Top
 Profile  
 
 Post subject:
PostPosted: 22 Aug 2008, 21:11 
Site Admin
User avatar

Joined: 22 Mar 2007, 22:50
Posts: 112
Well, if you need to set a default color for all of your labels then you should modify the file Default_Standard.hws, the default bevel definitions for the labels are the tables named scui.theme.Label_Bevel for the BevelStruct and scui.theme.Label_Text for the TextStruct.

If you modify the Fill1 color in the table scui.theme.Label_Bevel all subsequently created labels will have that background color.

Ofcourse you can modify directly the code in the Default_Standard.hws or you can change default tables at runtime.

Ask if you need an example!
:wink:


Top
 Profile  
 
 Post subject:
PostPosted: 22 Aug 2008, 21:17 

Joined: 27 May 2008, 19:38
Posts: 67
Location: Dresden / Germany
Well, here's what I want to do basicly:
Code:
If a = 0
    scui.Set("myLabel", { Bevel = { Colors = { Fill1 = { r = 250, g = 0, b = 0 } } } }, 1 )
Else
    scui.Set("myLabel", { Bevel = { Colors = { Fill1 = #DEFAULT_COLOR } }, 1 )
EndIf


This tag "#DEFAULT_COLOR" is what I meant with easily switch back to the default value (that is defined in Default_Standard.hws - I don't want to change the Default_Standard.hws, I want to use the values in it). Is that somehow possible?

_________________
CD32 + SX1; AmiKit (WinUAE) + OS3.9


Top
 Profile  
 
 Post subject:
PostPosted: 22 Aug 2008, 21:46 
Site Admin
User avatar

Joined: 22 Mar 2007, 22:50
Posts: 112
You can do the following:

Code:
; In the initialization section of your code, just after the interface is defined
Local lab = scui.Get("myLabel")
Local labColor = lab.Bevel.Colors.Fill1
; In this way you have saved the starting Fill1 color of your label (the default), so you can set it later in your loops.

; -------------------------------
If a = 0
    scui.Set("myLabel", { Bevel = { Colors = { Fill1 = { r = 250, g = 0, b = 0 } } } }, 1 )
Else
    scui.Set("myLabel", { Bevel = { Colors = { Fill1 = labColor } }, 1 )
EndIf


This should work... btw I've not tested it :P


Top
 Profile  
 
 Post subject:
PostPosted: 22 Aug 2008, 22:00 

Joined: 27 May 2008, 19:38
Posts: 67
Location: Dresden / Germany
Well, great idea! But it seems not to work here ... :-( But it is too late now, I spend a lot of hours with Hollywood and SCUIlib and it was great! I've learned a lot.

I will look for this later (I won't be at PC at the weekend :-/ ).

BTW: When I save the color, "labColor" is a table, right? So, should the syntax of the else branch (besides a forgotten } :)) be:
Code:
scui.Set("myLabel", { Bevel = { Colors = { Fill1 = { labColor } } } }, 1 )

Nevertheless that doesn't work as well ... :-(

Maybe you have an additional idea. :-)

Good night mate, and thanks a lot for all your help!

_________________
CD32 + SX1; AmiKit (WinUAE) + OS3.9


Top
 Profile  
 
 Post subject:
PostPosted: 22 Aug 2008, 23:23 
Site Admin
User avatar

Joined: 22 Mar 2007, 22:50
Posts: 112
I think I've got the trick... the problems are generated by the variables scope, I've resolved declaring at the beggining of the script the variable that will hold the defaul table gotten from the label:

Code:
Local labColor = {}


Then after the label creation I've stored the Fill1 color into this variable liek we have said in the previous post

Code:
Local lab = scui.Get("myLabel")
labColor = lab.Bevel.Colors.Fill1


Finally you can set your color and the restore it using the labColor table

Code:
If a = 0
    scui.Set("myLabel", { Bevel = { Colors = { Fill1 = { r = 250, g = 0, b = 0 } } } }, 1 )
Else
    scui.Set("myLabel", { Bevel = { Colors = { Fill1 = labColor } }, 1 )
EndIf


Hope this help!
Good night to you, at week end I'm not on PC too ;)

cya
Fabio


P.S.: about your code, you can't write
Code:
scui.Set("myLabel", { Bevel = { Colors = { Fill1 = { labColor } } } }, 1 )

because labColor is already a table, if you write the above code you are declaring a table within a table, it is equivalent to:
Code:
scui.Set("myLabel", { Bevel = { Colors = { Fill1[0] = labColor  } } }, 1 )

:wink:


Top
 Profile  
 
 Post subject: Re: ... set default color
PostPosted: 24 Aug 2008, 20:43 

Joined: 27 May 2008, 19:38
Posts: 67
Location: Dresden / Germany
Thanks a lot, Fabio, this works perfectly! :-)
Hope, you had a nice weekend!?

CU

_________________
CD32 + SX1; AmiKit (WinUAE) + OS3.9


Top
 Profile  
 
 Post subject: Re: ... set default color
PostPosted: 25 Aug 2008, 08:23 
Site Admin
User avatar

Joined: 22 Mar 2007, 22:50
Posts: 112
Yes :)
I had a good weekend, hope the same for you ;)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 8 posts ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron