*/}}

widgets.c 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. void Widgets(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  20. laColumn* c=laFirstColumn(uil);
  21. laColumn* cl,*cr;laSplitColumn(uil,c,0.5);cl=laLeftColumn(c,0);cr=laRightColumn(c,0);
  22. laShowLabel(uil,c,"This is a label",0,0);
  23. laShowLabel(uil,c,"This label is aligned to the center",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
  24. laShowLabel(uil,c,"This label is aligned to the right",0,0)->Flags|=LA_TEXT_ALIGN_RIGHT;
  25. laShowSeparator(uil,c);
  26. laUiItem* b=laBeginRow(uil,c,0,0);
  27. laShowLabel(uil,c,"This is a button:",0,0);
  28. laShowItem(uil,c,0,"LA_pure_yes_no");
  29. laEndRow(uil,b);
  30. laShowSeparator(uil,c);
  31. laUiItem* g=laMakeGroup(uil,cl,"Group",0); laUiList* gu=g->Page; laColumn* gc=laFirstColumn(gu);
  32. laShowLabel(gu,gc,"Label inside a group",0,0);
  33. g=laMakeTab(uil,cr,0);
  34. gu=laAddTabPage(g,"Page1"); gc=laFirstColumn(gu);
  35. laShowLabel(gu,gc,"Label 1 in tab",0,0);
  36. laShowLabel(gu,gc,"Label 2 in tab",0,0);
  37. gu=laAddTabPage(g,"Page2"); gc=laFirstColumn(gu);
  38. laShowLabel(gu,gc,"Label 3 in tab",0,0);
  39. laShowSeparator(uil,c);
  40. laShowLabel(uil,c,"Below are some built-in example properties,\ntry changing the values in them:",0,0)->Flags|=LA_TEXT_LINE_WRAP;
  41. laShowLabel(uil,cl,"Value slider:",0,0)->Flags|=LA_TEXT_ALIGN_RIGHT; laShowItem(uil,cr,0,"la.example_int");
  42. laShowLabel(uil,cl,"String editor:",0,0)->Flags|=LA_TEXT_ALIGN_RIGHT; laShowItem(uil,cr,0,"la.example_string")->Flags|=LA_TEXT_ONE_LINE;
  43. laShowLabel(uil,cl,"Color picker:",0,0)->Flags|=LA_TEXT_ALIGN_RIGHT; laShowItem(uil,cr,0,"la.themes.color");
  44. laShowLabel(uil,cl,"Multi-line string:",0,0)->Flags|=LA_TEXT_ALIGN_RIGHT;
  45. laShowItemFull(uil,cr,0,"la.example_string",LA_WIDGET_STRING_MULTI,0,0,0)->Extra->HeightCoeff=5;
  46. laShowSeparator(uil,c);
  47. laShowLabel(uil,cl,"This is a 3D viewer",0,0);
  48. laShowCanvas(uil,cl,0,"tns","la_3DView",6);
  49. laShowLabel(uil,cr,"And this is 2D",0,0);
  50. laCanvasExtra*ce=laShowCanvas(uil,cr,0,"tns.texture_list",0,6)->Extra; ce->ZoomX=10; ce->ZoomY=10;
  51. }
  52. int main(int argc, char *argv[]){
  53. laGetReady();
  54. laRegisterUiTemplate("my_widgets","Widgets", Widgets,0,0,"Demonstration", 0,0,0);
  55. laWindow* w = laDesignWindow(-1,-1,400,800);
  56. laLayout* l = laDesignLayout(w,"My Layout");
  57. laCreatePanel(l->FirstBlock,"my_widgets");
  58. laStartWindow(w);
  59. laMainLoop();
  60. }