shadow.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #pragma once
  8. #include "ui/rp_widget.h"
  9. #include "ui/rect_part.h"
  10. namespace style {
  11. struct Shadow;
  12. } // namespace style
  13. namespace Ui {
  14. class PlainShadow : public RpWidget {
  15. public:
  16. PlainShadow(QWidget *parent);
  17. PlainShadow(QWidget *parent, style::color color);
  18. protected:
  19. void paintEvent(QPaintEvent *e) override;
  20. private:
  21. style::color _color;
  22. };
  23. class Shadow : public TWidget {
  24. public:
  25. Shadow(
  26. QWidget *parent,
  27. const style::Shadow &st,
  28. RectParts sides = RectPart::AllSides)
  29. : TWidget(parent)
  30. , _st(st)
  31. , _sides(sides) {
  32. }
  33. static void paint(
  34. QPainter &p,
  35. const QRect &box,
  36. int outerWidth,
  37. const style::Shadow &st,
  38. RectParts sides = RectPart::AllSides);
  39. static void paint(
  40. QPainter &p,
  41. const QRect &box,
  42. int outerWidth,
  43. const style::Shadow &st,
  44. const std::array<QImage, 4> &corners,
  45. RectParts sides = RectPart::AllSides);
  46. static void paint(
  47. QPainter &p,
  48. const QRect &box,
  49. int outerWidth,
  50. const style::Shadow &st,
  51. const std::array<QImage, 4> &sides,
  52. const std::array<QImage, 4> &corners);
  53. static QPixmap grab(
  54. not_null<TWidget*> target,
  55. const style::Shadow &shadow,
  56. RectParts sides = RectPart::AllSides);
  57. protected:
  58. void paintEvent(QPaintEvent *e) override;
  59. private:
  60. const style::Shadow &_st;
  61. RectParts _sides;
  62. };
  63. } // namespace Ui