It is currently Mon Sep 23, 2019 7:16 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Animation [quality]
PostPosted: Tue Aug 20, 2019 8:02 pm 
Offline
User
User

Joined: Sat Jul 07, 2018 6:50 pm
Posts: 65
RASHAD, thank you, I always liked your WinAPI low level sources :D
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).


Top
 Profile  
Reply with quote  
 Post subject: Re: Animation [quality]
PostPosted: Wed Aug 21, 2019 6:41 am 
Offline
User
User

Joined: Sat May 14, 2011 10:39 am
Posts: 53
Everything wrote:
Sirius-2337 wrote:
Of course

Well... this is the best result I've ever get, thank you very mach 8)
There is some not covered moments like if you click fast for example


This code fixes the problem with fast clicking.

edit: Fixed it even more :)

Code:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Animation [quality]
PostPosted: Wed Aug 21, 2019 4:56 pm 
Offline
User
User

Joined: Sat Jul 07, 2018 6:50 pm
Posts: 65
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Animation [quality]
PostPosted: Thu Aug 22, 2019 9:38 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Oct 06, 2007 11:20 pm
Posts: 264
Location: France
No bulletproof but simple canvas method
Code:

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~

ResizerGold : The easiest way to resize your pictures and more
My webSite (french) : LDVMULTIMEDIA
PB - 5.4x LTS / 5.6x - W10 x64 - GTX1080 - i5 6600k
Repeat : try : until done = 1


Top
 Profile  
Reply with quote  
 Post subject: Re: Animation [quality]
PostPosted: Thu Aug 22, 2019 10:56 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1915
Location: Germany
A trigger of 25 milliseconds is usually enough.

Fames = 1000 / 25 = 40

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 13 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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye