main.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. 
  2. #include "../../DFPSR/includeFramework.h"
  3. using namespace dsr;
  4. // Embedding your interface's layout is the simplest way to get started
  5. // It works even if the application is called from another folder
  6. String interfaceContent =
  7. UR"QUOTE(
  8. Begin : Panel
  9. Name = "mainPanel"
  10. Color = 150,160,170
  11. Solid = 1
  12. End
  13. )QUOTE";
  14. // Global
  15. bool running = true;
  16. // GUI handles
  17. Window window;
  18. DSR_MAIN_CALLER(dsrMain)
  19. void dsrMain(List<String> args) {
  20. // Create a window
  21. window = window_create(U"GUI template", 1000, 700);
  22. // Register your custom components here
  23. //REGISTER_PERSISTENT_CLASS(className);
  24. // Load an interface to the window
  25. window_loadInterfaceFromString(window, interfaceContent);
  26. // Bind methods to events
  27. window_setCloseEvent(window, []() {
  28. running = false;
  29. });
  30. // Get your component handles here
  31. //myComponent = window_findComponentByName(window, U"myComponent");
  32. // Bind your components to events here
  33. //component_setPressedEvent(myButton, []() {});
  34. // Execute
  35. while(running) {
  36. // Wait for actions so that we don't render until an action has been recieved
  37. // This will save battery on laptops for applications that don't require animation
  38. while (!window_executeEvents(window)) {
  39. time_sleepSeconds(0.01);
  40. }
  41. // Draw interface
  42. window_drawComponents(window);
  43. // Show the final image
  44. window_showCanvas(window);
  45. }
  46. }