*/}}

operator.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Part of LaGUI demonstration programs
  3. * Copyright (C) 2022-2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "la_5.h"
  19. extern LA MAIN;
  20. int INV_MyOperator(laOperator* a, laEvent* e){
  21. printf("Something happened in stdout!\n");
  22. logPrint("Something happened in LaGUI terminal!\n");
  23. return LA_FINISHED;
  24. }
  25. int INV_MyModalOperator(laOperator* a, laEvent* e){
  26. printf("Modal opeator!\n");
  27. logPrint("Modal opeator!\n");
  28. return LA_RUNNING;
  29. }
  30. int MOD_MyModalOperator(laOperator* a, laEvent* e){
  31. printf("%d,%d\n",e->x,e->y);
  32. logPrint("%d,%d\n",e->x,e->y);
  33. if(e->type==LA_R_MOUSE_DOWN){
  34. printf("Modal opeator finished!\n");
  35. logPrint("Modal opeator finished!\n");
  36. return LA_FINISHED;
  37. }
  38. return LA_RUNNING;
  39. }
  40. void MyPanel(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  41. laColumn* c=laFirstColumn(uil);
  42. laShowLabel(uil,c,"Hello world!",0,0);
  43. laShowItem(uil,c,0,"MY_invoke_test");
  44. laShowItem(uil,c,0,"MY_modal_test");
  45. }
  46. int main(int argc, char *argv[]){
  47. laGetReady();
  48. laCreateOperatorType("MY_invoke_test", "Something!", "Print some strings.",0,0,0,INV_MyOperator,0,L'🗨',0);
  49. laCreateOperatorType("MY_modal_test", "Modal!", "Print mouse positions.",0,0,0,INV_MyModalOperator,MOD_MyModalOperator,L'🏃',0);
  50. laRegisterUiTemplate("my_panel","My Panel", MyPanel,0,0,"Demonstration", 0,0,0);
  51. // Uncomment this to load preferences.
  52. // laEnsureUserPreferences();
  53. if(!MAIN.Windows.pFirst){
  54. laWindow* w = laDesignWindow(-1,-1,600,600);
  55. laLayout* l = laDesignLayout(w,"My Layout");
  56. laSplitBlockHorizon(l->FirstBlock,0.5);
  57. laCreatePanel(l->FirstBlock->B1,"LAUI_terminal");
  58. laCreatePanel(l->FirstBlock->B2,"my_panel");
  59. laStartWindow(w);
  60. }
  61. laMainLoop();
  62. }