ProGUI V3 Alpha 4 Ready for testing!

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

Re: ProGUI V3 Alpha 3 Ready for testing!

Post by PrincieD »

Hi guys could you give this a go please? It's the Image Border Creator app, it combines a lot of Win32 common controls with ProGUI native widgets and layout engines. And now the new Windows 11 skin (which is still work in progress), If you're running it on Windows 10 it will look like a Windows 11 window and if you're running it on Windows 11 it should "almost" look like a Windows 11 window. https://www.progui.co.uk/downloads/BorderImgEditor.zip

Image

You can experiment with the images in the icons directory.

You can right click for a context menu and select a light or dark background on both the main preview and the 9 slice editors. You can also use the mouse wheel to zoom in and out on the 9 slice editors
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
PrincieD
Addict
Addict
Posts: 906
Joined: Wed Aug 10, 2005 2:08 pm
Location: Yorkshire, England
Contact:

Re: ProGUI V3 Alpha 3 Ready for testing!

Post by PrincieD »

Alpha 4 released! see top of thread :)

This is the source for the "test_CustomButtonWidget.pb" (gives you an idea of how easy it is to create custom widgets):

Code: Select all

#ProGUI_UseDll = #True

CompilerIf Not #PB_Compiler_Thread
    MessageRequester("ProGUI", "Please enable threadsafe executable", #PB_MessageRequester_Ok)
    End
CompilerEndIf

CompilerIf #PB_Compiler_DPIAware
    MessageRequester("ProGUI", "Please disable DPI aware executable, ProGUI handles per-monitor DPI", #PB_MessageRequester_Ok)
    End
CompilerEndIf

CompilerIf #ProGUI_UseDll
    IncludeFile "ProGUI_PB.pbi"
CompilerElse
    IncludeFile "ProGUI.pbi"
CompilerEndIf

CompilerIf #PB_Compiler_Backend = #PB_Backend_C
    Debug "Using C backend"
CompilerEndIf

StartProGUI(#PG_RenderDirect2D)

;- Constants

EnumerationBinary
    
    #_Button_IsMouseDown
    #_Button_IsHover
    
EndEnumeration

;- Structures

Structure ButtonWidget
    
    text.s
    flags.i
    
EndStructure

;- Macros

;- *** Internal Functions ***

Procedure eventHandler_ButtonDraw(Widget, EventType, *event.PG_EventDraw, *userData)
    
    Protected *button.ButtonWidget
    
    *button = WidgetGetUserData(Widget)
    
    If *button\text
        DrawSkinText(Widget, "", 0, 0, *event\width, *event\height, *button\text)
    EndIf
    
EndProcedure

Procedure eventHandler_ButtonMouse(Widget, EventType, *event.PG_EventMouse, *userData)
    
    Protected *button.ButtonWidget
    
    *button = WidgetGetUserData(Widget)
    
    Select EventType
            
        Case #PG_Event_MouseEnter
            
            If *button\flags & #_Button_IsMouseDown
                WidgetSetSkinState(Widget, "active")
            Else
                WidgetSetSkinState(Widget, "hover")
            EndIf
            
            *button\flags | #_Button_IsHover
            
        Case #PG_Event_MouseLeave
            
            If *button\flags & #_Button_IsMouseDown
                WidgetSetSkinState(Widget, "hover")
            Else
                WidgetSetSkinState(Widget, "")
            EndIf
            
            *button\flags &~ #_Button_IsHover
            
        Case #PG_Event_MouseLeftButtonDown, #PG_Event_MouseLeftDoubleClick
            
            WidgetSetMouseCapture(Widget)
            WidgetSetSkinState(Widget, "active")
            *button\flags | #_Button_IsMouseDown
            
        Case #PG_Event_MouseLeftButtonUp
            
            WidgetReleaseMouseCapture()
            
            If *button\flags & #_Button_IsHover
                DispatchEvent(Widget, #PG_Event_Action)
                WidgetSetSkinState(Widget, "hover")
            Else
                WidgetSetSkinState(Widget, "")
            EndIf
            
            *button\flags &~ #_Button_IsMouseDown
            
    EndSelect
    
EndProcedure

Procedure skin_Init_Button()
    
    SkinSetValue("mybutton", "", "", "background", "#E1E1E1")
    SkinSetValue("mybutton", "", "", "border", "solid 1px #ADADAD")
    SkinSetValue("mybutton", "", "", "color", "black")
    SkinSetValue("mybutton", "", "", "text-align", "center")
    SkinSetValue("mybutton", "", "", "vertical-align", "center")
    SkinSetValue("mybutton", "hover", "", "background", "#E5F1FB")
    SkinSetValue("mybutton", "hover", "", "border", "solid 1px #0078D7")
    SkinSetValue("mybutton", "hover", "", "color", "black")
    SkinSetValue("mybutton", "active", "", "background", "#CCE4F7")
    SkinSetValue("mybutton", "active", "", "border", "solid 1px #005499")
    SkinSetValue("mybutton", "active", "", "color", "black")
    SkinSetValue("mybutton", "", "", "transition", "background .4s, border .4s")
    SkinSetValue("mybutton", "active", "", "transition", "background .3s, border .3s")
    
EndProcedure

;- *** Public Functions ***

ProcedureDLL CreateCustomButton(x, y, Width, Height, Text.s = "", Flags = #Null)
    
    Protected *button.ButtonWidget, widget
    
    If Width < 0
        Width = 0
    EndIf
    
    If Height < 0
        Height = 0
    EndIf
    
    *button = AllocateStructure(ButtonWidget)
    *button\text = Text
    
    widget = CreateWidget(x, y, Width, Height, *button, Flags | #PG_Widget_Hide)
    
    WidgetSetClass(widget, "mybutton")
    
    AddEventHandler(widget, #PG_Event_Draw, @eventHandler_ButtonDraw())
    AddEventHandler(widget, #PG_Event_MouseEnter, @eventHandler_ButtonMouse())
    AddEventHandler(widget, #PG_Event_MouseLeave, @eventHandler_ButtonMouse())
    AddEventHandler(widget, #PG_Event_MouseLeftButtonDown, @eventHandler_ButtonMouse())
    AddEventHandler(widget, #PG_Event_MouseLeftButtonUp, @eventHandler_ButtonMouse())
    AddEventHandler(widget, #PG_Event_MouseLeftDoubleClick, @eventHandler_ButtonMouse())
    
    WidgetSetCursor(widget, #PG_Cursor_Default)
    
    If Not Flags & #PG_Widget_Hide And Not Flags & #PG_Widget_NoDraw
        WidgetShow(widget)
    EndIf
    
    ProcedureReturn widget
    
EndProcedure

Global SignalQuit
Procedure WindowCloseEventHandler(Window, EventType, *eventData, *userData)
    
    SignalQuit = #True
    
EndProcedure

skin_Init_Button()

window = CreateWindow(0, 0, 800, 600, "Test", #PG_Window_MinimizeWidget | #PG_Window_MaximizeWidget | #PG_Window_Sizeable)
AddEventHandler(window, #PG_Event_WindowClose, @WindowCloseEventHandler())

myButton = CreateCustomButton(100, 100, 100, 26, "Hello World")

WindowShow(window, #True, #PG_WindowShow_ScreenCentered)

Repeat
    
    Event = WaitWindowEvent()
    
Until Event = #PB_Event_CloseWindow Or Event = #PB_Event_RightClick Or SignalQuit

StopProGUI()
Cheers! Chris.
ProGUI - Professional Graphical User Interface Library - http://www.progui.co.uk
Post Reply