RASHAD, thank you, I always liked your WinAPI low level sources
Unfortunately in this case we have a lot of flickering, so far solution from Sirius-2337 is the best one (and maybe with mk-soft's timers it will be perfect, not tested yet).
Animation [quality]
-
- User
- Posts: 53
- Joined: Sat May 14, 2011 10:39 am
Re: Animation [quality]
This code fixes the problem with fast clicking.Everything wrote:Well... this is the best result I've ever get, thank you very machSirius-2337 wrote:Of course
There is some not covered moments like if you click fast for example
edit: Fixed it even more
Code: Select all
EnableExplicit
Enumeration EnumImage
#Image_FlyOut
EndEnumeration
Enumeration EnumWindow
#Window_Main
#Window_FlyOut
EndEnumeration
Enumeration EnumGadget
#Canvas_Bar
#Canvas_FlyOut
EndEnumeration
Enumeration EnumTimer
#Timer_FlyOut
#Timer_FlyIn
EndEnumeration
Define oldStyle, i
Global FlyOutWidth.d
Procedure Event_MoveWindow_Main()
Protected x = WindowX(#Window_Main) + GadgetWidth(#Canvas_Bar)
Protected y = WindowY(#Window_Main, #PB_Window_InnerCoordinate)
ResizeWindow(#Window_FlyOut, x, y, #PB_Ignore, #PB_Ignore)
EndProcedure
Procedure Event_Timer()
Protected Width.d
Select EventTimer()
Case #Timer_FlyOut
FlyOutWidth * 0.85
If FlyOutWidth < 1
FlyOutWidth = 0
RemoveWindowTimer(#Window_Main, #Timer_FlyOut)
EndIf
Width = GadgetWidth(#Canvas_FlyOut) - FlyOutWidth
Case #Timer_FlyIn
FlyOutWidth * 0.65
If FlyOutWidth < 1
FlyOutWidth = 0
HideWindow(#Window_FlyOut, #True)
RemoveWindowTimer(#Window_Main, #Timer_FlyIn)
EndIf
Width = FlyOutWidth
EndSelect
ResizeWindow(#Window_FlyOut, #PB_Ignore, #PB_Ignore, Width, #PB_Ignore)
EndProcedure
Procedure Event_CanvasBar_Click()
Static FlyDirection = #Timer_FlyIn
FlyOutWidth = GadgetWidth(#Canvas_FlyOut) - FlyOutWidth
If FlyDirection = #Timer_FlyIn
FlyDirection = #Timer_FlyOut
RemoveWindowTimer(#Window_Main, #Timer_FlyIn)
HideWindow(#Window_FlyOut, #False)
AddWindowTimer(#Window_Main, #Timer_FlyOut, 1)
Else
FlyDirection = #Timer_FlyIn
RemoveWindowTimer(#Window_Main, #Timer_FlyOut)
AddWindowTimer(#Window_Main, #Timer_FlyIn, 1)
EndIf
EndProcedure
LoadImage(#Image_FlyOut, #PB_Compiler_Home + "Examples\Sources\Data\PureBasicLogo.bmp")
OpenWindow(#Window_Main, 0, 0, 640, ImageHeight(#Image_FlyOut) * 6, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(#Canvas_Bar, 0, 0, 30, WindowHeight(#Window_Main))
If StartDrawing(CanvasOutput(#Canvas_Bar))
Box(0, 0, OutputWidth(), OutputHeight(), $989898)
StopDrawing()
EndIf
If OpenWindow(#Window_FlyOut, WindowX(#Window_Main) + GadgetWidth(#Canvas_Bar), WindowY(#Window_Main, #PB_Window_InnerCoordinate), ImageWidth(#Image_FlyOut), WindowHeight(#Window_Main), "", #PB_Window_BorderLess | #PB_Window_Invisible, WindowID(#Window_Main))
CanvasGadget(#Canvas_FlyOut, 0, 0, WindowWidth(#Window_FlyOut), WindowHeight(#Window_FlyOut))
If StartDrawing(CanvasOutput(#Canvas_FlyOut))
For i = 0 To OutputHeight() Step 68
DrawImage(ImageID(#Image_FlyOut), 0, i)
Next i
StopDrawing()
EndIf
; From RSBasic - WinAPI Library - Do not change focus
oldStyle=GetWindowLongPtr_(WindowID(#Window_FlyOut),#GWL_STYLE)
SetWindowLongPtr_(WindowID(#Window_FlyOut),#GWL_STYLE,oldStyle|#WS_CHILD &(~#WS_POPUP))
SetWindowPos_(WindowID(#Window_FlyOut), 0,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_NOZORDER|#SWP_FRAMECHANGED)
SetActiveWindow(#Window_Main)
ResizeWindow(#Window_FlyOut, #PB_Ignore, #PB_Ignore, 0, #PB_Ignore)
EndIf
BindEvent(#PB_Event_MoveWindow, @Event_MoveWindow_Main())
BindEvent(#PB_Event_Timer, @Event_Timer())
BindEvent(#PB_Event_Gadget, @Event_CanvasBar_Click(), #Window_Main, #Canvas_Bar, #PB_EventType_LeftClick)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
-
- Enthusiast
- Posts: 224
- Joined: Sat Jul 07, 2018 6:50 pm
Re: Animation [quality]
Excellent! And if it's possible to make a bulletproof antiflicker solution I think it will be perfect.
P.S.
The strange thing is that I have flickering 1 of ~20 times only on Win7 x64, but on WinXP or Win10 no problems at all...
Don't know how to interpret it.
P.S.
The strange thing is that I have flickering 1 of ~20 times only on Win7 x64, but on WinXP or Win10 no problems at all...
Don't know how to interpret it.
Re: Animation [quality]
No bulletproof but simple canvas method
Code: Select all
Global.b Clic,Expland
Global W.f
If OpenWindow(0, 0, 0, 220, 410, "Canvas container example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 10, 10, 200, 400)
StartDrawing(CanvasOutput(0))
Box(0,0,150,400,$FFFFFF)
Box(0,0,20,400,#Green)
StopDrawing()
AddWindowTimer(0,123,2)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Timer
If Clic = #True
speed.f = 5
StartDrawing(CanvasOutput(0))
If Expand = #False
Box(0,0,W,400,#Green)
W + speed
If W = 150
Expand = #True
Clic = #False
EndIf
ElseIf Expand = #True
Box(0,0,200,400,$FFFFFF)
Box(0,0,W,400,#Green)
W-speed
If W = 20
Expand = #False
Clic = #False
EndIf
EndIf
EndIf
StopDrawing()
EndIf
If Event = #PB_Event_Gadget And EventGadget() = 0
If EventType() = #PB_EventType_LeftButtonDown
Clic = #True
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
~Ar-S~
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4
Code: Select all
r3p347 : 7ry : un71l d0n3 = 1
Re: Animation [quality]
A trigger of 25 milliseconds is usually enough.
Fames = 1000 / 25 = 40
Fames = 1000 / 25 = 40
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive