abstract_layout_item.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "base/runtime_composer.h"
  9. #include "ui/click_handler.h"
  10. class PaintContextBase {
  11. public:
  12. PaintContextBase(crl::time ms, bool selecting)
  13. : ms(ms)
  14. , selecting(selecting) {
  15. }
  16. crl::time ms = 0;
  17. bool selecting = false;
  18. };
  19. class AbstractLayoutItem
  20. : public RuntimeComposer<AbstractLayoutItem>
  21. , public ClickHandlerHost {
  22. public:
  23. AbstractLayoutItem();
  24. AbstractLayoutItem(const AbstractLayoutItem &other) = delete;
  25. AbstractLayoutItem &operator=(
  26. const AbstractLayoutItem &other) = delete;
  27. [[nodiscard]] int maxWidth() const;
  28. [[nodiscard]] int minHeight() const;
  29. virtual int resizeGetHeight(int width);
  30. [[nodiscard]] int width() const;
  31. [[nodiscard]] int height() const;
  32. virtual void setPosition(int position);
  33. [[nodiscard]] int position() const;
  34. [[nodiscard]] bool hasPoint(QPoint point) const;
  35. virtual ~AbstractLayoutItem();
  36. protected:
  37. int _width = 0;
  38. int _height = 0;
  39. int _maxw = 0;
  40. int _minh = 0;
  41. int _position = 0; // < 0 means removed from layout
  42. };