summaryrefslogtreecommitdiffstats
path: root/src/livecode/context.h
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2019-12-02 20:33:28 +0000
committers-ol <s-ol@users.noreply.github.com>2019-12-02 20:33:28 +0000
commit1b69cd09de1e70d36cbca5f0c4a3f289ec684343 (patch)
tree42a91646b60d7879c1d541e921adddff4052a732 /src/livecode/context.h
parentadd draft janet interface for livecoding (diff)
downloadinkscape-1b69cd09de1e70d36cbca5f0c4a3f289ec684343.tar.gz
inkscape-1b69cd09de1e70d36cbca5f0c4a3f289ec684343.zip
more janet bindings
Diffstat (limited to 'src/livecode/context.h')
-rw-r--r--src/livecode/context.h34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/livecode/context.h b/src/livecode/context.h
index fb6b59ff7..4ebb73609 100644
--- a/src/livecode/context.h
+++ b/src/livecode/context.h
@@ -16,6 +16,8 @@
#include <2geom/point.h>
#include <2geom/rect.h>
#include <gdk/gdk.h>
+#include <giomm/file.h>
+#include <giomm/filemonitor.h>
#include <janet.h>
#include "xml/repr.h"
@@ -26,15 +28,30 @@
class SPDocument;
class SPItem;
-namespace Gio {
-class File;
-};
-
namespace Inkscape {
namespace Livecode {
class Mouse;
+class Script {
+public:
+ Script(JanetTable *env, std::string const &path);
+
+ void frame();
+ void commit();
+
+private:
+ JanetTable *env;
+ JanetFunction *function;
+ Glib::RefPtr<Gio::File> file;
+ Glib::RefPtr<Gio::FileMonitor> monitor;
+
+ void reload();
+ void file_changed(const Glib::RefPtr<Gio::File>& file,
+ const Glib::RefPtr<Gio::File>& other_file,
+ Gio::FileMonitorEvent event);
+};
+
class Context {
public:
Context(SPDesktop *desktop);
@@ -54,8 +71,7 @@ public:
void draw_ui(Glib::ustring const &id, Inkscape::XML::Node *item);
void push_event(GdkEvent *event);
- void setup_frame();
- void finish_frame();
+ void frame();
inline Geom::Affine ui2dt() const {
return doc_root->i2doc_affine();
@@ -81,13 +97,15 @@ public:
void load_script(Glib::ustring const &path);
private:
+ void setup_frame();
+ void finish_frame();
+
SPDesktop *desktop;
SPItem *doc_root, *ui_root;
JanetTable *env;
- JanetFunction *script_function;
- Glib::RefPtr<Gio::File> script_file;
+ std::unique_ptr<Script> _script;
Mouse _mouse;
Glib::ustring hot, active;