Update for nasal::Ghost changes
This commit is contained in:
parent
06ef376bd8
commit
0587db3b1e
3 changed files with 25 additions and 44 deletions
|
@ -86,18 +86,6 @@ void FGFileDialog::setShowHidden(bool show)
|
|||
_showHidden = show;
|
||||
}
|
||||
|
||||
naRef FGFileDialog::openFromNasal(const nasal::CallContext& ctx)
|
||||
{
|
||||
exec();
|
||||
return naNil();
|
||||
}
|
||||
|
||||
naRef FGFileDialog::closeFromNasal(const nasal::CallContext& ctx)
|
||||
{
|
||||
close();
|
||||
return naNil();
|
||||
}
|
||||
|
||||
class NasalCallback : public FGFileDialog::Callback
|
||||
{
|
||||
public:
|
||||
|
@ -133,21 +121,20 @@ private:
|
|||
int _gcKeys[2];
|
||||
};
|
||||
|
||||
naRef FGFileDialog::setCallbackFromNasal(const nasal::CallContext& ctx)
|
||||
void FGFileDialog::setCallbackFromNasal(const nasal::CallContext& ctx)
|
||||
{
|
||||
// wrap up the naFunc in our callback type
|
||||
naRef func = ctx.requireArg<naRef>(0);
|
||||
naRef object = ctx.getArg<naRef>(1, naNil());
|
||||
|
||||
setCallback(new NasalCallback(func, object));
|
||||
return naNil();
|
||||
}
|
||||
|
||||
typedef boost::shared_ptr<FGFileDialog> FileDialogPtr;
|
||||
typedef nasal::Ghost<FileDialogPtr> NasalFileDialog;
|
||||
|
||||
/**
|
||||
* Create new Canvas and get ghost for it.
|
||||
* Create new FGFileDialog and get ghost for it.
|
||||
*/
|
||||
static naRef f_createFileDialog(naContext c, naRef me, int argc, naRef* args)
|
||||
{
|
||||
|
@ -172,9 +159,9 @@ void postinitNasalGUI(naRef globals, naContext c)
|
|||
.member("show_hidden", &FGFileDialog::showHidden, &FGFileDialog::setShowHidden)
|
||||
.member("placeholder", &FGFileDialog::getPlaceholder, &FGFileDialog::setPlaceholderName)
|
||||
.member("pattern", &FGFileDialog::filterPatterns, &FGFileDialog::setFilterPatterns)
|
||||
.method<&FGFileDialog::openFromNasal>("open")
|
||||
.method<&FGFileDialog::closeFromNasal>("close")
|
||||
.method<&FGFileDialog::setCallbackFromNasal>("setCallback");
|
||||
.method("open", &FGFileDialog::exec)
|
||||
.method("close", &FGFileDialog::close)
|
||||
.method("setCallback", &FGFileDialog::setCallbackFromNasal);
|
||||
|
||||
nasal::Hash guiModule = nasal::Hash(globals, c).get<nasal::Hash>("gui");
|
||||
|
||||
|
|
|
@ -57,21 +57,19 @@ public:
|
|||
*/
|
||||
virtual ~FGFileDialog ();
|
||||
|
||||
virtual void exec() = 0;
|
||||
virtual void close() = 0;
|
||||
virtual void exec() = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
class Callback
|
||||
{
|
||||
public:
|
||||
virtual ~Callback() { }
|
||||
virtual void onFileDialogDone(FGFileDialog* ins, const SGPath& result) = 0;
|
||||
};
|
||||
class Callback
|
||||
{
|
||||
public:
|
||||
virtual ~Callback() { }
|
||||
virtual void onFileDialogDone(FGFileDialog* ins, const SGPath& result) = 0;
|
||||
};
|
||||
|
||||
virtual void setCallback(Callback* aCB);
|
||||
virtual void setCallback(Callback* aCB);
|
||||
|
||||
naRef openFromNasal(const nasal::CallContext& ctx);
|
||||
naRef closeFromNasal(const nasal::CallContext& ctx);
|
||||
naRef setCallbackFromNasal(const nasal::CallContext& ctx);
|
||||
void setCallbackFromNasal(const nasal::CallContext& ctx);
|
||||
protected:
|
||||
FGFileDialog(Usage use);
|
||||
|
||||
|
|
|
@ -178,13 +178,9 @@ naRef f_eventGetTarget(naContext c, sc::Event& event)
|
|||
return NasalElement::create(c, event.getTarget().lock());
|
||||
}
|
||||
|
||||
// TODO allow directly exposing functions without parameters and return type
|
||||
naRef f_eventStopPropagation(sc::Event& event, const nasal::CallContext& ctx)
|
||||
void f_eventStopPropagation(sc::Event& event)
|
||||
{
|
||||
if( ctx.argc != 0 )
|
||||
naRuntimeError(ctx.c, "Event::stopPropagation no argument expected");
|
||||
event.stopPropagation();
|
||||
return naNil();
|
||||
}
|
||||
|
||||
naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
|
||||
|
@ -192,7 +188,7 @@ naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
|
|||
NasalEvent::init("canvas.Event")
|
||||
.member("type", &sc::Event::getTypeString)
|
||||
.member("target", &f_eventGetTarget)
|
||||
.method_func<&f_eventStopPropagation>("stopPropagation");
|
||||
.method("stopPropagation", &f_eventStopPropagation);
|
||||
NasalMouseEvent::init("canvas.MouseEvent")
|
||||
.bases<NasalEvent>()
|
||||
.member("screenX", &sc::MouseEvent::getScreenX)
|
||||
|
@ -206,20 +202,20 @@ naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
|
|||
.member("_node_ghost", &elementGetNode<sc::Canvas>)
|
||||
.member("size_x", &sc::Canvas::getSizeX)
|
||||
.member("size_y", &sc::Canvas::getSizeY)
|
||||
.method_func<&f_canvasCreateGroup>("_createGroup")
|
||||
.method<&sc::Canvas::addEventListener>("addEventListener");
|
||||
.method("_createGroup", &f_canvasCreateGroup)
|
||||
.method("addEventListener", &sc::Canvas::addEventListener);
|
||||
NasalElement::init("canvas.Element")
|
||||
.member("_node_ghost", &elementGetNode<sc::Element>)
|
||||
.method<&sc::Element::addEventListener>("addEventListener")
|
||||
.method_func<&f_elementGetTransformedBounds>("getTransformedBounds");
|
||||
.method("addEventListener", &sc::Element::addEventListener)
|
||||
.method("getTransformedBounds", &f_elementGetTransformedBounds);
|
||||
NasalGroup::init("canvas.Group")
|
||||
.bases<NasalElement>()
|
||||
.method_func<&f_groupCreateChild>("_createChild")
|
||||
.method_func<&f_groupGetChild>("_getChild")
|
||||
.method_func<&f_groupGetElementById>("_getElementById");
|
||||
.method("_createChild", &f_groupCreateChild)
|
||||
.method("_getChild", &f_groupGetChild)
|
||||
.method("_getElementById", &f_groupGetElementById);
|
||||
NasalText::init("canvas.Text")
|
||||
.bases<NasalElement>()
|
||||
.method_func<&f_textGetNearestCursor>("getNearestCursor");
|
||||
.method("getNearestCursor", &f_textGetNearestCursor);
|
||||
|
||||
nasal::Hash globals_module(globals, c),
|
||||
canvas_module = globals_module.createHash("canvas");
|
||||
|
|
Loading…
Reference in a new issue