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 / DarkGUI for DBC

Author
Message
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 5th Apr 2010 16:25 Edited at: 13th May 2010 11:44
I'm putting together a new function library for DBC, that allows users to easily build Windows-style forms, buttons, checkboxes, textboxes...

The whole system is based around pasting images on screen, rather than calling Windows DLL's, which I think is much simpler to deal with. It has a few nifty features, including component "highlighting" on mouse click and the ability to change your mind about clicking something (most GUI's I've seen seem to log the click as soon as "Mouseclick() = 1", but in mine the click isn't registered until you let go of the mouse afterwards!)

Features already implemented:
Forms (multiple forms, changing order, clicking and dragging, forms always remain in screen)
Forms can now be resized
Buttons (Can be placed anywhere on a form, will automatically detect a click)
Checkboxes (Can be placed anywhere on a form, will automatically detect a click)
Radio buttons (multiple groups supported. Note that a group must only exist on one form)
Textboxes
Panels
Captions

SpinEdit boxes
Sliders
Limited Automation

Instant Click

The latest build of the librry is attached, for a demo, please see Lightning Limbs

Enjoy!

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

Attachments

Login to view attachments
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 5th Apr 2010 17:51 Edited at: 5th Apr 2010 17:56
cool, i'll try this out.

EDIT}}}}}}}}
Windows 95! AIEEEEEEEE!!!!!!!!!!, I mean, rob, this is really cool. Would be useful to some one making an app - Maybe even TDK with his darksprites. i'ma go back a ndy play with it again. ^_^

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 5th Apr 2010 22:17 Edited at: 5th Apr 2010 22:31
It looks pretty good. However, there are a few things that you should change:

Your should windows more dynamic so that it will be easier to code a resizing method for them.

Make the windows less Windoze 95-ish and more Windoze XP-ish or Vista-ish.

You will also need a place for windows to go when they get minimized.

The hardwire perimeter for buttons does not look very useful because there is nothing wrong with the button getting drawn multiple times. It would also be hard to code because if the button were hardwired into the form, your would have to write a separate method for displaying the button pressing state visually (unless your current one is compatible with a hardwired button).
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 6th Apr 2010 18:53 Edited at: 6th Apr 2010 18:54
Sorry about the Windows95 look - they were the only images I had to hand. Actually, you can use any image for the form backdrop, buti haven't gotten round to coding any auto-generate routines!

Quote: "Your should windows more dynamic so that it will be easier to code a resizing method for them."

In theory there isn't anything to stop you from changing the form's image, and defining a new size - I'll add functions to handle that later on. I did write a routine once to produce a "Windows form" (Win-95 only ) image, but I think it might be too slow to use dynamically.

Quote: "You will also need a place for windows to go when they get minimized."

Not quite sure what you mean - do you mean a startmenu/taskbar?

Quote: "The hardwire perimeter for buttons does not look very useful because there is nothing wrong with the button getting drawn multiple times"

The Build Form command is where hardwire comes into its own (it's taking shape on my own computer at the moment). Suppose a form has 1000 buttons on it - thats 1001 images to paste on screen. That would cripple the frame rate!

So, paste all the "default button state" images onto the form image at the outset, and grab that as the default form image. Now, to draw the form + 1000 buttons, we paste just one image! Simple!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 6th Apr 2010 19:07
Quote: "Sorry about the Windows95 look - they were the only images I had to hand. Actually, you can use any image for the form backdrop, buti haven't gotten round to coding any auto-generate routines!"


Hehe.......auto-generate sounds cool.

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 6th Apr 2010 21:13
Quote: "So, paste all the "default button state" images onto the form image at the outset, and grab that as the default form image. Now, to draw the form + 1000 buttons, we paste just one image! Simple! "

What if they are check boxes?

Quote: "Sorry about the Windows95 look - they were the only images I had to hand. Actually, you can use any image for the form backdrop, buti haven't gotten round to coding any auto-generate routines!"

I'll have a go at making some "auto-generating" graphics, I'll post something up if it looks good. I'm guessing from the words you use you feel the graphics should be very customizable for the end-use

Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 7th Apr 2010 16:57
@OBese87
Thanks for the offer, I'd be very grateful! I do want good graphics to ship with DarkGUI, but equally i've set evrything up to be fully customisable. A Windows-style radio button might be what one user wants, but another might want one in neon green - so they simply load their own images!

Quote: "What if they are check boxes?"

I'm really not explaining hardwire well! When the "Build Form" command is complete, it will paste your blank form to an offscreen bitmap. It will then paste every button (normal view), every checkbox and radio button (unchecked views), every panel (static image anyway) and every text caption (this lets you use multiple text fonts - changing font all the time ruins the frame rate). The same image is grabbed again - only this time, the "blank Form" now includes the components.

DarkGUI pastes this one image to screen then checks every component. If it's hardwired, then it skips pasting that image. If the state is changed though (e.g. checkbox has been ticked) then the checked image is pasted as well.

@All
I'm putting some images together for the Vista-look at the moment, so I should have something to show in the next day or so. Semi-transparent forms is possible, I'm sure, but I won't be attempting that!

I've also managed to add in panels, and extended the forms to include "Form Types" - standard forms, palette forms, and message box forms. Messagebox forms do not allow users to click any other form until they are closed/hidden. Palette forms are "floating windows", though drag and dock is not supported as yet. I'll get another demo out soon!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 8th Apr 2010 07:02
I have a question. What about resizing? Have you thought about it? At this point, you are using a form image captured from a 'print screen' button(i'm guessing here) which can't really be resized. Just wondering about how you are going to handle this(or if you are going to)

New Site! Check it out \/
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 8th Apr 2010 14:57 Edited at: 8th Apr 2010 16:01
I've made a nice gradient function

Now I'm going to see what effects I can add to this.

Are there any speed issues with resizing bitmaps? My first thought is to draw one big title bar (the biggest possible) then squeeze it into any size we need. Alternatively (and I think quite a neat idea) it could only use the part of the title bar image that the title bar is on, i.e. if there is a gradient of white to black from left to right and we have a window on the left of the screen its title bar will be mainly white but if we move it to the right it will become more black.
Or this could be an option for the user.

[edit]
Here's a simple effect made by layering one gradient on top of another.
Takes quite a while to generate on my old PC but I'm guessing this would only need to generate once.


[edit]
Woah! I totally messed up the radial gradient but this is pretty funky


[edit]
I am confused, this is as close as I can get to a radial gradient

I don't know why I want to do a radial gradient but it would be cool.

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 8th Apr 2010 17:44 Edited at: 8th Apr 2010 17:47
Oh you apparently are working on 'on the fly' drawings. Ok my question is irrelevant. lol

Obese:

I have a question. Whats i, and imax? When i made a gradient i just used a percentage to figure out the mixed color:

newcolor=color1 + ((color2-color1)*percent#)

percent of course would be 0.0-1.0

New Site! Check it out \/
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 8th Apr 2010 19:20
@Caleb1994
Yes, I'm trying to put together some functions for self-generating form images - I've got a couple already set, but they're for Windows 95/98 (still my favourite OS!)

@Obese
The functions look incredibly complex, I'll have to study these carefully - can't run them right now, I don't have DBC with me .

Scaling a bitmap to redraw the form won't be any good, because the form's border is always 2 or 3 pixels wide. A scaled bitmap would have a scaled border, which wouldn't look too good - it's better and easier to have a single offscreen bitmap the size of the computer monitor, and then draw any size form required directly onto that, grab the image, and use it.

I'll post what I mean later, my Win95 autogen functions were written for DBPro, and I haven't managed to dig them out yet! While a gradient couldn't be applied on the fly - the Ink command destroys a frame rate - I would like to try using it for static forms that don't need resizing!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 8th Apr 2010 20:18 Edited at: 8th Apr 2010 20:26
My function works much like caleb's method.
The imax is the maximum value of i, using a variable allows you to control the smoothness of the gradient, for example if I set imax to 9 then we'd only have 10 colours on the gradient, if I set imax to 999 we'd have 1000 colours on the gradient. i simply tells the function where in the gradient we want to grab a colour from.

I have kept the code quite loose while I'm working on it but I'm sure it can be optimized and simplified.

@Rob
I see what you're saying, so will the forms be "built" by sticking a few images together? i.e. each side of the outer frame and the title bar are all separate images that we cut what we need from and stick them together to make the size window we need. That should be pretty fast because if we store the images off-screen, all the drawing has been done and we just grab what we need and paste it all together.

I also have a rounded box function that might be useful for this.


Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 8th Apr 2010 22:53
Obese:

Oh ok i see what you are doing now! Nice idea!

New Site! Check it out \/
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 9th Apr 2010 00:40
OBese87:
The rounded box function might not work because even if the form image did have rounded edges, it wouldn't be transparent, so the corners of the bitmap image (not the rounded box) would look strange against a background that did not use a solid color. The only way around this would be to re-render the image every time the window is moved to update the transparency of the form.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 9th Apr 2010 01:36 Edited at: 9th Apr 2010 01:37
Quote: "The only way around this would be to re-render the image every time the window is moved to update the transparency of the form. "

Or perhaps, instead of drawing to a screen, draw to memblocks. If the color to be drawn is transparent (black in most cases but you could change this if you draw to memblocks) then instead of drawing black you use whatever the background color for that pixel position is.

In the end you write the memblock as an entire bitmap or as an image.

This also sets up the possibility of alpha blending where you can have semi-transparent overlays.

Enjoy your day.
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 9th Apr 2010 01:40
Quote: "(still my favourite OS!)"


95.........?????
What about Windows "Me" ?
It was pretty good, better than Vista/XP to me.(Dunno Why.)

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 9th Apr 2010 03:53 Edited at: 9th Apr 2010 03:54
@Sinani
You can paste images with transparency so it would just ignore the corners.
Or like latch says you could do it with a memblock and just not draw on those pixels.

Quote: "semi-transparent overlays"

Feature creep has officially begun!
That would be pretty cool though.

PS
I think memblocks are great for this sort of thing. I began a GUI thingy a while ago and converting it to memblocks made such a speed increase.

Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 9th Apr 2010 06:09
Quote: "I began a GUI thingy a while ago and converting it to memblocks made such a speed increase."


Are you talking about this? I don't remember you using memblocks for that. I have no idea how memblocks work, so if those would work for this application, then that would be great!
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 9th Apr 2010 19:00
@Sinani
You're right, I never converted that to memblocks
I must have been thinking of something else.

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 10th Apr 2010 05:11
@RTR

Where did you get the Win95 images?

Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 10th Apr 2010 07:10
Can you upload a .txt file of the source code for this program. Right now i'm on an android phone and i can't open up the zip file that you attached. I thought I might be able to work on it, even though I don't have a compiler with me.
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 11th Apr 2010 16:56
Haven't had a chance to get online the last few days, but I have managed to complete the new demo. It's attached to the first post and you can now resize forms (provided you like the Win95 look )

@Sinani201
Sorry, but the demo needs the included image files. I've attached the source code to this post, though, as a.dba for you to have a look at.

@Dark Dragon
The Win95 images come from Delphi - even on XP everything appears in the Win95/98 style. I never actually got to use Win ME, the only versions I've known are Win 3.1, 95, 98, XP and now Vista.

I still think 95/98 are the best - they were so simple to use, and looked quite stylish. XP was OK, once I set the default skin to look like Win98, but Vista is quite good...

@Obese
Quote: "I see what you're saying, so will the forms be "built" by sticking a few images together?"

Not quite - take a look at the DG_AG_Win95_Form function in the new demo (3rd from the end) and you'll see how I build forms using the 2D command set - it's just lines, box and CLS.

It seems to run quite fast, with no perceptible loss of frame rate (don't know how that will change when I add in the hardwire mode though!)

@All
Forms with rounded corners are easy to add in - just make the corners RGB(0,0,0) and set any other black parts to be RGB(1,1,1). The new "black" doesn't look any different, and so won't vanish!

I like the idea of semi-transparent overlays - the Vista Aero look would be a cool feature - but I'm not sure about the use of memblocks. I've never quite got them to work, except as a list of data entries when arrays actually proved faster!

Oh, one more thing - any ideas what I could use as an alternative to "Text Width()"? It runs a bit slow and the textbox routines I've writtne make extensive use of it!

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

Attachments

Login to view attachments
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 12th Apr 2010 03:15
Quote: "Forms with rounded corners are easy to add in - just make the corners RGB(0,0,0) and set any other black parts to be RGB(1,1,1). The new "black" doesn't look any different, and so won't vanish!"


Wouldn't it be easier just to make the corners (1,1,1) instead of 0? Or is the transparent color always black?
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Apr 2010 05:11
Quote: "is the transparent color always black? "

Yes. That's one advantage of memblocks, since you are writing the data you can use any colour as transparent, just check for that colour and don't write it to the memblock.

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 14th Apr 2010 01:37
Quote: "Forms with rounded corners are easy to add in - just make the corners RGB(0,0,0) and set any other black parts to be RGB(1,1,1). The new "black" doesn't look any different, and so won't vanish!"

Just check 16 bit and make sure the new black is not transparent.

Quote: "Oh, one more thing - any ideas what I could use as an alternative to "Text Width()"? It runs a bit slow and the textbox routines I've writtne make extensive use of it!"

Possibly store a table of font sizes as the fonts are changed tied directly to the font name so that you can look up the widths, heights, etc. You might use a key letter or an average of letters to set the fixed size. For example when the font is changed and a size is set, use text width("Q") as the base width for all of the characters of that font at that font size. Store it all in a table for reference later whenever you have to do any more sizing.

You get the final size by the length of the string * the stored font width.

Don't know if it'd be faster. The lookup table part might be, but getting the length of the string and multiplying it might not be. And it would result in fixed width sizes. There's quite a difference between an "i" and a "Q" depending on the type face.

Enjoy your day.
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 14th Apr 2010 11:28
@Latch
I did consider that, but I'm not sure if that would be too restrictive. My current code for working out where the cursor has been placed is:


whic works perfectly but calls Text Width around 240 times if 60 letters are on show. Also, my algorithm for working out howmany characters to show leaves a little to be desired, as it works through one letter at a time:


(DG_txt(n, 16) = First char shown, DG_Txt(n,17) = Num chars shown)

Basically, I just start with the entire remaining text string beyond the first character, and keep rempoving one letter until the string will fit in the textbox graphic.

I've been looking into binary sorts for the first one, as that could allow me to locate the clicked letter within about 6 checks for 60 letters on screen.

For the second, I suppose something similar might work until the number of characters was about right, and then switch to one letter at a time to fine tune it. I'm just struggling to get the algorithm working - it' strange, but the DB forums have a fair few thread on sorting, but very little about searching!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 1st May 2010 16:46
Ok, it's taken far longer than I thought it would to get textboxes implemented, but they are finally complete. The new demo is attached to the first post, and it includes a greatly enhanced library - for the first time, DarkGUI is in a useable state.

I used to make textboxes show text by calculating how many characters would fit in the textbox from the current start character, but I found it was faster (i.e. used fewer "text width()" commands) to render the text to an offscereen bitmap, grab an image, and paste that into the textbox instead. It also means that multiple fonts may be used, although DG must be informed of what the current font actually is (DG_Set_Text_Font), and no font changes should be affected afrter a call to DG_Click_Update().

Textboxes trigger a slight slow down in frame rate if text is input too rapidly - I'm aware of a fall from 380 to 340 fps on my computer (running in a 1280x1024 display mode). I have considered adding in a timer, so that the text bitmap only gets updated say once every 100ms, but that might trigger a stutter - what do you think?

Hardwire is also in (at last), though the demo doesn't show it off at its best. The radio buttons are hardwired in (last parameter = 1), which means that the default, unchecked image - the empty circle - is pasted as a part of the form image. If you have 50 of these radio buttons onm a form, only one will ever be checked. Ordinarily, DG would paste the form backdrop image, then the 49 radio buttons and finally the 1 checked radio button, a total of 51 Paste image commands. If the blank images are hardwired, they are a part of the form image, so DG simply pastes the Form and then the checked image - a total of 2 paste image commands. Might sound silly, but in tests on my PC with 50 radio buttons I can push the frame rate from about 280 back to 360fps.

Enjoy the new code library!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 13th May 2010 11:44
Ok, I think DarkGUI is almost ready to roll. The library has undergone a major transformation, and although spin edit boxes need tearing apart so I can throw in the optimisations I made to textboxes, I think the functions are mostly complete. The DG_AG library is still sadly lacking, but I aim to build that up steadily from now on. I'm also fixing minor flaws in DG as I go, but it all seems to work well.

We now have:
Sliders
Captions
Panels
Optimised textboxes for higher frame rate
Groups (allowing multiple forms, byuttons, etc. to be linked together and shown or hidden by calling a single command)
Instant Click (buttons trigger a click as soon as the mouse is pressed - still a little buggy)
Auto Update (DG will automatically hide a form, end the program, show a button, etc. wehen one component is clicked. It's a bit like DG automatically handling the "X" to close a form, rather than having you write code to check for the click and then Hide the form)

The latest build of the library has been uploaded in the first post (though without any demos - for that you should see Lightning Limbs ). Enjoy!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 28th May 2010 04:53
Could you please upload a example here? Something simple. Just one window with one or two children. I skimmed through the code, but am still not sure about how to use it. It looks great, but I would like to see a example!

New Site! Check it out \/

Login to post a reply

Server time is: 2024-04-23 17:00:52
Your offset time is: 2024-04-23 17:00:52