News:

*NEW* Current Version on STEAM16.793

Webchat:
Visit the chat



gui

Previous topic - Next topic

Guest

Hi,
are there plans to add GUI capabilities to GLBasic?

Like adding GUI Buttons, GUI List etc.?

There are several SDL based GUI's like aedgui, wgui, paragui etc.

Also this way you could use GLBasic for cross platform Application (non games programs) programming.

This would really be so cool, and blow all other Basic's away.

In this case I would consider to buy GLBasic as well (and promote it of course).

Kitty Hello

Then you would have to be able to resize a window as well as creating other new windws...
Hmmm... I've been thinking about a simple gui (buttons, edit boxes, dropdown boxes) for a game options menu. However, if I would write one, I'd do it in GLBasic, so you can extend it freely.
Here's a simple file selector. Maybe it's of some help? It's not really designed for extendability, however.

Code (glbasic) Select
// --------------------------------- //
// Project: FileDialog - a nice OpenGL File Dialog
// Start: Saturday, November 22, 2003
// IDE Version: 1.31120

// Simply insert this file into your project and call:
// name$ = FileDialog$("*.bmp", TRUE, 100, 100, 250, 220)
// IF name$="NO_FILE" THEN UserSelectedNothing()


FOR i=0 TO 40
DrawButton(RND(640)-120, RND(480)-80, RND(640-120), RND(400), RGB(224, 224, 224+RND(31)), RGB(128, 128, 128+RND(127)), RGB(64, 64, 64+RND(128)))
NEXT

FILLRECT 0,0,320,240,0

// Call the file dialog
name$ = FileDialog$("*.bmp", TRUE, 0, 0, 320, 240)
// Debug the file name
PRINT name$, 0, 100
SHOWSCREEN
MOUSEWAIT

// ------------------------------------------------------------- //
// -=#  FILEDIALOG  #=-
// ------------------------------------------------------------- //
FUNCTION FileDialog$: filter$, must_exist, pos_x, pos_y, size_x, size_y
// Diese Variablen sind als LOCAL definiert:
// open, filter$, filename$,

LOCAL files$[], i, offset, old_dir$, font_x, font_y, num, max_file, max_text, max_show
LOCAL r_width, displ$, mx, my, b2, b1
LOCAL name$, n_selected, curdir$
LOCAL c_lite, c_norm, c_dark

LOADFONT "filereqf.bmp", 2
SETFONT 2

r_width=12 // Width of ruler
c_lite = RGB(0xc0, 0xd0, 0xff)
c_norm = RGB(0xa0, 0xc0, 0xe0)
c_dark = RGB(0x40, 0x40, 0xa0)

USEASBMP // Store current back buffer for drawing
old_dir$ = GETCURRENTDIR$()

GETFONTSIZE font_x, font_y
// Buttons...
size_y = size_y - font_y*4 - 13 - 1// - 6
pos_x=pos_x+6
size_x=size_x-font_x
pos_y=pos_y+6+font_y+1

sort_n_show:
offset=0
n_selected=-1
num = GETFILELIST(filter$, files$[]) // For return value see manual
max_show=INTEGER(size_y/font_y)
max_file=BOUNDS(files$[], 0)-1
max_text=INTEGER((size_x-r_width)/font_x)

FOR i=0 TO INTEGER(num/0x10000)-1 // mark directories
files$[i] = "/"+files$[i]
NEXT
curdir$=GETCURRENTDIR$()
IF LEN(curdir$) > max_text+1
curdir$ = "..."+MID$(curdir$, LEN(curdir$)-max_text+3, max_text-3)
ENDIF

WHILE TRUE
PRINT num, 0, 0
// Dialog:
DrawButton(pos_x-6, pos_y-font_y-6, size_x+12, size_y+font_y*4+13, c_lite, c_norm, c_dark)
DrawButtonText(curdir$, pos_x, pos_y-font_y-5, size_x, font_y+2, c_dark, c_norm, c_lite)

// Input
caret=caret+1
displ$=name$
IF MOD(caret/30, 2)
displ$ = displ$+"|"
ELSE
displ$ = displ$+" "
ENDIF
PRINT "File:", pos_x+font_x, pos_y+size_y
DrawButtonText(displ$, pos_x+font_x, pos_y+size_y+font_y, size_x-2*font_x, font_y+2, c_dark, c_norm, c_lite)

// OK / Abort
DrawButtonText("OK", pos_x+font_x, pos_y+size_y+font_y*2+5, size_x/3, font_y, c_lite, c_norm, c_dark)
DrawButtonText("Exit", pos_x+size_x*2/3-font_x, pos_y+size_y+font_y*2+5, size_x/3, font_y, c_lite, c_norm, c_dark)

// List show
DrawButton(pos_x, pos_y-1, size_x, size_y+2, c_dark, c_norm, c_lite)
fin = max_file
IF fin>=offset+max_show THEN fin=offset+max_show-1
FOR i=offset TO fin
IF n_selected = i
FILLRECT pos_x, pos_y+(i - offset)*font_y, pos_x+size_x-r_width, pos_y+(i - offset + 1)*font_y, c_dark
ALPHAMODE 1
ENDIF
displ$ = files$[i]
IF LEN(displ$) > max_text
displ$ = MID$(displ$, 0, max_text-2) + ".."
ENDIF
// Draw folder-icon
IF MID$(displ$, 0, 1) = "/" THEN displ$ = "<" + MID$(displ$, 1, 2048) + ">"
PRINT displ$, pos_x+1, pos_y+(i - offset)*font_y
ALPHAMODE 0
NEXT

// Ruler
FILLRECT pos_x+size_x-r_width, pos_y, pos_x+size_x-2, pos_y+size_y, c_dark
rul_size = max_show / max_file
IF rul_size<1 // not all files visible
r_len = (max_show/max_file)*(size_y-font_y)
r_top = (size_y - 2*font_y - r_len) * (offset/(max_file-max_show)) + font_y
DrawButtonText("}", pos_x+size_x-r_width, pos_y, r_width-1, font_y-1, c_lite, c_norm, c_dark)
DrawButtonText("{", pos_x+size_x-r_width, pos_y+size_y-font_y, r_width-1, font_y, c_lite, c_norm, c_dark)
DrawButton(pos_x+size_x-r_width, pos_y+r_top, r_width-1, r_len, c_lite, c_norm, c_dark)
ENDIF

MOUSESTATE mx, my, b1, b2

STARTPOLY -1
POLYVECTOR mx, my, 0,0, c_lite
POLYVECTOR mx+10, my+18, 0,0,c_norm
POLYVECTOR mx+20, my+27 ,0,0,c_norm
POLYVECTOR mx+27, my+20 ,0,0,c_norm
POLYVECTOR mx+18, my+10 ,0,0,c_norm
ENDPOLY

mx=mx-pos_x
my=my-pos_y
IF b1
bn_clicked=0
IF mx>size_x-r_width AND mx IF my>=font_y AND my<=size_y-font_y // Ruler
offset = INTEGER(( (my-font_y)/(size_y-2*font_y) ) * max_file)
ELSE
IF my>0 AND my IF my>size_y-font_y AND my ENDIF
IF offset>=max_file-max_show THEN offset=max_file-max_show
IF offset<0 THEN offset=0
ELSE // Main window clicked?
IF mx>0 AND mx i = INTEGER(my/font_y)+offset
IF i>=0 AND i<=max_file
name$ = files$[i]
n_selected=i
bn_clicked=1
ENDIF
ENDIF
// OK / Cancel
IF my>size_y+font_y*2 AND my IF mx>0 AND mx IF mx>size_x*.66 AND mx ENDIF
ENDIF
ELSE // Mouse released??
SELECT bn_clicked
CASE 1
IF MID$(name$, 0, 1)="/" THEN GOTO change_folder
CASE 2
IF (must_exist AND DOESFILEEXIST(name$)) OR must_exist=FALSE THEN GOTO on_ok
CASE 3
GOTO on_cancel
ENDSELECT
ENDIF

IF KEY(14)
IF ky_hold=0 // Backspc
i=LEN(name$)-1
IF i<0 THEN i=0
name$ = MID$(name$, 0, i)
ENDIF
ky_hold=14
ELSE
IF KEY(28)
ky_hold=28
GOTO on_ok // Enter / OK
ELSE
ky_hold=0
name$=name$+INKEY$()
ENDIF
ENDIF
SHOWSCREEN
WEND

change_folder:
IF MID$(name$, 0, 1) = "/"
name$ = MID$(name$, 1, 2048)
SETCURRENTDIR(name$)
ENDIF
GOTO sort_n_show

on_cancel:
BLACKSCREEN
SETCURRENTDIR(old_dir$)
RETURN "NO_FILE"

on_ok:
LOADFONT "", 2
SETFONT 0
BLACKSCREEN
SETCURRENTDIR(old_dir$)
RETURN GETCURRENTDIR$() + name$

ENDFUNCTION // filename$

FUNCTION DrawButtonText: t$, px, py, dx, dy, c1, c2, c3
LOCAL fx, fy
DrawButton(px, py, dx, dy, c1, c2, c3)
GETFONTSIZE fx, fy
px = px + (dx - LEN(t$)*fx)/2
py = py + (dy - fy)/2

c1=RGB(255,255,255)
SELECT t$
CASE "{"
DRAWLINE px+fx/2, py+fy/3,   px,    py,      c1
DRAWLINE px+fx/2, py+fy/3,   px+fx, py,      c1
DRAWLINE px+fx/2, py+fy*.83, px   , py+fy/2, c1
DRAWLINE px+fx/2, py+fy*.83, px+fx, py+fy/2, c1
CASE "}"
DRAWLINE px+fx/2, py,      px,    py+fy/3,   c1
DRAWLINE px+fx/2, py,      px+fx, py+fy/3,   c1
DRAWLINE px+fx/2, py+fy/2, px   , py+fy*.83, c1
DRAWLINE px+fx/2, py+fy/2, px+fx, py+fy*.83, c1
DEFAULT
PRINT t$, px, py
ENDSELECT
ENDFUNCTION

FUNCTION DrawButton: px, py, dx, dy, c1, c2, c3
FILLRECT px, py, px+dx, py+dy, c2
DRAWLINE px, py, px+dx-1, py, c1
DRAWLINE px, py, px, py+dy-1, c1
DRAWLINE px+dx, py+1, px+dx, py+dy, c3
DRAWLINE px+1, py+dy, px+dx, py+dy, c3
ENDFUNCTION

Kitty Hello

Yep, there it is: A GUI for GLBasic written 100% in GLBasic:
http://www.glbasic.com/showroom/data/DDgui.php?lang=de

goomoo

Perhaps the PureBasic is more fitter with you.
http://www.purebasic.com
http://www.purearea.net