1
0
Fork 0

GUICompat: fix binding activation, close callback

With this change, binding can be activated mostly-correctly from
the compatability layer. Closing still isn't working quite right, more
changes to follow.
This commit is contained in:
James Turner 2022-03-24 10:32:48 +00:00
parent abb394935d
commit 7a0be3f000
3 changed files with 20 additions and 1 deletions

View file

@ -85,7 +85,9 @@ void FGPUICompatDialog::setupGhost(nasal::Hash& compatModule)
.member("y", &FGPUICompatDialog::getY)
.member("width", &FGPUICompatDialog::width)
.member("height", &FGPUICompatDialog::height)
.member("root", f_dialogRootObject);
.member("root", f_dialogRootObject)
.method("close", &FGPUICompatDialog::requestClose);
using NasalDialogPeer = nasal::Ghost<SGSharedPtr<DialogPeer>>;
NasalDialogPeer::init("CompatDialogPeer")
@ -106,6 +108,8 @@ FGPUICompatDialog::FGPUICompatDialog(SGPropertyNode* props) : FGDialog(props),
FGPUICompatDialog::~FGPUICompatDialog()
{
_peer->callMethod<void>("doClose");
_props->setIntValue("lastx", getX());
_props->setIntValue("lasty", getY());
// FIXME: save width/height as well?
@ -762,3 +766,9 @@ std::string FGPUICompatDialog::nasalModule() const
{
return _module;
}
void FGPUICompatDialog::requestClose()
{
auto gui = globals->get_subsystem<NewGUI>();
gui->closeDialog(_name);
}

View file

@ -119,6 +119,8 @@ private:
// Show the dialog.
void display(SGPropertyNode* props);
void requestClose();
#if 0
// Build the dialog or a subobject of it.
puObject* makeObject(SGPropertyNode* props,

View file

@ -12,6 +12,7 @@
#include <simgear/props/props_io.hxx> // for copyProperties
#include <GUI/FGPUICompatDialog.hxx>
#include <GUI/new_gui.hxx>
#include <Main/fg_props.hxx>
#include <Scripting/NasalSys.hxx>
@ -153,6 +154,7 @@ void PUICompatObject::init()
}
SGSharedPtr<PUICompatObject> childObject = createForType(nodeName, childNode);
childObject->_parent = this;
_children.push_back(childObject);
}
@ -268,7 +270,12 @@ void PUICompatObject::createNasalPeer()
void PUICompatObject::activateBindings()
{
assert(_enabled);
auto guiSub = globals->get_subsystem<NewGUI>();
assert(guiSub);
guiSub->setActiveDialog(dialog());
fireBindingList(_bindings);
guiSub->setActiveDialog(nullptr);
}
void PUICompatObject::setGeometry(const SGRectd& g)