1
0
Fork 0

Update for nasal::Ghost changes

This commit is contained in:
Thomas Geymayer 2013-03-03 15:27:06 +01:00
parent 06ef376bd8
commit 0587db3b1e
3 changed files with 25 additions and 44 deletions

View file

@ -86,18 +86,6 @@ void FGFileDialog::setShowHidden(bool show)
_showHidden = 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 class NasalCallback : public FGFileDialog::Callback
{ {
public: public:
@ -133,21 +121,20 @@ private:
int _gcKeys[2]; 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 // wrap up the naFunc in our callback type
naRef func = ctx.requireArg<naRef>(0); naRef func = ctx.requireArg<naRef>(0);
naRef object = ctx.getArg<naRef>(1, naNil()); naRef object = ctx.getArg<naRef>(1, naNil());
setCallback(new NasalCallback(func, object)); setCallback(new NasalCallback(func, object));
return naNil();
} }
typedef boost::shared_ptr<FGFileDialog> FileDialogPtr; typedef boost::shared_ptr<FGFileDialog> FileDialogPtr;
typedef nasal::Ghost<FileDialogPtr> NasalFileDialog; 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) 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("show_hidden", &FGFileDialog::showHidden, &FGFileDialog::setShowHidden)
.member("placeholder", &FGFileDialog::getPlaceholder, &FGFileDialog::setPlaceholderName) .member("placeholder", &FGFileDialog::getPlaceholder, &FGFileDialog::setPlaceholderName)
.member("pattern", &FGFileDialog::filterPatterns, &FGFileDialog::setFilterPatterns) .member("pattern", &FGFileDialog::filterPatterns, &FGFileDialog::setFilterPatterns)
.method<&FGFileDialog::openFromNasal>("open") .method("open", &FGFileDialog::exec)
.method<&FGFileDialog::closeFromNasal>("close") .method("close", &FGFileDialog::close)
.method<&FGFileDialog::setCallbackFromNasal>("setCallback"); .method("setCallback", &FGFileDialog::setCallbackFromNasal);
nasal::Hash guiModule = nasal::Hash(globals, c).get<nasal::Hash>("gui"); nasal::Hash guiModule = nasal::Hash(globals, c).get<nasal::Hash>("gui");

View file

@ -69,9 +69,7 @@ public:
virtual void setCallback(Callback* aCB); virtual void setCallback(Callback* aCB);
naRef openFromNasal(const nasal::CallContext& ctx); void setCallbackFromNasal(const nasal::CallContext& ctx);
naRef closeFromNasal(const nasal::CallContext& ctx);
naRef setCallbackFromNasal(const nasal::CallContext& ctx);
protected: protected:
FGFileDialog(Usage use); FGFileDialog(Usage use);

View file

@ -178,13 +178,9 @@ naRef f_eventGetTarget(naContext c, sc::Event& event)
return NasalElement::create(c, event.getTarget().lock()); return NasalElement::create(c, event.getTarget().lock());
} }
// TODO allow directly exposing functions without parameters and return type void f_eventStopPropagation(sc::Event& event)
naRef f_eventStopPropagation(sc::Event& event, const nasal::CallContext& ctx)
{ {
if( ctx.argc != 0 )
naRuntimeError(ctx.c, "Event::stopPropagation no argument expected");
event.stopPropagation(); event.stopPropagation();
return naNil();
} }
naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave) naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
@ -192,7 +188,7 @@ naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
NasalEvent::init("canvas.Event") NasalEvent::init("canvas.Event")
.member("type", &sc::Event::getTypeString) .member("type", &sc::Event::getTypeString)
.member("target", &f_eventGetTarget) .member("target", &f_eventGetTarget)
.method_func<&f_eventStopPropagation>("stopPropagation"); .method("stopPropagation", &f_eventStopPropagation);
NasalMouseEvent::init("canvas.MouseEvent") NasalMouseEvent::init("canvas.MouseEvent")
.bases<NasalEvent>() .bases<NasalEvent>()
.member("screenX", &sc::MouseEvent::getScreenX) .member("screenX", &sc::MouseEvent::getScreenX)
@ -206,20 +202,20 @@ naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
.member("_node_ghost", &elementGetNode<sc::Canvas>) .member("_node_ghost", &elementGetNode<sc::Canvas>)
.member("size_x", &sc::Canvas::getSizeX) .member("size_x", &sc::Canvas::getSizeX)
.member("size_y", &sc::Canvas::getSizeY) .member("size_y", &sc::Canvas::getSizeY)
.method_func<&f_canvasCreateGroup>("_createGroup") .method("_createGroup", &f_canvasCreateGroup)
.method<&sc::Canvas::addEventListener>("addEventListener"); .method("addEventListener", &sc::Canvas::addEventListener);
NasalElement::init("canvas.Element") NasalElement::init("canvas.Element")
.member("_node_ghost", &elementGetNode<sc::Element>) .member("_node_ghost", &elementGetNode<sc::Element>)
.method<&sc::Element::addEventListener>("addEventListener") .method("addEventListener", &sc::Element::addEventListener)
.method_func<&f_elementGetTransformedBounds>("getTransformedBounds"); .method("getTransformedBounds", &f_elementGetTransformedBounds);
NasalGroup::init("canvas.Group") NasalGroup::init("canvas.Group")
.bases<NasalElement>() .bases<NasalElement>()
.method_func<&f_groupCreateChild>("_createChild") .method("_createChild", &f_groupCreateChild)
.method_func<&f_groupGetChild>("_getChild") .method("_getChild", &f_groupGetChild)
.method_func<&f_groupGetElementById>("_getElementById"); .method("_getElementById", &f_groupGetElementById);
NasalText::init("canvas.Text") NasalText::init("canvas.Text")
.bases<NasalElement>() .bases<NasalElement>()
.method_func<&f_textGetNearestCursor>("getNearestCursor"); .method("getNearestCursor", &f_textGetNearestCursor);
nasal::Hash globals_module(globals, c), nasal::Hash globals_module(globals, c),
canvas_module = globals_module.createHash("canvas"); canvas_module = globals_module.createHash("canvas");