
Code: Select all
Enumeration
#popupWindow
#mainWindow
#button_1
#button_2
#text_1
EndEnumeration
ExamineDesktops()
Global mWindowID
#Ex_Dropdown = 0
#Ex_Dropright = 1
Procedure WindowEffect(mWindowID, mWinWidth.f, mWinHeight.f, mWinEffect, mSpeed.f);, WSpeed, HSpeed)
;exResult = OpenWindow(mWindowID,0,0,mWinResizeWidth,mWinResizeHeight,mWinTitle.s,mWinFlags)
If mSpeed > 10 : mSpeed = 10 : ElseIf mSpeed <= 1 : mSpeed = 1 : EndIf ; -- A speed higher than 10 makes a window resize oddly
HideWindow(mWindowID,1) : Delay(2) : HideWindow(mWindowID,0) ; -- Tries to prevent "flashing"
While Ex_Effect = 0 : WaitWindowEvent(10)
If mWinEffect = #Ex_Dropdown
If mWinResizeHeight >= mWinHeight : Else
mWinResizeHeight + mSpeed
EndIf
mWinResizeWidth = mWinWidth
ResizeWindow(mWindowID, #PB_Ignore, #PB_Ignore, mWinResizeWidth, mWinResizeHeight)
ResizeWindow(#mainWindow, WindowX(#popupWindow)+WindowWidth(#popupWindow)+6,WindowY(#popupWindow),#PB_Ignore,#PB_Ignore)
EndIf
If mWinEffect = #Ex_Dropright
If mWinResizeHeight >= mWinHeight : Else
mWinResizeHeight + mSpeed
EndIf
If mWinResizeWidth >= mWinWidth : Else
mWinResizeWidth + mSpeed
EndIf
ResizeWindow(mWindowID, #PB_Ignore, #PB_Ignore, mWinResizeWidth, mWinResizeHeight)
ResizeWindow(#mainWindow, WindowX(#popupWindow)+WindowWidth(#popupWindow)+6,WindowY(#popupWindow),#PB_Ignore,#PB_Ignore)
EndIf
; -- Check if we've reached our window width and height..
If mWinResizeHeight >= mWinHeight And mWinResizeWidth >= mWinWidth
ResizeWindow(mWindowID, #PB_Ignore, #PB_Ignore, mWinWidth, mWinHeight) ; -- fail safe to keep large numbers from making large windows
Break
EndIf
Wend
EndProcedure
OpenWindow(#mainWindow,-100,-100,0,0,"Menu",#PB_Window_Tool) ; -- I set the position to -100 because having it pop up on the top corner was quite annoying
ButtonGadget(#button_1,0,5,125,25,"Drop Down")
ButtonGadget(#button_2,0,30,125,25,"Drop Right")
Delay(10)
OpenWindow(#popupWindow,DesktopWidth(0)/2.7,DesktopHeight(0)/2.5,150,120,"Window Effects",#PB_Window_SystemMenu)
TextGadget(#text_1,5,25,150,55,"Click on a button in the menu"+#LF$+"The menu starts with a drop down effect.")
WindowEffect(#mainWindow,126,70, #Ex_Dropdown, 1)
Repeat
eventID = WaitWindowEvent(10)
ResizeWindow(#mainWindow, WindowX(#popupWindow)+WindowWidth(#popupWindow)+6,WindowY(#popupWindow),#PB_Ignore,#PB_Ignore)
If eventID = #PB_Event_Gadget
Select EventGadget()
Case #button_1
WindowEffect(#popupWindow,150,175,#Ex_Dropdown,1)
SetGadgetText(#text_1,"Drop down!")
Case #button_2
WindowEffect(#popupWindow,250,250,#Ex_Dropright,10)
SetGadgetText(#text_1,"Drop to the right!")
EndSelect
EndIf
Until eventID = #PB_Event_CloseWindow