*/}}
1
0

la_resource.c 10 KB

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