Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Overlay Plugin, MBS Picture Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Overlay/OverlayMagician
This example is the version from Mon, 15th Mar 2015.
Project "OverlayMagician.xojo_binary_project"
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
start
End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
Window2.Show
End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action()
Window3.Show
End EventHandler
End Control
Protected Sub start()
Dim o As FadingInterfaceFx
o=New FadingInterfaceFx( Self.left, Self.top, 200, 50, true )
o.MakeScreenshot
// Make something appear or disapear here
// it must be placed behind the created overlay window
StaticText2.Visible=Not StaticText2.Visible
o.show // Show the overlay and start fading effect
End Sub
End Class
Class Window2 Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
EventHandler Function CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) As Boolean
if Me.Selected(row) and AboutToDelete then
g.ForeColor=&cB6000A
elseif Me.Selected(row) then
g.ForeColor=&c2E75D8
else
g.ForeColor=&cFFFFFF
end if
g.FillRect 0,0,g.Width,g.Height
if Me.Selected(row) and Me.SelCount>0 then
g.ForeColor=&cFFFFFF
g.DrawLine 0,0,g.Width,0
end if
return true
End EventHandler
EventHandler Sub Change()
if Me.SelCount>0 then
PushButton1.Enabled=true
else
PushButton1.Enabled=false
end if
End EventHandler
EventHandler Sub Open()
Me.AddRow "A first test row"
Me.AddRow "A second test row"
Me.AddRow "A third test row"
Me.AddRow "A last one"
End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
HighlightSelected
End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
RemoveSelected
End EventHandler
End Control
Protected Sub HighlightSelected()
// AboutToDelete is used to make the listbox change the
// color of the select rows right before to delete them
AboutToDelete=true
for i as integer=0 to Listbox1.ListCount-1
if Listbox1.Selected(i) then Listbox1.InvalidateCell(i,0)
next
Timer1.Mode=1
End Sub
Protected Sub RemoveSelected()
Dim i As Integer
Dim o As FadingInterfaceFx
o=New FadingInterfaceFx( Self.left+Listbox1.Left, Self.top+Listbox1.top, Listbox1.width,Listbox1.Height, true )
o.MakeScreenshot
// We delete the selected rows
for i=Listbox1.ListCount-1 DownTo 0
if Listbox1.Selected(i) then Listbox1.RemoveRow(i)
next
o.show // Show the overlay window and start fading effect
AboutToDelete=false
End Sub
Property Protected AboutToDelete As Boolean
End Class
Class Window3 Inherits Window
Control PPanel Inherits PagePanel
ControlInstance PPanel Inherits PagePanel
End Control
Control EditField1 Inherits TextField
ControlInstance EditField1(0) Inherits TextField
ControlInstance EditField1(1) Inherits TextField
ControlInstance EditField1(2) Inherits TextField
ControlInstance EditField1(3) Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1(0) Inherits Label
ControlInstance StaticText1(1) Inherits Label
ControlInstance StaticText1(2) Inherits Label
ControlInstance StaticText1(3) Inherits Label
ControlInstance StaticText1(4) Inherits Label
End Control
Control RadioButton1 Inherits RadioButton
ControlInstance RadioButton1 Inherits RadioButton
End Control
Control RadioButton2 Inherits RadioButton
ControlInstance RadioButton2 Inherits RadioButton
End Control
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
EventHandler Sub Open()
Me.AddRow "A first test row"
Me.AddRow "A second test row"
Me.AddRow "A third test row"
Me.AddRow "A last one"
End EventHandler
End Control
Control ToolbarWin31 Inherits ToolbarWin3
ControlInstance ToolbarWin31 Inherits ToolbarWin3
EventHandler Sub Action(item As ToolItem)
Select case item.Name
case "ToolItem1"
ChangePanelPage(0)
case "ToolItem2"
ChangePanelPage(1)
end select
End EventHandler
End Control
Protected Sub ChangePanelPage(PageValue As integer)
if PageValue<>PPanel.Value then
Dim o As FadingInterfaceFx
o=New FadingInterfaceFx( Self.left+PPanel.Left, Self.top+PPanel.top, PPanel.width,PPanel.Height , true)
o.MakeScreenshot
// We change the page
PPanel.Value=PageValue
o.show // Show the overlay window and start fading effect
end if
End Sub
End Class
Class ToolbarWin3 Inherits Toolbar
ToolbarItem ToolItem1
ToolbarItem ToolItem2
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
Class FadingInterfaceFx Inherits OverlayMBS
EventHandler Sub WindowShown()
RunFx
End EventHandler
Sub MakeScreenshot(TestMode As Boolean=False)
if TestMode then
// Set TestMode=True for testing with a color rectangle instead of the screenshot
dim p As New Picture( width,height,32 )
p.Graphics.ForeColor=&cB6000A
p.Graphics.FillRect 0,0,width,height
Pict=p
else
// Make the screenshot of the area defined
// by the overlay window's coordidates
Pict=ScreenshotRectMBS( Left,top,width,height )
end if
dim m As New Picture( width,height,32 )
m.Graphics.ForeColor=&c000000
m.Graphics.FillRect 0,0,width,height
Mask=m
UpdateShow
End Sub
Sub RunFx()
// Create and start the timer
ti=New FadingInterfaceFxTimer
ti.Mode=0
ti.win=Self
ti.StartFx(speed)
End Sub
Property speed As Integer = 5
Property Protected ti As FadingInterfaceFxTimer
End Class
Class FadingInterfaceFxTimer Inherits Timer
EventHandler Sub Action()
if count>0.0 then
win.Alpha=count
win.Update
count=count-stp
else
Mode=0
Win.Hide
win = nil
end if
End EventHandler
Sub StartFx(speed As integer=5)
// Speed goes from 1 to 10
if speed<1 then
speed=1
elseif speed>10 then
speed=10
end if
Period=100/speed
Count=1.0
stp=0.05
Mode=2
End Sub
Property Win As FadingInterfaceFx
Property Protected count As Double
Property Protected stp As Double
End Class
End Project
The items on this page are in the following plugins: MBS Overlay Plugin.