Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCG/Self made Window Fade Transition
Required plugins for this example: MBS MacCG Plugin, MBS MacOSX Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/Self made Window Fade Transition
This example is the version from Thu, 16th Nov 2016.
Project "Self made Window Fade Transition.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim f as new FadeTransition(self) if PagePanel1.Value=1 then PagePanel1.Value=0 else PagePanel1.Value=1 end if f.perform 2 // 2 seconds End EventHandler
End Control
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.ForeColor=rgb(rnd*256,rnd*256,rnd*256) g.FillRect 0,0,g.Width,g.Height End EventHandler
End Control
Control PagePanel1 Inherits PagePanel
ControlInstance PagePanel1 Inherits PagePanel
End Control
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control CheckBox1 Inherits CheckBox
ControlInstance CheckBox1 Inherits CheckBox
End Control
Control EditField1 Inherits TextField
ControlInstance EditField1 Inherits TextField
End Control
Control GroupBox1 Inherits GroupBox
ControlInstance GroupBox1 Inherits GroupBox
End Control
Control PopupMenu1 Inherits PopupMenu
ControlInstance PopupMenu1 Inherits PopupMenu
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
End Control
Control ProgressBar1 Inherits ProgressBar
ControlInstance ProgressBar1 Inherits ProgressBar
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control Separator1 Inherits Separator
ControlInstance Separator1 Inherits Separator
End Control
Control ProgressBar2 Inherits ProgressBar
ControlInstance ProgressBar2 Inherits ProgressBar
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class FadeTransition Inherits timer
EventHandler Sub Action() if Overlay=nil then mode=0 lock=nil else counter=counter-10 Overlay.Transparency=counter/1000 if counter=0 then Stop end if end if End EventHandler
Sub Constructor(w as window) mode=0 if w=nil then Return win=w pic=w.ScreenshotWindowMBS if pic=nil then Return dim mask as Picture mask = new Picture(pic.Width,pic.Height,32) if mask=nil then Return dim g as Graphics g=mask.graphics // mask must be black g.forecolor=&c000000 g.fillrect 0,0,g.width,g.height CGImage=CGCreateImageMBS(pic,mask) Overlay=new FadeTransitionWindow if 0=Overlay.Create(w.left,w.Top,w.Width,w.Height) then dim c as CGContextMBS Overlay.IgnoreClicks=true Overlay.Show c=Overlay.Context c.DrawPicture(CGImage,CGMakeRectMBS(0,0,CGImage.Width,CGImage.Height)) c.Flush else // cancel Overlay=nil CGImage=nil mask=nil win=nil end if Exception End Sub
Sub Perform(duration as double) counter=duration*1000 if overlay<>nil then lock=self period=10 mode=2 end if End Sub
Sub stop() Overlay=nil CGImage=nil pic=nil mode=0 lock=nil End Sub
Property Lock As FadeTransition
Property cgimage As cgimageMBS
Property counter As Integer
Property overlay As fadeTransitionwindow
Property pic As picture
Property win As window
End Class
Class FadeTransitionWindow Inherits OverlayWindowMBS
End Class
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCG Plugin.

MBS Xojo PDF Plugins