document.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * document.cpp - document
  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. #include <core/node_info.h>
  19. #include <core/document.h>
  20. #include <core/context.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. if (root_)
  31. set_root(root_);
  32. else
  33. set_root(make_node_with_name<BaseValue<Renderable>>("Empty"));
  34. new_id();
  35. }
  36. Document::~Document() {
  37. }
  38. DocumentType Document::get(shared_ptr<Context> /*context*/) const {
  39. return {};
  40. }
  41. shared_ptr<Context> Document::get_default_context() {
  42. if (!default_context) {
  43. default_context = make_shared<Context>(static_pointer_cast<Document>(shared_from_this()));
  44. }
  45. return default_context;
  46. }
  47. } // namespace rainynite::core