Searching for a past thread on UI design

Everything else that doesn't fall into one of the other PB categories.
PBJim
Enthusiast
Enthusiast
Posts: 296
Joined: Fri Jan 19, 2024 11:56 pm

Searching for a past thread on UI design

Post by PBJim »

There was a thread during the earlier part of 2023, or possibly end of 2022, in which a PureBasic developer had designed a new UI as an include. Out of interest, I've been searching but can't find it.

The detail I recall is that the developer had spent a lot of time on it and indicated the code was a mess and probably buggy, but nevertheless it looked good. He or she wasn't giving the work away, but invited forum members to try it, with the intention of charging for it. We didn't hear any further on the subject. The style of the UI was a solid blue rectangle on the left side of the window, with the space for text boxes on the right. I'm interested in the subject of UIs and the direction in which the discussion progressed, if at all, not the actual code offering

Anyone remember?
User avatar
idle
Always Here
Always Here
Posts: 6020
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Searching for a past thread on UI design

Post by idle »

PBJim wrote: Fri Mar 01, 2024 11:18 pm There was a thread during the earlier part of 2023, or possibly end of 2022, in which a PureBasic developer had designed a new UI as an include. Out of interest, I've been searching but can't find it.

The detail I recall is that the developer had spent a lot of time on it and indicated the code was a mess and probably buggy, but nevertheless it looked good. He or she wasn't giving the work away, but invited forum members to try it, with the intention of charging for it. We didn't hear any further on the subject. The style of the UI was a solid blue rectangle on the left side of the window, with the space for text boxes on the right. I'm interested in the subject of UIs and the direction in which the discussion progressed, if at all, not the actual code offering

Anyone remember?
This might be similar should work windows 10/11 and osx with a few tweaks

Code: Select all

;SideBarGadget v1.0.1.7a  PB 5.73 -PB 6.02
;Sliding SideBar Menu 
;Author Idle, slide in and out adapted from falsam (what me worry)  
;licence MIT 
;Windows DPI aware 

DeclareModule SideBarGadget 
  
  Enumeration 
    #Sidebar_Small
    #Sidebar_medium
    #Sidebar_large 
  EndEnumeration 
  
  Prototype pCBSlide()
  
  Declare SideBarGadget(GadgetNumber,window,w,h,FrontColor,BackColor,ActiveColor,inActiveColor,bhover.i=#True,font.s="Tahoma",small=11,medium=20,large=36,statusbar=0) 
  Declare AddMenuItem(Gadget,image.i,lable.s,menuid.l=0,tooltip.s="",fontsize=#Sidebar_Small,ActiveColor=0,FrontColor=0,BackColor=0,InActiveColor=0) 
  Declare CreateMenuEmoji(item,emoji.s)
  Declare SetMenuItemImageState(item,state)  
  Declare SetMessage(Gadget,msg.s,color=0) 
  Declare.s StrChr(v.i) 
  Declare ForceGadgetZOrder(gadget, zorder = 0) 
  Declare SidebarGetMinWidth(gadget) 
  Declare SetSlideCallback(gadget,*pfn.pCBSlide)
  
EndDeclareModule 

Module SideBarGadget  
  
  EnableExplicit   
   
  #SideBar_Menuclose = -1
  #sideBar_menuOpened  = 0 
  #SideBar_MenuOpen = 1
    
  Structure sidebar_fonts
    font.i[3] 
    color.i
  EndStructure   
  
  Structure SideBar_ID 
    GadgetID.i
    ParentID.i
    Type.i         
    menuid.i
  EndStructure  
  
  Structure SideBar_Menuitems_image 
    GadgetId.i
    imageOn.i
    imgageHover.i
    ImageOff.i 
    state.i 
    w.i 
    h.i 
  EndStructure   
    
  Structure SideBar_Menuitems Extends SideBar_ID
    Lable.s 
    Tooltip.s 
    Font.i
    FrontColor.i
    BackColor.i 
    ActiveColor.i
    inActiveColor.i 
    image.SideBar_Menuitems_image 
  EndStructure   
  
  Structure SideBar_Gadget  Extends SideBar_ID
    width.i
    maxwidth.i
    height.i
    minHeight.i
    minWidth.i
    left.i
    MinLeft.i
    BackColor.i
    FrontColor.i
    ActiveColor.i 
    InActiveColor.i
    MenuState.i
    ShowArrow.s
    HideArrow.s 
    PinArrow.s
    showhidegad.i
    bHover.i 
    hovertime.i
    dwell.i 
    titlesize.i 
    bclick.i
    moving.i
    WindowStatusBar .i        ;window status bar number if any 
    SideMessageColor.i
    SideMessage.s
    *cbSlide.pCBSlide
    Fonts.sidebar_fonts
    List MenuItems.SideBar_Menuitems() 
  EndStructure  
  
  Declare Sidebar_StartSlide()
  Declare SideBar_EventMenu() 
  Declare SideBar_Event()  
  
  Global NewList SideBarGadgets()
  
  Procedure.s StrChr(v.i) 
    Protected high, low
    If v < $10000
      ProcedureReturn Chr(v)
    Else
      v - $10000
      high = (v >> 10) + $D800  
      low = (v & 1023) + $DC00  
      ProcedureReturn Chr(high) + Chr(low)
    EndIf
  EndProcedure
  
  Global sfx.d,sfy.d 
  
  sfx = DesktopResolutionX() 
  sfy = DesktopResolutionY() 
  
  Macro _GadgetWidth(gad) 
    (GadgetWidth(gad)*sfx) 
  EndMacro   
  
  Macro _GadgetHeight(gad) 
    (GadgetHeight(gad)*sfy) 
  EndMacro   
  
  CompilerIf #PB_Compiler_OS <> #PB_OS_Windows 
    Macro LockWindowUpdate_(ew) : EndMacro() 
    Macro UpdateWindow_(ew) : EndMacro()   
  CompilerEndIf  
  
  Procedure SideBar_Draw()   
    Protected timg,w,h,x,y,cy,ph =10
    Protected gadget,*sidebar.SideBar_Gadget=0
    Protected menuid,bfirst=1  
    Protected wid = WindowID(EventWindow())
    
    LockWindowUpdate_(wid)    
    
    gadget = EventGadget() 
    
    If IsGadget(gadget) 
      *sidebar = GetGadgetData(gadget)
      If *sidebar <> 0  
        ForEach *sidebar\MenuItems() 
          If (IsGadget(*sidebar\MenuItems()\ParentID) And GadgetWidth(*sidebar\MenuItems()\ParentID) = 0)  
            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)
            
            If IsImage(*sidebar\MenuItems()\image\imageOn) 
              ResizeGadget(*sidebar\MenuItems()\image\GadgetId,10,ph,ImageWidth(*sidebar\MenuItems()\image\imageOn),ImageHeight(*sidebar\MenuItems()\image\imageOn)) 
              ResizeGadget(*sidebar\MenuItems()\ParentID,ImageWidth(*sidebar\MenuItems()\image\imageOn)*2,ph,w,h) 
              w+ImageWidth(*sidebar\MenuItems()\image\imageOn)*2    
            Else 
              ResizeGadget(*sidebar\MenuItems()\ParentID,10,ph,w,h) 
            EndIf 
            
             If *sidebar\MenuItems()\tooltip <> "" 
                GadgetToolTip(*sidebar\MenuItems()\ParentID, *sidebar\MenuItems()\tooltip) 
              EndIf   
              ph+h*1.5
              If w >= *sidebar\maxwidth 
                *sidebar\maxwidth = w 
              EndIf   
              SetGadgetColor(*sidebar\MenuItems()\ParentID,#PB_Gadget_FrontColor,*sidebar\MenuItems()\frontcolor)   
              SetGadgetColor(*sidebar\MenuItems()\ParentID,#PB_Gadget_BackColor,*sidebar\MenuItems()\BackColor)   
              SetGadgetFont(*sidebar\MenuItems()\ParentID,FontID(*sidebar\MenuItems()\font))
              SetGadgetData(*sidebar\MenuItems()\ParentID,*sidebar\MenuItems()) 
              BindEvent(#PB_Event_Gadget,@SideBar_EventMenu(),*sidebar\ParentId,*sidebar\MenuItems()\ParentID)  
             
          Else 
              w =  GadgetWidth(*sidebar\MenuItems()\ParentID) * 1.5
              If w >= *sidebar\maxwidth 
                *sidebar\maxwidth = w 
              EndIf  
              If IsImage(*sidebar\MenuItems()\image\imageOn) 
                If *sidebar\MenuItems()\image\state = 1
                  SetGadgetState(*sidebar\MenuItems()\image\GadgetId,ImageID(*sidebar\MenuItems()\image\imageOn))
                Else   
                  SetGadgetState(*sidebar\MenuItems()\image\GadgetId,ImageID(*sidebar\MenuItems()\image\ImageOff)) 
                EndIf
              EndIf   
              SetGadgetText(*sidebar\MenuItems()\ParentID,*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 
          If *sidebar\PinArrow = "" 
             *sidebar\pinArrow = strchr($23F8)  
          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\showArrow,*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\minWidth = _GadgetWidth(gadget)+(*sidebar\left*sfx)+5
          *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\WindowStatusBar 
        
        ResizeGadget(*sidebar\gadgetID,*sidebar\left,0,*sidebar\maxwidth,WindowHeight(*sidebar\ParentId)-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\ParentId)-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 
             
    LockWindowUpdate_(0)
    UpdateWindow_(wid)
    
  EndProcedure  
  
  Procedure SideBar_EventMenu() 
    Protected gadget,*menu.SideBar_Menuitems 
    gadget = EventGadget()     
    If IsGadget(gadget) 
      *menu = GetGadgetData(gadget)
      PostEvent(#PB_Event_Menu,EventWindow(),*menu\MenuID,#PB_All,*menu\ParentID)  
      PostEvent(#PB_Event_LeftClick,EventWindow(),*menu\ParentID) 
    EndIf 
  EndProcedure 
  
  Procedure SideBar_Event() 
    
    Protected window,Gadget,*sidebar.SideBar_Gadget
    Protected mx,my,sx.f 
    
    If EventType() = #PB_EventType_MouseEnter Or EventType() = #PB_EventType_MouseLeave Or EventType() = #PB_EventType_LeftClick
      
      gadget = EventGadget()
      If IsGadget(gadget)  
        *sidebar = GetGadgetData(Gadget)
        If *sidebar 
          If *sidebar\gadgetID = gadget 
            If *sidebar\bHover 
              mx = WindowMouseX(*sidebar\ParentId)
              my = WindowMouseY(*sidebar\ParentId)  
              If EventType() = #PB_EventType_MouseEnter  
                If (mx > ((*sidebar\left*sfx)+_GadgetWidth(gadget)-30*sfx) And my > (*sidebar\titleSize*sfy))                   
                  If ElapsedMilliseconds() > *sidebar\hovertime 
                    *sidebar\MenuState = 1   
                    If IsGadget(*sidebar\ShowHideGad)
                      SetGadgetText(*sidebar\ShowHideGad,*sidebar\HideArrow)
                      GadgetToolTip(*sidebar\ShowHideGad, "Close Sidebar")
                    EndIf 
                  Else 
                    *sidebar\hovertime  = ElapsedMilliseconds() + *sidebar\dwell 
                  EndIf
                EndIf 
              ElseIf EventType() = #PB_EventType_MouseLeave 
                If (mx > ((*sidebar\left*sfx)+(_GadgetWidth(gadget)-(30*sfx))) And my > (*sidebar\titleSize*sfy)) 
                  If ElapsedMilliseconds() > *sidebar\hovertime 
                    *sidebar\MenuState = -1   
                    If IsGadget(*sidebar\ShowHideGad)
                      SetGadgetText(*sidebar\ShowHideGad,*sidebar\ShowArrow) 
                      GadgetToolTip(*sidebar\ShowHideGad, "Open Sidebar")
                    EndIf 
                  Else 
                    *sidebar\hovertime  = ElapsedMilliseconds() + *sidebar\dwell 
                  EndIf   
                EndIf 
              EndIf 
            EndIf
          EndIf 
        EndIf 
      EndIf   
      
      ForEach SideBarGadgets() 
        *sidebar.SideBar_Gadget = SideBarGadgets()  
        gadget = *sidebar\gadgetID  
        window = EventWindow() 
        If (IsGadget(gadget) And IsWindow(window))
          If WindowWidth(window) < GadgetWidth(gadget)-60 
            Debug "Post Gadget"
            PostEvent(#PB_Event_Gadget,EventWindow(),gadget,#PB_EventType_Resize) 
          EndIf
          If WindowHeight(window)-*sidebar\WindowStatusBar < GadgetHeight(gadget) Or WindowHeight(window)-*sidebar\WindowStatusBar > GadgetHeight(gadget)
            Debug "post Wind"
            PostEvent(#PB_Event_Gadget,EventWindow(),gadget,#PB_EventType_Resize) 
          EndIf
        EndIf 
      Next 
    EndIf 
  EndProcedure   
  
  Procedure SideBar_OpenClose()
    Protected Gadget,*sidebar.SideBar_Gadget
    Static x 
    If Not x 
      x = 1 
    EndIf   
    gadget = EventTimer()
    If IsGadget(gadget) 
      *sidebar = GetGadgetData(gadget)
      If *sidebar\MenuState 
        If (*sidebar\left >= *sidebar\minLeft And *sidebar\MenuState = #SideBar_Menuclose) 
          If *sidebar\left < (*sidebar\minLeft+10) 
            *sidebar\left  - 1 
          Else   
             *sidebar\left - 10
          EndIf    
          ;ResizeGadget(gadget, *sidebar\left , #PB_Ignore, #PB_Ignore, #PB_Ignore) 
          ResizeWindow(*sidebar\ParentId,#PB_Ignore, #PB_Ignore, #PB_Ignore,WindowHeight(*sidebar\ParentId)+x)        
        EndIf
        
        If (*sidebar\left  <= 0 And *sidebar\MenuState = #SideBar_MenuOpen)
          If *sidebar\left > -10 
            *sidebar\left  + 1 
          Else   
             *sidebar\left + 10
          EndIf    
          ;ResizeGadget(gadget,*sidebar\left, #PB_Ignore, #PB_Ignore, #PB_Ignore)  
          ResizeWindow(*sidebar\ParentId, #PB_Ignore, #PB_Ignore, #PB_Ignore,WindowHeight(*sidebar\ParentId)+x)   
        EndIf   
        x*-1   
      EndIf   
    EndIf 
  EndProcedure
  
  Procedure Sidebar_StartSlide()
    Protected gadget, *sidebar.SideBar_Gadget
    
    gadget = EventGadget() 
    If IsGadget(gadget) 
      *sidebar = GetGadgetData(gadget)
      If *sidebar 
        *sidebar\MenuState * -1   
        If  *sidebar\MenuState = 0 
          *sidebar\MenuState = -1
        EndIf   
        If *sidebar\MenuState = -1
          SetGadgetText(*sidebar\ShowHideGad,*sidebar\ShowArrow) 
          GadgetToolTip(*sidebar\ShowHideGad, "Open Sidebar")
        Else
          SetGadgetText(*sidebar\ShowHideGad,*sidebar\HideArrow)
          GadgetToolTip(*sidebar\ShowHideGad, "Close Sidebar")
        EndIf
        SetActiveGadget(*sidebar\ShowHideGad)
      EndIf 
    EndIf 
  EndProcedure   
  
  Procedure SetMessage(gadget,msg.s,color=0) 
    Protected *sidebar.SideBar_Gadget
    
    If IsGadget(Gadget) 
      *sidebar = GetGadgetData(gadget)
      If *sidebar 
        *sidebar\SideMessage = msg
        If color = 0 
          *sidebar\SideMessageColor = *sidebar\FrontColor 
        Else 
          *sidebar\SideMessageColor = color 
        EndIf   
      EndIf 
    EndIf   
  EndProcedure   
  
  Procedure AddMenuItem(Gadget,image.i,lable.s,menuid.l=0,tooltip.s="",fontsize=#Sidebar_Small,ActiveColor=0,FrontColor=0,BackColor=0,InActiveColor=0) 
    Protected *sidebar.SideBar_Gadget
    Static ct 
    If IsGadget(Gadget) 
      
      *sidebar = GetGadgetData(gadget)
      If *sidebar 
        AddElement(*sidebar\MenuItems()) 
        
        *sidebar\MenuItems()\Lable = lable 
               
        *sidebar\MenuItems()\image\imageOn = image 
        
        If fontsize < 3 
          *sidebar\MenuItems()\Font = *sidebar\Fonts\font[fontsize]   
        EndIf    
        
        If menuid 
          *sidebar\MenuItems()\menuid = menuid 
        Else 
          *sidebar\MenuItems()\menuid = ct 
          ct+1 
        EndIf   
        If FrontColor  
          *sidebar\MenuItems()\frontcolor = FrontColor  
        Else 
          *sidebar\MenuItems()\frontcolor  = *sidebar\FrontColor 
        EndIf 
        If BackColor
          *sidebar\MenuItems()\backcolor = BackColor 
        Else 
          *sidebar\MenuItems()\backcolor = *sidebar\BackColor
        EndIf   
        If ActiveColor 
          *sidebar\MenuItems()\activecolor = activecolor  
        Else 
          *sidebar\MenuItems()\activecolor = *sidebar\activecolor    
        EndIf   
        If InActiveColor 
          *sidebar\MenuItems()\inactivecolor = InActiveColor  
        Else   
          *sidebar\MenuItems()\inActiveColor = *sidebar\InActiveColor 
        EndIf 
         
        *sidebar\MenuItems()\tooltip = tooltip 
        
        OpenGadgetList(*sidebar\gadgetID) 
        
        *sidebar\MenuItems()\image\GadgetId = ImageGadget(#PB_Any,0,0,0,0,0)
                
        *sidebar\MenuItems()\ParentID = HyperLinkGadget(#PB_Any,0,0,0,0,*sidebar\MenuItems()\lable,*sidebar\MenuItems()\activecolor)
              
         SetGadgetData(*sidebar\MenuItems()\ParentID,@*sidebar\MenuItems())
                    
         CloseGadgetList() 
        
        ProcedureReturn *sidebar\MenuItems()\ParentID 
        
      EndIf 
      
    EndIf 
    
    
  EndProcedure  
  
  Procedure SetMenuItemImageState(item,state)  
    Protected *menu.SideBar_Menuitems 
    If IsGadget(item) 
      *menu = GetGadgetData(item) 
      *menu\image\state = state 
      Select *menu\image\state
        Case 0 
          If IsImage(*menu\image\ImageOff) 
            SetGadgetState(*menu\image\GadgetId,ImageID(*menu\image\ImageOff)) 
          EndIf   
        Case 1
          If IsImage(*menu\image\ImageOn) 
            SetGadgetState(*menu\image\GadgetId,ImageID(*menu\image\ImageOn)) 
          EndIf   
      EndSelect     
    EndIf   
    
  EndProcedure 
  
  Procedure CreateMenuEmoji(item,emoji.s) 
    
    Protected timg,img,w,h 
    Protected *menu.SideBar_Menuitems 
    
    If IsGadget(item) 
      *menu = GetGadgetData(item) 
      timg = CreateImage(#PB_Any,1,1)            
      If StartDrawing(ImageOutput(timg))
        DrawingFont(FontID(*menu\Font))  
        CompilerIf #PB_Compiler_OS = #PB_OS_MacOS 
          w = DesktopUnscaledX(TextWidth(emoji)) *1.5
          h = DesktopUnscaledY(TextHeight(emoji)) * 1.5 
        CompilerElse 
          w = DesktopUnscaledX(TextWidth(emoji)) 
          h = DesktopUnscaledY(TextHeight(emoji))
        CompilerEndIf   
        StopDrawing() 
        img = CreateImage(#PB_Any,w,h,32,*menu\BackColor) 
        If StartDrawing(ImageOutput(img))  
          DrawingFont(FontID(*menu\Font))  
          DrawText(0,0,emoji,*menu\ActiveColor,*menu\BackColor)  ; on 
          StopDrawing()    
        EndIf   
        *menu\image\imageOn = img 
        img = CreateImage(#PB_Any,w,h,32,*menu\BackColor) 
        If StartDrawing(ImageOutput(img))  
          DrawingFont(FontID(*menu\Font))  
          DrawText(0,0,emoji,*menu\ActiveColor,*menu\BackColor)  ; hover 
          StopDrawing()    
        EndIf   
        *menu\image\imgageHover = img       
         img = CreateImage(#PB_Any,w,h,32,*menu\BackColor) 
         If StartDrawing(ImageOutput(img))  
           DrawingFont(FontID(*menu\Font))  
           DrawText(0,0,emoji,*menu\InActiveColor,*menu\BackColor)  ; off  
           StopDrawing()    
        EndIf   
        *menu\image\ImageOff = img         
        *menu\image\state = 1 
         SetGadgetState(*menu\image\GadgetId,ImageID(*menu\image\imageOn))   
      EndIf   
      FreeImage(timg) 
    EndIf   
    
  EndProcedure   
  
  
  CompilerIf #PB_Compiler_OS = #PB_OS_Windows 
    
    Procedure ForceGadgetZOrder(gadget, zorder = 0)    
      If IsGadget(gadget)
        SetWindowLong_(GadgetID(gadget), #GWL_STYLE, GetWindowLong_(GadgetID(gadget), #GWL_STYLE) | #WS_CLIPSIBLINGS)
        If zorder = 1
          SetWindowPos_ (GadgetID (gadget), #HWND_BOTTOM, 0,0,0,0, #SWP_NOSIZE | #SWP_NOMOVE)
        Else
          SetWindowPos_ (GadgetID(gadget), #HWND_TOP, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE)
        EndIf
      EndIf
    EndProcedure
    
  CompilerElse 
    
    Procedure ForceGadgetZOrder(gadget, zorder = 0) 
      ProcedureReturn 1 
    EndProcedure 
    
  CompilerEndIf 
  
  Procedure SidebarGetMinWidth(gadget)  
    Protected *sidebar.SideBar_Gadget
    If IsGadget(gadget) 
      *sidebar = GetGadgetData(gadget) 
      If *sidebar 
        ProcedureReturn *sidebar\minWidth
      EndIf 
    EndIf 
  EndProcedure
  
  Procedure SetSlideCallback(gadget,*pfn.pCBSlide) 
    Protected *sidebar.SideBar_Gadget
    If IsGadget(gadget) 
      *sidebar = GetGadgetData(gadget) 
      If *sidebar
        *sidebar\cbSlide = *pfn 
      EndIf
    EndIf   
  EndProcedure   
    
  Procedure SideBarGadget(GadgetNumber,window,w,h,FrontColor,BackColor,ActiveColor,inActiveColor,bhover.i=#True,font.s="Tahoma",small=11,medium=20,large=36,statusbar=0) 
    Protected *sidebar.SideBar_Gadget = AllocateStructure(SideBar_Gadget) 
    Protected res
            
    AddElement(SideBarGadgets()) 
    SideBarGadgets() = *sidebar
    
    If statusbar
      *sidebar\WindowStatusBar = StatusBarHeight(statusbar)  
    EndIf  
    
    res = CanvasGadget(GadgetNumber,0,0,w,h-*sidebar\WindowStatusBar,#PB_Canvas_Container)    
    
    CloseGadgetList() 
    
    If GadgetNumber = #PB_Any 
      *sidebar\gadgetID = res 
    Else 
      *sidebar\gadgetID = GadgetNumber
    EndIf 
    *sidebar\bHover = bhover 
    *sidebar\MenuState = #SideBar_Menuclose
    *sidebar\BackColor = BackColor
    *sidebar\FrontColor = FrontColor 
    *sidebar\ActiveColor = ActiveColor 
    *sidebar\InActiveColor = InActiveColor 
    *sidebar\ParentId = window 
    *sidebar\dwell = 0  ;hover time to use  
    *sidebar\fonts\font[0] = LoadFont(#PB_Any,font,small) 
    *sidebar\fonts\font[1] = LoadFont(#PB_Any,font,medium)
    *sidebar\fonts\font[2] = LoadFont(#PB_Any,font,large)
    
    SetGadgetData(*sidebar\gadgetID,*sidebar)
    SetGadgetColor(*sidebar\gadgetID, #PB_Gadget_BackColor,BackColor) 
    SetGadgetColor(*sidebar\gadgetID, #PB_Gadget_FrontColor,FrontColor)
    
    AddWindowTimer(window,*sidebar\gadgetID,2)
    BindEvent(#PB_Event_Timer,@SideBar_OpenClose())
    
    BindGadgetEvent(*sidebar\gadgetID,@SideBar_Draw(),#PB_EventType_Resize)
    
    BindGadgetEvent(*sidebar\gadgetID,@SideBar_Event())
    
    BindEvent(#PB_Event_SizeWindow,@SideBar_Event())  
    
    PostEvent(#PB_Event_Gadget,window,*sidebar\gadgetID,#PB_EventType_Resize) 
    
    ProcedureReturn *sidebar\gadgetID 
    
  EndProcedure 
  
  DisableExplicit 
  
EndModule 

CompilerIf #PB_Compiler_IsMainFile  
  
  UseModule SideBarGadget 
  
  #BlockListGadget = 301
  #AllowListGadget = 302
  #DataGadget =303
  #MainStatusBar = 304
  #SplitHoritontal = 305 
  #SplitVertical = 306 
  Global gwin,sb
  
  Procedure Resize() 
    Protected cw,bh,hh,pad 
    pad = 5
    
    gwx = WindowX(gwin) 
    gwy = WindowY(gwin)
    gww = WindowWidth(gwin)
    gwh = WindowHeight(gwin) 
    
    cw=gww/2 - pad 
    bh=gwh/2 
    hh = StatusBarHeight(#MainStatusBar) + (pad*2)
       
    gwx = SidebarGetMinWidth(sb)  
    If gwx = 0 
      gwx=30*DesktopResolutionX()
    EndIf   
    
    ResizeGadget(#SplitHoritontal,gwx,5,gwW-(gwx+5),gwh-hh) 
    
    SetGadgetItemAttribute(#DataGadget,0,#PB_Explorer_ColumnWidth,gww/4-2,0) 
    SetGadgetItemAttribute(#DataGadget,1,#PB_Explorer_ColumnWidth,gww/4-2,1) 
    SetGadgetItemAttribute(#DataGadget,2,#PB_Explorer_ColumnWidth,gww/4-2,2) 
    SetGadgetItemAttribute(#DataGadget,3,#PB_Explorer_ColumnWidth,gww/4-2,3) 
    SetGadgetItemAttribute(#DataGadget,4,#PB_Explorer_ColumnWidth,gww/4-6,4)
       
    
  EndProcedure  
  
  Global dnsstate=1,bloomstate=1  
  
  #DNSMENU = 1101 
  #BLOOMMENU = 1102 
  Global dnsgad,bloomgad  
  
  Procedure DNS_Onclick()  
    dnsstate ! 1 
    If IsGadget(dnsgad) 
       SetMenuItemImageState(dnsgad,dnsstate)  
    EndIf 
  EndProcedure   
  
  Procedure Bloom_OnClick() 
    bloomstate ! 1 
    If IsGadget(bloomgad) 
       SetMenuItemImageState(bloomgad,bloomstate)  
    EndIf  
  EndProcedure   
    
    
  Global sb,event
  Global msg.s = "SideBarGadget v1.0.1.7a test"
  
  gwin = OpenWindow(-1,0,0,640,480,msg, #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget) 
  
  SetWindowColor(gwin,$FCFCFC) 
  
  CreateStatusBar(#MainStatusBar, WindowID(gwin))
  AddStatusBarField(#PB_Ignore)
  AddStatusBarField(#PB_Ignore)
  AddStatusBarField(#PB_Ignore)
  AddStatusBarField(#PB_Ignore) 
    
  w = WindowWidth(gwin) - 50
  h = WindowHeight(gwin)
  ListViewGadget(#BlockListGadget,5,5,w/2-5,h/2-10)
  ListViewGadget(#AllowListGadget,w/2+5,5,w/2-10,h/2-10)
  SetGadgetColor(#AllowListGadget, #PB_Gadget_FrontColor ,RGB(0,192,0))
  SetGadgetColor(#BlockListGadget,#PB_Gadget_FrontColor ,RGB(192,0,0))
  EnableGadgetDrop(#AllowListGadget,#PB_Drop_Text, #PB_Drag_Copy)
  EnableGadgetDrop(#BlockListGadget,#PB_Drop_Text, #PB_Drag_Copy)
  ListIconGadget(#DataGadget,5,h/2,w,h/2,"URL",w/2-8,#PB_ListIcon_FullRowSelect | #PB_ListIcon_CheckBoxes) 
    
  AddGadgetColumn(#DataGadget,1,"IP address",w/4) 
  AddGadgetColumn(#DataGadget,2,"Time",w/4) 
  AddGadgetColumn(#DataGadget,3,"Renew",w/4)
  
  ForceGadgetZOrder(#BlockListGadget,1)
  ForceGadgetZOrder(#AllowListGadget,1) 
  ForceGadgetZOrder(#DataGadget,1)
  
  StatusBarText(#MainStatusBar,0, "DNS 127.0.0.1 / 1.1.1.1")
  StatusBarText(#MainStatusBar,1, "Blocked 19710 Total 33246")
  StatusBarText(#MainStatusBar,2, "Allowed items 3127")
  StatusBarText(#MainStatusBar,3, "Denied items 641")
  
  SplitterGadget(#SplitVertical,0,0,w-50,h/2,#BlockListGadget,#AllowListGadget,#PB_Splitter_Vertical)
  SplitterGadget(#SplitHoritontal,0,0,w-50,h-60,#SplitVertical,#DataGadget)
  
  ForceGadgetZOrder(#SplitVertical,1)
  ForceGadgetZOrder(#SplitHoritontal,1) 
  
  AddGadgetItem(#AllowListGadget,-1,"fr.purebasic.www") 
  AddGadgetItem(#AllowListGadget,-1,"com.bing.www")
  AddGadgetItem(#BlockListGadget,-1,"com.windowsupdate.ctldl")
  AddGadgetItem(#BlockListGadget,-1,"com.live.login")
  AddGadgetItem(#BlockListGadget,-1,"com.microsoft.edge")
  AddGadgetItem(#BlockListGadget,-1,"com.skype.edge.config")
  
  ;-sidebargadget 
  
  sb = SideBarGadget(#PB_Any,gwin,200,600,$FCFCFC,$5C1200,$DA00,$DA,#True,"Segoe UI",11,24,36,#MainStatusBar)  
  AddMenuItem(sb,0,"  " + strchr($1F30E),1100,"DNScope",#Sidebar_large)  
       
  dnsgad = AddMenuItem(sb,0,"DNS",#DNSMENU,"Firewall On Off",#Sidebar_small)   
  CreateMenuEmoji(dnsgad,strChr($1F525)) 
  BindGadgetEvent(dnsgad,@DNS_Onclick(),#PB_EventType_LeftClick) 
  
  bloomgad = AddMenuItem(sb,0,"Bloom",#BLOOMMENU,"Filter On Off",#Sidebar_small) 
  CreateMenuEmoji(bloomgad,strchr($267E)) 
  BindGadgetEvent(bloomgad,@Bloom_Onclick(),#PB_EventType_LeftClick) 
  
  
  AddMenuItem(sb,0,strchr($26CF) + "   Status",1103,"Block ON Off") 
  AddMenuItem(sb,0,strChr($2699) + "   Settings",1104)       
  AddMenuItem(sb,0,strchr($2712) + "   Contact",1105)  
  AddMenuItem(sb,0,strchr($1F30e) + "   Donate",1106) 
  AddMenuItem(sb,0,strchr($2753) + "   Help",1107) 
  
  SetMessage(sb,msg,RGB(0,255,0)) 
  ;SetSlideCallback(sb,@Resize())
    
  ForceGadgetZOrder(sb)
    
  Resize()
 
  BindEvent(#PB_Event_SizeWindow, @Resize(),gwin)
  
   
  Repeat 
    Event = WaitWindowEvent()
    Select Event
      Case #PB_Event_Menu 
        
        Debug EventMenu() 
           
      Case #PB_Event_Gadget 
        Select EventType()
            Case #PB_EventType_DragStart
               Text$ = GetGadgetItemText(EventGadget(), GetGadgetState(EventGadget()))
               If text$ <> ""
                  DragText(Text$) 
                  RemoveGadgetItem(EventGadget(),GetGadgetState(EventGadget()))
               EndIf     
           Case #PB_EventType_LeftClick 
              ;Debug "click" 
              ;Debug GetGadgetText(EventGadget())
         EndSelect 
      Case #PB_Event_GadgetDrop         
         AddGadgetItem(EventGadget(), -1, EventDropText()) 
    EndSelect 
  Until Event = #PB_Event_CloseWindow 
  
CompilerEndIf 

PBJim
Enthusiast
Enthusiast
Posts: 296
Joined: Fri Jan 19, 2024 11:56 pm

Re: Searching for a past thread on UI design

Post by PBJim »

idle wrote: Fri Mar 01, 2024 11:30 pm This might be similar should work windows 10/11 and osx with a few tweaks
Yes, it's similar. I've located the post I was looking for, but the design looks less impressive to me, having now seen it again. It's a subject that I find is being raised by users and claimed to be a reason to move to another system.
Post Reply