*/}}

la_resource.c 10.0 KB

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