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:
parent
abb394935d
commit
7a0be3f000
3 changed files with 20 additions and 1 deletions
|
@ -85,7 +85,9 @@ void FGPUICompatDialog::setupGhost(nasal::Hash& compatModule)
|
||||||
.member("y", &FGPUICompatDialog::getY)
|
.member("y", &FGPUICompatDialog::getY)
|
||||||
.member("width", &FGPUICompatDialog::width)
|
.member("width", &FGPUICompatDialog::width)
|
||||||
.member("height", &FGPUICompatDialog::height)
|
.member("height", &FGPUICompatDialog::height)
|
||||||
.member("root", f_dialogRootObject);
|
.member("root", f_dialogRootObject)
|
||||||
|
.method("close", &FGPUICompatDialog::requestClose);
|
||||||
|
|
||||||
|
|
||||||
using NasalDialogPeer = nasal::Ghost<SGSharedPtr<DialogPeer>>;
|
using NasalDialogPeer = nasal::Ghost<SGSharedPtr<DialogPeer>>;
|
||||||
NasalDialogPeer::init("CompatDialogPeer")
|
NasalDialogPeer::init("CompatDialogPeer")
|
||||||
|
@ -106,6 +108,8 @@ FGPUICompatDialog::FGPUICompatDialog(SGPropertyNode* props) : FGDialog(props),
|
||||||
|
|
||||||
FGPUICompatDialog::~FGPUICompatDialog()
|
FGPUICompatDialog::~FGPUICompatDialog()
|
||||||
{
|
{
|
||||||
|
_peer->callMethod<void>("doClose");
|
||||||
|
|
||||||
_props->setIntValue("lastx", getX());
|
_props->setIntValue("lastx", getX());
|
||||||
_props->setIntValue("lasty", getY());
|
_props->setIntValue("lasty", getY());
|
||||||
// FIXME: save width/height as well?
|
// FIXME: save width/height as well?
|
||||||
|
@ -762,3 +766,9 @@ std::string FGPUICompatDialog::nasalModule() const
|
||||||
{
|
{
|
||||||
return _module;
|
return _module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FGPUICompatDialog::requestClose()
|
||||||
|
{
|
||||||
|
auto gui = globals->get_subsystem<NewGUI>();
|
||||||
|
gui->closeDialog(_name);
|
||||||
|
}
|
||||||
|
|
|
@ -119,6 +119,8 @@ private:
|
||||||
// Show the dialog.
|
// Show the dialog.
|
||||||
void display(SGPropertyNode* props);
|
void display(SGPropertyNode* props);
|
||||||
|
|
||||||
|
void requestClose();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Build the dialog or a subobject of it.
|
// Build the dialog or a subobject of it.
|
||||||
puObject* makeObject(SGPropertyNode* props,
|
puObject* makeObject(SGPropertyNode* props,
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <simgear/props/props_io.hxx> // for copyProperties
|
#include <simgear/props/props_io.hxx> // for copyProperties
|
||||||
|
|
||||||
#include <GUI/FGPUICompatDialog.hxx>
|
#include <GUI/FGPUICompatDialog.hxx>
|
||||||
|
#include <GUI/new_gui.hxx>
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#include <Scripting/NasalSys.hxx>
|
#include <Scripting/NasalSys.hxx>
|
||||||
|
|
||||||
|
@ -153,6 +154,7 @@ void PUICompatObject::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
SGSharedPtr<PUICompatObject> childObject = createForType(nodeName, childNode);
|
SGSharedPtr<PUICompatObject> childObject = createForType(nodeName, childNode);
|
||||||
|
childObject->_parent = this;
|
||||||
_children.push_back(childObject);
|
_children.push_back(childObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +270,12 @@ void PUICompatObject::createNasalPeer()
|
||||||
void PUICompatObject::activateBindings()
|
void PUICompatObject::activateBindings()
|
||||||
{
|
{
|
||||||
assert(_enabled);
|
assert(_enabled);
|
||||||
|
auto guiSub = globals->get_subsystem<NewGUI>();
|
||||||
|
assert(guiSub);
|
||||||
|
|
||||||
|
guiSub->setActiveDialog(dialog());
|
||||||
fireBindingList(_bindings);
|
fireBindingList(_bindings);
|
||||||
|
guiSub->setActiveDialog(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PUICompatObject::setGeometry(const SGRectd& g)
|
void PUICompatObject::setGeometry(const SGRectd& g)
|
||||||
|
|
Loading…
Reference in a new issue