*/}}

la_resource.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. laUiDefineFunc _LA_SUBPROP_DONT_CARE;
  59. laBoxedTheme *_LA_THEME_PANEL;
  60. laBoxedTheme *_LA_THEME_VALUATOR;
  61. laBoxedTheme *_LA_THEME_BUTTON;
  62. laBoxedTheme *_LA_THEME_STRING;
  63. laBoxedTheme *_LA_THEME_SELECTOR;
  64. laBoxedTheme *_LA_THEME_COLLECTION_SELECTOR;
  65. laBoxedTheme *_LA_THEME_LABEL;
  66. laBoxedTheme *_LA_THEME_TAB;
  67. laBoxedTheme *_LA_THEME_COLLECTION_GROUP;
  68. laBoxedTheme *_LA_THEME_COLLECTION_ITEM;
  69. laBoxedTheme *_LA_THEME_FLOATING_PANEL;
  70. laBoxedTheme *_LA_THEME_3D_VIEW;
  71. laBoxedTheme *_LA_THEME_2D_VIEW;
  72. laBoxedTheme *_LA_THEME_SOCKET;
  73. laProp *_LA_PROP_PANEL;
  74. laProp *_LA_PROP_BLOCK;
  75. laProp *_LA_PROP_WINDOW;
  76. laProp *_LA_PROP_UI_ITEM;
  77. laProp *_LA_PROP_FAILED_ITEM;
  78. laProp *_LA_PROP_TRASH_ITEM;
  79. laProp *_LA_PROP_NODE_GRAPH;
  80. laPropContainer *_LA_PROP_3D_EXTRA;
  81. laPropContainer *_LA_PROP_2D_EXTRA;
  82. laPropContainer *_LA_PROP_FILE_BROWSER;
  83. laProp _P_LA_USE_INSTANCE_ONLY;
  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, 0, LA_SIGNAL_EVENT, LA_SIGNAL_OPEN, 0);
  96. laAssignNewKey(km, 0, "LA_managed_save", 0, 0, LA_SIGNAL_EVENT, LA_SIGNAL_SAVE, "quiet=true;");
  97. laAssignNewKey(km, 0, "LA_managed_save", 0, 0, LA_SIGNAL_EVENT, LA_SIGNAL_SAVE_AS, 0);
  98. laAssignNewKey(km, 0, "LA_switch_layout", 0, 0, LA_SIGNAL_EVENT, LA_SIGNAL_LAYOUT_PREV, "reverse=true;");
  99. laAssignNewKey(km, 0, "LA_switch_layout", 0, 0, LA_SIGNAL_EVENT, LA_SIGNAL_LAYOUT_NEXT, 0);
  100. laAssignNewKey(km, 0, "LA_undo", 0, 0, LA_SIGNAL_EVENT, LA_SIGNAL_UNDO, 0);
  101. laAssignNewKey(km, 0, "LA_redo", 0, 0, LA_SIGNAL_EVENT, LA_SIGNAL_REDO, 0);
  102. laAssignNewKey(km, 0, "LA_fullscreen", 0, 0, LA_SIGNAL_EVENT, LA_SIGNAL_FULLSCREEN, "toggle=true;");
  103. laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
  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. LA_SET3(t->WarningColor, 0.9,0.45,0.2);
  131. t->InactiveMix=0.7; t->InactiveSaturation=0.2;
  132. t->CursorAlpha=0.9; t->SelectionAlpha=0.5;
  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. LA_SET3(t->WarningColor, 0.9,0.45,0.2);
  171. t->InactiveMix=0.7; t->InactiveSaturation=0.2;
  172. t->CursorAlpha=0.9; t->SelectionAlpha=0.4;
  173. t->WireBrightness=0.6; t->WireSaturation=0.7; t->WireTransparency=0.65;
  174. t->EdgeBrightness=0.05; t->EdgeTransparency=0.8; t->VertexBrightness=0.05, t->VertexTransparency=0.9;
  175. t->SelectedFaceTransparency=0.6,t->SelectedEdgeTransparency=0.9, t->SelectedVertexTransparency=1.0;
  176. bt = laDesignBoxedTheme(t, "Panel",&_LA_THEME_PANEL,
  177. 0.2, 0.2, 0.1, 0.7, 0.9, 0.8, 1, 1, 1, 1, 1, 1, 1, 1);
  178. memAssignRef(bt, &bt->Parent, t1);
  179. bt = laDesignBoxedTheme(t, "Floating Panel",&_LA_THEME_FLOATING_PANEL,
  180. 0.05, 0.05, 0.4, 0.8, 0.9, 0.8, 1, 1, 1, 1, 1, 1, 1, 1);
  181. memAssignRef(bt, &bt->Parent, t1);
  182. bt = laDesignBoxedTheme(t, "Valuator",&_LA_THEME_VALUATOR,
  183. 0.3, 0.1, 0.4, 0.8, 0.9, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  184. memAssignRef(bt, &bt->Parent, t1);
  185. bt = laDesignBoxedTheme(t, "Button",&_LA_THEME_BUTTON,
  186. 0.1, 0.9, 0.3, 0.8, 0.1, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  187. bt = laDesignBoxedTheme(t, "String",&_LA_THEME_STRING,
  188. 0.1, 0.03, 0.3, 0.8, 0.9, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  189. bt = laDesignBoxedTheme(t, "Selector",&_LA_THEME_SELECTOR,
  190. 0.15, 0.7, 0.3, 0.8, 0.2, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  191. bt = laDesignBoxedTheme(t, "Collection Selector",&_LA_THEME_COLLECTION_SELECTOR,
  192. 0.15, 0.1, 0.3, 0.8, 0.9, 0.95, 0, 0, -1, -1, 1, 1, 1, 1);
  193. bt = laDesignBoxedTheme(t, "Label",&_LA_THEME_LABEL,
  194. 0.15, 0.1, 0.3, 0.8, 0.9, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  195. bt = laDesignBoxedTheme(t, "Tab",&_LA_THEME_TAB,
  196. 0.2, 0.3, 0.8, 0.7, 0.1, 0.9, 1, 1, 1, 1, 1, 1, 1, 1);
  197. bt = laDesignBoxedTheme(t, "Socket",&_LA_THEME_SOCKET,
  198. 0.1, 0.65, 0.7, 0.8, 0.1, 0.95, 1, 1, 1, 1, 1, 1, 1, 1);
  199. bt = laDesignBoxedTheme(t, "Collection Group",&_LA_THEME_COLLECTION_GROUP,
  200. 0.25, 0.35, 0.4, 0.7, 0.1, 0.45, 1, 1, 0, 0, 1, 1, 1, 1);
  201. bt = laDesignBoxedTheme(t, "Collection Item",&_LA_THEME_COLLECTION_ITEM,
  202. 0.25, 0.35, 0.8, 0.7, 0.1, 0.3, 1, 1, 0, 0, 1, 1, 1, 1);
  203. bt = laDesignBoxedTheme(t, "3D Viewer",&_LA_THEME_3D_VIEW,
  204. 0.25, 0.5, 0.5, 0.7, 0.1, 0.6, 1, 1, 1, 1, 1, 1, 1, 1);
  205. bt = laDesignBoxedTheme(t, "2D Viewer",&_LA_THEME_2D_VIEW,
  206. 0.25, 0.5, 0.55, 0.7, 0.1, 0.6, 1, 1, 1, 1, 1, 1, 1, 1);
  207. la_RefreshThemeColor(t);
  208. }
  209. }