// SPDX-License-Identifier: GPL-2.0-or-later /* * An experimental Livecoding Tool * * Authors: * Sol Bekic * Copyright (C) 2019 Authors * * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ #include #include #include #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/ersaser"; LivecodeTool::LivecodeTool() : ToolBase(nullptr, false) , api(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) { api.push_event(event); } return ret; } 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 const &frame_clock) { api.setup_frame(); api.input_point("p", &p); api.input_arrow("a->b", &a, &b); api.input_rect("rect", &rect); api.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 :