editor_context.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * editor_context.h - editor Context
  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__GENERIC__EDITOR_CONTEXT_H__4E809780
  19. #define __STUDIO__GENERIC__EDITOR_CONTEXT_H__4E809780
  20. #include <core/context.h>
  21. #include <core/action.h>
  22. namespace studio {
  23. class EditorContext {
  24. public:
  25. EditorContext(std::shared_ptr<core::Context> context_) :
  26. context(context_)
  27. {}
  28. public:
  29. inline std::shared_ptr<core::Context> get_context() const {
  30. return context;
  31. }
  32. void set_active_node(std::shared_ptr<core::AbstractValue> node);
  33. inline core::ActionStack& action_stack() {
  34. return action_stack_;
  35. }
  36. public:
  37. inline boost::signals2::signal<void(core::Time)>& changed_time() {
  38. return context->changed_time;
  39. }
  40. inline boost::signals2::signal<void(std::shared_ptr<core::AbstractValue>)>& changed_active_node() {
  41. return changed_active_node_;
  42. }
  43. private:
  44. std::shared_ptr<core::Context> context;
  45. std::shared_ptr<core::AbstractValue> active_node;
  46. core::ActionStack action_stack_;
  47. private:
  48. boost::signals2::signal<void(std::shared_ptr<core::AbstractValue>)> changed_active_node_;
  49. };
  50. std::shared_ptr<EditorContext> global_dummy_context();
  51. } // namespace studio
  52. #endif