View Full Version : UI + TBGL + Oxygen Project
Charles Pegge
30-08-2009, 18:26
This project is a PlayPen for exploring User Interfaces for thinBasic with TBGL and O2. You have probably seen some earlier manifestation of this before.
So far it includes:
Dynamic control creation / deletion
Oxygen program editbox (controling color)
Tracking of mouse
Tracking of TextBox Caret (Char index)
Object rotation (left button)
Object Translation (right button)
This posting will be updated often - I hope it proves to be useful - like the curate's egg (Alright in parts!)
Charles
ErosOlmi
30-08-2009, 22:15
Great! :eusaclap:
I especially like "Test 1" with mouse movements and right/left button pressed.
Petr Schreiber
30-08-2009, 22:21
Very nice Charles,
I liked the mouse manipulation too!
Charles Pegge
31-08-2009, 14:12
Hi Petr,
Is it possible to run many canvases simultaneously within different labels? :diablo:
Charles
Petr Schreiber
31-08-2009, 14:26
Hi Charles,
currently not. As help file says :P, only one window or canvas at the same moment is possible.
This limitation is there due to garbage collection and object (textures/models/display lists) sharing.
I investigated this before summer, but school made me drive of this part. I will look into it again.
Charles Pegge
31-08-2009, 15:09
Yes I see complexity there.
One option would be to capture the image of a frame and paint it onto the label, for an inactive control. Then build a new canvas, drawing list etc from scratch for next control selected.
Charles
ErosOlmi
31-08-2009, 15:15
I think the full set of TBGL functions must be changed because (if I'm not wrong) programmer should have to pass the handle of the window where to draw.
Currently there is only one active handle so TBGL functions know where to draw next TBGL command but in case of multiple handle every TBGL function should have an additional param.
Just guessing, maybe I'm wrong.
Eros
Michael Hartlef
31-08-2009, 15:31
Nope, you could have a TBGL_SetDrawTarget command. That is what I did way back with IBasic Pro and it's 2D pak. It was only able to use one window, but not anymore after I was done with it. :)
ErosOlmi
31-08-2009, 15:41
That is great.
But I was thinking about (for example) two or more MDI windows acting as TBGL canvas. Each window will fire multiple redrawing events simultaneously. How can you manage such a situation? Maybe with a semaphore variable that will fire green light when the first drawing loop has finished or things like that.
There is an example in \thinBasic\SampleScripts\UI\MDI\ called "MDI_Test_DialogEdit_And_TBGL.tbasic" that shows it. Maybe it can be amended to show how to use multiple TBGL canvas windows.
Ciao
Eros
Charles Pegge
31-08-2009, 16:22
Yes I saw that example. It supports a separate image for each new child dialog created.
Incidently, you may need to take a closer look at these MDI examples, when you have some time to spare. They don't seem to work as expected - possibly something broken with more recent thinBasic development. - controls on child dialogs not working.
Charles
Petr Schreiber
31-08-2009, 17:08
Hi guys,
I think the TBGL_SetActive... would be good, and I was thinking about it like that for future ( still, window and keyboard commands are multiple controls ready, as they use handle ). OpenGL works this way - you set some rendering context as active use it, bind other...
Eros, I think the problem might occur only when using multiple threads. For other cases I think the functions go one after other, not executing in paralel. But maybe I got it wrong, I did not slept much :)
I think it is realisable, just need careful plan to not make a mistake in design.
There is magic command called wglShareLists which could help me in achieving the task of shared resources between multiple rendering surfaces.
Petr
ErosOlmi
31-08-2009, 17:30
Yes I saw that example. It supports a separate image for each new child dialog created.
Incidently, you may need to take a closer look at these MDI examples, when you have some time to spare. They don't seem to work as expected - possibly something broken with more recent thinBasic development. - controls on child dialogs not working.
Charles
Thanks, I will check.
lydia_sp
08-09-2009, 14:14
hello all. dear charles. very good script. I like the scaling and the whole GUI ! but for me one script with all includes files would be better. this kind confuses me at the moment. prefer not too much scripts separetely. any other way to build such oxygen/tbgl scripts with includes more functions ?
best regards, Lydia
Charles Pegge
08-09-2009, 18:15
Hi Lydia,
Yes I agree this is not the ideal way to present an example. When developing code, I like to divide it down into its architectural components - this makes it much easier to do large scale changes when the code is being developed, In Oxygen for instance, I have separate files for lexing, parsing, basic, assembling, linking and so forth. And I prefer using notepad, with the entire screen stacked with files.
Fortunately, it is very easy to stitch the files together into a single unit. See if the file below is easier to read :)
Charles
lydia_sp
10-09-2009, 11:55
hello charles. thank you for new example. this script has quite better overview for me. I will test one of your oxygen scripts. show it next time. I am climbing mount oxygen everest! but I have no idea about assembler coding. sorry. nice day for family oxygen :)
if you can give hint. do you mean there is a good sense to learn oxygen when I am playing with ui / tbgl features ? for me tbgl and ui module are big stuff enough to learn you can imagine. java script was easier to learn. one software, one world wide language ! oxygen and thinbasic works fine together, why ? thought you have programmed oxygen with freebasic ? don`t know freebasic. I will test powerbasic until autumn. then start studying.
so long, lydia
Petr Schreiber
10-09-2009, 12:24
Lydia,
I think it is better to learn one thing at time, and make sure you understand it well.
For smooth learning curve, I would recommend to start with console module.
You can use console as "laboratory" for your experiments.
First learn how to print text, and how to retrieve input
Examine use of TYPEs and Arrays - how to create them, how to seek in them...
Then I would recommend to have a look at string functions, there is big power in them
Have a look at flow statements - while/wend, for/next, do/loop, if/endif, select/end select
Then you can have a look at file module - how to save, how to load information
Important, in my opinion, is to not do just "test scripts", but try to do scripts which have some purpose (text analysis, format conversion,...)
Once you are sure you know how it works, you can add another module and so on.
Maybe its just me, but learning too much things at once can result in problems in focus, and in the end you do not know nothing in depth. Better to take it ... sequentially. But take it just as my personal opinion/recommendation, there might be better ways to learn.
Charles Pegge
10-09-2009, 12:48
Hi Lydia,
If you want something to go very fast then Oxygen is there to help you. It is like creating a DLL inside your thinBasic Script and invoking it directly. The basic syntax is very similar to thinBasic/FreeBasic/PowerBasic and the Assembler is there when you need it.
Not many people understand assembler, and a good compiler will often generate assembly code just as fast as handwritten assembler.
Oxygen also has OOP and other techniques for encapsulating code such as functions inside functions. An Oxygen program can also compile strings of source code while it is running - which you can't do in C++ :)
But I have not written a manual for the Oxygen Basic side yet. It is coming to the end of an experimental stage and the language is defined by the examples included.
I chose to write Oxygen in FreeBasic to make a Linux version possible. I found FB to be very reliable with neat syntax, and it also has a partial implementation of OOP.
Oxygen has very few built in functions but enough to build substantial code libraries - and of course work cooperatively with thinBasic which is not at all thin in functionality. :)
Charles
lydia_sp
11-09-2009, 18:37
petr, charles, many thanks to you for good advices ! I will try to find my own way to capture all knowledge and decide what best way for me to get a constant learning curve.
for charles. I have tried this morning module maker and a test script . does it mean you can create own DLL or exe files as stand alone application? you can create own exe files by programming thinbasic tools? I think you mean last thing, isn`t it? not very clear for me to understand. sorry. I know by my father assembler code is very, very fast. I will use your script at another time, cause I have to work enough with/for ui/tbgl :)
another thing. you can programm a own basic language with all include files with thinbasic? powerbasic ? freebasic? you choosed freebasic. but I have bought last week powerbasic ! damned ;)
nice evening, lydia
Charles Pegge
11-09-2009, 21:23
Hi Lydia,
You can create general purpose EXEs, DLLs and DLL modules to extend thinBasic. I chose FreeBasic for writing Oxygen because it runs on Linux as well as MS. But I have PB as well and it is a little easier to use for writing TBmodules than FreeBasic. You will also find it has a much more extensive range of built in functions.
My first experience of PB was back in the late 1980s when it was known as TurboBasic and came on a 5.25 inch floppy disk, which I still have somewhere, among my computer relics. But I doubt it is usable now since these media demagnetise over a period of time and lose vital bits.
The interesting thing about the x86 Assembler is that it goes back around thirty years and has not changed very much in that time - far more stable than most high level languages, though there were many different CPUs around at that time. We did not anticipate that this family of Intel processors would become so dominant - even displacing the PowerPC processor in the latest generation of Apple Macs. So I think learning some assembler is a good investment of time and effort, and once you understand the Assembler code for one processor it is easy to understand others.
Charles