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 Discussion / Dark Windows

Author
Message
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 7th Dec 2008 16:44
Hi guys! It's been a while since I've been around here, but I'm just getting back into DB and computer programming. The last project I was working on, Lightning Limbs 1.1, fizzled out to nothing becuase I got fed up spending most of my time specifying the screen coordindates needed for users to click buttons and stuff.

So, last week I started work on a new project to make GUI building far simpler - Dark Windows. I'm not smart enough to access the Win Api dll (I think that's the one, anyway) to place true Windows components on screen, but I have found a way to simulate them in DB using simple bitmap images.

So far, I've only managed to implement buttons in the style of the familiar "OK" and "Cancel" buttons, but the whole Dark Windows system is very flexible and has a lot of room for expansion. When complete, I'm intending to have a full-fledged Windows GUI system, allowing you to add checkboxes, radio button groups and text boxes in just two or three lines of code.

I've attached a demo illustrating what I've got so far - just remember, to run the program you'll need the two images in the Zip file as well. There's also a pdf file with an explanation of how the commands work.

Anyone interested?

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Not_Maindric
18
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 7th Dec 2008 16:54
Not bad. I like it. Looking forward to seeing it advance. =D

Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 7th Dec 2008 17:13 Edited at: 7th Dec 2008 17:16
Quote: "The last project I was working on, Lightning Limbs 1.1, fizzled out to nothing becuase I got fed up spending most of my time specifying the screen coordindates needed for users to click buttons and stuff"

Don't bad mouth a quality program!! Especially after we twisted our brains in knots working on quaternions! I'm still waiting for lightning lights to be modified into a level editor with lightning limbs paired as an animator.

Looking over your code a bit... Just curious: why did you use a memblock instead of an array to store your info? To avoid having to include a global array perhaps?

Enjoy your day.
steve paul thomas
17
Years of Service
User Offline
Joined: 4th Nov 2008
Location: United Kingdom
Posted: 7th Dec 2008 17:19 Edited at: 7th Dec 2008 18:30
@Robert The Robot

This is a very good idea. Using coordinates for click testing is very tedious.

I like the way you have implemented the "move the mouse away to abort" functionality that you see in real Windows command buttons when you keep the mouse button down and drag away.

Good work

P.S. Also, I think the DLL you mean is comctl32.dll (Common Controls). Not used DLLs myself, but reading your post I wondered if it was possible to draw and control a button with a dll. Have found this on msdn:

http://msdn.microsoft.com/en-us/library/bb775493(VS.85).aspx

http://msdn.microsoft.com/en-us/library/bb776779(VS.85).aspx

Wouldn't know how to handle any of this from DB though, but figure its probably possible.

I don't Adam and believe it!
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 7th Dec 2008 22:27 Edited at: 7th Dec 2008 22:29
@Latch
Quote: "Don't bad mouth a quality program!!"

I suppose you're right, in a way! But I'm afraid I did lose interest in LL because I realised I was spending most of my time just updating screen coordinates and adding virtually no new features. The real killer on the project was when I did the screen coords, then wanted to add a new button on the toolbar and had to redo everything.

That's the reason I started on Dark Windows - I've been after these functions for the last twelve months, and now I've finally managed to figure out most of it - it's all down on paper at the moment

Quote: "Looking over your code a bit... Just curious: why did you use a memblock instead of an array to store your info?"

Primarily because it would be a more efficient use of memory. For instance, when you create a 2d array (e.g. Array(2, 5)) you can actually write an integer to position Array(0), Array(1) and Array(2). Since these positions are never needed, they're just clogging up RAM.

The other reason is that anything involving memblocks runs blindingly fast (although I've never tested how they compare to arrays).


@Steve Paul Thomas
Quote: "I like the way you have implemented the "move the mouse away to abort" functionality that you see in real Windows command buttons "

Glad you like it

Quote: "Using coordinates for click testing is very tedious."

It sure is...

Quote: "I wondered if it was possible to draw and control a button with a dll."

I'm not entirely sure, it's not something I've ever properly looked into. I think Latch may have done it, though - I'm sure he once mentioned a 3d animation package he'd been working on that used proper Windows components. Might be wrong though...

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Dec 2008 02:34
Quote: "I'm not entirely sure, it's not something I've ever properly looked into. I think Latch may have done it, though - "


Yeah... The thing with buttons is that they are actually a little window. Creating a window using the win32 api requires more DLL function parameters than DBC can handle... there's a way around that, but the best bet is to create a custom DLL using the win32 api that has your own function(s) that work(s) out of the box with DBC. DBC runs in a Windows environment so all of the tools of Windows are available. Just takes some work.

Quote: "I'm sure he once mentioned a 3d animation package he'd been working on that used proper Windows components"


Once I got the Windows menu system working, got list boxes working, figured out how to keep message boxes and open/save dialog boxes from wiping out the background when they are dragged, I ran out of steam on the project. I put so much effort into getting the actual Windows portion working, I was barely interested in continuing - and lightning limbs was available - so the project is still sitting there looking at me.

Also it made me think that the Windows environment itself was taking something of me away from the project. Here I was making things work the way Windows has decided things should work. It's a good interface, no doubt, but there's something to building one's own interface...

It'll be great to see where you go with this! Keep up the good work.

Enjoy your day.
steve paul thomas
17
Years of Service
User Offline
Joined: 4th Nov 2008
Location: United Kingdom
Posted: 8th Dec 2008 04:26 Edited at: 8th Dec 2008 04:36
Latch said:
Quote: "
The thing with buttons is that they are actually a little window. Creating a window using the win32 api requires more DLL function parameters than DBC can handle...DBC runs in a Windows environment so all of the tools of Windows are available. Just takes some work."


@Robert The Robot

Looks like your Dark Windows Functions will certainly reduce the time needed, and hopefully simplify what is needed to get quite sophisticated windows-like controls into apps made with DBC.

The PDF and example show just how simple you have made it. Great work, so far


Quote: "
Also it made me think that the Windows environment itself was taking something of me away from the project. Here I was making things work the way Windows has decided things should work. It's a good interface, no doubt, but there's something to building one's own interface...
"


Before I say anything else, I must point out that some of what I have written below leans to personal preference. That in mind, please take the words as ideas rather than me saying what is right or wrong. Onwards...

That does seem to be a good point. Perhaps it is sometimes better to break away from the standard look-and-feel and established GUI elements and invent what you feel is suitable/appropriate to what it is that you are developing.

Lets say you were developing a game with a medieval theme. A "button" that looked like a sword with its purpose engraved on it would look much more appealing and more fitting than a simple windows command button (in my opinion).

However, there are times where forms, buttons, checkboxes, etc have their place/make sense to use. For things such as editors and map-makers,etc (applications). Not that I am saying that you can't have a custom GUI/interface for your editor, only that sometimes it seems right to use windows-like controls for applications. (IMO)

Even DBC's default development environment (DB.exe) would have benefited from looking and acting like a Windows application (my opinion creeping in again).

Of course, its entirely up to the developer as to what they think is best suited for their program.

I don't Adam and believe it!
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Dec 2008 16:28 Edited at: 8th Dec 2008 20:37
@steve
If you hadn't put that disclaimer in there I would be fuming!! Just kidding!

I suppose I differentiate between "point and click" and an environment encapsulated in a Windows facade; so I appreciate someone tackling the task of creating a GUI.

Enjoy your day.
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 8th Dec 2008 16:58 Edited at: 8th Dec 2008 16:59
I think you're right saying that Windows components and custom GUI elements each have their own places, but I can't help feeling that behind the scenes they will always behave in the same way - a button is a button, after all.

For instance, taking Steve's example of a sword button, it's still going to behave like a Windows 'OK' button - you click it, something happens to highlight the click, and on the release of the mouse button the sword will execute its task.

Part of the beauty of using custom DB code to generate windows style components is that you aren't limited to what's in the standard dlls. With DBC you can change your images, and turn a grey rectangle into a silver sword - all it takes is a little thinking 'outside the box'.

Actually, talking about this has made me realise - I ought to have added an extra byte so you could control button transparency. It wouldn't do to have that sword button on a black rectangle that obscured the backdrop, would it

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
steve paul thomas
17
Years of Service
User Offline
Joined: 4th Nov 2008
Location: United Kingdom
Posted: 8th Dec 2008 17:15 Edited at: 8th Dec 2008 17:49
Quote: "If you hadn't put that disclaimer in there I would be fuming!! Just kidding! "


LOL! Well after proof-reading what I wrote, I thought I'd better make a statement like that or I'd get slapped in the face with a load of flames.


Robert The Robert is doing a great job.


If I was making a map editor for my own use, then I probably wouldn't be too bothered about its appearance. It would be nice to be able to drop some code into it that sets up some buttons or checkboxes. I could then focus on adding the subroutines that go with the onclick, etc events and quickly kick out a tool for knocking up maps.

If others would use it, I *might* think about making a custom GUI. Just to make it fit in with the game's theme/motif.


If I was just making an application, such as a paint program or text editor then I would probably lean towards a more MS Windows look. Simply because when you use an application like this, your productivity increases if you can just quickly do things by using a familiar interface. This article (although old) is a good one:

Principles of good GUI Design

I'm not saying that the user couldn't take some time to learn a custom GUI and then be efficient with it. Its whether you want them to spend time learning a new layout, set of components, etc or to just allow them to get on with whatever it is they want to do.

Just some ideas on the benefits of both "standard" and "custom". Also I'm no expert on this as such, just some common sense that I take with me when making projects.


Quote: "I ought to have added an extra byte so you could control button transparency. It wouldn't do to have that sword button on a black rectangle that obscured the backdrop, would it"


Definitely a good idea

I don't Adam and believe it!
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 8th Dec 2008 22:10
@Steve
Very interesting article, I'll be keeping a fair bit of that in mind for future applications. You've also got some very good ideas yourself...

@Everyone
Ok, I think I can say that 'Windows buttons' are finished, and with a whole host of new functions. I get a comfortable 31 frames a second with 255 buttons being drawn on screen each refresh, so that's probably the recommended limit (1000 buttons makes the fps fall to 11).

Button transparency has been added, although to do it I had to sidestep another glitch in DB1.20. Paste image comes with an optional transparency parameter, but when it's in place you can't actually disable the transparency. "Paste image 1, 50, 50, 1" makes the image transparent, but so does "Paste image 1, 50, 50, 0" and it's not supposed to!

Anyway, I've attached the new functions library, with a pdf of the full Windows button command set (I'm afraid the contents hyperlinks don't work perfectly, they only take you to the page where the command is detailed and not to the relevant portion of the page).

I still need to go through the code and optimise it, there are several unnecessary calculations being performed in the minor functions, and I want to see if I can tidy up the main Click and Draw functions a bit. I'll hang fire on that, though, in case anyone has any suggestions for improvements for this set of commands.

Oh, and you'll notice that the demo program has the two buttons overlapping this time. This is a situation that shouldn't ordinarily arise, but Dark Windows can still handle it - the top button will be clicked before the lower button is. Next up, checkboxes...

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Dec 2008 23:20
Quote: "Button transparency has been added, although to do it I had to sidestep another glitch in DB1.20. Paste image comes with an optional transparency parameter, but when it's in place you can't actually disable the transparency. "Paste image 1, 50, 50, 1" makes the image transparent, but so does "Paste image 1, 50, 50, 0" and it's not supposed to!"


For non transparency, don't use ,0 just leave it blank
paste image <img>,x,y




And in case you weren't aware, function calls can be pretty slow. If you are changing the attributes of a button, it would be better to have one function call with a list of attributes to change. For example, you have individual x and y positioning which could equal 2 function calls for every change in a position.

The same for the return parameters. It's more efficient to use a memblock or an array to return multiple attributes with one function call instead of multiple function calls.

Enjoy your day.
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 10th Dec 2008 17:28
Hi Latch!

I see what you mean about Paste image - I checked in DB1.13, and the mere presence of that fourth parameter is enough to set the images to transparent. I must have misremembered how the command worked!

Anyway, I've been running some tests on the time taken for the DW functions to execute, but I'm not really getting any slow downs. This code:



gets executed in around 0 to 16ms, although it's hard to say because the timer keeps flickering.

Calling this code:


gives a time of around 50ms, so each function is taking about 0.000454ms (it's so tiny, the timer difference for a single function shows as zero!)
I'm curious - could you try dropping these code snippets into the DW demo's main Do-Loop and let me know what times you get?

I must say I'd prefer not to have to merge all the settings commands down into just one command, one of the things I hate about the Set Object command is that you can't alter the parameters individually and there are so many that I can never remember what order the parameters go in!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 11th Dec 2008 18:20
On the second snippet it averages to about 60ms on my machine.

Quote: "I must say I'd prefer not to have to merge all the settings commands down into just one command"


Don't get me wrong. Your function set is great! It's not really necessary to merge anything, just if you want optimal performance, you'll want to make as few function calls as possible. For every function call, the current line count has to be stored, the address of the function has to recalled, the program jumps to the function and executes it, then jumps back to line from where it was called. The jumps back and forth and the pushing and pulling of stack information takes up some time (though in most cases it's negligible).

If you could even combine a few, like the x and y positioning as one, you can eliminate a function call.

It comes down to use vs performance. You could tweak it until the end of time getting as much performance out of it as you want but in the end, maybe you end up with one function call with 200 parameters! That doesn't make any sense for ease of use.

Quote: "...I hate about the Set Object command is that you can't alter the parameters individually and there are so many that I can never remember what order the parameters go in!"


I know! I have to look it up every single time I use it!

Enjoy your day.
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 11th Dec 2008 22:12
Quote: "For every function call, the current line count has to be stored, the address of the function has to recalled, the program jumps to the function and executes it, then jumps back to line from where it was called. The jumps back and forth and the pushing and pulling of stack information takes up some time (though in most cases it's negligible)."

Ah, I see what you mean. thinking about it, I ought to combine the XY positioning functions into a single command, and possibly the three Image parameters down to one command as well.

What if I was to add an extra command to the set where every parameter can be changed in one go? That would leave you with the option of individual adjustments, but also faster execution if the speed proved to be an issue...

Quote: "I know! I have to look it up every single time I use it!"


"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 14th Dec 2008 16:33
Ok, here's a new component for Dark Windows - we have Radio Buttons!

The command set isn't quite complete - I haven't yet produced the "return value" functions as I'm in the middle of setting up error checking for all the functions in the Winows button library I posted earlier. However, I'm posting what I've gotten so far.

When you run the attached demo, you'll see 100 radio buttons randomly scattered on the screen but only one may be selected at any time. This command set also gives you the ability to set up groups of radio button, like the ones seen on the "Edit - Options - Media Options" tab of DarkEdit.

The three numbers on the right hand side of the screen are (reading down) the current screen fps, the time in ms taken for "Sync : CLS" to execute, and the time taken for both the DW Click and draw functions to execute - note that this never rises above 0!

Fuoll documentation of the commands will follow, but if you just read the function names and the various parameters, I think you'll get the idea of what everything does. Enjoy!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 1st Jan 2009 16:21
Hi guys! Happy New Year!

It's been a while since I posted on this (this has fallen to the second page! ), so I thought I ought to let you how things were going. The code for the standard message box buttons is in pieces at the moment (I'm hoping to get it back together and fully optimised in the next week or two).

However, I've got Windows Radio Buttons and Windows Checkboxes fully functional. The source code and full documentation is included in the attached zip file, along with a demo of the components. Hope you like them!

You'll notice that (like true windows components) the buttons are highlighted when you click them. I have plans for a duplicate set where this 'flicker' is permanently disabled - it could be done by just setting the highlighted images to be the same as the normal/clicked images, but I like to give myself a hard time

Also in the pipeline are textboxes and possibly a medialess colour palette, but I'm open to other suggestions!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Digital Demolition
19
Years of Service
User Offline
Joined: 8th Oct 2006
Location: Minnesota
Posted: 17th Jan 2009 09:34
Robert you are the man!!!!..
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 19th Jan 2009 19:06
Quote: "Also in the pipeline are textboxes and possibly a medialess colour palette, but I'm open to other suggestions!"

How about list boxes or combo boxes with drop down controls? Check out the latest DBC challenge for list box/text box ideas. Phaelax created a pretty slick sizeable/movable text box.

Enjoy your day.
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 19th Jan 2009 21:10
Quote: "Robert you are the man!!!!.."

I assume you liked the command set...

Quote: "How about list boxes or combo boxes with drop down controls?"

I'll bear that idea in mind, though it may be a while before I can add them. I'm currently in the process of completely rewriting DarkWindows so that everything works from just one memblock.

I tried adding in forms to the existing system, and I found I'd have had almost no way of keeping track of where each component went, whether it was visible o not, etc. So I just tried to come up with a more logical system, and I think I've got it. It's also semi-modular, so quite flexible and easy to extend! Will post a demo as soon as I can get the code working!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."

Login to post a reply

Server time is: 2026-07-05 01:47:15
Your offset time is: 2026-07-05 01:47:15