document.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* document.cpp - document
  2. * Copyright (C) 2017 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. #include <core/node_info.h>
  18. #include <core/document.h>
  19. #include <core/context.h>
  20. #include <core/action_stack.h>
  21. namespace rainynite::core {
  22. REGISTER_NODE(Document);
  23. Document::Document(shared_ptr<BaseValue<Renderable>> root_) :
  24. default_context(nullptr),
  25. action_stack(make_shared<ActionStack>())
  26. {
  27. init<Renderable>(root, {});
  28. init<Geom::Point>(size, {320, 240});
  29. init<TimePeriod>(main_time_period, {Time(0, 12), Time(5, 12)});
  30. // TODO: use constraints
  31. init_property(soundtrack, Type(typeid(Audio)), make_node_with_name("EmptyAudio"));
  32. if (root_)
  33. set_root(root_);
  34. else
  35. set_root(make_node_with_name<BaseValue<Renderable>>("Empty"));
  36. new_id();
  37. }
  38. Document::~Document() {
  39. }
  40. DocumentType Document::get(shared_ptr<Context> /*context*/) const {
  41. return {};
  42. }
  43. shared_ptr<Context> Document::get_default_context() {
  44. if (!default_context) {
  45. default_context = make_shared<Context>(static_pointer_cast<Document>(shared_from_this()));
  46. }
  47. return default_context;
  48. }
  49. } // namespace rainynite::core