node_edit.h 1.9 KB

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