main.cpp 1.4 KB

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