*/}}

widget_flags.c 6.6 KB

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