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.

100 lines
4.0KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
  4. * Copyright (C) 2019-2021 Jean Pierre Cimalando <jp-dev@inbox.ru>
  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. #include "DemoWidgetBanner.hpp"
  18. START_NAMESPACE_DGL
  19. // -----------------------------------------------------------------------
  20. static const char* banner =
  21. " "
  22. " * * * * * "
  23. " ** ** * * * * "
  24. " * * * * * * * "
  25. " * * * **** *** * **** * * ** **** * *** "
  26. " * * * * ** * * * * * * ** * "
  27. " * * ***** * * ****** * * * * * * * "
  28. " * * * * * * * * * * * * * * "
  29. " * * * ** * ** * * * * * * * * * * "
  30. " * * *** * *** * **** ** ** ***** ** * * "
  31. " "
  32. " "
  33. " "
  34. " ***** **** ***** "
  35. " * * * * * "
  36. " * * * * * "
  37. " * * * * * "
  38. " * * **** **** "
  39. " * * * * "
  40. " * * * * "
  41. " * * * * "
  42. " ***** * * "
  43. " ";
  44. enum
  45. {
  46. rows = 23,
  47. columns = 72,
  48. };
  49. DemoWidgetBanner::DemoWidgetBanner(SubWidget* parent)
  50. : CairoSubWidget(parent) {}
  51. DemoWidgetBanner::DemoWidgetBanner(TopLevelWidget* parent)
  52. : CairoSubWidget(parent) {}
  53. void DemoWidgetBanner::onCairoDisplay(const CairoGraphicsContext& context)
  54. {
  55. cairo_t* cr = context.handle;
  56. Size<uint> sz = getSize();
  57. int w = sz.getWidth();
  58. int h = sz.getHeight();
  59. double diameter = (double)w / columns;
  60. double radius = 0.5 * diameter;
  61. double xoff = 0;
  62. double yoff = 0.5 * (h - rows * diameter);
  63. for (int r = 0; r < rows; ++r)
  64. {
  65. for (int c = 0; c < columns; ++c)
  66. {
  67. double cx = xoff + radius + c * diameter;
  68. double cy = yoff + radius + r * diameter;
  69. char ch = banner[c + r * columns];
  70. if (ch != ' ')
  71. cairo_set_source_rgb(cr, 0.5, 0.9, 0.2);
  72. else
  73. cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
  74. cairo_save(cr);
  75. cairo_translate(cr, cx, cy);
  76. cairo_scale(cr, radius, radius);
  77. cairo_arc(cr, 0.0, 0.0, 1.0, 0.0, 2 * M_PI);
  78. cairo_restore(cr);
  79. cairo_fill(cr);
  80. }
  81. }
  82. }
  83. // -----------------------------------------------------------------------
  84. END_NAMESPACE_DGL