sGUI

User projects written in or related to FreeBASIC.
ppf
Posts: 88
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » Mar 05, 2020 17:56

Combobox control logic improved like pleasant & comfort, with a psychological aspect, a bit.(Version 0.84ext)

Because origin one is set too strong&resctrictive (loosing control off a gad), IMHO,
I invest one hour to read sources and made some experiments.Third went to planned success.
Let me explain.
Now you can do selection of an item quickly, even if riding a mouse off the Miniselector gad,
but holding LMB.When leavin mousepress & mice is anywhere, nothing happens.Miniselector gad
remains opened.

LMB click on gad area means 'Select this item !', as usual.
LMB click off gad area means 'Ehh, not now, I'll do another mici/key/gad job.Close it! ( the miniselector gad)'
RMB click anywhere means 'CLOSE it !

Final changes in "Miniselector.bas" file

Code: Select all

#include once "ListBox.bas"

namespace sGUI

declare function MiniSelector(PosX as integer,PosY as integer,NumChars as integer, NumRows as integer, TOAddr as textobject ptr=0, EntrySelected as integer=0,DisplayMode as integer=0) as integer

function MiniSelector(posx as integer,posy as integer,NumChars as integer, NumRows as integer, TOAddr as textobject ptr=0, EntrySelected as integer=0,DisplayMode as integer=0) as integer
'... a few lines of code
'...
' and control loop ...   
    do
      event->xSleep(1,1)
      if event->GADGETMESSAGE then
        select case event->GADGETMESSAGE
          case list
          function=GetListBoxVal(list)
          event->EXITEVENT=1
        end select

      else
/'
'~~~~~~~~~~~~~~~~~~~~~~~~~   OLD code     ~~~~~~~~~~~~~~~~~~
   'orig code
        if LMB=HOLD then
          if (MOUSEX<posx) or (MOUSEX>posx+boxw-1) or (MOUSEY<posy) or (MOUSEY>posy+boxh-1) then
            function=0
            event->EXITEVENT=1
          end if
        end if
'~~~~~~~~~~~~~~~~~~~~~~~~~   OLD code    ~~~~~~~~~~~~~~~~~~   
'/

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   'new code
          if RMB=HIT then
            function=0
            event->EXITEVENT=1
          end if
          if LMB=HIT andalso ((MOUSEX<posx) or (MOUSEX>posx+boxw-1) or (MOUSEY<posy) or (MOUSEY>posy+boxh-1)) then
            function=0
            event->EXITEVENT=1
          end if
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      end if
    loop until event->EXITEVENT
'... the rest of file   

(Seems, this 'loosin' behavior was main hidden reason in my mind to write 'Context search' feature;
posted previously.
Last feature missing is displaying text item (LongestLine) in Miniselector gad longer then x-screensize,
with hidden&additional Hslider.But who wants it ? If somebody will write it, what an exciting moment !)

IMO, Combobox now is perfect & fit. Happy coding, enjoy it !
ppf
Posts: 88
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » Mar 21, 2020 7:20

Hi,
important tip.
If mixed Multikey and Key commands, add Key="" to Multikey If block, othervice crazy behavior when some code in part If Key block.
ppf
Posts: 88
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » May 03, 2020 16:18

Hello folks,
founded complete solution (second half) for correct gad's drawing funcionality, if sGui stuff called from some user graphics operations.
(Asked previous year - solution is keyword 'window').
In these hard Kovit-19 days with a lot of free time I invest a moment to search (0.84) sources and test all graphics commands from FB manual.
If I understand rightly, sGui Init (one times at beginning of program) uses default window coordinate settings for own functionality.
As shown in the next short example with drawin a diagonal , messagebox and change of window coordinates that behavior; and founded solution.
What is this one easy short line of code (below already encapsulated in macro)

Code: Select all

#macro checkSet_sGuiWindow()
scope
 var scrW=0:var scrH=0
 ScreenInfo scrW, scrH   
  if scrH<>PMap(scrH, 1) then window        'final solution line
end scope
#endmacro

and means "if comes from job where changed window coordinates, change it to default for proper sGui funcionality".
Also it looks like the closest getter to function 'window (x0,y0)-(xMax,yMax)', then it must be in app core routines, e.g. as macro.

After inspecting my apps codes my opinion is :
- to add this line to Filerequesters and MessageBoxes, othervice using that macro first
- to add this macro prior calling any sGui stuff, if mixing user graphics and sGui stuff.This also means next logical question -
if going back, or to new graphics drawings, where to re/set/renew window coordinates for graphic commands ?
Is it sGui matter, or part of user graphics solution ? I will investigate further.
Muttonhead
Posts: 130
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » May 05, 2020 17:26

(Asked previous year - solution is keyword 'window')

unfortunately completely incompatible to the previous version, but already more than an attempt.
the complete functionality of the "old" sGUI has not yet been reproduced.
https://1drv.ms/u/s!AsTPhVzcfzRriKUMvhQX3t9xR8Marw?e=JVKyi9

Mutton
xiaoyao
Posts: 77
Joined: May 05, 2020 2:01

Re: sGUI

Postby xiaoyao » May 06, 2020 5:00

Coolman wrote:great job. shame that the comments are in German in the source codes. English would have been better. thank you for the examples provided. missing documentation. I know. This is most annoying to do ...

If the released code retains a comment in the original national language and then adds a comment in English, I think it is the best.
The code I posted earlier contains a small amount of Chinese, which was severely criticized by the forum administrator, and I am also uncomfortable.
systemctl
Posts: 182
Joined: Mar 27, 2020 5:15

Re: sGUI

Postby systemctl » May 06, 2020 9:01

xiaoyao wrote:The code I posted earlier contains a small amount of Chinese, which was severely criticized by the forum administrator, and I am also uncomfortable.


No, you are just too sensitive.
Coolman
Posts: 228
Joined: Nov 05, 2010 15:09

Re: sGUI

Postby Coolman » May 06, 2020 15:07

xiaoyao wrote:
Coolman wrote:great job. shame that the comments are in German in the source codes. English would have been better. thank you for the examples provided. missing documentation. I know. This is most annoying to do ...

If the released code retains a comment in the original national language and then adds a comment in English, I think it is the best.
The code I posted earlier contains a small amount of Chinese, which was severely criticized by the forum administrator, and I am also uncomfortable.


Don't get discouraged and don't worry about the critics. It doesn't matter. Keep up the good work.
ppf
Posts: 88
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » May 06, 2020 15:18

Hi Mutton,

quick test of your new version ok here on Linux 64 bit,
thanks for sharing that preview.
Only one crash - "Error 139 in WinDemo-Windowmessage.bas",
but compiled OK so other problem there is probably.
Also CPU cores usage is too high - more then 87-95% in all demos, maybe Event-loop
not slowed with Sleep 25,1 ?, I didn't read sources yet, just quick tip..

I'll track that file with my debug macros in the night, and quick tests repeating on
Linux 32 bit for all demos.

Regards
Coolman
Posts: 228
Joined: Nov 05, 2010 15:09

Re: sGUI

Postby Coolman » May 06, 2020 16:12

i just tested this version on kde neon 64 (ubuntu). all examples compile and work well. cpu occupancy rate 3% to 12%. reasonable. excellent.

only WinDemo_WINDOWMESSAGE causes an error message :

Segmentation fault

there would be documentation in english!
Muttonhead
Posts: 130
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » May 06, 2020 16:18

thanks for testing.
Also CPU cores usage is too high - more then 87-95% in all demos,....

no good news. In general the CPU load is a bit higher, the GUI is now rebuilt in every frame. But I can't reproduce this high CPU load here. I only have 3% here (win10).
To the "WinDemo_WINDOWMESSAGE.bas", this code here should work:

Code: Select all

#include "sGUI\sGUI.bas"
#include once "sGUI\Gadget_SimpleToggle.bas"
using sGUI

screen 19,32
InitGUI

LoadProportionalFont("Ubuntu\Ubuntu-R\Ubuntu-R.bmp")
LoadFixedFont("Ubuntu\UbuntuMono-R\UbuntuMono-R.bmp")

dim as sGUIWindow ptr winA,winB,winC,winD
dim as Gadget ptr buttonA,buttonB,buttonC,buttonD
winA=AddWindow(0,10,10,200,200,"winA",WFLAG_WINDOWTYPE2 or WFLAG_DRAGABLE)
  winB=AddWindow(winA,20,20,150,150,"winB",WFLAG_WINDOWTYPE2 or WFLAG_DRAGABLE or WFLAG_SENDWMSGASPARENT)
    winC=AddWindow(WinB,1,1,50,25,"winC",WFLAG_WINDOWTYPE2 or WFLAG_DRAGABLE or WFLAG_SENDWMSGASPARENT)
    winD=AddWindow(WinB,60,60,50,25,"winD",WFLAG_WINDOWTYPE2 or WFLAG_DRAGABLE or WFLAG_SENDWMSGASPARENT)
   
ShowWindow(winA)
ShowWindow(winB)
ShowWindow(winC)
ShowWindow(winD)

buttonA=AddSimpleGadget(winA,1,1,30,,"A")
buttonB=AddSimpleGadget(winB,1,1,30,,"B")
buttonC=AddSimpleGadget(winC,1,1,30,,"C")
buttonD=AddSimpleGadget(winD,1,1,30,,"D")

GadgetOn(buttonA)
GadgetOn(buttonB)
GadgetOn(buttonC)
GadgetOn(buttonD)

dim as integer ff=freefile
open cons for output as ff
print #ff,"main dialog window: " & winA
do
  sleep 1
  MasterControlProgram
  if WINDOWMESSAGE then
    print #ff,WINDOWMESSAGE
  end if
loop until SCREENCLOSEBUTTON
close ff


Mutton
ppf
Posts: 88
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » May 06, 2020 20:24

Typo founded quickly in 'ShowWindow(winB)'
Just changed to 'ShowWindow(winE)' and demo works.

High CPU - maybe I have cracked OS or something, I see boot error msg and fault is on my side.
5 years linux not updated on my box.Now going to 32 bit testing.
ppf
Posts: 88
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » May 06, 2020 22:52

Linux 32 bit Ok.
Cpu 18 - 51%, smmoother motion.
ppf
Posts: 88
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » May 14, 2020 16:11

Hi Mutton,

small improvement of sGUI 084ext;
to my debugin macros https://freebasic.net/forum/viewtopic.php?f=7&t=28457
I added macros 'gdg() and logUI()' for easy trackin sGUI user code in scrollable gadget,
because macro 'ss(a)' is not very handy if free place on screen is insufficient..
('gdg' aka 'gadget' trackin debug)
These macros are placed in new file "sGUI_macros.bas""
(Note - macro 'dbg()' is used for trackin internal functionality of sGUI library & crashes mostly by newbies.)

Usage, f.e.:
"someAppName.bas"

Code: Select all

#Include "debug.bi"
#Include once "vbcompat.bi"
#Include "sGUI\sGUI.bas"
#Include "sGUI\sGUI_macros.bas"
' the rest
' of app
' code



"sGUI code in app e.g."

Code: Select all

scope         'sGUI stuff f.e. in scope/sub/func
dim as EventHandle ptr event=new EventHandle

' some code

debugbox=AddMultiLineEditBox(event,250,30,35,8,1)                'is SHARED !, so local dimensioning not needed !
TO_SetText(debugbox,"       Trackin/debugin logs here..","|")      'classic syntax
TO_AppendLine(debugbox,"wizRAD()   ....  start")
TO_AppendLine(debugbox," RADmode=" & RADmodeB)
UpdateGadget(debugbox)

' some code

logUI(debugbox," ubound (saveWiGad)= " & ubound(saveWiGad))
gdg(" propsFflag=" & propsFflag)

' some code

REM logUI(debugbox,"..xSleep is now " & setValuexSleep) 
gdg("..xSleep is now " & setValuexSleep)               ' shorter notation of previous line  /;)

' some code

delete event
scope         'sGUI scope ended



Pic here:
https://postimg.cc/q68zvwpd
Last edited by ppf on May 14, 2020 20:52, edited 1 time in total.
ppf
Posts: 88
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » May 14, 2020 20:50

Apologies, forgotten
"sGUI_macros.bas" here

Code: Select all

namespace sGUI

dim shared as Gadget ptr debugbox         

REM    'for tracking - print in (enabled + visible) MultilineEdit gadget  ( if sGUI stuff is WORKING !!! )
#macro logUI(a,logs)
 if debugMode then
   TO_AppendLine(a,logs)
   UpdateGadget(a)
 end if
#endmacro
#define gdg(logs) logUI(debugbox,logs)

end namespace

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 6 guests