main.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. int main(int argn, char **argv) {
  19. // Create a window
  20. window = window_create(U"GUI template", 1000, 700);
  21. // Register your custom components here
  22. //REGISTER_PERSISTENT_CLASS(className);
  23. // Load an interface to the window
  24. window_loadInterfaceFromString(window, interfaceContent);
  25. // Bind methods to events
  26. window_setCloseEvent(window, []() {
  27. running = false;
  28. });
  29. // Get your component handles here
  30. //myComponent = window_findComponentByName(window, U"myComponent");
  31. // Bind your components to events here
  32. //component_setPressedEvent(myButton, []() {});
  33. // Execute
  34. while(running) {
  35. // Wait for actions so that we don't render until an action has been recieved
  36. // This will save battery on laptops for applications that don't require animation
  37. while (!window_executeEvents(window)) {
  38. time_sleepSeconds(0.01);
  39. }
  40. // Draw interface
  41. window_drawComponents(window);
  42. // Show the final image
  43. window_showCanvas(window);
  44. }
  45. }