*/}}

la_resource.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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_RegisterViewerOperators();
  84. void la_RegisterMainOperators(){
  85. la_RegisterUiOperatorsBasic();
  86. la_RegisterViewerOperators();
  87. la_RegisterBuiltinOperators();
  88. }
  89. void la_RegisterMainUiTypes(){
  90. la_RegisterUiTypesBasic();
  91. la_RegisterUiTypesViewerWidgets();
  92. }
  93. void la_RegisterWindowKeys(){
  94. laKeyMapper* km=&MAIN.KeyMap;
  95. laAssignNewKey(km, 0, "LA_udf_read", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'o', 0);
  96. laAssignNewKey(km, 0, "LA_managed_save", 0, LA_KEY_CTRL, LA_KEY_DOWN, 's', "quiet=true;");
  97. laAssignNewKey(km, 0, "LA_managed_save", 0, LA_KEY_CTRL|LA_KEY_SHIFT, LA_KEY_DOWN, 's', 0);
  98. laAssignNewKey(km, 0, "LA_manage_udf", 0, LA_KEY_SHIFT, LA_KEY_DOWN, 'r', 0);
  99. laAssignNewKey(km, 0, "LA_switch_layout", 0, LA_KEY_CTRL, LA_KEY_DOWN, LA_KEY_ARRLEFT, "reverse=true;");
  100. laAssignNewKey(km, 0, "LA_switch_layout", 0, LA_KEY_CTRL, LA_KEY_DOWN, LA_KEY_ARRRIGHT, 0);
  101. laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
  102. laAssignNewKey(km, 0, "LA_undo", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'z', 0);
  103. laAssignNewKey(km, 0, "LA_redo", 0, LA_KEY_CTRL|LA_KEY_SHIFT, LA_KEY_DOWN, 'z', 0);
  104. laAssignNewKey(km, 0, "LA_fullscreen", 0, 0, LA_KEY_DOWN, LA_KEY_F11, "toggle=true;");
  105. }
  106. void la_RegisterMainThemes(){
  107. laBoxedTheme *bt;
  108. strSafeSet(&MAIN.example_string,
  109. "hello(){\n"
  110. " world!\n"
  111. " This is a LaGUI application 🤔\n"
  112. "}");
  113. la_UDFAppendSharedTypePointer("BT Panel", &_LA_THEME_PANEL);
  114. la_UDFAppendSharedTypePointer("BT Floating Panel", &_LA_THEME_FLOATING_PANEL);
  115. la_UDFAppendSharedTypePointer("BT Valuator", &_LA_THEME_VALUATOR);
  116. la_UDFAppendSharedTypePointer("BT Button", &_LA_THEME_BUTTON);
  117. la_UDFAppendSharedTypePointer("BT String", &_LA_THEME_STRING);
  118. la_UDFAppendSharedTypePointer("BT Selector", &_LA_THEME_SELECTOR);
  119. la_UDFAppendSharedTypePointer("BT Collection Selector", &_LA_THEME_COLLECTION_SELECTOR);
  120. la_UDFAppendSharedTypePointer("BT Label", &_LA_THEME_LABEL);
  121. la_UDFAppendSharedTypePointer("BT Tab", &_LA_THEME_TAB);
  122. la_UDFAppendSharedTypePointer("BT Collection Group", &_LA_THEME_COLLECTION_GROUP);
  123. la_UDFAppendSharedTypePointer("BT Collection Item", &_LA_THEME_COLLECTION_ITEM);
  124. la_UDFAppendSharedTypePointer("BT 3D Viewer", &_LA_THEME_3D_VIEW);
  125. la_UDFAppendSharedTypePointer("BT 2D Viewer", &_LA_THEME_2D_VIEW);
  126. la_UDFAppendSharedTypePointer("BT Socket", &_LA_THEME_SOCKET);
  127. laTheme *t;
  128. t = laDesignTheme("Classic Light", "YimingWu");{
  129. LA_SET3(t->Color, 0.58,0.58,0.55);
  130. LA_SET3(t->AccentColor, 0.27,0.47,0.79);
  131. t->InactiveMix=0.7; t->InactiveSaturation=0.2;
  132. t->CursorAlpha=0.9; t->SelectionAlpha=0.3;
  133. t->WireBrightness=0.5; t->WireSaturation=0.6; t->WireTransparency=0.65;
  134. t->EdgeBrightness=0.65; t->EdgeTransparency=0.8; t->VertexBrightness=0.65, t->VertexTransparency=0.9;
  135. t->SelectedFaceTransparency=0.6,t->SelectedEdgeTransparency=0.9, t->SelectedVertexTransparency=1.0;
  136. laDesignBoxedTheme(t, "Panel",&_LA_THEME_PANEL,
  137. 0.85, 0.5, 0.9, 0.2, 0.1, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  138. laDesignBoxedTheme(t, "Floating Panel",&_LA_THEME_FLOATING_PANEL,
  139. 0.95, 0.8, 0.15, 0.15, 0.1, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  140. laDesignBoxedTheme(t, "Valuator",&_LA_THEME_VALUATOR,
  141. 0.8, 0.5, 0.3, 0.2, 0.1, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  142. laDesignBoxedTheme(t, "Button",&_LA_THEME_BUTTON,
  143. 0.97, 0.2, 0.3, 0.2, 0.9, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  144. laDesignBoxedTheme(t, "String",&_LA_THEME_STRING,
  145. 0.9, 0.95, 0.3, 0.2, 0.1, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  146. laDesignBoxedTheme(t, "Selector",&_LA_THEME_SELECTOR,
  147. 0.97, 0.25, 0.3, 0.2, 0.9, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  148. laDesignBoxedTheme(t, "Collection Selector",&_LA_THEME_COLLECTION_SELECTOR,
  149. 0.85, 0.7, 0.3, 0.2, 0.1, 0.95, 0, 0, -1, -1, 1, 1, 1, 1);
  150. laDesignBoxedTheme(t, "Label",&_LA_THEME_LABEL,
  151. 0.7, 0.8, 0.3, 0.1, 0.05, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  152. laDesignBoxedTheme(t, "Tab",&_LA_THEME_TAB,
  153. 0.9, 0.8, 0.2, 0.1, 0.7, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  154. laDesignBoxedTheme(t, "Socket",&_LA_THEME_SOCKET,
  155. 0.97, 0.2, 0.3, 0.2, 0.9, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  156. laDesignBoxedTheme(t, "Collection Group",&_LA_THEME_COLLECTION_GROUP,
  157. 0.75, 0.65, 0.2, 0.1, 0.7, 0.3, 1, 1, 0, 0, 1, 1, 1, 1);
  158. laDesignBoxedTheme(t, "Collection Item",&_LA_THEME_COLLECTION_ITEM,
  159. 0.75, 0.65, 0.2, 0.1, 0.7, 0.3, 1, 1, 0, 0, 1, 1, 1, 1);
  160. laDesignBoxedTheme(t, "3D Viewer",&_LA_THEME_3D_VIEW,
  161. 0.75, 0.6, 0.50, 0.1, 0.92, 0.6, 1, 1, 1, 1, 1, 1, 1, 1);
  162. laDesignBoxedTheme(t, "2D Viewer",&_LA_THEME_2D_VIEW,
  163. 0.75, 0.6, 0.50, 0.1, 0.92, 0.6, 1, 1, 1, 1, 1, 1, 1, 1);
  164. la_RefreshThemeColor(t);
  165. }
  166. laTheme* t1=t;
  167. t = laDesignTheme("Classic Dark", "YimingWu");{
  168. LA_SET3(t->Color, 0.5,0.4,0.3);
  169. LA_SET3(t->AccentColor, 0.17,0.74,0.49);
  170. t->InactiveMix=0.7; t->InactiveSaturation=0.2;
  171. t->CursorAlpha=0.9; t->SelectionAlpha=0.3;
  172. t->WireBrightness=0.6; t->WireSaturation=0.7; t->WireTransparency=0.65;
  173. t->EdgeBrightness=0.05; t->EdgeTransparency=0.8; t->VertexBrightness=0.05, t->VertexTransparency=0.9;
  174. t->SelectedFaceTransparency=0.6,t->SelectedEdgeTransparency=0.9, t->SelectedVertexTransparency=1.0;
  175. bt = laDesignBoxedTheme(t, "Panel",&_LA_THEME_PANEL,
  176. 0.2, 0.2, 0.1, 0.7, 0.9, 0.8, 1, 1, 1, 1, 1, 1, 1, 1);
  177. memAssignRef(bt, &bt->Parent, t1);
  178. bt = laDesignBoxedTheme(t, "Floating Panel",&_LA_THEME_FLOATING_PANEL,
  179. 0.05, 0.05, 0.4, 0.8, 0.9, 0.8, 1, 1, 1, 1, 1, 1, 1, 1);
  180. memAssignRef(bt, &bt->Parent, t1);
  181. bt = laDesignBoxedTheme(t, "Valuator",&_LA_THEME_VALUATOR,
  182. 0.3, 0.1, 0.4, 0.8, 0.9, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  183. memAssignRef(bt, &bt->Parent, t1);
  184. bt = laDesignBoxedTheme(t, "Button",&_LA_THEME_BUTTON,
  185. 0.1, 0.9, 0.3, 0.8, 0.1, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  186. bt = laDesignBoxedTheme(t, "String",&_LA_THEME_STRING,
  187. 0.1, 0.03, 0.3, 0.8, 0.9, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  188. bt = laDesignBoxedTheme(t, "Selector",&_LA_THEME_SELECTOR,
  189. 0.15, 0.7, 0.3, 0.8, 0.2, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  190. bt = laDesignBoxedTheme(t, "Collection Selector",&_LA_THEME_COLLECTION_SELECTOR,
  191. 0.15, 0.1, 0.3, 0.8, 0.9, 0.95, 0, 0, -1, -1, 1, 1, 1, 1);
  192. bt = laDesignBoxedTheme(t, "Label",&_LA_THEME_LABEL,
  193. 0.15, 0.1, 0.3, 0.8, 0.9, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  194. bt = laDesignBoxedTheme(t, "Tab",&_LA_THEME_TAB,
  195. 0.2, 0.3, 0.8, 0.7, 0.1, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  196. bt = laDesignBoxedTheme(t, "Socket",&_LA_THEME_SOCKET,
  197. 0.1, 0.65, 0.7, 0.8, 0.1, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  198. bt = laDesignBoxedTheme(t, "Collection Group",&_LA_THEME_COLLECTION_GROUP,
  199. 0.25, 0.35, 0.4, 0.7, 0.1, 0.45, 1, 1, 0, 0, 1, 1, 1, 1);
  200. bt = laDesignBoxedTheme(t, "Collection Item",&_LA_THEME_COLLECTION_ITEM,
  201. 0.25, 0.35, 0.8, 0.7, 0.1, 0.3, 1, 1, 0, 0, 1, 1, 1, 1);
  202. bt = laDesignBoxedTheme(t, "3D Viewer",&_LA_THEME_3D_VIEW,
  203. 0.25, 0.5, 0.5, 0.7, 0.1, 0.6, 1, 1, 1, 1, 1, 1, 1, 1);
  204. bt = laDesignBoxedTheme(t, "2D Viewer",&_LA_THEME_2D_VIEW,
  205. 0.25, 0.5, 0.55, 0.7, 0.1, 0.6, 1, 1, 1, 1, 1, 1, 1, 1);
  206. la_RefreshThemeColor(t);
  207. }
  208. }