attach_controls.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 "ui/abstract_button.h"
  9. #include "ui/round_rect.h"
  10. #include "ui/rp_widget.h"
  11. namespace Ui {
  12. class AttachControls final {
  13. public:
  14. enum class Type {
  15. Full,
  16. EditOnly,
  17. None,
  18. };
  19. AttachControls();
  20. void paint(QPainter &p, int x, int y);
  21. void setType(Type type);
  22. void setVertical(bool vertical);
  23. [[nodiscard]] int width() const;
  24. [[nodiscard]] int height() const;
  25. [[nodiscard]] Type type() const;
  26. [[nodiscard]] bool vertical() const;
  27. private:
  28. RoundRect _rect;
  29. Type _type = Type::Full;
  30. bool _vertical = false;
  31. };
  32. class AttachControlsWidget final : public RpWidget {
  33. public:
  34. AttachControlsWidget(
  35. not_null<RpWidget*> parent,
  36. AttachControls::Type type = AttachControls::Type::Full);
  37. [[nodiscard]] rpl::producer<> editRequests() const;
  38. [[nodiscard]] rpl::producer<> deleteRequests() const;
  39. private:
  40. const base::unique_qptr<AbstractButton> _edit;
  41. const base::unique_qptr<AbstractButton> _delete;
  42. AttachControls _controls;
  43. };
  44. } // namespace Ui