Page 1 of 1

SetGadgetColor

Posted: Thu Dec 29, 2016 5:31 am
by RamRat
Ok, I want the ListViewGadget to pulse when selecting an item

sooo what's the easiest way to get this to fade to black then back to white? SetGadgetColor(2, #PB_Gadget_FrontColor, $FFFFFF)

Do I chuck it in a quick loop while adjusting the colour? If so how easy is it do put this $FFFFFF in a quick loop?

Cheers!

Re: SetGadgetColor

Posted: Thu Dec 29, 2016 2:16 pm
by PureLust
Maybe this could push you in the right direction. :wink:

Code: Select all

OpenWindow(0,0,0,200,300,"Flashing ...", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
ListViewGadget(0,5,5,190,290)
For n = 1 To 37
	AddGadgetItem(0,-1,"Hello, I'm Line number "+Str(n))
Next

Color = 255					; starting from white
stepper = 32				; stepping up/down 32 shades

Repeat
	Event = WaitWindowEvent()
	Select Event
		Case #PB_Event_Timer
			color - stepper
			If color < 0
				color = 255						; set back to white
				RemoveWindowTimer(0,0)		; remove timer
			EndIf
			SetGadgetColor(0,#PB_Gadget_BackColor, RGB(Color, Color, Color))	; set actual color
		Case #PB_Event_Gadget
			If EventGadget() = 0
				If EventType() = #PB_EventType_LeftClick
					AddWindowTimer(0,0,10)	; Change color every 10ms
				EndIf
			EndIf
	EndSelect
Until Event = #PB_Event_CloseWindow

Re: SetGadgetColor

Posted: Fri Dec 30, 2016 2:04 am
by RamRat
Thanks! Did not realise I could throw RGB in there lol, beats my embarrassing attempt :oops:

Code: Select all

  

        SetGadgetColor(2, #PB_Gadget_FrontColor, $FFFFFF)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $EEEEEE) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $DDDDDD) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $CCCCCC) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $BBBBBB) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $AAAAAA) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $999999) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $888888) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $777777) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $555555) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $333333) : Delay(5)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $111111) : Delay(5)
        
               
        FileName$ = ReplaceString(GetGadgetText(2)," ","%20")
        SetGadgetState(2,-1)
        *buf = ReceiveHTTPMemory("http://www.omdbapi.com/?t=" + FileName$)
        OMDB$ = PeekS(*buf,-1,#PB_Ascii)
        
        
        SetGadgetColor(2, #PB_Gadget_FrontColor, $111111) : Delay(5)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $333333) : Delay(5)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $555555) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $777777) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $999999) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $BBBBBB) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $CCCCCC) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $DDDDDD) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $EEEEEE) : Delay(10)
        SetGadgetColor(2, #PB_Gadget_FrontColor, $FFFFFF) : Delay(10)

Re: SetGadgetColor

Posted: Fri Dec 30, 2016 2:17 am
by mk-soft
Don“t use Delay() with Gadget functions. Always need a Event-Loop for update window...