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.

97 lines
3.8KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "DemoWidgetBanner.hpp"
  17. #include "Cairo.hpp"
  18. #include "Window.hpp"
  19. static const char* banner =
  20. " "
  21. " * * * * * "
  22. " ** ** * * * * "
  23. " * * * * * * * "
  24. " * * * **** *** * **** * * ** **** * *** "
  25. " * * * * ** * * * * * * ** * "
  26. " * * ***** * * ****** * * * * * * * "
  27. " * * * * * * * * * * * * * * "
  28. " * * * ** * ** * * * * * * * * * * "
  29. " * * *** * *** * **** ** ** ***** ** * * "
  30. " "
  31. " "
  32. " "
  33. " ***** **** ***** "
  34. " * * * * * "
  35. " * * * * * "
  36. " * * * * * "
  37. " * * **** **** "
  38. " * * * * "
  39. " * * * * "
  40. " * * * * "
  41. " ***** * * "
  42. " ";
  43. enum
  44. {
  45. rows = 23,
  46. columns = 72,
  47. };
  48. DemoWidgetBanner::DemoWidgetBanner(Widget* group)
  49. : Widget(group)
  50. {
  51. }
  52. void DemoWidgetBanner::onDisplay()
  53. {
  54. cairo_t* cr = getParentWindow().getGraphicsContext().cairo;
  55. Point<int> pt = getAbsolutePos();
  56. Size<uint> sz = getSize();
  57. int x = pt.getX();
  58. int y = pt.getY();
  59. int w = sz.getWidth();
  60. int h = sz.getHeight();
  61. double diameter = (double)w / columns;
  62. double radius = 0.5 * diameter;
  63. double xoff = 0;
  64. double yoff = 0.5 * (h - rows * diameter);
  65. for (int r = 0; r < rows; ++r)
  66. {
  67. for (int c = 0; c < columns; ++c)
  68. {
  69. double cx = x + xoff + radius + c * diameter;
  70. double cy = y + yoff + radius + r * diameter;
  71. char ch = banner[c + r * columns];
  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. }