Page 3 of 4

Re: Simple Window Manager

Posted: Tue Sep 24, 2013 3:16 pm
by Jor'Mox
So, just so I can be clear about what you are trying to do here:

You created a label, and you want to click on the label, and have it open a console, or something else, which will be used by other stuff. Yes? Do you want it positioned in the same way that the menu buttons are positioned, or just made visible when you click the button?

Re: Simple Window Manager

Posted: Tue Sep 24, 2013 3:22 pm
by icesteruk
made visable but use the scripts positioning...

basically I posted a pic on the other post, I want a console to open below the botton(s) .... which I can edit..

With the script it keeps asking about v.button stuff so I'm a little confused

Re: Simple Window Manager

Posted: Tue Sep 24, 2013 3:27 pm
by Jor'Mox
The positioning logic for just one object is really easy. It is only moderately complicated for a whole menu, but enough so that I made something to do the math for you.

Your best strategy is to must make a normal label. Position and style it as you prefer. Then add a clickCallback to that label to display the console you want to display. Since you can retrieve the position and size info for a GUI object from windowManager, you can have it grab the info for the label you are clicking when it is clicked, so that your console can use those values to determine what position it should be in.

Re: Simple Window Manager

Posted: Tue Sep 24, 2013 3:38 pm
by Jor'Mox
By the way, I just updated the front script to include a windowManager.create function. So you can use that instead of the windowManager.add function, and it will create the object for you, if you prefer.

Re: Simple Window Manager

Posted: Tue Sep 24, 2013 3:47 pm
by Jor'Mox
This should do something like what you are talking about.
Code: [show] | [select all] lua
local is_visible = false

function toggle_console()
	if is_visible then
		windowManager.hide("myConsole")
		is_visible = false
	else
		windowManager.show("myConsole")
		is_visible = true
	end
end

function test()
	windowManager.create("myLabel","label","10%","10%","20%","10%","topleft")
	windowManager.create("myConsole","miniconsole","10%","20%","40%","40%","topleft")
	windowManager.show("myLabel")
	windowManager.hide("myConsole")
	echo("myLabel",[[<font color ="#FFFFFF">My Label</font>]])
	setLabelClickCallback("myLabel","toggle_console")
end

Re: Simple Window Manager

Posted: Tue Sep 24, 2013 4:00 pm
by Jor'Mox
So, the code I put up before had a bit of an error with it... I just changed it to fix it (I forgot you can't pass a function directly to setLabelClickCallback).

Re: Simple Window Manager

Posted: Fri Feb 07, 2014 9:34 pm
by Jor'Mox
I have added "autowrap" windows to the Simple Window Manager, which are miniConsole windows that automatically rewrap the text in them when they are resized. When they are created (preferably via windowManager.create), just use "autowrap" as the type, and pass the font size (optional) as the last argument, or as font_size in a table.

This effect is created via the use of a buffer, created as follows:
Code: [show] | [select all] lua
createBuffer(name .. "_windowManager_buffer")
setWindowWrap(name .. "_windowManager_buffer",1000)
The original text is stored, unwrapped (so long as it isn't over 1000 characters long) in the buffer, and then rewritten to the window as it is resized.

Note that you do not have to create or otherwise manipulate such a buffer, it is created automatically when you use windowManager.create. It can optionally be created with windowManager.makeBuffer(name) if you need to create a miniConsole first, and then add it to windowManager after it is created.

If you have any suggestions, I would love to hear them. :-)

Re: Simple Window Manager

Posted: Sun Jun 08, 2014 11:20 pm
by Jor'Mox
I fixed a math bug that was causing occasional issues for window resizing (doing subtraction of percent and pixel values from percent and pixel values would compute incorrect results). If anyone actually uses this and runs into any other problems, please let me know.

Re: Simple Window Manager

Posted: Sat Oct 18, 2014 6:41 am
by Belgarath
Soon as I get another PC (people keep breaking my puters :() I'm going to try this out!

Re: Simple Window Manager

Posted: Sat Oct 18, 2014 1:55 pm
by Jor'Mox
I'm just glad that someone is interested. Admittedly, I created this for my own purposes, but it is nice when people use things that I have created. :-)