[MODULE] A very small windows system (with Drag&Drop and resizing)

Started by Monsieur OUXX, Tue 11/06/2013 00:24:21

Previous topic - Next topic

Monsieur OUXX

What does it do?
- This allows to create small windows, as if you were in your favorite OS.
- They have a title bar
- They are skinned (borders+background) -- in the screenshot, Dennis is a window with a transparent shape. You can create as many styles as you want.
- you can do drag&drop to move them and resize them
- the window with the focus is on top of the others (z-buffer)

Why not just use built-in AGS GUIs?
This allows you to do things similar with playing with GUIs (moving them around, using Z-order, etc.), except all the windows here are drawn to a surface of your choice. For example you can have all your small windows drawn to the background of a GUI, or to the room's background.
This lets you have more control over what you draw and where you draw it.
Also this is an open door to infinite refinements if you decide to expand the code (frames, new controls, etc.).
Finally, you can have hundreds of windows (if you used GUIs you'd be blocked by AGS built-in GUIs and Controls upper limit)

No, seriously, why not just use built-in AGS GUIs?
Do as you like.

Is this module any good?
No. Performance-wise, it probably doesn't scale up well. Also the code is not optimized at all, and probably badly written in some places.
But this is still a nice little piece of script if you needed a primitive windowing system (to simulate a computer screen, etc.) but were too lazy to create it.


DOWNLOAD (version 1.0)


Manual
See "Windows.Test()" for the most simple code snippet in the universe.

Compatibility: Made with AGS 3.2.1
 

Ghost

This looks fun. Can I actually have GUI elements (labels, buttons et al) on them, or some means to catch a click and process it? Or is this "just" to display images?

Monsieur OUXX

Quote from: Ghost on Tue 11/06/2013 01:12:16
This looks fun. Can I actually have GUI elements (labels, buttons et al) on them, or some means to catch a click and process it? Or is this "just" to display images?

Yes, you can do it yourself rather simply, but it's not implemented -- but here is how I intend on doing it for version 2:
- either you draw your own controls and use the boundaries detection functions already present in the code to intercept clicks there
OR
- you use regular GUIControls, and in repeatedly_execute_always you make them "follow" the windows as they get dragged around.
Either way, it's very simple.
 

Kitai

Hey, pretty nice module! The rendering looks good.

I'm note sure it would be that simple to implement GUI elements (especially textboxes and listboxes) without using regular GUIControls (having to check for cursor position, dynamic text length, etc.).
By the way, how do you intend to handle elements positions and sizes when resizing windows in version 2? I mean, usually when resizing the owing window, elements don't get resized (not buttons at least), except for wide stuff such as textboxes and listboxes. Also, you have to make sure that (if you update positions when resizing) elements don't overlap.
Curious to see how you will do.

Anyway, gratz for this module. Next step: a menu/toolbar module? ;)

(By the way, shouldn't this topic go in the Modules&Plugins board?)

Calin Leafshade

Looking good!

I actually wrote a more complete GUI system for AGS which had support for layout based arrangements and had a full suite of controls but it's written in Lua so I doubt anyone would use it.

Monsieur OUXX

Quote from: Kitai on Tue 11/06/2013 09:35:04
I'm note sure it would be that simple to implement GUI elements (especially textboxes and listboxes) without using regular GUIControls (having to check for cursor position, dynamic text length, etc.).
By the way, how do you intend to handle elements positions and sizes when resizing windows in version 2?
I'll be resizing the controls while the window gets resized, and when the control is overlapped I'll make it either fully visible or fully invisible, or something. Or replace it with a gray rectangle. There's always a simple workaround.

Quote from: Kitai on Tue 11/06/2013 09:35:04
Next step: a menu/toolbar module? ;)
We'll see. I don't need those for my personal project.

Quote from: Kitai on Tue 11/06/2013 09:35:04
(By the way, shouldn't this topic go in the Modules&Plugins board?)
It's done manually by the admins. It has to be posted here first.

Quote from: Calin Leafshade on Tue 11/06/2013 09:40:13
I actually wrote a more complete GUI system for AGS which had support for layout based arrangements and had a full suite of controls but it's written in Lua so I doubt anyone would use it.
Post it here! I was looking for one!
 

Calin Leafshade

Here is my GUI system. It's VERY WIP and needs to be wired up to AGS's event system.

The gui system: http://pastebin.com/iB06ufJ4

The GUI manager: http://pastebin.com/rvs2DHke

I might have missed off some utility functions or something. Let me know if you need any guidance. I doubt it will be of any use and its very poorly made but it might be educational.

And a picture with some controls:



Usage example:

Code: lua

--test gui

gui = require('gui')

testgui = gui:new({text= "Test GUI", x = 100, y = 50,width = 150, height = 80})

testgui.layout = gui.layout:new({x = 0, y = 10}, testgui)
testgui.textbox1 = gui.textbox:new({label = "Name", x=0, y=0, width = 100, height = 12, text = "Calin"}, testgui.layout)
testgui.textbox2 = gui.textbox:new({label = "Age", x=0, y=0, width = 100, height = 12, text = "lol not telling."}, testgui.layout)
testgui.button1 = gui.button:new({x = 0, y = 0, width = 33, height = 12, text = "hello!"}, testgui.layout)

function testgui.button1:onClick()
	ags.Display("Lol you clicked me")
end

return testgui

SMF spam blocked by CleanTalk