node_edit_dock.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * node_edit_dock.h - simple text editing of selecting node
  3. * Copyright (C) 2017 caryoscelus
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __STUDIO__NODE_EDIT_DOCK_H__49AA85D4
  19. #define __STUDIO__NODE_EDIT_DOCK_H__49AA85D4
  20. #include <core/std/memory.h>
  21. #include <core/context.h>
  22. #include <generic/node_editor.h>
  23. #include <generic/dock_registry.h>
  24. #include "close_destroy_dock.h"
  25. namespace Ui {
  26. class NodeEditDock;
  27. }
  28. namespace rainynite::studio {
  29. /**
  30. * Node editing dock, supporting basic text editor and custom editors based on
  31. * node type.
  32. */
  33. class NodeEditDock : public DockWidget, public NodeEditor {
  34. Q_OBJECT
  35. public:
  36. explicit NodeEditDock(shared_ptr<EditorContext> context_, QWidget* parent = nullptr);
  37. ~NodeEditDock();
  38. public:
  39. void active_node_changed(shared_ptr<core::AbstractValue> node) override;
  40. void time_changed(core::Time time) override;
  41. void node_update() override;
  42. private Q_SLOTS:
  43. void write_node();
  44. private:
  45. void update_value();
  46. void update_generic();
  47. void update_custom();
  48. void setup_custom_widget(shared_ptr<core::AbstractValue> node);
  49. private:
  50. unique_ptr<Ui::NodeEditDock> ui;
  51. QWidget* custom_widget = nullptr;
  52. shared_ptr<core::AbstractValue> active_node;
  53. };
  54. REGISTER_DOCK("Node editor", NodeEditDock, Qt::LeftDockWidgetArea);
  55. }
  56. #endif