node_tree_dock.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * node_tree_dock.h - Dock with node tree
  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_TREE_DOCK_H__8AC1EE40
  19. #define __STUDIO__NODE_TREE_DOCK_H__8AC1EE40
  20. #include <generic/context_listener.h>
  21. #include <generic/dock_registry.h>
  22. #include "close_destroy_dock.h"
  23. namespace Ui {
  24. class NodeTreeDock;
  25. }
  26. class QMenu;
  27. namespace rainynite::studio {
  28. class NodeModel;
  29. /**
  30. * Node graph tree representation dock.
  31. *
  32. * Until visual node editor is done, this is the main place for node
  33. * manipulation.
  34. */
  35. class NodeTreeDock : public DockWidget, public ContextListener {
  36. Q_OBJECT
  37. public:
  38. explicit NodeTreeDock(shared_ptr<EditorContext> context_, QWidget* parent_ = nullptr);
  39. virtual ~NodeTreeDock();
  40. public:
  41. void set_context(shared_ptr<EditorContext> context_) override;
  42. Q_SIGNALS:
  43. void activated(shared_ptr<core::AbstractValue> node);
  44. protected:
  45. void contextMenuEvent(QContextMenuEvent* event) override;
  46. private Q_SLOTS:
  47. void activate(QModelIndex const& index);
  48. private:
  49. unique_ptr<Ui::NodeTreeDock> ui;
  50. unique_ptr<NodeModel> model;
  51. unique_ptr<QMenu> menu;
  52. };
  53. REGISTER_DOCK("Node tree", NodeTreeDock, Qt::LeftDockWidgetArea);
  54. } // namespace rainynite::studio
  55. #endif