*/}}

la_resource.c 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * LaGUI: A graphical application framework.
  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. extern struct _tnsMain *T;
  21. laUiType *_LA_UI_FIXED_GROUP;
  22. laUiType *_LA_UI_TAB;
  23. laUiType _LA_UI_CONDITION; //NO PTR
  24. laUiType _LA_UI_CONDITION_END; //NO PTR
  25. laUiType _LA_UI_CONDITION_ELSE; //NO PTR
  26. laUiType _LA_UI_ROW_BEGIN; //NO PTR
  27. laUiType _LA_UI_ROW_END; //NO PTR
  28. laUiType *_LA_UI_COLLECTION;
  29. laUiType *_LA_UI_COLLECTION_ITEM;
  30. laUiType *_LA_UI_COLLECTION_SELECTOR;
  31. laUiType *_LA_UI_COLLECTION_SINGLE;
  32. laUiType *_LA_UI_BUTTON;
  33. laUiType *_LA_UI_LABEL;
  34. laUiType *_LA_UI_INT;
  35. laUiType *_LA_UI_VALUE_METER;
  36. laUiType *_LA_UI_VALUE_METER_2D;
  37. laUiType *_LA_UI_FLOAT;
  38. laUiType *_LA_UI_FLOAT_COLOR;
  39. laUiType *_LA_UI_FLOAT_COLOR_HCY;
  40. laUiType *_LA_UI_ENUM_SELECTOR;
  41. laUiType *_LA_UI_MENU_ROOT;
  42. laUiType *_LA_UI_CONDITION_TOGGLE;
  43. laUiType *_LA_UI_STRING;
  44. laUiType *_LA_UI_STRING_MULTI;
  45. laUiType *_LA_UI_ALIGN;
  46. laUiType *_LA_UI_CANVAS;
  47. laUiType *_LA_UI_COLUMN_ADJUSTER;
  48. laUiType *_LA_UI_SYMBOL;
  49. laUiType *_LA_UI_COLUMN_VIEWER;
  50. laUiType *_LA_UI_NODE_SOCKET;
  51. laUiType *_LA_UI_HEIGHT_ADJUSTER;
  52. laUiType *_LA_UI_RAW;
  53. laUiType *_LA_UI_MAPPER;
  54. laUiType *_LA_UI_IMAGE;
  55. laUiDefineFunc _LA_SUBPROP_DONT_CARE;
  56. laBoxedTheme *_LA_THEME_PANEL;
  57. laBoxedTheme *_LA_THEME_VALUATOR;
  58. laBoxedTheme *_LA_THEME_BUTTON;
  59. laBoxedTheme *_LA_THEME_STRING;
  60. laBoxedTheme *_LA_THEME_SELECTOR;
  61. laBoxedTheme *_LA_THEME_COLLECTION_SELECTOR;
  62. laBoxedTheme *_LA_THEME_LABEL;
  63. laBoxedTheme *_LA_THEME_TAB;
  64. laBoxedTheme *_LA_THEME_COLLECTION_GROUP;
  65. laBoxedTheme *_LA_THEME_COLLECTION_ITEM;
  66. laBoxedTheme *_LA_THEME_FLOATING_PANEL;
  67. laBoxedTheme *_LA_THEME_3D_VIEW;
  68. laBoxedTheme *_LA_THEME_2D_VIEW;
  69. laBoxedTheme *_LA_THEME_SOCKET;
  70. laProp *_LA_PROP_PANEL;
  71. laProp *_LA_PROP_BLOCK;
  72. laProp *_LA_PROP_WINDOW;
  73. laProp *_LA_PROP_UI_ITEM;
  74. laProp *_LA_PROP_FAILED_ITEM;
  75. laProp *_LA_PROP_TRASH_ITEM;
  76. laProp *_LA_PROP_NODE_GRAPH;
  77. laPropContainer *_LA_PROP_3D_EXTRA;
  78. laPropContainer *_LA_PROP_2D_EXTRA;
  79. laPropContainer *_LA_PROP_FILE_BROWSER;
  80. laProp _P_LA_USE_INSTANCE_ONLY;
  81. void la_RegisterMainOperators(){
  82. la_RegisterUiOperatorsBasic();
  83. la_RegisterViewerOperators();
  84. la_RegisterBuiltinOperators();
  85. }
  86. void la_RegisterMainUiTypes(){
  87. la_RegisterUiTypesBasic();
  88. la_RegisterUiTypesViewerWidgets();
  89. }
  90. void la_RegisterWindowKeys(){
  91. laKeyMapper* km=&MAIN.KeyMap;
  92. laAssignNewKey(km, 0, "LA_udf_read", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'o', 0);
  93. laAssignNewKey(km, 0, "LA_managed_save", 0, LA_KEY_CTRL, LA_KEY_DOWN, 's', "quiet=true;");
  94. laAssignNewKey(km, 0, "LA_managed_save", 0, LA_KEY_CTRL|LA_KEY_SHIFT, LA_KEY_DOWN, 's', 0);
  95. laAssignNewKey(km, 0, "LA_manage_udf", 0, LA_KEY_SHIFT, LA_KEY_DOWN, 'r', 0);
  96. laAssignNewKey(km, 0, "LA_switch_layout", 0, LA_KEY_CTRL, LA_KEY_DOWN, LA_KEY_ARRLEFT, "reverse=true;");
  97. laAssignNewKey(km, 0, "LA_switch_layout", 0, LA_KEY_CTRL, LA_KEY_DOWN, LA_KEY_ARRRIGHT, 0);
  98. laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
  99. laAssignNewKey(km, 0, "LA_undo", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'z', 0);
  100. laAssignNewKey(km, 0, "LA_redo", 0, LA_KEY_CTRL|LA_KEY_SHIFT, LA_KEY_DOWN, 'z', 0);
  101. laAssignNewKey(km, 0, "LA_fullscreen", 0, 0, LA_KEY_DOWN, LA_KEY_F11, "toggle=true;");
  102. }
  103. void la_RegisterMainThemes(){
  104. laBoxedTheme *bt;
  105. strSafeSet(&MAIN.example_string,
  106. "hello(){\n"
  107. " world!\n"
  108. " This is a LaGUI application 🤔\n"
  109. "}");
  110. la_UDFAppendSharedTypePointer("BT Panel", &_LA_THEME_PANEL);
  111. la_UDFAppendSharedTypePointer("BT Floating Panel", &_LA_THEME_FLOATING_PANEL);
  112. la_UDFAppendSharedTypePointer("BT Valuator", &_LA_THEME_VALUATOR);
  113. la_UDFAppendSharedTypePointer("BT Button", &_LA_THEME_BUTTON);
  114. la_UDFAppendSharedTypePointer("BT String", &_LA_THEME_STRING);
  115. la_UDFAppendSharedTypePointer("BT Selector", &_LA_THEME_SELECTOR);
  116. la_UDFAppendSharedTypePointer("BT Collection Selector", &_LA_THEME_COLLECTION_SELECTOR);
  117. la_UDFAppendSharedTypePointer("BT Label", &_LA_THEME_LABEL);
  118. la_UDFAppendSharedTypePointer("BT Tab", &_LA_THEME_TAB);
  119. la_UDFAppendSharedTypePointer("BT Collection Group", &_LA_THEME_COLLECTION_GROUP);
  120. la_UDFAppendSharedTypePointer("BT Collection Item", &_LA_THEME_COLLECTION_ITEM);
  121. la_UDFAppendSharedTypePointer("BT 3D Viewer", &_LA_THEME_3D_VIEW);
  122. la_UDFAppendSharedTypePointer("BT 2D Viewer", &_LA_THEME_2D_VIEW);
  123. la_UDFAppendSharedTypePointer("BT Socket", &_LA_THEME_SOCKET);
  124. laTheme *t;
  125. t = laDesignTheme("Classic Light", "YimingWu");{
  126. LA_SET3(t->Color, 0.58,0.58,0.55);
  127. LA_SET3(t->AccentColor, 0.27,0.47,0.79);
  128. t->InactiveMix=0.7; t->InactiveSaturation=0.2;
  129. t->CursorAlpha=0.9; t->SelectionAlpha=0.3;
  130. t->WireBrightness=0.5; t->WireSaturation=0.6; t->WireTransparency=0.65;
  131. t->EdgeBrightness=0.65; t->EdgeTransparency=0.8; t->VertexBrightness=0.65, t->VertexTransparency=0.9;
  132. t->SelectedFaceTransparency=0.6,t->SelectedEdgeTransparency=0.9, t->SelectedVertexTransparency=1.0;
  133. laDesignBoxedTheme(t, "Panel",&_LA_THEME_PANEL,
  134. 0.85, 0.5, 0.9, 0.2, 0.1, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  135. laDesignBoxedTheme(t, "Floating Panel",&_LA_THEME_FLOATING_PANEL,
  136. 0.95, 0.8, 0.15, 0.15, 0.1, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  137. laDesignBoxedTheme(t, "Valuator",&_LA_THEME_VALUATOR,
  138. 0.8, 0.5, 0.3, 0.2, 0.1, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  139. laDesignBoxedTheme(t, "Button",&_LA_THEME_BUTTON,
  140. 0.97, 0.2, 0.3, 0.2, 0.9, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  141. laDesignBoxedTheme(t, "String",&_LA_THEME_STRING,
  142. 0.9, 0.95, 0.3, 0.2, 0.1, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  143. laDesignBoxedTheme(t, "Selector",&_LA_THEME_SELECTOR,
  144. 0.97, 0.25, 0.3, 0.2, 0.9, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  145. laDesignBoxedTheme(t, "Collection Selector",&_LA_THEME_COLLECTION_SELECTOR,
  146. 0.85, 0.7, 0.3, 0.2, 0.1, 0.95, 0, 0, -1, -1, 1, 1, 1, 1);
  147. laDesignBoxedTheme(t, "Label",&_LA_THEME_LABEL,
  148. 0.7, 0.8, 0.3, 0.1, 0.05, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  149. laDesignBoxedTheme(t, "Tab",&_LA_THEME_TAB,
  150. 0.9, 0.8, 0.2, 0.1, 0.7, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  151. laDesignBoxedTheme(t, "Socket",&_LA_THEME_SOCKET,
  152. 0.97, 0.2, 0.3, 0.2, 0.9, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  153. laDesignBoxedTheme(t, "Collection Group",&_LA_THEME_COLLECTION_GROUP,
  154. 0.75, 0.65, 0.2, 0.1, 0.7, 0.3, 1, 1, 0, 0, 1, 1, 1, 1);
  155. laDesignBoxedTheme(t, "Collection Item",&_LA_THEME_COLLECTION_ITEM,
  156. 0.75, 0.65, 0.2, 0.1, 0.7, 0.3, 1, 1, 0, 0, 1, 1, 1, 1);
  157. laDesignBoxedTheme(t, "3D Viewer",&_LA_THEME_3D_VIEW,
  158. 0.75, 0.6, 0.50, 0.1, 0.92, 0.6, 1, 1, 1, 1, 1, 1, 1, 1);
  159. laDesignBoxedTheme(t, "2D Viewer",&_LA_THEME_2D_VIEW,
  160. 0.75, 0.6, 0.50, 0.1, 0.92, 0.6, 1, 1, 1, 1, 1, 1, 1, 1);
  161. la_RefreshThemeColor(t);
  162. }
  163. laTheme* t1=t;
  164. t = laDesignTheme("Classic Dark", "YimingWu");{
  165. LA_SET3(t->Color, 0.5,0.4,0.3);
  166. LA_SET3(t->AccentColor, 0.17,0.74,0.49);
  167. t->InactiveMix=0.7; t->InactiveSaturation=0.2;
  168. t->CursorAlpha=0.9; t->SelectionAlpha=0.3;
  169. t->WireBrightness=0.6; t->WireSaturation=0.7; t->WireTransparency=0.65;
  170. t->EdgeBrightness=0.05; t->EdgeTransparency=0.8; t->VertexBrightness=0.05, t->VertexTransparency=0.9;
  171. t->SelectedFaceTransparency=0.6,t->SelectedEdgeTransparency=0.9, t->SelectedVertexTransparency=1.0;
  172. bt = laDesignBoxedTheme(t, "Panel",&_LA_THEME_PANEL,
  173. 0.2, 0.2, 0.1, 0.7, 0.9, 0.8, 1, 1, 1, 1, 1, 1, 1, 1);
  174. memAssignRef(bt, &bt->Parent, t1);
  175. bt = laDesignBoxedTheme(t, "Floating Panel",&_LA_THEME_FLOATING_PANEL,
  176. 0.05, 0.05, 0.4, 0.8, 0.9, 0.8, 1, 1, 1, 1, 1, 1, 1, 1);
  177. memAssignRef(bt, &bt->Parent, t1);
  178. bt = laDesignBoxedTheme(t, "Valuator",&_LA_THEME_VALUATOR,
  179. 0.3, 0.1, 0.4, 0.8, 0.9, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  180. memAssignRef(bt, &bt->Parent, t1);
  181. bt = laDesignBoxedTheme(t, "Button",&_LA_THEME_BUTTON,
  182. 0.1, 0.9, 0.3, 0.8, 0.1, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  183. bt = laDesignBoxedTheme(t, "String",&_LA_THEME_STRING,
  184. 0.1, 0.03, 0.3, 0.8, 0.9, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  185. bt = laDesignBoxedTheme(t, "Selector",&_LA_THEME_SELECTOR,
  186. 0.15, 0.7, 0.3, 0.8, 0.2, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  187. bt = laDesignBoxedTheme(t, "Collection Selector",&_LA_THEME_COLLECTION_SELECTOR,
  188. 0.15, 0.1, 0.3, 0.8, 0.9, 0.95, 0, 0, -1, -1, 1, 1, 1, 1);
  189. bt = laDesignBoxedTheme(t, "Label",&_LA_THEME_LABEL,
  190. 0.15, 0.1, 0.3, 0.8, 0.9, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  191. bt = laDesignBoxedTheme(t, "Tab",&_LA_THEME_TAB,
  192. 0.2, 0.3, 0.8, 0.7, 0.1, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  193. bt = laDesignBoxedTheme(t, "Socket",&_LA_THEME_SOCKET,
  194. 0.1, 0.65, 0.7, 0.8, 0.1, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  195. bt = laDesignBoxedTheme(t, "Collection Group",&_LA_THEME_COLLECTION_GROUP,
  196. 0.25, 0.35, 0.8, 0.7, 0.1, 0.3, 1, 1, 0, 0, 1, 1, 1, 1);
  197. bt = laDesignBoxedTheme(t, "Collection Item",&_LA_THEME_COLLECTION_ITEM,
  198. 0.25, 0.35, 0.8, 0.7, 0.1, 0.3, 1, 1, 0, 0, 1, 1, 1, 1);
  199. bt = laDesignBoxedTheme(t, "3D Viewer",&_LA_THEME_3D_VIEW,
  200. 0.25, 0.5, 0.5, 0.7, 0.1, 0.6, 1, 1, 1, 1, 1, 1, 1, 1);
  201. bt = laDesignBoxedTheme(t, "2D Viewer",&_LA_THEME_2D_VIEW,
  202. 0.25, 0.5, 0.55, 0.7, 0.1, 0.6, 1, 1, 1, 1, 1, 1, 1, 1);
  203. la_RefreshThemeColor(t);
  204. }
  205. }