name-dialog.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #if defined(Hiro_NameDialog)
  2. struct NameDialog {
  3. using type = NameDialog;
  4. NameDialog();
  5. auto create(string name = "") -> string;
  6. auto rename(string name) -> string;
  7. auto setIcon(const image& icon = {}) -> type&;
  8. auto setAlignment(Alignment = Alignment::Center) -> type&;
  9. auto setAlignment(sWindow relativeTo, Alignment = Alignment::Center) -> type&;
  10. auto setText(const string& text = {}) -> type&;
  11. auto setTitle(const string& title = {}) -> type&;
  12. private:
  13. auto show(string mode, string name) -> string;
  14. Window window;
  15. VerticalLayout layout{&window};
  16. Label textLabel{&layout, Size{~0, 0}};
  17. HorizontalLayout nameLayout{&layout, Size{~0, 0}};
  18. Canvas typeIcon{&nameLayout, Size{16_sx, 16_sy}};
  19. LineEdit nameValue{&nameLayout, Size{~0, 0}};
  20. HorizontalLayout controlLayout{&layout, Size{~0, 0}};
  21. Widget controlSpacer{&controlLayout, Size{~0, 0}};
  22. Button acceptButton{&controlLayout, Size{80, 0}};
  23. Button cancelButton{&controlLayout, Size{80, 0}};
  24. struct State {
  25. Alignment alignment = Alignment::Center;
  26. image icon;
  27. sWindow relativeTo;
  28. string text;
  29. string title;
  30. } state;
  31. string response;
  32. };
  33. #endif