*/}}

widget_flags.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. #define SHOW_FLAG(what) \
  20. laShowSeparator(uil,c); laShowLabel(uil,cl, #what ,0,0)->Flags|=LA_TEXT_MONO;
  21. #define BR b=laBeginRow(uil,cr,0,0);
  22. #define ER laEndRow(uil,b);
  23. void Widgets(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
  24. laColumn* c=laFirstColumn(uil);
  25. laColumn* cl,*cr;laSplitColumn(uil,c,0.3);cl=laLeftColumn(c,0);cr=laRightColumn(c,0);
  26. laUiItem* b;
  27. laShowColumnAdjuster(uil,c);
  28. laShowLabel(uil,cl,"UI Flags",0,0); laShowLabel(uil,cr,"Description",0,0);
  29. SHOW_FLAG(LA_UI_FLAGS_EXPAND);
  30. laShowLabel(uil,cr,"Enum properties are shown with a menu.",0,0);
  31. BR laShowItem(uil,cr,0,"la.user_preferences.panel_multisample"); ER
  32. laShowLabel(uil,cr,"You can expand the enum selections by using this flag.",0,0);
  33. BR laShowItem(uil,cr,0,"la.user_preferences.panel_multisample")->Flags|=LA_UI_FLAGS_EXPAND; ER
  34. SHOW_FLAG(LA_UI_FLAGS_TRANSPOSE);
  35. laShowLabel(uil,cr,"And you can also make the expansion vertical.",0,0);
  36. laShowLabel(uil,cr,"This also applies to array values.",0,0);
  37. BR laShowItem(uil,cr,0,"la.user_preferences.panel_multisample")->Flags|=LA_UI_FLAGS_TRANSPOSE|LA_UI_FLAGS_EXPAND; ER
  38. SHOW_FLAG(LA_UI_FLAGS_ICON);
  39. laShowLabel(uil,cr,"Buttons/Selectors typically show an icon and a name.",0,0);
  40. BR laShowItem(uil,cr,0,"LA_pure_yes_no"); ER
  41. laShowLabel(uil,cr,"You could choose to only show icons.",0,0);
  42. BR laShowItem(uil,cr,0,"LA_pure_yes_no")->Flags|=LA_UI_FLAGS_ICON; ER
  43. SHOW_FLAG(LA_UI_FLAGS_NO_DECAL);
  44. laShowLabel(uil,cr,"This stops the UI from drawing background box.",0,0);
  45. laShowLabel(uil,cr,"The UI will still accept user inputs.",0,0);
  46. BR laShowItem(uil,cr,0,"la.user_preferences.interface_size"); laShowItem(uil,cr,0,"la.user_preferences.interface_size")->Flags|=LA_UI_FLAGS_NO_DECAL; ER
  47. BR laShowItem(uil,cr,0,"la.user_preferences.panel_multisample"); laShowItem(uil,cr,0,"la.user_preferences.panel_multisample")->Flags|=LA_UI_FLAGS_NO_DECAL; ER
  48. SHOW_FLAG(LA_UI_FLAGS_NO_EVENT);
  49. laShowLabel(uil,cr,"This stops the UI from accepting user inputs.",0,0);
  50. BR laShowItem(uil,cr,0,"la.user_preferences.interface_size")->Flags|=LA_UI_FLAGS_NO_EVENT; ER
  51. BR laShowItem(uil,cr,0,"la.user_preferences.panel_multisample")->Flags|=LA_UI_FLAGS_NO_EVENT; ER
  52. SHOW_FLAG(LA_UI_FLAGS_NO_CONFIRM);
  53. laShowLabel(uil,cr,"This stops widgets from generating a confirm event when executed or values changed.",0,0)->Flags|=LA_TEXT_LINE_WRAP;
  54. SHOW_FLAG(LA_TEXT_ALIGN_LEFT);
  55. laShowLabel(uil,cr,"A lot of widgets supports text aligning flags, not just labels.",0,0);
  56. laShowLabel(uil,cr,"Align left",0,0)->Flags|=LA_TEXT_ALIGN_LEFT;
  57. SHOW_FLAG(LA_TEXT_ALIGN_CENTER);
  58. laShowLabel(uil,cr,"Align center",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
  59. SHOW_FLAG(LA_TEXT_ALIGN_RIGHT);
  60. laShowLabel(uil,cr,"Align right",0,0)->Flags|=LA_TEXT_ALIGN_RIGHT;
  61. SHOW_FLAG(LA_TEXT_ALIGN_AUTO);
  62. laShowLabel(uil,cr,"Align auto",0,0)->Flags|=LA_TEXT_ALIGN_AUTO;
  63. SHOW_FLAG(LA_TEXT_USE_NEWLINE);
  64. laShowLabel(uil,cr,"Will use '\\n' in string properties and switch to a new line.",0,0);
  65. SHOW_FLAG(LA_TEXT_LINE_WRAP);
  66. laShowLabel(uil,cr,"Will use '\\n' in labels\n as well as wrapping the line.",0,0)->Flags|=LA_TEXT_LINE_WRAP;
  67. SHOW_FLAG(LA_TEXT_REVERT_Y);
  68. laShowLabel(uil,cr,"Text would be drawn up-size-down, convenient in different coordinate systems.",0,0)->Flags|=LA_TEXT_LINE_WRAP;
  69. laShowLabel(uil,cr," ",0,0);
  70. laShowLabel(uil,cr,"Just like this",0,0)->Flags|=LA_TEXT_REVERT_Y;
  71. SHOW_FLAG(LA_TEXT_MONO);
  72. laShowLabel(uil,cr,"Text would be in monospace font.",0,0);
  73. SHOW_FLAG(LA_UI_FLAGS_PREFER_BOTTOM);
  74. laShowLabel(uil,cr,"UI list would prefer to stay at the bottom.",0,0);
  75. laShowLabel(uil,cr,"Resize the terminal window and see the effect.",0,0);
  76. BR laShowItemFull(uil,cr,0,"LA_panel_activator",0,"panel_id=LAUI_terminal;text=Show Terminal",0,0); ER
  77. SHOW_FLAG(LA_UI_FLAGS_NO_GAP);
  78. laShowLabel(uil,cr,"Draw UI as if there's no gap between itself and its adjacent UI items.",0,0);
  79. BR laShowItem(uil,cr,0,"LA_pure_yes_no"); ER
  80. BR laShowItem(uil,cr,0,"LA_pure_yes_no")->Flags|=LA_UI_FLAGS_NO_GAP; laShowLabel(uil,cr," <-- Like this one",0,0); ER
  81. SHOW_FLAG(LA_UI_FLAGS_UNDERNEATH);
  82. laShowLabel(uil,cr,"Show this UI item as if it's underneath the next one.",0,0);
  83. laShowLabel(uil,cr,"Under",0,0)->Flags|=LA_UI_FLAGS_UNDERNEATH;
  84. laShowLabel(uil,cr,"--------- Over",0,0);
  85. SHOW_FLAG(LA_UI_FLAGS_NO_HEIGHT);
  86. laShowLabel(uil,cr,"Same as above, but also removes margins etc.",0,0);
  87. SHOW_FLAG(LA_UI_FLAGS_NO_OVERLAY);
  88. laShowLabel(uil,cr,"Hide UI overlays on top of a canvas widget",0,0);
  89. SHOW_FLAG(LA_TEXT_OVERFLOW_ARROW);
  90. laShowLabel(uil,cr,"Show an arrow in long string box",0,0);
  91. BR laShowItem(uil,cr,0,"la.example_string")->Flags|=LA_TEXT_ONE_LINE|LA_TEXT_OVERFLOW_ARROW; ER
  92. SHOW_FLAG(LA_UI_FLAGS_DISABLED);
  93. laShowLabel(uil,cr,"Like this, also used on other widgets",0,0)->Flags|=LA_UI_FLAGS_DISABLED;
  94. SHOW_FLAG(LA_UI_FLAGS_HIGHLIGHT);
  95. laShowLabel(uil,cr,"Like this, also used on other widgets",0,0)->Flags|=LA_UI_FLAGS_HIGHLIGHT;
  96. SHOW_FLAG(LA_UI_FLAGS_NODE_CONTAINER);
  97. laShowLabel(uil,cr,"Set this UI as the node container",0,0);
  98. SHOW_FLAG(LA_UI_COLLECTION_NO_HIGHLIGHT);
  99. laShowLabel(uil,cr,"If this is a collection UI, then this stops it from showing the background of active element.",0,0)->Flags|=LA_TEXT_LINE_WRAP;
  100. SHOW_FLAG(LA_TEXT_ONE_LINE);
  101. laShowLabel(uil,cr,"Show string property values in one line, even if there's a '\\n'.",0,0)->Flags|=LA_TEXT_LINE_WRAP;
  102. SHOW_FLAG(LA_UI_FLAGS_INT_ICON);
  103. laShowLabel(uil,cr,"Show an int property as if its value is a unicode codepoint and display its corresponding glyph.'.",0,0)->Flags|=LA_TEXT_LINE_WRAP;
  104. SHOW_FLAG(LA_UI_FLAGS_PLAIN);
  105. laShowLabel(uil,cr,"LA_UI_FLAGS_NO_DECAL|LA_UI_FLAGS_NO_EVENT",0,0)->Flags|=LA_TEXT_MONO;
  106. SHOW_FLAG(LA_UI_SOCKET_LABEL_N);
  107. laShowLabel(uil,cr,"Set node socket label to north. Default not shown.",0,0);
  108. SHOW_FLAG(LA_UI_SOCKET_LABEL_S);
  109. SHOW_FLAG(LA_UI_SOCKET_LABEL_W);
  110. SHOW_FLAG(LA_UI_SOCKET_LABEL_E);
  111. }
  112. int main(int argc, char *argv[]){
  113. laGetReady();
  114. laRegisterUiTemplate("my_widget_flags","Widget Flags", Widgets,0,0,"Demonstration", 0,0,0);
  115. laWindow* w = laDesignWindow(-1,-1,1000,600);
  116. laLayout* l = laDesignLayout(w,"My Layout");
  117. laCreatePanel(l->FirstBlock,"my_widget_flags");
  118. laStartWindow(w);
  119. laMainLoop();
  120. }