Re: SideBarGadget
Posted: Fri May 26, 2023 3:16 am
Updated fixed some bugs, blocking event or other gadgets open/close gadget list.
see code 1st post
see code 1st post
Thanks for the info,BarryG wrote: Fri May 26, 2023 3:22 am First post doesn't say "Edited" ?
Also, from MSDN: "It is only necessary to call DestroyIcon for icons created with the CreateIconIndirect function."
No it show the edit count as I'm a Mod, which is a good thing in my case as I often don't see mistakes until I post a messageBarryG wrote: Fri May 26, 2023 3:38 am No, what I mean is see how my post above says "Lasted edited..." on it? Your first post doesn't, so I can't tell when it's edited/updated. Is that a forum bug, or because you're a moderator?
On macOS, drag and drop has not worked properly for some time. Something has been changed in the OS that makes it very complicated. But it is on the to-do list
Yes hover and click will be easy to add.Caronte3D wrote: Fri May 26, 2023 9:23 am Feature request:
Would be nice if we can show/hide the menu clicking on an empty area instead of only on the little arrow.
An option to auto-hide after click on a menu item would be nice too.
I found a work around but wasn't sure if it was a bug or not.
Added Auto show hide activated by mouse enter leave and timed dwell, I still need to test how it works dpi scaled and on osxCaronte3D wrote: Fri May 26, 2023 9:23 am Feature request:
Would be nice if we can show/hide the menu clicking on an empty area instead of only on the little arrow.
An option to auto-hide after click on a menu item would be nice too.
Code: Select all
Procedure SideBar_Draw()
;Disable updates
Protected ew = WindowID(EventWindow())
LockWindowUpdate_(ew)
Protected timg,w,h,x,y,cy,ph =10
Protected gadget,*sidebar.SideBar_Gadget=0
Protected menuid,bfirst=1
gadget = EventGadget()
If IsGadget(gadget)
*sidebar = GetGadgetData(gadget)
If *sidebar <> 0
ForEach *sidebar\MenuItems()
If Not IsGadget(*sidebar\MenuItems()\ID)
timg = CreateImage(#PB_Any,1,1)
StartDrawing(ImageOutput(timg))
DrawingFont(FontID(*sidebar\MenuItems()\font))
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
w = DesktopUnscaledX(TextWidth(*sidebar\MenuItems()\lable)) *1.5
h = DesktopUnscaledY(TextHeight(*sidebar\MenuItems()\lable)) * 1.5
CompilerElse
w = DesktopUnscaledX(TextWidth(*sidebar\MenuItems()\lable))
h = DesktopUnscaledY(TextHeight(*sidebar\MenuItems()\lable))
CompilerEndIf
StopDrawing()
FreeImage(timg)
OpenGadgetList(*sidebar\gadgetID)
*sidebar\MenuItems()\ID = HyperLinkGadget(#PB_Any,10,ph,w,h,*sidebar\MenuItems()\lable,*sidebar\MenuItems()\activecolor)
CloseGadgetList()
If *sidebar\MenuItems()\ID
If *sidebar\MenuItems()\tooltip <> ""
GadgetToolTip(*sidebar\MenuItems()\ID, *sidebar\MenuItems()\tooltip)
EndIf
ph+h*1.5
If w >= *sidebar\maxwidth
*sidebar\maxwidth = w
EndIf
SetGadgetColor(*sidebar\MenuItems()\ID,#PB_Gadget_FrontColor,*sidebar\MenuItems()\frontcolor)
SetGadgetColor(*sidebar\MenuItems()\ID,#PB_Gadget_BackColor,*sidebar\MenuItems()\BackColor)
SetGadgetFont(*sidebar\MenuItems()\ID,FontID(*sidebar\MenuItems()\font))
SetGadgetData(*sidebar\MenuItems()\ID,*sidebar\MenuItems())
BindEvent(#PB_Event_Gadget,@SideBar_EventMenu(),*sidebar\PID,*sidebar\MenuItems()\ID)
EndIf
Else
w = GadgetWidth(*sidebar\MenuItems()\id) * 1.5
If w >= *sidebar\maxwidth
*sidebar\maxwidth = w
EndIf
SetGadgetText(*sidebar\MenuItems()\ID,*sidebar\MenuItems()\lable)
EndIf
Next
If Not IsGadget(*sidebar\ShowHideGad)
timg = CreateImage(#PB_Any,1,1)
StartDrawing(ImageOutput(timg))
DrawingFont(FontID(*sidebar\fonts\font[1]))
If *sidebar\ShowArrow = ""
*sidebar\ShowArrow = strchr($25B6)
EndIf
If *sidebar\HideArrow = ""
*sidebar\HideArrow = strchr($25C0)
EndIf
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
w = TextWidth(*sidebar\ShowArrow) * 1.5
h = TextHeight(*sidebar\ShowArrow) * 1.5
CompilerElse
w = TextWidth(*sidebar\ShowArrow)
h = TextHeight(*sidebar\ShowArrow)
CompilerEndIf
StopDrawing()
FreeImage(timg)
If bfirst
*sidebar\titlesize = h
bfirst = 0
EndIf
OpenGadgetList(*sidebar\gadgetID)
*sidebar\ShowHideGad = HyperLinkGadget(-1,*sidebar\maxwidth-w-5,0,w,h,*sidebar\HideArrow,*sidebar\ActiveColor)
CloseGadgetList()
SetGadgetColor(*sidebar\ShowHideGad,#PB_Gadget_FrontColor,*sidebar\FrontColor)
SetGadgetColor(*sidebar\ShowHideGad,#PB_Gadget_BackColor,*sidebar\BackColor)
SetGadgetFont(*sidebar\ShowHideGad,FontID(*sidebar\fonts\font[1]))
SetGadgetData(*sidebar\ShowHideGad,*sidebar)
GadgetToolTip(*sidebar\ShowHideGad, "Close Sidebar")
BindGadgetEvent(*sidebar\ShowHideGad,@Sidebar_StartSlide(),#PB_EventType_LeftClick)
Else
*sidebar\minLeft = -(*sidebar\maxwidth-GadgetWidth(*sidebar\ShowHideGad)-10)
ResizeGadget(*sidebar\ShowHideGad,*sidebar\maxwidth-GadgetWidth(*sidebar\ShowHideGad)-5,0,GadgetWidth(*sidebar\ShowHideGad),GadgetHeight(*sidebar\ShowHideGad))
EndIf
Protected sh
sh = *sidebar\WinhasStatus
ResizeGadget(*sidebar\gadgetID,*sidebar\left,0,*sidebar\maxwidth,WindowHeight(*sidebar\PID)-sh)
If *sidebar\SideMessage <> ""
If StartDrawing(CanvasOutput(*sidebar\gadgetID))
DrawingFont(FontID(*sidebar\fonts\font[0]))
w = TextWidth(*sidebar\SideMessage)
h = TextHeight(*sidebar\SideMessage)
cy = ((WindowHeight(*sidebar\PID)-sh) - DesktopUnscaledX(w)) * 0.5
If IsGadget(*sidebar\ShowHideGad)
y = GadgetY(*sidebar\ShowHideGad) + GadgetHeight(*sidebar\ShowHideGad)
EndIf
DrawingFont(FontID(*sidebar\fonts\font[0]))
x = DesktopScaledX(*sidebar\maxwidth-h)
y = DesktopScaledY(y)
h = DesktopScaledY(h)
w = DesktopScaledX(GadgetHeight(*sidebar\gadgetID))-y
Box(x-5,y,h+5,w,*sidebar\BackColor)
x = DesktopScaledX(*sidebar\maxwidth)
y = DesktopScaledY(cy)
DrawRotatedText(x,y,*sidebar\SideMessage,-90,*sidebar\SideMessageColor)
StopDrawing()
EndIf
EndIf
EndIf
EndIf
;Restore updates
LockWindowUpdate_(0)
UpdateWindow_(ew)
Delay(1)
EndProcedure