1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /*
- * canvas_editor.h - on-canvas value edit/display "widgets"
- * Copyright (C) 2017 caryoscelus
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #ifndef __STUDIO__CANVAS_EDITOR_H__F294C054
- #define __STUDIO__CANVAS_EDITOR_H__F294C054
- #include <typeindex>
- #include <memory>
- namespace core {
- class AbstractValue;
- }
- namespace studio {
- class Canvas;
- class CanvasEditor {
- public:
- virtual ~CanvasEditor() = default;
- public:
- virtual void set_canvas(Canvas* canvas_);
- inline Canvas* get_canvas() const {
- return canvas;
- }
- private:
- Canvas* canvas = nullptr;
- };
- class CanvasEditorFactory {
- public:
- virtual std::unique_ptr<CanvasEditor> operator()() const = 0;
- };
- class CanvasEditorShowChildren {
- public:
- virtual bool operator()() const = 0;
- };
- void add_canvas_editor(Canvas& canvas, std::shared_ptr<core::AbstractValue> node);
- } // namespace studio
- #define REGISTER_CANVAS_EDITOR(Name, Type, Editor) \
- class Name##Factory : \
- public CanvasEditorFactory, \
- private class_init::Registered<Name##Factory, Type, CanvasEditorFactory> \
- { \
- public: \
- virtual std::unique_ptr<CanvasEditor> operator()() const override { \
- return std::make_unique<Editor>(); \
- } \
- }
- #define REGISTER_CANVAS_SHOW_CHILDREN(Name, node_name, value) \
- class Name##ShowChildren : \
- public CanvasEditorShowChildren, \
- private class_init::StringRegistered<Name##ShowChildren, CanvasEditorShowChildren> \
- { \
- public: \
- static std::string name() { \
- return node_name; \
- } \
- public: \
- virtual bool operator()() const override { \
- return value; \
- } \
- }
- #endif
|