1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* An experimental Livecoding Tool
*
* Authors:
* Sol Bekic <s+inkscape@s-ol.nu>
* Copyright (C) 2019 Authors
*
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
*/
#include <gtkmm.h>
#include <glibmm/i18n.h>
#include <boost/none_t.hpp>
#include "desktop-style.h"
#include "desktop.h"
#include "inkscape.h"
#include "verbs.h"
#include "display/sodipodi-ctrl.h"
#include "display/sp-canvas-util.h"
#include "display/sp-canvas.h"
#include "object/sp-defs.h"
#include "object/sp-flowtext.h"
#include "object/sp-namedview.h"
#include "object/sp-root.h"
#include "object/sp-shape.h"
#include "object/sp-text.h"
#include "svg/stringstream.h"
#include "svg/svg-color.h"
#include "svg/svg.h"
#include "ui/tools/livecode-tool.h"
#include "util/units.h"
namespace Inkscape {
namespace UI {
namespace Tools {
const std::string& LivecodeTool::getPrefsPath()
{
return LivecodeTool::prefsPath;
}
const std::string LivecodeTool::prefsPath = "/tools/livecode";
LivecodeTool::LivecodeTool()
: ToolBase(nullptr, false)
, context(SP_ACTIVE_DESKTOP)
{
}
LivecodeTool::~LivecodeTool()
{
}
void LivecodeTool::setup()
{
ToolBase::setup();
Gtk::Widget* w = Glib::wrap(GTK_WIDGET(desktop->getCanvas()));
tick_callback = w->add_tick_callback(sigc::mem_fun(this, &LivecodeTool::handle_tick));
}
void LivecodeTool::finish()
{
Gtk::Widget* w = Glib::wrap(GTK_WIDGET(desktop->getCanvas()));
w->remove_tick_callback(tick_callback);
ToolBase::finish();
}
bool LivecodeTool::root_handler(GdkEvent* event)
{
gint ret = FALSE;
ret = ToolBase::root_handler(event);
if (!ret) {
context.push_event(event);
}
return ret;
}
void LivecodeTool::load_script(Glib::ustring const &path)
{
context.load_script(path);
}
static Geom::Point p(100, 100);
static Geom::Point a(50, 100), b(120, 300);
static Geom::Rect rect(Geom::Point(20, 200), Geom::Point(220, 20));
bool LivecodeTool::handle_tick(Glib::RefPtr<Gdk::FrameClock> const &frame_clock)
{
context.setup_frame();
context.input_point("p", &p);
context.input_arrow("a->b", &a, &b);
context.input_rect("rect", &rect);
context.finish_frame();
return true;
}
}
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
|