app.d 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. ComboBox { id: type1; text: ""; items: ["Exclude", "Include"] }
  32. //TextWidget { text: "param 2" }
  33. EditLine { id: edit2; text: "*.md, *.MD"; layoutWidth: fill }
  34. Button { id: btnRun; text: "Run" }
  35. Button { id: btnCopy; text: "Copy" }
  36. //TextWidget { text: "some radio buttons" }
  37. // arrange some radio buttons vertically
  38. //VerticalLayout {
  39. // layoutWidth: fill
  40. // RadioButton { id: rb1; text: "Item 1" }
  41. // RadioButton { id: rb2; text: "Item 2" }
  42. // RadioButton { id: rb3; text: "Item 3" }
  43. //}
  44. //TextWidget { text: "and checkboxes" }
  45. // arrange some checkboxes horizontally
  46. //HorizontalLayout {
  47. // layoutWidth: fill
  48. // CheckBox { id: cb1; text: "checkbox 1" }
  49. // CheckBox { id: cb2; text: "checkbox 2" }
  50. // ComboEdit { id: ce1; text: "some text"; minWidth: 20pt; items: ["Item 1", "Item 2", "Additional item"] }
  51. //}
  52. }
  53. //EditBox { layoutWidth: 20pt; layoutHeight: 10pt }
  54. EditBox { layoutWidth: FILL_PARENT; layoutHeight: FILL_PARENT; minWidth: 1000; minHeight: 750 }
  55. //EditBox { minWidth: 1000; minHeight: 200 }
  56. //HorizontalLayout {
  57. // Button { id: btnOk; text: "Ok" }
  58. // Button { id: btnCancel; text: "Cancel" }
  59. //}
  60. }
  61. });
  62. //window.mainWidget.minWidth(900);
  63. //window.mainWidget.minHeight(500);
  64. // you can access loaded items by id - e.g. to assign signal listeners
  65. auto edit1 = window.mainWidget.childById!EditLine("edit1");
  66. auto edit2 = window.mainWidget.childById!EditLine("edit2");
  67. // close window on Cancel button click
  68. //window.mainWidget.childById!Button("btnCancel").click = delegate(Widget w) {
  69. // window.close();
  70. // return true;
  71. //};
  72. // show message box with content of editors
  73. window.mainWidget.childById!Button("btnRun").click = delegate(Widget w) {
  74. window.showMessageBox(UIString.fromRaw("Run button pressed"d),
  75. UIString.fromRaw("Editors content\nEdit1: "d ~ edit1.text ~ "\nEdit2: "d ~ edit2.text));
  76. return true;
  77. };
  78. // show window
  79. window.show();
  80. // run message loop
  81. return Platform.instance.enterMessageLoop();
  82. }