Jump to content

GUI...


chrisknapp001
 Share

Recommended Posts

Why can´t the GUI be used like any other? A canvas/base in pixels, with elements like button (e.g Torque 2d), rendered on a layer above the graphics.

This has to be included - GUI must be ueable, presently it is only for off-game-menus.

Thanks, i paid a lot of money for leadwerks pro, but the GUI has to work.

Please fix this ASAP.

 

Regards, Chris

 

 

 

Link to comment
Share on other sites

He's using Pro so C++, right?  In his defense, the Widget and GUI documentation sections still don't have a single C++ example to go off of.  Should I submit that to Bugs forum?  That said, it should be very possible to handle keyboard and mouse input with Leadwerks using the Windows commands here: https://www.leadwerks.com/learn?page=API-Reference_Object_Window
You can also draw your own buttons by using DrawImage.

Link to comment
Share on other sites

Here is an example for the button command, set up to work with the styles system in version 4.6:

#include "Leadwerks.h"

using namespace Leadwerks;

int main(int argc, const char *argv[])
{
	auto window = Window::Create();
	auto context = Context::Create(window);
	auto gui = GUI::Create(context);
	auto base = gui->GetBase();
	base->SetScript("Scripts/GUI/Panel.lua");

	int x = 20;
	int y = 20;
	int sep = 30;

	auto button = Widget::Button("Push", x, y, 76, 26, base);
	y = y + sep;

	auto checkbox = Widget::Button("Checkbox", x, y, 76, 26, base);

	//Retrieve the style constant from the script
	Interpreter::GetGlobal("BUTTON_CHECKBOX");
	int style = Interpreter::ToNumber();

	checkbox->SetStyle(style);

	while (!window->Closed())
	{
		if (window->KeyHit(Key::Escape)) break;

		while (EventQueue::Peek())
		{
			auto event = EventQueue::Wait();
			if (event.id == Event::WidgetAction)
			{
				System::Print("WidgetAction");
			}
			else if (event.id == Event::WidgetSelect)
			{
				System::Print("WidgetSelect");
			}
		}
		context->Sync();
	}
}

 

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

This is a little safer:

	//Retrieve the style constant from the script
	int stacksize = Interpreter::GetStackSize();
	Interpreter::GetGlobal("BUTTON_CHECKBOX");
	if (Interpreter::IsNumber())
	{
		int style = Interpreter::ToNumber();
		checkbox->SetStyle(style);
	}
	Interpreter::SetStackSize(stacksize);

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

The widget scripts declare their own style constants in the script, but the script is not run until the first time it is used. For C++ this poses a problem because the style constant only exists in the Lua virtual machine. It can be retrieved, but this seems needlessly complicated, as shown above.

What I will do is declare the style constants for the default widget scripts in the engine, so they are easily accessible from C++ and Lua. There aren't actually that many, just a few for button and label settings, so although this solution is sort of inconsistent I think it will be the easiest on everyone.

The whole reason for this complication is the fact that the widget system is totally customizable, and you can insert completely new types of GUI elements you create yourself with a new script.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

On 3/2/2019 at 4:27 AM, chrisknapp001 said:

I follow your example. A button appears, with a black background. My world disappear, with all model in it, of course.

This just dont work.

This is happening because the base GUI object, which can be thought of as a "desktop" is being assigned a panel script. If you don't want it to be a solid color, you can just skip that step and it will be invisible. This is how the default menu system is done.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...