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.

DarkBASIC Professional Discussion / DarkGUI - a user interface command library

Author
Message
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 27th Jan 2011 15:20 Edited at: 7th Feb 2011 15:11

Update: New Demo available for download! 7/2/11

I've written a set of functions in DBPro that gives you access to Windows-style user interface components. They behave just like the ones in Windows, but the whole thing works by choosing which image to paste on screen depending on where the Mouse is and whether or not it's been clicked. This avoids fiddling around with Windows Dlls, and also allows greater freedom in the design and look of custom user interfaces.

The library sports three types of form, which can be freely moved around the DBPro window (because its based on "paste image", the forms cannot leave this main window!). "Standard" are the usual ones, "Palette" always sit on top like floating toolboxes, and "Message Boxes" appear on top of everything, preventing anything from being clicked until they are removed.

For components, you can choose from buttons, checkboxes, radio buttons or textboxes - this last one was quite a challenge, but you can use the Home, End, Scroll and Delete keys, and the text automatically wraps around!

Screenshot:


Feature List
Core functionality
Standard Forms
Palette Forms
Message Box Forms
Buttons
Checkboxes
Radio Buttons
Textboxes
Hardwired Components
Form Resizing (form images generated at runtime)
Spinedit boxes
Panels
Captions
Menu bars
Optional rendering using sprites
Complete command libraries for all components
Port from DBPro code to C++ plugin

I've attached a zip file holding two demo projects. One simply showcases the currently implemented features of DarkGUI. The other illustrates the new hardwire functionality I've just added to the library. If hardwire is set 1, the default image of the component is merged with the form image - so pasting the form image on screen automatically puts all the components on screen. You should notice a major boost in performance with this feature turned on!

Let me know what you think!

We spend our lives chasing dreams. Dark Basic lets us catch some of them.
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 28th Jan 2011 01:17
Very nice, it looks really pro. Ran really smooth on my laptop.
Is there a limit to the number of forms you can have showing at once?
Looks like the kind of thing every level editor needs!

Thanks,
Broken_Code
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 28th Jan 2011 15:31
Glad you liked it!

You can create and show as many forms or components as you want - literally the only limit is the frame rate when DarkGUI tries to paste the images on screen.

Like sprites, you can have any number on screen at any time, but for speed critical programs your should stick to just a few hundred.

Thanks for downloading!

We spend our lives chasing dreams. Dark Basic lets us catch some of them.
Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 28th Jan 2011 15:35
looks good. will be using this. thanks!

Virtual Nomad @ California, USA . DBPro V7.5
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Jan 2011 17:05
Great start there Robert. Few things:

- There's an issue with using multiple textboxes.
- If forms are limited to pre-made images then you'd have to make an image for every form size. That could be a lot of images, which are of the same thing. Since the form image is very simple, it can be pre-render in DBP and you can have any size you want.
- Don't use DBP stock text commands, they are incredibly slow. Use cloggy's D3D plugin which give you a massive boost in all thing 2D (great for pre-rendering as well), plus you can have AA text.
- You do an incredible amount of region checks with the mouse, this could be made to just two checks. One for the form and one for the hit forms gagdets. When you hit something, you only need to update the hit, unless something has focus and requires update.

So:


There's a few minor issue, but as you work on the code, they'll disappear. Hope this helps.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 29th Jan 2011 16:26
Thanks for the comments guys!

Quote: "- There's an issue with using multiple textboxes."

Ah, I never actually tested using more than one textbox! I'll get back to you on that one...

Quote: "If forms are limited to pre-made images then you'd have to make an image for every form size."

One planned feature is for form resizing (I had it working on a very old draft written in DBC!) so the code will have to be able to generate form images on the fly. I can do that, but you'd be stuck with whatever form styles I gave you the funtions to create - or perhaps I could try and write a scripting system, so at startup you loaded the instructions on how the form should be drawn. I might have to come back to that later on though.

Quote: "- You do an incredible amount of region checks with the mouse, this could be made to just two checks. "

I'm not too sure I follow - I think my code already does what you suggest. The basic outline is:



Or do you mean that even when a component has focus (and so no other can be clicked) I still check every single component for a mouse click? I don't think that's what I'm doing, but I'll double check later.


Quote: "- Don't use DBP stock text commands, they are incredibly slow. "

Actually one of the things I really wanted to do was make sure the library ran without any dependencies - there have been a couple of commands from IanM's Matrix1 collection I'd have loved to have used too. I'm not sure whether it's better to leave it standalone or go for the increased performance these plugins offer!

We spend our lives chasing dreams. Dark Basic lets us catch some of them.
Stab in the Dark software
Valued Member
23
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 30th Jan 2011 00:42 Edited at: 27th Oct 2011 06:50
Quote: "IanM's Matrix1 collection I'd have loved to have used too. I'm not sure whether it's better to leave it standalone or go for the increased performance these plugins offer!"


IanM's Matrix1 collection are probably considered an accepted part of DBPro. I use them in all my projects.

Great Work, I tested your Hardwired example, and I get the same fps either way (250 fps). FYI my resolution is 1920x1080.

[img][/img]


WindowsXP SP3,Vista,Windows 7 SP1, DBpro v7.7RC7
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.
1beginner1
17
Years of Service
User Offline
Joined: 28th Jun 2009
Location: Belgium
Posted: 6th Feb 2011 16:17
Hello

I want to type a number in the textbox that works but how to use it, how to read the number and then do some mathematics with it?
Nice functions
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 7th Feb 2011 15:25
Ok, it's been a week and I think I've managed to iron out all of the bugs. I've also added in error messages - specify an incorrect parameter, and the program terminates using "Exit Prompt" to tell you what has gone wrong. That should also take care of problems with textboxes.

I've also simplified the DG_Add_ functions, so you only have to specify the first image in a run of (say) 3 for regular buttons, or 6 for checknboxes/radio buttons. DG_start() no longer takes any parameters, it assumes that you use the true Windows pointer (Show Mouse), automnatically finds a free bitmap, and assumes that the left mouse button is the default. Finally, I've added in captions so you can add text to the forms/components. It's best to hardwire these otherwise there is a major drop in system performance.

The new demo showcases all of this, and illustrates the use of Palette and Message box forms (click the normal button to make one appear!). Sorry about the poor documentation so far, I'll try and correct that in the next day or so.


@1beginner1
For the moment, the library is largely incomplete while I try and get the core functions working. There will be a command for this, but for the time being you need to run the following code:



This will return the value typed by the user in the variable UserTypedNumber. More accurately, your program loop should look like this:


Hope this helps!

We spend our lives chasing dreams. Dark Basic lets us catch some of them.
1beginner1
17
Years of Service
User Offline
Joined: 28th Jun 2009
Location: Belgium
Posted: 7th Feb 2011 22:52
Ok tnx going to test it in the weekend, got no time right now because of school.
SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 9th Feb 2011 03:12
It would be cool to see minimize and maximize so far so god tho
1beginner1
17
Years of Service
User Offline
Joined: 28th Jun 2009
Location: Belgium
Posted: 9th Feb 2011 17:19 Edited at: 9th Feb 2011 17:19
Ey
Wasn't able to get your code up and running. Like you posted it, I don't understand array very well, but it is working. Only one question why do I need to use Dg_txt(0) for txtNo 1 and Dg_txt(1) for txtNo 2?
Small part of code
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 9th Feb 2011 20:41
@Commico Inc
Jiust curious, do you mean create a Start menu, or go for something like in Linux, where you can shrink a form to is titlebar? That last one shouldn't be too hard, though I'm not sure about any animation. Give me a couple of days...

@1beginner1
Sorry the code didn't work, it might be a bug in DarkGUI. I'll have to look into it, but at least you've got something working! Basically, arrays always start from 0 not from 1, and behind the scenes DG stores everything in numerical order. So, textbox 1 goes into the first array slot (0), textbox 2 goes into the second array slot (1), etc.

We spend our lives chasing dreams. Dark Basic lets us catch some of them.
1beginner1
17
Years of Service
User Offline
Joined: 28th Jun 2009
Location: Belgium
Posted: 9th Feb 2011 21:54
Quote: "arrays always start from 0 not from 1,"

Ok thanks for explainig it, I didn't know that.

Login to post a reply

Server time is: 2026-07-16 04:35:48
Your offset time is: 2026-07-16 04:35:48