DPF OpenGL examples
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.

111 lines
3.0KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2014 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. // ------------------------------------------------------
  17. // DGL Stuff
  18. #include "ImageButton.hpp"
  19. #include "StandaloneWindow.hpp"
  20. #include "widgets/ExampleColorWidget.hpp"
  21. #include "widgets/ExampleImagesWidget.hpp"
  22. #include "widgets/ExampleRectanglesWidget.hpp"
  23. #include "widgets/ExampleShapesWidget.hpp"
  24. #include "widgets/ExampleTextWidget.hpp"
  25. #include "widgets/NanoPerfWidget.hpp"
  26. // ------------------------------------------------------
  27. // Images
  28. #include "demo_res/DemoArtwork.cpp"
  29. #include "images_res/CatPics.cpp"
  30. // ------------------------------------------------------
  31. // use namespace
  32. using DGL::App;
  33. using DGL::ImageButton;
  34. using DGL::Line;
  35. using DGL::Size;
  36. // ------------------------------------------------------
  37. // Single Widget Window
  38. static int gWindowCount = 0;
  39. template<class WIG>
  40. class SingleWidgetWindow : public Window
  41. {
  42. public:
  43. SingleWidgetWindow(App& app)
  44. : Window(app),
  45. fWidget(*this),
  46. fIsMain(true)
  47. {
  48. setSize(fWidget.getSize());
  49. setTitle("demo-multi");
  50. show();
  51. }
  52. SingleWidgetWindow(App& app, Window& parent)
  53. : Window(app, parent),
  54. fWidget(*this),
  55. fIsMain(false)
  56. {
  57. setResizable(false);
  58. setSize(fWidget.getSize());
  59. setTitle(d_string("transient #") + d_string(++gWindowCount));
  60. show();
  61. }
  62. protected:
  63. void onReshape(uint width, uint height) override
  64. {
  65. fWidget.setSize(width, height);
  66. Window::onReshape(width, height);
  67. }
  68. void onClose() override
  69. {
  70. Window::onClose();
  71. if (fIsMain)
  72. getApp().quit();
  73. }
  74. private:
  75. WIG fWidget;
  76. bool fIsMain;
  77. };
  78. // ------------------------------------------------------
  79. // main entry point
  80. int main()
  81. {
  82. App app;
  83. SingleWidgetWindow<ExampleColorWidget> wColor(app);
  84. SingleWidgetWindow<ExampleImagesWidget> wImages(app, wColor);
  85. SingleWidgetWindow<ExampleRectanglesWidget> wRects(app, wColor);
  86. SingleWidgetWindow<ExampleShapesWidget> wShapes(app, wColor);
  87. SingleWidgetWindow<ExampleTextWidget> wText(app, wColor);
  88. app.exec();
  89. return 0;
  90. }
  91. // ------------------------------------------------------