OPB v0.56 (objective PB)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
X
Enthusiast
Enthusiast
Posts: 311
Joined: Tue Apr 04, 2006 6:27 am

Re: OPB v0.51 (objective PB)

Post by X »

fsw wrote:Surely interesting stuff.
Because it's low level asm it's tight to 32bit OS.
Had to install PB32 in order to try it out...

Still very nice.
Wait ... this is limited to 32bit PB?
User avatar
idle
Always Here
Always Here
Posts: 5844
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: OPB v0.53 (objective PB)

Post by idle »

It was but it's fixed now, should be fine for 64bit but I can't test it
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: OPB v0.53 (objective PB)

Post by fsw »

Yes it works on Win7-64 (not tested on Linux-64...)
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: OPB v0.53 (objective PB)

Post by fsw »

Hello,
just wanted to mention that I had time over the weekend and looked at the misbehaving event loop.

Here the fix:

Code: Select all

; this is inside the event loop...
; some code and then:
;...
        If EventGadget  
          
          ForEach *win\gadget()  
            *gad = *win\gadget() 
          
            If *gad\gadget = EventGadget 
              GadgetFound = #True                                          <- added this
              Break 
            EndIf  
            
          Next 
          
          If GadgetFound                                                       <- added this
            
            Select EventType
                
              Case #PB_EventType_LeftClick

; and then do:

          ; reset GadgetFound = prep for new event...
          GadgetFound = #False                                           <- added this
          
        Else 
          ClassWindowCheckHits(*win) 
        EndIf

; and so on...

that's all.

Even created a small SQLite app with an extended cWindow (changed some stuff for less typing) - it was a breeze.

What I like about this approach is that it can live alongside "normal" PB commands/syntax.

Will soon post my cWindow extensions when I'm done.

Thanks
fsw
User avatar
idle
Always Here
Always Here
Posts: 5844
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: OPB v0.53 (objective PB)

Post by idle »

Thanks I'll fix up the example.
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
idle
Always Here
Always Here
Posts: 5844
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: OPB v0.54 (objective PB)

Post by idle »

updated it

changed it so OPB can also be used as a shared object or statically compiled with a class
and extended the window manager example so it can be used as a shared object also to test modularity

see the Readme in the zip
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
idle
Always Here
Always Here
Posts: 5844
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: OPB v0.54 (objective PB)

Post by idle »

Extended the event driven window manager to handle a windowed screen with multiple control windows
isn't complete yet or extensively debugged and not sure if #PB_Event_DeactivateWindow is present on windows

Events are registered with a precedence
1 a specific gadget and event "OnClick" ...
2 a specific gadget or any gadget and all its events via "Onevent"
1 a specific window and event "OnWindowMaximize"
2 a specific window or any window and all its gadgets events via "OnEvent"
1 a WindowScreen callback for rendering

keyboard functions replace PB keyboard (*don't use pb InitKeyboard)
US english keyboard is currently text mapped scan includes lowercase keys

ClassWindowKeyboardPressed(windowObject,#OPBKey_UP) to test for multiple key presses
ClassWindowKeyboardReleased(windowObject,#OPBKey_DOWN)
key = ClassWindowGetKey(windowobject) ;gets the current key pressed down
keyString = ClassWindowGetKeyString(key) ;converts the key to it's string (needs to be language mapped)

[edit]
Added MouseScroll events
Fixed a few bugs

Code: Select all

Procedure Window2_OK_OnClick()
;...
Endprocedure

w2 = NewWindow("w2",0,0,300,200,"Window2",#PB_Window_ScreenCentered) 
wn2 = ClassWindowGetWindowNumber(w2)
 
If CreateMenu(0,ClassWindowGetWindowID(w2))
  MenuTitle("Project")
  MenuItem(1, "Open")
  MenuBar()                  
  MenuItem(4, "Close")
EndIf

;register menu callback
ClassWindowRegisterWindowEvent(w2,#OnMenu,@Window2_OnMenu())
;Add a gadget and register a event pass in the gadget ID   
b2 = ClassWindowAddGadget(w2,ButtonGadget(#PB_Any,235,5,60,20,"OK"), #OnClick,@Window2_OK_OnClick())
;add additional events for the gadget mouse enter / leave  
ClassWindowRegisterGadgetEvent(b2,#OnMouseEnter,@Window2_OK_OnMouseEnter())
ClassWindowRegisterGadgetEvent(b2,#OnMouseLeave,@Window2_OK_OnMouseLeave())
lv2 = ListViewGadget(#PB_Any,3,30,293,160)
;enter the main loop 
ClassWindowMain()
;program will end when all window are closed 
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
idle
Always Here
Always Here
Posts: 5844
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: OPB v0.54 (objective PB)

Post by idle »

Added Foreign Function Interface class based on code by Wilbert
so you can call functions in libs with varargs

Code: Select all

file.s = OpenFileRequester("FFI","","*.*",1)
;open a lib loads it's exported functions
Global mlib = FFI_OpenLibrary(file,@enumfuncs())

;make wrapper functions to call the library functions
Procedure.f Foof(a.f,b.f)
  Static fn
  If Not fn   ;get the named function and set the number of parameters 
    fn = FFI_GetFunction(mlib,"foof",2) 
  EndIf   
  FFI_PushF(fn,a) ;push the parameters by type 
  FFI_PushF(fn,b)
  ProcedureReturn FFI_CallF(fn)   ;call the function via the required return type 
EndProcedure 

Procedure.s Foos()
  Static fn 
  If Not fn 
    fn = FFI_GetFunction(mlib,"foos",0)
  EndIf 
  ProcedureReturn PeekS(FFI_CallL(fn))
EndProcedure 

;call the functions 
Debug StrF(Foof(5.5,4.3))
Debug foos()

;free the library
FFI_FreeLibrary(mlib)  
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: OPB v0.54 (objective PB)

Post by fsw »

@idle,
downloaded the v054 and wanted to add the GUI stuff I added to v53 a while ago but while doing it I realized that the NewWindow procedure should actually return the WindowNumber instead of the class instance.
This way it can be used as a "normal" PureBasic Window and the OPBWindowGetWindowNumber and OPBWindowGetWindowID procedures are not needed anymore.
In my version of v053 I also substituted OPBWindowAddGadget with NewButton, NewPanel etc. as OPBWindowAddGadget looked to cryptic.

All OPB procedures that need the class information could retrieve the class instance through the WindowNumber.

This approach would align OPB to PureBasic instead of doing his own thing.

What do you think?
User avatar
idle
Always Here
Always Here
Posts: 5844
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: OPB v0.54 (objective PB)

Post by idle »

Yes sounds like a better plan.
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
idle
Always Here
Always Here
Posts: 5844
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: OPB v0.54 (objective PB)

Post by idle »

updated v0.55

removed introspection
updated the event driven window class so it returns the PB object numbers
added the FFI into the runtime (FFI is 32bit only at the moment)

changed how to start and stop OPB by calling OPBStart() and OPBStop()
it returns a module instance, though you can still create additional modules
also if it's used from a Dll you will need to call OPBClose() to close the lib
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
idle
Always Here
Always Here
Posts: 5844
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: OPB v0.55 (objective PB)

Post by idle »

quick update v0.55.1
Changed a classes user data store to a dynamic structure
so it's only instantiated if you call OPBClassSetData() when building a class or passing it through.
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
idle
Always Here
Always Here
Posts: 5844
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: OPB v0.56 (objective PB)

Post by idle »

update v.56
made it compatible with Interfaces
User avatar
idle
Always Here
Always Here
Posts: 5844
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: OPB v0.56 (objective PB)

Post by idle »

Added in remaining PB types to FFI
Windows 11, Manjaro, Raspberry Pi OS
Image
Post Reply