SideBarGadget
Re: SideBarGadget
Updated fixed some bugs, blocking event or other gadgets open/close gadget list.
see code 1st post
see code 1st post
Re: SideBarGadget
First post doesn't say "Edited" ? Also, from MSDN: "It is only necessary to call DestroyIcon for icons created with the CreateIconIndirect function."
Last edited by BarryG on Fri May 26, 2023 3:37 am, edited 1 time in total.
Re: SideBarGadget
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?
Re: SideBarGadget
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 message
Re: SideBarGadget
Ok I've almost got it working on osx
In the SideBar_Draw() ive added a compiler ifs for OSX lines 103 and 151
code 1st post.
drag and drop doesn't seem to work osx?

In the SideBar_Draw() ive added a compiler ifs for OSX lines 103 and 151
code 1st post.
drag and drop doesn't seem to work osx?

Re: SideBarGadget
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
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: SideBarGadget
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.
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.
Re: SideBarGadget
Yes hover and click will be easy to add.
I need to figure out the oddities on osx it was hard to click the arrow.
I have no idea how to do the zorder yet, hopefully there's an easy enough api
Re: SideBarGadget
I found a work around but wasn't sure if it was a bug or not.
Thanks for confirming.
Re: SideBarGadget
Added Auto show hide activated by mouse enter leave and timed dwell, I still need to test how it works dpi scaled and on osx
the target area is a rect 25px wide by sidebar height-arrow size
next will be footer text and a background image.
I'm also thinking about adding pages with tabs on the side, It requires a bit more thought on implementation and I also have to work out how to make the rotated text work with a screen reader, replace with image gadgets perhaps.
I want to avoid API's if possible.
latest version 1.0.1.4a
changed font to Tahoma
There may still be a bug on osx or maybe it needs thread safe enabled, I got an IMA in SideBar_Event() while repeatedly activating the slide.
Also I've fixed bug when you resize the window width smaller than the gadget width, next update
and I'm adding adjustment to handle windows status bar
need to fix hover for dpi scaling
Re: SideBarGadget
I think auto-hide would be better with a timer starting at mouse leave (or something like that), because now the auto-hide doesn't work if you move the mouse out fast
At least on Windows, It flicker very much when window is scaled on the height dimension.
If you lock the window update on the SideBar_Draw() procedure, you can get rid of almost all the flicker:
At least on Windows, It flicker very much when window is scaled on the height dimension.
If you lock the window update on the SideBar_Draw() procedure, you can get rid of almost all the flicker:
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
Re: SideBarGadget
Yes that should be ok thanks.
The problem I was trying to address with the slide is that the mouse enter and leave events fire within the gadget if you touch the hyperlinks. The dpi scaling is still confusing
There's still a bug in the draw on osx, I will pay more attention to that when I plan to use it.
At least zorder isn't a problem on OSX, one thing less to worry about
The problem I was trying to address with the slide is that the mouse enter and leave events fire within the gadget if you touch the hyperlinks. The dpi scaling is still confusing
There's still a bug in the draw on osx, I will pay more attention to that when I plan to use it.
At least zorder isn't a problem on OSX, one thing less to worry about

Re: SideBarGadget
Very useful, had to grab it.
Nice work!
It seems the Mac Version looks so much better. I haven't fully tested it or gone through the code, but I suppose it could be a help for a Raspberry app or so, or when working with touchscreens maybe (?)
If you want to make it "perfect" you could also include:
- Real images / icons per item (optionally of course)
- LTR+RTL text direction (not for me personally, but you can never know)
- additional anchoring points/slides for the gadgets if not already implemented (right, top, bottom)
This could make a very interactive/responsive GUI with the more important "action" taking place in the middle, and the images/icons would make it look the same on all machines and add more possibilities. Well I hope this won't make too much work but I guess it does.
Nice work!
It seems the Mac Version looks so much better. I haven't fully tested it or gone through the code, but I suppose it could be a help for a Raspberry app or so, or when working with touchscreens maybe (?)
If you want to make it "perfect" you could also include:
- Real images / icons per item (optionally of course)
- LTR+RTL text direction (not for me personally, but you can never know)
- additional anchoring points/slides for the gadgets if not already implemented (right, top, bottom)
This could make a very interactive/responsive GUI with the more important "action" taking place in the middle, and the images/icons would make it look the same on all machines and add more possibilities. Well I hope this won't make too much work but I guess it does.

Re: SideBarGadget
@benube
Thanks and yes there's still a lot to do, I'm still at the stage of playing with it to see how it can be used.
Slide in/out, pin open closed. I will also add a layout grid eventually so you can also add other gadgets.
Thanks and yes there's still a lot to do, I'm still at the stage of playing with it to see how it can be used.
Slide in/out, pin open closed. I will also add a layout grid eventually so you can also add other gadgets.