ProGUI V3 Alpha Sneak Peek!

Developed or developing a new product in PureBasic? Tell the world about it.
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by PrincieD »

yoxola wrote: Mon Apr 29, 2024 11:25 am Hi, PrincieD

I've purchased a license a long time ago (2010/10/24 from my archive, my old mail is y**l*.com.tw), but my mail address is long gone, how do I caontact you(still have theoriginal purchase mail), the last mail I recieve is around v2.01/1.41.

How do I contact you for further information, my user name is "Tsai **** Tzung", thanks!
I've sent you a privmessage yoxola.

Chris.
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by PrincieD »

ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
Zach
Addict
Addict
Posts: 1675
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by Zach »

Liking these progress updates, can't wait for the test release 8)
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by PrincieD »

Zach wrote: Sat May 04, 2024 4:00 am Liking these progress updates, can't wait for the test release 8)
Hehe me too mate! I'm keen to see what the rendering performance will be like on decent hardware. I've been developing on my 2014 Alienware laptop and the dedicated Nvidia 880m GPU gave up the ghost the beginning of last year, so all the dev work has been based on the Intel integrated chipset. I kind of think that's a good thing though as you're forced to optimise stuff properly!

Another quick update: I've replaced the LoadImg code with WIC now (https://learn.microsoft.com/en-us/windo ... c/-wic-api), I was previously using PB's LoadImage with a custom filter for premultiplying the alpha that was becoming too slow for multi-resolution Imgs (and PNGs were only supported previously). Also gearing-up the Img API for 'frames' - APNG, GIF

Chris.
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by PrincieD »

Today I've been faced with another classic example of Microsoft's API where you can load in an ICO using WIC and enumerate all the frames (the different sizes) however the GUID for the pixel format is always the same which is "GUID_WICPixelFormat32bppBGRA" regardless of the ICO's header and individual bitdepth and alpha channels (that are actually encoded) - so you have a choclate fire guard scenario where the loaded frames are useless because you can't differentiate between the bitdepths, so an icon has 1, 2, 4, 8, 24, 32 bit versions and sizes - nope lol all GUID_WICPixelFormat32bppBGRA, so I want 32bit with an alpha channel if it exists (nope) - rant mode over lol
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by PrincieD »

So unless you know what each index of the frame is beforehand (whether 8 bit palette indexed or 32bit with alpha channel) you have no clue and to top it all there is no correlation with the frames returned by WIP and parsing the ICO header structure - WTF! lol - rant over
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by PrincieD »

Hi guys, multi-resoluton '.ico' files are now working correctly - the algorithm will only load in the highest bit-depth versions it can find (usually 32bit with alpha) and ignore the rest. Per-monitor DPI is also now working correctly for the WebView2 widget thanks to the new DrawDPI() command which allows you to alter/set (on the fly) the DPI of the current draw output. So the draw event handler for the WebView2 widget was basically a DrawImg() command with an internal Img buffer - previously that was getting scaled automatically based on the output DPI now there is a DrawDPI(#Null) command just before it.

https://www.youtube.com/watch?v=inssV902zdM

Chris.
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
User avatar
❤x1
User
User
Posts: 49
Joined: Thu Jan 10, 2019 5:56 pm

Re: ProGUI V3 Alpha Sneak Peek!

Post by ❤x1 »

Hey, ProGUI 3 looks remarkable; do you have an estimated time of arrival? Will it be sold as sources or binaries?
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by PrincieD »

❤x1 wrote: Tue May 21, 2024 7:49 pm Hey, ProGUI 3 looks remarkable; do you have an estimated time of arrival? Will it be sold as sources or binaries?
Thanks! :) I'm hoping to get the first alpha released the end of this month for testing. There will be the cheaper binaries only license and a license with source (it won't be up for sale until the beta though).

Chris.
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 575
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Re: ProGUI V3 Alpha Sneak Peek!

Post by bembulak »

PrincieD wrote: Tue May 21, 2024 9:43 pm
❤x1 wrote: Tue May 21, 2024 7:49 pm Hey, ProGUI 3 looks remarkable; do you have an estimated time of arrival? Will it be sold as sources or binaries?
Thanks! :) I'm hoping to get the first alpha released the end of this month for testing. There will be the cheaper binaries only license and a license with source (it won't be up for sale until the beta though).

Chris.
ProGUI is a different product than IceDesign GUI Designer, right? So, I will have to buy ProGUI seperately, if I buy IceDesign now?
So, I'm looking forward to the beta! :)
cheers,

bembulak
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by PrincieD »

bembulak wrote: Sat May 25, 2024 6:53 pm
PrincieD wrote: Tue May 21, 2024 9:43 pm
❤x1 wrote: Tue May 21, 2024 7:49 pm Hey, ProGUI 3 looks remarkable; do you have an estimated time of arrival? Will it be sold as sources or binaries?
Thanks! :) I'm hoping to get the first alpha released the end of this month for testing. There will be the cheaper binaries only license and a license with source (it won't be up for sale until the beta though).

Chris.
ProGUI is a different product than IceDesign GUI Designer, right? So, I will have to buy ProGUI seperately, if I buy IceDesign now?
So, I'm looking forward to the beta! :)
Hi bembulak, yes that's correct (I'm looking forward to the beta too! :D )
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by PrincieD »

A couple of new vids!

https://www.youtube.com/watch?v=K5IqqQWXjTM
https://www.youtube.com/shorts/-70LfEtlxTs

The first one is testing out the new animation transition functions (45 in total) and the second video is the new ScrollBar widget controlling a multi-res image. I'm currently in the process of hooking up the ScrollBar widget to the layout engines.

Chris.
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by PrincieD »

This is the animate event handler code for the test widget in the first video:

Code: Select all

Procedure TestWidgetAnimEventHandler2(*widget.Widget, EventType, *eventData.PG_EventAnimate, *sprite.Sprite)
   
    endValue = 180
    
    *sprite\x = Transition_Ease(*eventData\currentTime, 0, endValue-50, *eventData\duration)
    
    *sprite\width = Transition_EaseInOutElastic(*eventData\currentTime, 20, 50, *eventData\duration)
    *sprite\height = Transition_EaseInOutElastic(*eventData\currentTime, 20, 50, *eventData\duration)
    *sprite\y = (*eventData\height / 2) - (*sprite\height / 2)
    
    WidgetRedraw(*widget)
    
    If *eventData\state = #PG_Event_Animate_End
        StartAnimation(*widget, 0, 1000)
    EndIf
    
EndProcedure
And the draw event handler:

Code: Select all

Procedure drawTestWidgetAnim(*widget.Widget, EventType, *eventData.PG_EventData, *sprite.Sprite)
    
    DrawBox(0, 0, *eventData\width, *eventData\height, RGB(0, 200, 0), 0.5)
    
    DrawBox(*sprite\x, *sprite\y, *sprite\width, *sprite\height, RGB(200, 0, 0), 0.8)
    
EndProcedure
And the creation code for the test widget:

Code: Select all

Procedure CreateTestWidgetAnim(x, y, width, height)
    
    *widget = CreateWidget(x, y, width, height)
    
    *sprite.Sprite = AllocateStructure(Sprite)
    *sprite\width = 20
    *sprite\height = 20
    *sprite\y = (height / 2) - (*sprite\height / 2)
    
    AddEventHandler(*widget, #PG_Event_Draw, @drawTestWidgetAnim(), *sprite)
    AddEventHandler(*widget, #PG_Event_Animate, @TestWidgetAnimEventHandler2(), *sprite)
    AddEventHandler(*widget, #PG_Event_MouseLeftButtonDown, @WidgetMouseLeftButtonDownEventHandler())
    
    ;anim = StartAnimation(*widget)
 
    ProcedureReturn *widget
    
EndProcedure
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by PrincieD »

The following is the complete source (WIP) for the ScrollBar widget (a deceptively fairly complicated widget), using all of the framework API (with a few direct pointer/structure access). Hopefully should give you a good idea of how you create your own custom widgets:

Code: Select all

XIncludeFile "ProGUI_Core.pbi"
XIncludeFile "ProGUI_Widget.pbi"

;- Constants

#_ScrollBar_ThumbSize = 17 ; GetSystemMetrics_(#SM_CXHTHUMB)
#_ScrollBar_ScrollDelay = 300
#_ScrollBar_ScrollFPS = 20
#_ScrollBar_HorizontalHeight = 17 ; GetSystemMetrics_(#SM_CYHSCROLL)
#_ScrollBar_VerticalWidth = 17 ; GetSystemMetrics_(SM_CXVSCROLL)

; ScrollBar state flags
EnumerationBinary
    
    #_ScrollBar_TrackBarDrag
    #_ScrollBar_LeftTopThumbDown
    #_ScrollBar_RightBottomThumbDown
    #_ScrollBar_LeftTopPageDown
    #_ScrollBar_RightBottomPageDown
    
    #_ScrollBar_TrackBarHover
    #_ScrollBar_LeftTopThumbHover
    #_ScrollBar_RightBottomThumbHover
    
EndEnumeration

; ScrollBar animation IDs
Enumeration
    
    #_ScrollBar_AnimateScroll
    
EndEnumeration

;- Structures

Structure ScrollBarWidget
    
    min.i
    max.i
    pageSize.i
    pos.i
    lastPos.i
    
    flags.i
    
    thumbSize.i
    thumbDownScrollDelay.i
    thumbDownScrollFPS.i
    
    state.i
    dragDelta.i
    trackBarPos.d
    lastTrackBarPos.d
    mouseX.d
    mouseY.d
    
EndStructure

;- Macros

Macro CalculateTrackAreaSize(diminsionSize, thumbSize)
    
    trackAreaSize.d = diminsionSize - (thumbSize * 2)
    
EndMacro

Macro CalculateTrackBarSize(min, max, pageSize, trackAreaSize, thumbSize, trackBarSize)
    
    trackBarSize.d = (pageSize / (max - min)) * trackAreaSize
    If trackBarSize < thumbSize
        trackAreaSize - (thumbSize - trackBarSize)
        trackBarSize = thumbSize
    EndIf
    
EndMacro

Macro CalculateTrackBarPos(min, max, pos, trackAreaSize, thumbSize)
    
    trackBarPos.d = thumbSize + (((pos - min) / (max - min)) * trackAreaSize)
    
EndMacro

Macro CalculateTrackBarVisible(diminsionSize, thumbSize)
    
    trackBarVisible = #True
    If diminsionSize < thumbSize * 3
        trackBarVisible = #False
    EndIf
    
EndMacro

;-
;- *** Internal Functions ***

Procedure eventHandler_ScrollBarDraw(*widget.Widget, EventType, *event.PG_EventData, *userData)
    
    Define width.d, height.d, size.d, trackAreaSize.d, trackBarSize.d, trackBarPos.d
    Define min, max, pageSize, pos, thumbSize, trackBarVisible
    
    *scrollbar.ScrollBarWidget = *widget\userData
    
    width.d = *event\width
    height.d = *event\height
    
    min = *scrollbar\min
    max = *scrollbar\max + 1
    pageSize = *scrollbar\pageSize
    pos = *scrollbar\pos
    
    thumbSize = *scrollbar\thumbSize
    
    If *scrollbar\flags & #PG_ScrollBar_Vertical
        CalculateTrackAreaSize(height, thumbSize)
        size = height
    Else
        CalculateTrackAreaSize(width, thumbSize)
        size = width
    EndIf    
    
    CalculateTrackBarSize(min, max, pageSize, trackAreaSize, thumbSize, trackBarSize)
    
    If *scrollbar\state & #_ScrollBar_TrackBarDrag And *scrollbar\trackBarPos
        trackBarPos.d = *scrollbar\trackBarPos
    Else
        CalculateTrackBarPos(min, max, pos, trackAreaSize, thumbSize)
    EndIf
    
    CalculateTrackBarVisible(size, thumbSize)
    
    backColor = RGB(23, 23, 23)
    thumbColor = RGB(23, 23, 23)
    trackBarColor = RGB(77, 77, 77)
    
    leftTopThumbColor = thumbColor
    rightBottomThumbColor = thumbColor
    
    trackBarHoverColor = RGB(122, 122, 122)
    trackBarDownColor = RGB(166, 166, 166)
    thumbHoverColor = RGB(55, 55, 55)
    thumbDownColor = RGB(166, 166, 166)
    
    ; Set colors based on state
    
    If *scrollbar\state & #_ScrollBar_TrackBarDrag
        
        trackBarColor = trackBarDownColor
        
    ElseIf *scrollbar\state & #_ScrollBar_TrackBarHover
    
        trackBarColor = trackBarHoverColor
    
    EndIf
    
    If *scrollbar\state & #_ScrollBar_LeftTopThumbDown
        
        leftTopThumbColor = thumbDownColor
        
        If Not *scrollbar\state & #_ScrollBar_LeftTopThumbHover
            leftTopThumbColor = thumbHoverColor
        EndIf
        
    ElseIf *scrollbar\state & #_ScrollBar_LeftTopThumbHover
    
        leftTopThumbColor = thumbHoverColor
    
    EndIf
    
    If *scrollbar\state & #_ScrollBar_RightBottomThumbDown
        
        rightBottomThumbColor = thumbDownColor
        
        If Not *scrollbar\state & #_ScrollBar_RightBottomThumbHover
            rightBottomThumbColor = thumbHoverColor
        EndIf
        
    ElseIf *scrollbar\state & #_ScrollBar_RightBottomThumbHover
    
        rightBottomThumbColor = thumbHoverColor
    
    EndIf
    
    ; Draw vertical scrollbar
    If *scrollbar\flags & #PG_ScrollBar_Vertical
        
        ; draw background
        DrawBox(0, 0, width, height, backColor, 0.7)
        
        ; draw top thumb
        DrawBox(0, 0, width, thumbSize, leftTopThumbColor, 1)
        
        ; draw bottom thumb
        DrawBox(0, height - thumbSize, width, thumbSize, rightBottomThumbColor, 1)
        
        ; draw trackbar
        If trackBarVisible    
            DrawBox(0, trackBarPos, width, trackBarSize, trackBarColor, 1)
        EndIf
        
    ; Draw horizontal scrollbar
    Else
    
        ; draw background
        DrawBox(0, 0, width, height, backColor, 0.7)
        
        ; draw left thumb
        DrawBox(0, 0, thumbSize, height, leftTopThumbColor, 1)
        
        ; draw right thumb
        DrawBox(width - thumbSize, 0, thumbSize, height, rightBottomThumbColor, 1)
        
        ; draw trackbar
        If trackBarVisible    
            DrawBox(trackBarPos, 0, trackBarSize, height, trackBarColor, 1)
        EndIf
    
    EndIf
    
EndProcedure

Procedure eventHandler_ScrollBarMouse(*widget.Widget, EventType, *event.PG_EventData, *userData)
    
    Define x.d, y.d, width.d, height.d, mousePos.d, mousePos2.d, size.d, size2.d, trackAreaSize.d, trackBarSize.d, trackBarPos.d
    Define min, max, pageSize, pos, thumbSize, trackBarVisible
    
    *scrollbar.ScrollBarWidget = *widget\userData
    
    If EventType = #PG_Event_MouseLeave
        If *scrollbar\state & #_ScrollBar_TrackBarHover Or *scrollbar\state & #_ScrollBar_LeftTopThumbHover Or *scrollbar\state & #_ScrollBar_RightBottomThumbHover
            *scrollbar\state &~ #_ScrollBar_TrackBarHover &~ #_ScrollBar_LeftTopThumbHover &~ #_ScrollBar_RightBottomThumbHover
            WidgetRedraw(*widget)
        EndIf
        ProcedureReturn 0
    EndIf
    
    x.d = *event\x
    y.d = *event\y
    width.d = *widget\parentLayoutItem\width ;-*needs changing event to handle width height
    height.d = *widget\parentLayoutItem\height
    
    min = *scrollbar\min
    max = *scrollbar\max + 1
    pageSize = *scrollbar\pageSize
    pos = *scrollbar\pos
    
    thumbSize = *scrollbar\thumbSize
    
    If *scrollbar\flags & #PG_ScrollBar_Vertical
        CalculateTrackAreaSize(height, thumbSize)
        mousePos.d = y
        mousePos2.d = x
        size.d = height
        size2.d = width
    Else
        CalculateTrackAreaSize(width, thumbSize)
        mousePos.d = x
        mousePos2.d = y
        size.d = width
        size2.d = height
    EndIf    
    
    CalculateTrackBarSize(min, max, pageSize, trackAreaSize, thumbSize, trackBarSize)
    
    CalculateTrackBarPos(min, max, pos, trackAreaSize, thumbSize)
    
    trackBarPos = Round(trackBarPos, #PB_Round_Nearest)
    trackBarSize = Round(trackBarSize, #PB_Round_Nearest)
    
    CalculateTrackBarVisible(size, thumbSize)
    
    Select EventType
            
        Case #PG_Event_MouseMove
            
            *scrollbar\mouseX = x
            *scrollbar\mouseY = y
            
            ; handle trackbar drag
            If trackBarVisible And *scrollbar\state & #_ScrollBar_TrackBarDrag
                
                *scrollbar\trackBarPos = mousePos - *scrollbar\dragDelta
                
                If *scrollbar\trackBarPos <= thumbSize
                    *scrollbar\trackBarPos = thumbSize
                ElseIf *scrollbar\trackBarPos >= size - (thumbSize + trackBarSize)
                    *scrollbar\trackBarPos = size - (thumbSize + trackBarSize)
                EndIf
                
                If *scrollbar\trackBarPos <> *scrollbar\lastTrackBarPos
                
                    *scrollbar\pos = (*scrollbar\trackBarPos - thumbSize) * (max - min) / trackAreaSize + min
                    
                    If *scrollbar\pos <> *scrollbar\lastPos
                        DispatchEvent(*widget, #PG_Event_Action, *scrollbar\pos)
                    EndIf
                    
                    *scrollbar\lastPos = *scrollbar\pos
                    
                    WidgetRedraw(*widget)
                    
                EndIf
                
                *scrollbar\lastTrackBarPos = *scrollbar\trackBarPos
                
            EndIf
            
            ; handle hovering
            
            ; don't process hovering if page scrolling
            If *scrollbar\state & #_ScrollBar_LeftTopPageDown Or *scrollbar\state & #_ScrollBar_RightBottomPageDown
                ProcedureReturn 0
            EndIf
            
            ; trackBar hovering
            If Not *scrollbar\state & #_ScrollBar_LeftTopThumbDown And Not *scrollbar\state & #_ScrollBar_RightBottomThumbDown
                If trackBarVisible And mousePos >= trackBarPos And mousePos < trackBarPos + trackBarSize
                    If Not *scrollbar\state & #_ScrollBar_TrackBarHover
                        *scrollbar\state | #_ScrollBar_TrackBarHover
                        WidgetRedraw(*widget)
                    EndIf
                Else
                    If *scrollbar\state & #_ScrollBar_TrackBarHover
                        *scrollbar\state &~ #_ScrollBar_TrackBarHover
                        WidgetRedraw(*widget)
                    EndIf
                EndIf
            EndIf
            
            ; thumb button hovering
            If Not *scrollbar\state & #_ScrollBar_TrackBarDrag
            
                ; left / top thumb
                If Not *scrollbar\state & #_ScrollBar_RightBottomThumbDown
                    If mousePos >= 0 And mousePos <= thumbSize And mousePos2 >= 0 And mousePos2 <= size2
                        If Not *scrollbar\state & #_ScrollBar_LeftTopThumbHover
                            *scrollbar\state | #_ScrollBar_LeftTopThumbHover
                            WidgetRedraw(*widget)
                        EndIf
                    Else
                        If *scrollbar\state & #_ScrollBar_LeftTopThumbHover
                            *scrollbar\state &~ #_ScrollBar_LeftTopThumbHover
                            WidgetRedraw(*widget)
                        EndIf
                    EndIf
                EndIf
                
                ; right / bottom thumb
                If Not *scrollbar\state & #_ScrollBar_LeftTopThumbDown
                    If mousePos >= size - thumbSize And mousePos <= size And mousePos2 >= 0 And mousePos2 <= size2
                        If Not *scrollbar\state & #_ScrollBar_RightBottomThumbHover
                            *scrollbar\state | #_ScrollBar_RightBottomThumbHover
                            WidgetRedraw(*widget)
                        EndIf
                    Else
                        If *scrollbar\state & #_ScrollBar_RightBottomThumbHover
                            *scrollbar\state &~ #_ScrollBar_RightBottomThumbHover
                            WidgetRedraw(*widget)
                        EndIf
                    EndIf
                EndIf
                
            EndIf
            
        Case #PG_Event_MouseLeftButtonDown, #PG_Event_MouseLeftDoubleClick
            
            ; trackBar
            If trackBarVisible And mousePos >= trackBarPos And mousePos < trackBarPos + trackBarSize
                
                *scrollbar\state | #_ScrollBar_TrackBarDrag
                *scrollbar\dragDelta = mousePos - trackBarPos
                
                *scrollbar\trackBarPos = mousePos - *scrollbar\dragDelta
                
                If *scrollbar\trackBarPos <= thumbSize
                    *scrollbar\trackBarPos = thumbSize
                ElseIf *scrollbar\trackBarPos >= size - (thumbSize + trackBarSize)
                    *scrollbar\trackBarPos = size - (thumbSize + trackBarSize)
                EndIf
                
                WidgetRedraw(*widget)
                WidgetSetMouseCapture(*widget)
                
            ; left / top thumb
            ElseIf mousePos >= 0 And mousePos <= thumbSize
                
                *scrollbar\state | #_ScrollBar_LeftTopThumbDown
                
                If pos > min
                    pos - 1
                    updatePos = #True
                EndIf
                update = #True
                
            ; right / bottom thumb
            ElseIf mousePos >= size - thumbSize And mousePos <= size
                
                *scrollbar\state | #_ScrollBar_RightBottomThumbDown
                
                If pos < max - pageSize
                    pos + 1
                    updatePos = #True
                EndIf
                update = #True
                
            ; left / top of trackbar background    
            ElseIf trackBarVisible And mousePos > thumbSize And mousePos < trackBarPos
                
                *scrollbar\state | #_ScrollBar_LeftTopPageDown
                
                pos - pageSize
                If pos < min
                    pos = min
                EndIf
                updatePos = #True
                update = #True
                
            ; right / bottom of trackbar background
            ElseIf trackBarVisible And mousePos > trackBarPos And mousePos < size - thumbSize
                
                *scrollbar\state | #_ScrollBar_RightBottomPageDown
                
                pos + pageSize
                If pos > max - pageSize
                    pos = max - pageSize
                EndIf
                updatePos = #True
                update = #True
                
            EndIf
            
            If update
                
                StartAnimation(*widget, #_ScrollBar_AnimateScroll, 0, *scrollBar\thumbDownScrollFPS)
                
                If updatePos
                    *scrollbar\pos = pos
                    *scrollbar\lastPos = pos
                    DispatchEvent(*widget, #PG_Event_Action, pos)
                EndIf
                
                WidgetRedraw(*widget)
                WidgetSetMouseCapture(*widget)
                
            EndIf
            
        Case #PG_Event_MouseLeftButtonUp
            
            If *scrollbar\state & #_ScrollBar_TrackBarDrag
                
                If trackBarVisible
                    
                    *scrollbar\pos = (*scrollbar\trackBarPos - thumbSize) * (max - min) / trackAreaSize + min
                    
                    If *scrollbar\pos <> *scrollbar\lastPos
                        DispatchEvent(*widget, #PG_Event_Action, *scrollbar\pos)
                    EndIf
                    
                    *scrollbar\lastPos = *scrollbar\pos
                    
                EndIf
                
            Else
                
                StopAnimation(*widget, #_ScrollBar_AnimateScroll)
                
            EndIf
            
            WidgetReleaseMouseCapture()
            
            *scrollbar\state = #Null
            WidgetRedraw(*widget)
            
    EndSelect
    
EndProcedure

Procedure eventHandler_ScrollBarAnimate(*widget.Widget, EventType, *eventData.PG_EventAnimate)
    
    Define x.d, y.d, width.d, height.d, mousePos.d, size.d, trackAreaSize.d, trackBarSize.d, trackBarPos.d
    Define min, max, pageSize, pos, thumbSize, trackBarVisible
    
    Select *eventData\id
            
        Case #_ScrollBar_AnimateScroll
            
            *scrollBar.ScrollBarWidget = *widget\userData
            
            x.d = *scrollBar\mouseX
            y.d = *scrollBar\mouseY
            width.d = *eventData\width
            height.d = *eventData\height
            
            min = *scrollbar\min
            max = *scrollbar\max + 1
            pageSize = *scrollbar\pageSize
            pos = *scrollbar\pos
            
            thumbSize = *scrollbar\thumbSize
            
            If *scrollbar\flags & #PG_ScrollBar_Vertical
                CalculateTrackAreaSize(height, thumbSize)
                size = height
                mousePos = y
            Else
                CalculateTrackAreaSize(width, thumbSize)
                size = width
                mousePos = x
            EndIf    
            
            CalculateTrackBarSize(min, max, pageSize, trackAreaSize, thumbSize, trackBarSize)
    
            CalculateTrackBarPos(min, max, pos, trackAreaSize, thumbSize)
            
            trackBarPos = Round(trackBarPos, #PB_Round_Nearest)
            trackBarSize = Round(trackBarSize, #PB_Round_Nearest)
            
            If *eventData\currentTime >= *scrollBar\thumbDownScrollDelay
                
                If x >= 0 And x <= width And y >= 0 And y <= height ; mouse is inside the widget
                
                    If *scrollBar\state & #_ScrollBar_LeftTopThumbDown
                        
                        If mousePos <= thumbSize And pos > min
                            
                            pos - 1
                            update = #True
                            
                        EndIf
                        
                    ElseIf *scrollBar\state & #_ScrollBar_RightBottomThumbDown
                        
                        If mousePos >= size - thumbSize And pos < max - pageSize
                            
                            pos + 1
                            update = #True
                            
                        EndIf
                        
                    ElseIf *scrollBar\state & #_ScrollBar_LeftTopPageDown
                        
                        If mousePos > thumbSize And trackBarPos > mousePos
                        
                            pos - pageSize
                            If pos < min
                                pos = min
                            EndIf
                            update = #True
                            
                        EndIf
                        
                    ElseIf *scrollBar\state & #_ScrollBar_RightBottomPageDown
                        
                        If mousePos < size - thumbSize And trackBarPos + trackBarSize < mousePos
                            
                            pos + pageSize
                            If pos > max - pageSize
                                pos = max - pageSize
                            EndIf
                            update = #True
                            
                        EndIf
                        
                    EndIf
                    
                    If update
                        
                        *scrollbar\pos = pos
                        *scrollbar\lastPos = pos
                        DispatchEvent(*widget, #PG_Event_Action, pos)
                        WidgetRedraw(*widget)
                        
                    EndIf
                    
                EndIf
                
            EndIf
            
    EndSelect
    
EndProcedure

;-
;- *** Public Functions ***

ProcedureDLL CreateScrollBar(x, y, Width, Height, Minimum, Maximum, PageSize, Flags = #Null)
    
    If Minimum < 0
        Minimum = 0
    EndIf
    
    If Maximum < Minimum
        Maximum = Minimum + 1
    EndIf
    
    If PageSize > Maximum
        PageSize = Maximum
    EndIf
    
    If Width < 0
        Width = 0
    EndIf
    
    If Height < 0
        Height = 0
    EndIf
    
    *scrollBar.ScrollBarWidget = AllocateStructure(ScrollBarWidget)
    *scrollBar\thumbSize = #_ScrollBar_ThumbSize
    *scrollBar\thumbDownScrollDelay = #_ScrollBar_ScrollDelay
    *scrollBar\thumbDownScrollFPS = #_ScrollBar_ScrollFPS
    *scrollBar\min = Minimum
    *scrollBar\max = Maximum
    *scrollBar\pageSize = PageSize
    *scrollBar\pos = *scrollBar\min
    
    If Flags & #PG_ScrollBar_Vertical
        *scrollBar\flags | #PG_ScrollBar_Vertical
        If Not Width
            Width = #_ScrollBar_VerticalWidth
        EndIf
    Else
        If Not Height
            Height = #_ScrollBar_HorizontalHeight
        EndIf
    EndIf
    
    *widget.Widget = CreateWidget(x, y, Width, Height, *scrollBar, flags | #PG_Widget_Hide)
    
    AddEventHandler(*widget, #PG_Event_Draw, @eventHandler_ScrollBarDraw())
    AddEventHandler(*widget, #PG_Event_MouseMove, @eventHandler_ScrollBarMouse())
    AddEventHandler(*widget, #PG_Event_MouseLeave, @eventHandler_ScrollBarMouse())
    AddEventHandler(*widget, #PG_Event_MouseLeftButtonDown, @eventHandler_ScrollBarMouse())
    AddEventHandler(*widget, #PG_Event_MouseLeftButtonUp, @eventHandler_ScrollBarMouse())
    AddEventHandler(*widget, #PG_Event_MouseLeftDoubleClick, @eventHandler_ScrollBarMouse())
    AddEventHandler(*widget, #PG_Event_Animate, @eventHandler_ScrollBarAnimate())
    
    If Not flags & #PG_Widget_Hide And Not flags & #PG_Widget_NoDraw
        WidgetShow(*widget)
    EndIf
    
    ProcedureReturn *widget
    
EndProcedure
Notice how there is absolutelty no DPI logic, that's because ProGUI handles everything automatically (all based on Device Independent Pixels)
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
PrincieD
Addict
Addict
Posts: 858
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha Sneak Peek!

Post by PrincieD »

Hi guys,

If you've bought a license for the old ProGUI V1.41 and still haven't received your keys and source, please make sure you check your spam folder or if you have aggressive spam filtering make sure any email from progui.co.uk is added as an exception (also make sure your inbox hasn't exceded it's limits) otherwise it's impossible for me to get in contact. Please, also feel free to private message me on here and we'll get it sorted. Thanks! Chris.
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
Post Reply