canvas.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* canvas.h - main canvas widget
  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_WIDGETS_CANVAS_H_20C351D1_AD17_5E84_B8D3_6EC2A325B3E4
  18. #define STUDIO_WIDGETS_CANVAS_H_20C351D1_AD17_5E84_B8D3_6EC2A325B3E4
  19. #include <core/std/memory.h>
  20. #include <core/std/vector.h>
  21. #include <canvas/registry.h>
  22. class QGraphicsScene;
  23. class QGraphicsItem;
  24. class QGraphicsRectItem;
  25. class QSlider;
  26. class QToolButton;
  27. namespace rainynite::studio {
  28. class Canvas : public AbstractCanvas {
  29. public:
  30. explicit Canvas(QWidget* parent = nullptr);
  31. virtual ~Canvas();
  32. protected:
  33. void set_context(shared_ptr<EditorContext> context) override;
  34. void active_node_index_changed(core::NodeTreeIndex index) override;
  35. void resizeEvent(QResizeEvent* event) override;
  36. private:
  37. void update_border();
  38. private:
  39. unique_ptr<QGraphicsRectItem> image_border;
  40. observer_ptr<QSlider> zoom_slider;
  41. observer_ptr<QToolButton> zoom_reset;
  42. };
  43. REGISTER_CANVAS(Canvas);
  44. } // namespace rainynite::studio
  45. #endif