Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / TopGUI - Open source immediate mode GUI

Author
Message
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th Aug 2011 01:10 Edited at: 6th Aug 2011 01:11
Very strange

Does this compiled version work? If it does, I suggest making sure you have the latest version of Matrix1Utils and Advanced2D. If not, it's probably a hardware issue, so it would be helpful to know your computer specs and whether it works on any other computers you can try it on.

[b]

Attachments

Login to view attachments
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 6th Aug 2011 01:58 Edited at: 5th Sep 2011 05:47
Diggsey, Firstly let me say this is a great piece of code.

I started modifying TopGui for my own use but don’t have time right now to finish with the alteration. Figured I would post as a suggestion for development purposes. I would be interested to know what you think of the idea. I have attached the code.

The Context Menu works for me.

[img][/img]


WindowsXP SP1,Vista,Windows 7 DBpro v7.61
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.

Attachments

Login to view attachments
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 6th Aug 2011 01:59 Edited at: 6th Aug 2011 11:39
The compiled version works fine. I have the latest versions of IanM's and A2D. My specs are

------------------
System Information
------------------
Time of this report: 8/5/2011, 17:56:06
Machine name: AREA-51
Operating System: Windows Vista™ Home Premium (6.0, Build 6002) Service Pack 2
System Manufacturer: alienware
System Model: alienware
BIOS: Phoenix - AwardBIOS v6.00PG
Processor: Intel(R) Core(TM)2 Duo CPU E8200 @ 2.66GHz (2 CPUs), ~2.7GHz
Memory: 2046MB RAM
Page File: 1083MB used, 3249MB available
---------------
Display Devices
---------------
Card name: NVIDIA GeForce GTX 280
Manufacturer: NVIDIA
Chip type: GeForce GTX 280
DAC type: Integrated RAMDAC
Display Memory: 1776 MB
Dedicated Memory: 1009 MB
Shared Memory: 767 MB
Current Mode: 1680 x 1050 (32 bit) (60Hz)
Monitor: Acer LCD Monitor X223W
Driver Name: nvd3dum.dll,nvwgf2um.dll,nvwgf2um.dll
Driver Version: 8.17.0012.5896 (English)
DDI Version: 10

EDIT: I just noticed that the compiled version has the real menus as well. Very cool!

Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 6th Aug 2011 02:03 Edited at: 6th Aug 2011 02:08
Stab In The Dark - I get the old "constant name TRUE cannot be the same as a reserved word" error. I'm guessing one of the plugins I've got installed does that, but I really don't know which one.

EDIT: Also for FALSE of course, and DEGTORAD and RADTODEG.

Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 6th Aug 2011 05:12 Edited at: 5th Sep 2011 05:48
Rich not sure either which plugin would cause that error.You can remark those and use the commands from that plugin.I did not use DEGTORAD and RADTODEG so you can just delete those.

[img][/img]


WindowsXP SP1,Vista,Windows 7 DBpro v7.61
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th Aug 2011 13:00 Edited at: 6th Aug 2011 13:00
@Stab in the Dark software
I can kind of see what you are trying to do. At the moment I've gone a different route though. I moved all colour values out to constants in a separate theme file, but other values must still be specified.

Things like the size of controls will almost always be different for every control, so a default set of properties wouldn't be much use for them.

Instead of making the drawing itself as flexible as possible, and by doing that increasing the number of parameters that need to be specified, I've just put all drawing into separate functions which can then be replaced where needed to get a completely different appearance.

@Rich Dersheimer
If the compiled version works and you have the latest plugins then it must be your DBPro version. I know that U76 and later should work.

[b]
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 6th Aug 2011 15:35 Edited at: 6th Aug 2011 16:30
@Diggsey - Ohhh... I'm still on U75, so I'll load up 76 and carry on. Thanks for looking at the problem.

@Stab in the Dark software - It was eXtends that was throwing the error on using TRUE as a constant. I don't use anything in eXtends anymore, so I just moved it out of my plugins. Problem solved.

EDIT: U76 did NOT do the trick, and neither did U77. Still can't see the context menu. Very strange.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th Aug 2011 16:40
@Rich Dersheimer
Could you send me your compiled .exe which demonstrates the problem. That way I should be able to see what's going on.

[b]
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 6th Aug 2011 18:26
I can send you the .exe later today, but...

Funny thing. I loaded up r28 on an old XP computer at work, and the context and regular menus work great!

I'm going to check r28 on the Vista system when I get home tonight. Is it possible that I loaded a "not quite finished" r25 and r28 will work okay on the Vista system? I'm hoping that's the case.

Anyway, r28 looks great on an old XP workstation with integrated graphics and running DBPro U75.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th Aug 2011 20:01 Edited at: 6th Aug 2011 20:02
I've just uploaded a new version which has support for panels, scrollable panels and sliders (both horizontal and vertical). Panels and scrollable panels support a custom background colour and image which can be tiled. Panels also support a custom border colour.

[b]
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 6th Aug 2011 20:17 Edited at: 7th Aug 2011 00:33
WOot! Christmas in August. I'm downloading now. Sliders!

Here's a Slider/Panel example I put together.





Attachments

Login to view attachments
Ranietz
AGK Gold Backer
19
Years of Service
User Offline
Joined: 2nd Sep 2004
Location: Norway
Posted: 6th Aug 2011 22:33 Edited at: 6th Aug 2011 22:44
I get an error when I try to compile the program. Could not determine parameter type of 'reserve free image()' at line 903.

Line 675 in the TopGui.dba



Anyone know what I'm doing wrong?

Edit: Never mind. I didn't have the latest version of the Matrix1 plugin. I got it working now.
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 7th Aug 2011 00:38 Edited at: 7th Aug 2011 01:37
@Diggsey - On the vertical sliders, it seems to me like a zero value should be at the bottom of the slider, and the max value should be at the top, but you've got them the other way around.

Does that make any sense? Or is it a "northern hemisphere" vs "southern hemisphere" kind of thing?

EDIT: Well, I got r32 at home and I'm still seeing the problem with no context or regular menus showing up. I'm attaching the .exe, hopefully it will help.

Attachments

Login to view attachments
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th Aug 2011 01:45
@Rich Dersheimer
It should be a simple matter just to invert the result. It just works that way for consistency both with scrollbars and so that an increase in value is an increase in pixel position because the origin is in the top left.

Also, nice example
I'm just testing your .exe now.

@Ranietz
Glad you got it working

[b]
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 7th Aug 2011 02:11 Edited at: 5th Sep 2011 05:49
Diggsey, Let me explain. The idea is not to create a default set of properties for the control. That would make it less flexible. But to create a Type which defines the control.
Then when creating a new window control just create a variable of guiWindowCtrl type.
Then create a function which would then set all the properties of the variable for that Window. This would not require rewriting the controls Draw or logic functions with hard coded parameters every time you create a new window. By passing into the guiWindowBegin function one variable, you eliminate large numbers of parameters being passed into the functions. Thus it would be easier to create a Window and controls designer for this project. In theory the designer would create a global variable for each new control and then create a function to initialize the properties of the control.

[img][/img]


WindowsXP SP1,Vista,Windows 7 DBpro v7.61
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th Aug 2011 02:25
@Stab in the Dark software
Ah, I see. Still, I don't see how it helps that much. You still have to set the same number of properties. To me it makes more sense to specify them as parameters at the point where you need them rather than in some function before-hand. It's no more efficient either since UDTs are passed by value in DBPro. I suppose it's more a matter of personal taste.

I can see why it might make it easier to make a designer, but only if you try to fit a standard GUI designer to an immediate mode GUI. I can think of a number of ways that a designer could be made to work differently when used with an immediate mode GUI, possibly making it even easier to integrate with normal code.

@Rich Dersheimer
I think I see the problem. You've overridden Matrix1Util_23.dll with the 2DPluginKIT.dll which appears to have a broken version of the RGBA function. I suggest you switch back to Matrix1Util_23.dll, or edit its string table so that there is no conflict and then replace all uses of RGBA with whatever you renamed it to.

[b]
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 7th Aug 2011 02:44 Edited at: 7th Aug 2011 02:44
@Diggsey - I'll try removing the 2DPluginKIT.dll, since I'm not using it for anything I'm currently working on.

Thanks so much for looking into this!

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th Aug 2011 02:56
You may need to reinstall Matrix1Utils after removing 2DPluginKIT.dll if Matrix1Util_23.dll is not in the plugins-user folder. Presumably you must have moved Matrix1Util_23.dll out of the plugins-user folder for it not to cause a conflict, or maybe DBPro automatically allows licensed plugins to override normal ones.

[b]
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 7th Aug 2011 04:21
Happy Day! I moved 2DPluginKIT out, and now the context and regular menus show up just fine!

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th Aug 2011 13:58 Edited at: 7th Aug 2011 20:59
I've updated again. This time spinner controls are supported! You can choose the min/max values, the number of decimal places, and the step value, so it's possible to make it go up in .5 or something. It will automatically validate user input too, only allowing numeric input and rounding to the nearest allowed value

edit:
I've started working on a text area control. I've designed it in such a way that it should be easy to plug in your own parsing function and get syntax highlighting really easily. It will also support code folding, word-wrap, and variable width fonts.

It slightly departs from the usual immediate mode design because there is no built in type suitable for storing a text document, so I've created by own, and the document itself needs to be created/deleted where appropriate. The actual control itself will still be immediate mode though.

It uses a UDT which contains a pointer to an array of lines of text. These lines are connected together as a linked list, so that it is fast to insert new lines in the middle. There will be functions to handle all the complexity though, so all you need to do is pass around the UDT. It will be a single function call to convert between a text document and a string, array of strings or a file.

Also, I had a cool idea for a visual designer feature (for when I make the visual designer). I could make it so that you open the code file in your favourite editor (ie. codesurge) and then run the designer. The designer would load the GUI created by that code file, and then as you edited the GUI it would update the text in the editor in real-time, so you can add code to run when events happen as you design the GUI. All of this I already know how to do

[b]
Teh Stone
14
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 8th Aug 2011 01:45
Really Like the look of this but ive got a problem. I have imported all the files, and only put in a few lines to setup the default DBPro window but get an error

Could not determine parameter type of 'reserve free image()' *at line 679 of the TopGUI.dba*

i think i am just missing something but i dont know what.

I have also used guiInit() and guiUpdate() as you have said to do in the previous posts

hope you can help
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 8th Aug 2011 02:19
Make sure you ar using the latest version of IanM's utils.

Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 8th Aug 2011 04:25
Quote: "I've updated again."


Diggsey, you are awesome! I've added spinners and sliders to my planet generator, they can be seen in action here.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 9th Aug 2011 02:25 Edited at: 9th Aug 2011 02:27
My progress so far on the textarea control



To show how easy it is to make a custom parser I wrote one for DBPro syntax in a few minutes (one of the hardest to parse since commands can contain spaces!)

It's not interactive yet, but it has word-wrap functionality already, and the commands for managing text documents are there. Also the 99fps is because I'm running it on a laptop which doesn't have great specs.

[b]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Aug 2011 00:40
I'm just putting together my first GUI with this. The one problem I have right now is that I have no background in my window control:



As far as I can see by following the code this should work like the examples, but I have no window background at all.

Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 15th Aug 2011 09:46 Edited at: 15th Aug 2011 10:09
Have you changed the value for THEME_BACKGROUND_DARK? That's the color used for the window background. Check to see if maybe it has an alpha value of zero. It's in the TopGUI_Theme.dba

EDIT - I just checked the window example I wrote for a "user guide" and I don't see the window either. So something's changed.

FURTHER EDIT - sorry, it actually IS showing up, I made the demo wait for a button press before showing the window, and then I fogot to click the button to check it.

Here's the code I'm using...



I've set THEME_BACKGROUND_DARK to 0x80FF0000.

.

Also, 2DPluginKIT could be causing a problem, see the posts above

Attachments

Login to view attachments
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 15th Aug 2011 12:07 Edited at: 15th Aug 2011 12:08
@BatVink
I'm guessing you have a black background? By default a semi-transparent black is used, which would have no effect on an already black background. As Rich said, you can easily change it in TopGui_Theme.dba.

[b]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Aug 2011 13:35
Thanks both of you.

Quote: "I'm guessing you have a black background?"

Ah yes, I've written a little setup program while I configure the window, and it currently has a black background.

Doh!

Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 16th Aug 2011 01:19 Edited at: 16th Aug 2011 06:32
Wow I am DEFINITELY going to use this in my new game's editor (see here)

New screenshots showing my use of it will be out soon.

At first I just found TopGUI COMPLICATED. I could not understand it one bit. Then, slowly, I realised how it all worked. And now I think it's excellent!

EDIT: Just realised something - "TopGUI COMPLICATED" = TGC

Good work Diggsey!

Clonkex

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Aug 2011 01:27 Edited at: 16th Aug 2011 01:28
Thanks Do you have any suggestions to make it easier to understand straight away? What parts of it did you find complicated?

News:
I've got basic editing features in the textarea control now! Just need to add in the more advanced features (automatically scroll when selecting text, copy and paste, etc.)

Also fixed an extremely annoying bug which caused unexplainable crashes at random points in the code, with no error messages and a corrupt stack. And all because of the work-arounds needed to get around DBPro's lack of complex data types and inability to return UDTs from functions... (This bug only occured because of the new textarea code, don't worry)

[b]
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 16th Aug 2011 01:35 Edited at: 16th Aug 2011 06:31
Well, for a start, the general lack of help files was a big factor in my non-understanding of it.

I wasn't sure which parts of the code were necessary for TopGUI to function (eventually I started commenting stuff out).

I also still have no idea which functions in TopGUI.dba are for the user to use and which are internal - they're not marked in any way.

Then, I found the shear number of include files a bit overwhelming. And there's no help to speak of. I couldn't understand what the GEN_ID stuff was for (I do now, sort of).

And I wasn't sure whether any or all of the global variables in Tester.dba were necessary. I still don't know what would happen if they were removed. Would the code still work?

Ok, enough whining for now

Clonkex

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Aug 2011 02:42 Edited at: 16th Aug 2011 02:46
Quote: "I wasn't sure which parts of the code were necessary for TopGUI to function (eventually I started commenting stuff out)."


Everything in TopGui.dba, TopGui_Keys.dba and TopGui_Theme.dba is essential. The others are only needed if you use a control from one of them. (ie. if you use buttons, you need TopGui_Button.dba.

Quote: "I also still have no idea which functions in TopGUI.dba are for the user to use and which are internal - they're not marked in any way."


There isn't really a cut-off beyond which a function is internal, it just depends how much flexibility you need. There's a reason I made it in DBPro rather than as a plugin: this way it's much more customisable. The functions you will need most often are called "gui<control name>[Begin|End]" as these actually make the controls. You will probably also need "guiMoveX/Y" and "guiResizeW/H" if you have anything resizable.

Quote: "Then, I found the shear number of include files a bit overwhelming."

It's easier to find stuff that way as opposed to having all the code in one file. The actual amount of code is fairly small when you consider how much it actually does.

Quote: "And there's no help to speak of."

It's still WIP atm, but I'll put more detailed help and examples when it's nearer completion.

Quote: "I couldn't understand what the GEN_ID stuff was for."

You don't really need to know how it works internally to use it. Just know that normally you need to write GEN_ID for the ID parameter, unless you're creating controls in a loop, in which case use INDEX_ID. It's just a way of getting a number that identifies the contol, the way it calculates this is quite complicated (inline ASM to get the return address). There are simpler ways of implementing it, but none are so easy to use from the user's perspective.

Quote: "And I wasn't sure whether any or all of the global variables in Tester.dba were necessary. I still don't know what would happen if they were removed. Would the code still work?"


Everything in Tester.dba is only needed for the test program itself. The global variables hold stuff like the window positions/sizes and values of controls. It would probably be better to use a UDT or something to avoid so many. Alternatively you could put the global variables immediately above the functions that use them to keep it more organised. Normally you would link these values directly with the back-end of your application, but since the tester program has no back-end, it just uses globals.

[b]
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 16th Aug 2011 03:10 Edited at: 16th Aug 2011 06:26
Quote: "Everything in TopGui.dba, TopGui_Keys.dba and TopGui_Theme.dba is essential. The others are only needed if you use a control from one of them. (ie. if you use buttons, you need TopGui_Button.dba."


I meant in Tester.dba, but you answered my question with this:

Quote: "Everything in Tester.dba is only needed for the test program itself"


Quote: "It's easier to find stuff that way as opposed to having all the code in one file."


I know, I'm not saying having that many includes is a bad thing, I'm just saying they surprised me somewhat. That's the most DBPro include files I've ever seen in one project.

Quote: "inline ASM to get the return address"


I've tried to learn what inline things were in C++ but never could understand it. I haven't the faintest idea what ASM is.

EDIT: Editing to test my new sig
EDIT2: Testing again.
EDIT3: Testing clickable sig

Clonkex

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Aug 2011 09:26
Quote: "Do you have any suggestions to make it easier to understand straight away? What parts of it did you find complicated?"


The window example is a bit confusing. I got it eventually, but for a new user it would be difficult to understand how the Windows work on a basic level. It just needs the simplest of demos.

I'm sure I could dig a little deeper to work this out, but is there any way to "filter" which controls need attention? For example I want a list of fonts, but creating that every loop would kill the system, it could be hundreds of entries and I have no control over how many a user would have. I'm looking for ideas to deal with this.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Aug 2011 12:50
Quote: "The window example is a bit confusing."

Yes that's the part I'm least happy about, but I couldn't see any easier way of allowing the z-order of windows to change.

Quote: "For example I want a list of fonts, but creating that every loop would kill the system, it could be hundreds of entries and I have no control over how many a user would have."

It shouldn't take that long. Each listbox item except the visible ones would see that it's not visible and return almost immediately. I suggest you try it to see how long it takes, and if it really does affect performance, it shouldn't be too much work for one of us to make a combobox or listbox optimised for a large number of items.

[b]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Aug 2011 13:34
Quote: "Yes that's the part I'm least happy about, but I couldn't see any easier way of allowing the z-order of windows to change"


Perhaps include a basic example and this more advanced example. My confusion was that I assumed that windows always need array pointers and some clever voodoo. In reality, they work just like all other controls.

I'm currently taxing my brain to work out how to simplify the creation of HUDs using this tool. I did it years ago for BlueGUI and generated the HUD from the Editor design files. This needs a little more thought but maybe it could be achieved the same way by embedding the variable names you intend to use in your program.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Aug 2011 15:28
I tried out the listbox for fonts.

No Font listbox - 354 FPS
Font listbox with 20 items - 330 FPS
Filled Font Listbox - 104 FPS

So there is a significant impact to consider.
I may not have created it properly, my code is below. The reason I say it's not properly coded is that I cannot scroll the listbox, and I can't work out what is wrong.




Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Aug 2011 16:43
You need to call guiScrollX/Y after guiListboxEnd that's all.

[b]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Aug 2011 18:18
Excellent, thank you!

I've decided to make my font list an additional panel that only appears when selecting the font, to keep the overhead of this function to a minimum.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Aug 2011 19:00
I could make a generic control wrapper which caches the surface of the control. The control is only updated when it's focused. At other times, it simply pastes the last image of its surface.

[b]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Aug 2011 19:22
That's a good idea, i was thinking about how to achieve this for my extra font panel, so I could "Freeze" the other controls while it was active. Your idea would allow you to implement modal controls.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Aug 2011 19:29 Edited at: 16th Aug 2011 19:30
Well, it wouldn't be modal, it would just mean that you would only have to draw the listbox while the listbox is actually being interacted with. Modal controls are another thing I need to add though!

[b]
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 17th Aug 2011 00:10 Edited at: 17th Aug 2011 00:15
I've just uploaded a new version. This one contains the brand new textarea control. It's a bit more complicated to use than the others because of the complicated data structure needed to store the text efficiently.

Textareas are just a view of the actual text in them. This text is referred to as a TextDocument. The data is stored using the TextDocumentType UDT.

Instead of constantly passing around this UDT, the GUI uses a current TextDocument, which you can set using guiSetCurrentTextDocument(). The global "guiCurrentTextDocument" stores the current TextDocument.

To create a new TextDocument, you can call guiCreateTextDocument(). The current TextDocument is the one just created. There are a number of ways to set the text in the current TextDocument:
guiSetTextDocumentFromString()
guiSetTextDocumentFromStringArray()
guiSetTextDocumentFromFile()

And to get the text:
guiGetStringFromTextDocument()
guiGetStringArrayFromTextDocument()
guiGetFileFromTextDocument()

When you draw a textarea using guiTextarea(), the current TextDocument will be displayed inside. Any time the current TextDocument may be modified, you must get the new changes by assigning "guiCurrentTextDocument" to your variable storing it.

eg.


When a text document is modified, any variables still set to the old one will become invalid. Using them may result in crashes, which is why you should always update your variables as shown.

You can optionally set a parser to use with a TextDocument. In Tester.dba there is a DBPro syntax parser as an example. Essentially, your parser is called whenever the textarea needs to know how a particular line of text should be formatted. A function pointer is passed in which the parser must call a number of times. Each time, you can specify a different colour and font.

[b]
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 17th Aug 2011 03:22
Quote: "I've just uploaded a new version."


Oh great. Now I have to download it again. Don't worry I'm only kidding, it's tiny and downloads in about 0.5 seconds even on my awful connection

Quote: "This one contains the brand new textarea control."


Yay....I think....not that I really need a textarea- wait, that's PERFECT!! THANKYOU!! I had been wondering how I was going to implement in-game script editing in Rift, now you've just gone and solved the problem! Thankyou!

Clonkex

DemonHill
16
Years of Service
User Offline
Joined: 20th Mar 2008
Location:
Posted: 17th Aug 2011 10:12
Does anyone have a list of the commands for TOPgui, an INI or help file please ?

Would be interested to see an example of a popup with a graphic in the box. I have used other plugin and they require WINDOW ON to be enabled, which screws up the resolution. Looking forward to testing TOPgui, looks very good.
DemonHill
16
Years of Service
User Offline
Joined: 20th Mar 2008
Location:
Posted: 17th Aug 2011 10:18
Come to think of it, do you need WINDOW ON for this to work ?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Aug 2011 12:16
Quote: "Come to think of it, do you need WINDOW ON for this to work ?"


No, it's all done in DirectX with Diggsey's other Advanced 2D plugin. This really is an incredible piece of work, DBP-native and open source too! I may resurrect SmartParticles with this, which didn't work fantastically well with Windows controls. I just need to come up with a good way to make the design and implementation process slicker.

Diggsey, when I mentioned Modal earlier, I was thinking that pasting a static image of unfocused controls effectively disables them and could be used to add modality.

WorldBot
12
Years of Service
User Offline
Joined: 5th Aug 2011
Location: In a Worms game
Posted: 17th Aug 2011 13:17
Very nice and thanks Diggsey, that's a very cool GUI!
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 17th Aug 2011 13:28 Edited at: 17th Aug 2011 13:35
A small warning about textareas:
It should be fine to share TextDocuments between multiple textareas, but only when you don't use word-wrap. Word-wrap alters the layout of the TextDocument, so it will have to reformat all of the text every loop because the textareas could be different widths.

I'm thinking of having two types of modal dialog:
- Simple modal
You call a function which doesn't return until modal interaction has finished. To preserve the background, the GUI will automatically copy the background into a bitmap or image. This will then be used as the background, on top of which the modal dialogs can draw. In this mode the GUI will do all the hard work, you just have to pass in a pointer to a function that will draw the modal dialog, or whatever else you want.

- Complex modal
The modal function will return immediately, but will have some way of disabling interaction with the other controls, perhaps by using a screen sized transparent overlay. This mode would be useful if you want things in the background to continue to update.

In both modes it will probably default to darkening the rest of the screen. I've used this before and it looks quite good . It won't darken instantly, it will take a second or two to fade to the darker version.

[b]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Aug 2011 18:33
Quote: "- Simple modal
You call a function which doesn't return until modal interaction has finished. To preserve the background, the GUI will automatically copy the background into a bitmap or image. This will then be used as the background, on top of which the modal dialogs can draw"


That's good, because that is how I planned to deal with the font issue!

Login to post a reply

Server time is: 2024-04-25 17:25:25
Your offset time is: 2024-04-25 17:25:25