DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
4.3KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2019-2021 Jean Pierre Cimalando <jp-dev@inbox.ru>
  4. * Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
  5. *
  6. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  7. * or without fee is hereby granted, provided that the above copyright notice and this
  8. * permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  11. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  12. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  14. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  15. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #pragma once
  18. #include "Cairo.hpp"
  19. START_NAMESPACE_DGL
  20. // -----------------------------------------------------------------------
  21. static constexpr const char banner[] =
  22. " "
  23. " * * * * * "
  24. " ** ** * * * * "
  25. " * * * * * * * "
  26. " * * * **** *** * **** * * ** **** * *** "
  27. " * * * * ** * * * * * * ** * "
  28. " * * ***** * * ****** * * * * * * * "
  29. " * * * * * * * * * * * * * * "
  30. " * * * ** * ** * * * * * * * * * * "
  31. " * * *** * *** * **** ** ** ***** ** * * "
  32. " "
  33. " "
  34. " "
  35. " ***** **** ***** "
  36. " * * * * * "
  37. " * * * * * "
  38. " * * * * * "
  39. " * * **** **** "
  40. " * * * * "
  41. " * * * * "
  42. " * * * * "
  43. " ***** * * "
  44. " ";
  45. static constexpr const int kNumRows = 23;
  46. static constexpr const int kNumColumns = 72;
  47. class DemoWidgetBanner : public CairoSubWidget
  48. {
  49. public:
  50. explicit DemoWidgetBanner(SubWidget* const parent)
  51. : CairoSubWidget(parent) {}
  52. explicit DemoWidgetBanner(TopLevelWidget* const parent)
  53. : CairoSubWidget(parent) {}
  54. protected:
  55. void onCairoDisplay(const CairoGraphicsContext& context) override
  56. {
  57. cairo_t* const cr = context.handle;
  58. Size<uint> sz = getSize();
  59. int w = sz.getWidth();
  60. int h = sz.getHeight();
  61. const double diameter = (double)w / kNumColumns;
  62. const double radius = 0.5 * diameter;
  63. const double xoff = 0;
  64. const double yoff = 0.5 * (h - kNumRows * diameter);
  65. for (int r = 0; r < kNumRows; ++r)
  66. {
  67. for (int c = 0; c < kNumColumns; ++c)
  68. {
  69. double cx = xoff + radius + c * diameter;
  70. double cy = yoff + radius + r * diameter;
  71. char ch = banner[c + r * kNumColumns];
  72. if (ch != ' ')
  73. cairo_set_source_rgb(cr, 0.5, 0.9, 0.2);
  74. else
  75. cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
  76. cairo_save(cr);
  77. cairo_translate(cr, cx, cy);
  78. cairo_scale(cr, radius, radius);
  79. cairo_arc(cr, 0.0, 0.0, 1.0, 0.0, 2 * M_PI);
  80. cairo_restore(cr);
  81. cairo_fill(cr);
  82. }
  83. }
  84. }
  85. };
  86. // -----------------------------------------------------------------------
  87. END_NAMESPACE_DGL