app.d 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //module app;
  2. import dlangui;
  3. mixin APP_ENTRY_POINT;
  4. /// entry point for dlangui based application
  5. extern (C) int UIAppMain(string[] args) {
  6. // load theme from file "theme_default.xml"
  7. //Platform.instance.uiTheme = "theme_default";
  8. // create window
  9. Log.d("Creating window");
  10. //Window window = Platform.instance.createWindow("DlangUI example - HelloWorld", null);
  11. Window window = Platform.instance.createWindow("local git for GPT - git4GPT", null, 1, 1200, 900);
  12. Log.d("Window created");
  13. // create some widget to show in window
  14. //window.mainWidget = (new Button()).text("Hello, world!"d).margins(Rect(20,20,20,20));
  15. window.mainWidget = parseML(q{
  16. VerticalLayout {
  17. margins: 4pt
  18. padding: 3pt
  19. layoutWidth: fill
  20. // red bold text with size = 150% of base style size and font face Arial
  21. //TextWidget { text: "Hello World example for DlangUI"; textColor: "red"; fontSize: 150%; fontWeight: 800; fontFace: "Arial" }
  22. //TextWidget { text: "______________________________ localhost RepoGPT ______________________________"; fontSize: 90%; fontFace: "Arial" }
  23. // arrange controls as form - table with two columns
  24. TableLayout {
  25. colCount: 2
  26. layoutWidth: fill
  27. TextWidget { text: "path to git repo" }
  28. EditLine { id: edit1; text: "todo read default path from toml file"; layoutWidth: fill }
  29. //ComboEdit { id: type1; text: ""; minWidth: 100pt; items: ["Exclude", "Include"] }
  30. ComboEdit { id: type1; text: ""; items: ["Exclude", "Include"] }
  31. //TextWidget { text: "param 2" }
  32. EditLine { id: edit2; text: "*.md, *.MD"; layoutWidth: fill }
  33. Button { id: btnRun; text: "Run" }
  34. Button { id: btnCopy; text: "Copy" }
  35. //TextWidget { text: "some radio buttons" }
  36. // arrange some radio buttons vertically
  37. //VerticalLayout {
  38. // layoutWidth: fill
  39. // RadioButton { id: rb1; text: "Item 1" }
  40. // RadioButton { id: rb2; text: "Item 2" }
  41. // RadioButton { id: rb3; text: "Item 3" }
  42. //}
  43. //TextWidget { text: "and checkboxes" }
  44. // arrange some checkboxes horizontally
  45. //HorizontalLayout {
  46. // layoutWidth: fill
  47. // CheckBox { id: cb1; text: "checkbox 1" }
  48. // CheckBox { id: cb2; text: "checkbox 2" }
  49. // ComboEdit { id: ce1; text: "some text"; minWidth: 20pt; items: ["Item 1", "Item 2", "Additional item"] }
  50. //}
  51. }
  52. //EditBox { layoutWidth: 20pt; layoutHeight: 10pt }
  53. EditBox { layoutWidth: FILL_PARENT; layoutHeight: FILL_PARENT; minWidth: 1000; minHeight: 750 }
  54. //EditBox { minWidth: 1000; minHeight: 200 }
  55. //HorizontalLayout {
  56. // Button { id: btnOk; text: "Ok" }
  57. // Button { id: btnCancel; text: "Cancel" }
  58. //}
  59. }
  60. });
  61. //window.mainWidget.minWidth(900);
  62. //window.mainWidget.minHeight(500);
  63. // you can access loaded items by id - e.g. to assign signal listeners
  64. auto edit1 = window.mainWidget.childById!EditLine("edit1");
  65. auto edit2 = window.mainWidget.childById!EditLine("edit2");
  66. // close window on Cancel button click
  67. //window.mainWidget.childById!Button("btnCancel").click = delegate(Widget w) {
  68. // window.close();
  69. // return true;
  70. //};
  71. // show message box with content of editors
  72. window.mainWidget.childById!Button("btnRun").click = delegate(Widget w) {
  73. window.showMessageBox(UIString.fromRaw("Run button pressed"d),
  74. UIString.fromRaw("Editors content\nEdit1: "d ~ edit1.text ~ "\nEdit2: "d ~ edit2.text));
  75. return true;
  76. };
  77. // show window
  78. window.show();
  79. // run message loop
  80. return Platform.instance.enterMessageLoop();
  81. }