canvas.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 resizeEvent(QResizeEvent* event) override;
  35. private:
  36. void update_border();
  37. private:
  38. unique_ptr<QGraphicsRectItem> image_border;
  39. observer_ptr<QSlider> zoom_slider;
  40. observer_ptr<QToolButton> zoom_reset;
  41. };
  42. REGISTER_CANVAS(Canvas);
  43. } // namespace rainynite::studio
  44. #endif