*/}}

la_widgets.c 111 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772
  1. #include "../la_5.h"
  2. extern LA MAIN;
  3. extern tnsMain* T;
  4. laWidget _LA_WIDGET_FIXED_GROUP={0};
  5. laWidget _LA_WIDGET_TAB={0};
  6. laWidget _LA_WIDGET_COLLECTION={0};
  7. laWidget _LA_WIDGET_COLLECTION_ITEM={0};
  8. laWidget _LA_WIDGET_COLLECTION_SELECTOR={0};
  9. laWidget _LA_WIDGET_COLLECTION_SINGLE={0};
  10. laWidget _LA_WIDGET_CONDITION_TOGGLE={0};
  11. laWidget _LA_WIDGET_COLUMN_ADJUSTER={0,LA_UI_FLAGS_NO_HEIGHT};
  12. laWidget _LA_WIDGET_COLUMN_VIEWER={0};
  13. laWidget _LA_WIDGET_BUTTON={0};
  14. laWidget _LA_WIDGET_BUTTON_NO_CONFIRM={0};
  15. laWidget _LA_WIDGET_LABEL={0};
  16. laWidget _LA_WIDGET_INT={0};
  17. laWidget _LA_WIDGET_INT_PLAIN={0, LA_UI_FLAGS_PLAIN};
  18. laWidget _LA_WIDGET_INT_PLAIN_ICON={0, LA_UI_FLAGS_INT_ICON};
  19. laWidget _LA_WIDGET_VALUE_METER={0,LA_TEXT_ALIGN_CENTER};
  20. laWidget _LA_WIDGET_VALUE_METER_2D={0,LA_TEXT_ALIGN_CENTER};
  21. laWidget _LA_WIDGET_FLOAT={0};
  22. laWidget _LA_WIDGET_FLOAT_PLAIN={0, LA_UI_FLAGS_PLAIN};
  23. laWidget _LA_WIDGET_FLOAT_COLOR={0};
  24. laWidget _LA_WIDGET_FLOAT_COLOR_HCY={0};
  25. laWidget _LA_WIDGET_ENUM_SELECTOR={0};
  26. laWidget _LA_WIDGET_ENUM_SELECTOR_ICON={0, LA_UI_FLAGS_ICON};
  27. laWidget _LA_WIDGET_ENUM_CYCLE={0, LA_UI_FLAGS_CYCLE};
  28. laWidget _LA_WIDGET_ENUM_CYCLE_ICON={0, LA_UI_FLAGS_CYCLE|LA_UI_FLAGS_ICON};
  29. laWidget _LA_WIDGET_ENUM_ICON_PLAIN={0, LA_UI_FLAGS_PLAIN|LA_UI_FLAGS_ICON};
  30. laWidget _LA_WIDGET_ENUM_HIGHLIGHT={0, LA_UI_FLAGS_HIGHLIGHT|LA_UI_FLAGS_CYCLE|LA_TEXT_ALIGN_CENTER};
  31. laWidget _LA_WIDGET_STRING={0};
  32. laWidget _LA_WIDGET_STRING_PLAIN={0, LA_UI_FLAGS_PLAIN};
  33. laWidget _LA_WIDGET_STRING_MONO_PLAIN={0, LA_TEXT_MONO|LA_UI_FLAGS_PLAIN};
  34. laWidget _LA_WIDGET_STRING_MULTI={0, LA_TEXT_MONO};
  35. laWidget _LA_WIDGET_MENU_ROOT={0};
  36. laWidget _LA_WIDGET_ALIGN={0};
  37. laWidget _LA_WIDGET_3D_VIEW={0};
  38. laWidget _LA_WIDGET_2D_VIEW={0};
  39. laWidget _LA_WIDGET_SYMBOL={0};
  40. laWidget _LA_WIDGET_NODE_SOCKET={0};
  41. laWidget _LA_WIDGET_HEIGHT_ADJUSTER={0};
  42. laWidget _LA_WIDGET_RAW={0};
  43. laWidget *LA_WIDGET_FIXED_GROUP=&_LA_WIDGET_FIXED_GROUP;
  44. laWidget *LA_WIDGET_TAB=&_LA_WIDGET_TAB;
  45. laWidget *LA_WIDGET_COLLECTION=&_LA_WIDGET_COLLECTION;
  46. laWidget *LA_WIDGET_COLLECTION_ITEM=&_LA_WIDGET_COLLECTION_ITEM;
  47. laWidget *LA_WIDGET_COLLECTION_SELECTOR=&_LA_WIDGET_COLLECTION_SELECTOR;
  48. laWidget *LA_WIDGET_COLLECTION_SINGLE=&_LA_WIDGET_COLLECTION_SINGLE;
  49. laWidget *LA_WIDGET_CONDITION_TOGGLE=&_LA_WIDGET_CONDITION_TOGGLE;
  50. laWidget *LA_WIDGET_COLUMN_ADJUSTER=&_LA_WIDGET_COLUMN_ADJUSTER;
  51. laWidget *LA_WIDGET_COLUMN_VIEWER=&_LA_WIDGET_COLUMN_VIEWER;
  52. laWidget *LA_WIDGET_BUTTON=&_LA_WIDGET_BUTTON;
  53. laWidget *LA_WIDGET_BUTTON_NO_CONFIRM=&_LA_WIDGET_BUTTON_NO_CONFIRM;
  54. laWidget *LA_WIDGET_LABEL=&_LA_WIDGET_LABEL;
  55. laWidget *LA_WIDGET_INT=&_LA_WIDGET_INT;
  56. laWidget *LA_WIDGET_INT_PLAIN=&_LA_WIDGET_INT_PLAIN;
  57. laWidget *LA_WIDGET_INT_PLAIN_ICON=&_LA_WIDGET_INT_PLAIN_ICON;
  58. laWidget *LA_WIDGET_VALUE_METER=&_LA_WIDGET_VALUE_METER;
  59. laWidget *LA_WIDGET_VALUE_METER_2D=&_LA_WIDGET_VALUE_METER_2D;
  60. laWidget *LA_WIDGET_FLOAT=&_LA_WIDGET_FLOAT;
  61. laWidget *LA_WIDGET_FLOAT_PLAIN=&_LA_WIDGET_FLOAT_PLAIN;
  62. laWidget *LA_WIDGET_FLOAT_COLOR=&_LA_WIDGET_FLOAT_COLOR;
  63. laWidget *LA_WIDGET_FLOAT_COLOR_HCY=&_LA_WIDGET_FLOAT_COLOR_HCY;
  64. laWidget *LA_WIDGET_ENUM_SELECTOR=&_LA_WIDGET_ENUM_SELECTOR;
  65. laWidget *LA_WIDGET_ENUM_SELECTOR_ICON=&_LA_WIDGET_ENUM_SELECTOR_ICON;
  66. laWidget *LA_WIDGET_ENUM_CYCLE=&_LA_WIDGET_ENUM_CYCLE;
  67. laWidget *LA_WIDGET_ENUM_CYCLE_ICON=&_LA_WIDGET_ENUM_CYCLE_ICON;
  68. laWidget *LA_WIDGET_ENUM_ICON_PLAIN=&_LA_WIDGET_ENUM_ICON_PLAIN;
  69. laWidget *LA_WIDGET_ENUM_HIGHLIGHT=&_LA_WIDGET_ENUM_HIGHLIGHT;
  70. laWidget *LA_WIDGET_STRING=&_LA_WIDGET_STRING;
  71. laWidget *LA_WIDGET_STRING_PLAIN=&_LA_WIDGET_STRING_PLAIN;
  72. laWidget *LA_WIDGET_STRING_MULTI=&_LA_WIDGET_STRING_MULTI;
  73. laWidget *LA_WIDGET_STRING_MONO_PLAIN=&_LA_WIDGET_STRING_MONO_PLAIN;
  74. laWidget *LA_WIDGET_MENU_ROOT=&_LA_WIDGET_MENU_ROOT;
  75. laWidget *LA_WIDGET_ALIGN=&_LA_WIDGET_ALIGN;
  76. laWidget *LA_WIDGET_3D_VIEW=&_LA_WIDGET_3D_VIEW;
  77. laWidget *LA_WIDGET_2D_VIEW=&_LA_WIDGET_2D_VIEW;
  78. laWidget *LA_WIDGET_SYMBOL=&_LA_WIDGET_SYMBOL;
  79. laWidget *LA_WIDGET_NODE_SOCKET=&_LA_WIDGET_NODE_SOCKET;
  80. laWidget *LA_WIDGET_HEIGHT_ADJUSTER=&_LA_WIDGET_HEIGHT_ADJUSTER;
  81. laWidget *LA_WIDGET_RAW=&_LA_WIDGET_RAW;
  82. //============================================== [Draw]
  83. int la_ArrayGetHeight(laUiItem *ui){
  84. return laGetArrayLength(&ui->PP);
  85. }
  86. int la_ValueGetHeight(laUiItem*ui){
  87. if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){ return la_ArrayGetHeight(ui); }
  88. return 1;
  89. }
  90. int la_ValueMeterGetHeight(laUiItem*ui){
  91. if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){ return ui->Extra->HeightCoeff?ui->Extra->HeightCoeff:6; }
  92. return laGetArrayLength(&ui->PP);
  93. }
  94. int la_ValueMeter2DGetHeight(laUiItem*ui){
  95. return ui->Extra->HeightCoeff?ui->Extra->HeightCoeff:(ui->Extra->HeightCoeff=(ui->TR-ui->TL)/LA_RH);
  96. }
  97. int la_CanvasGetHeight(laUiItem *ui){
  98. return ui->Expand;
  99. }
  100. int la_EnumGetHeight(laUiItem *ui){
  101. // norm e1
  102. // expand e1 e2 e3
  103. // expand vertical (vertical)
  104. // arr expand e1 e2 e3
  105. // e1 e2 e3
  106. // arr exp+vert e1 e1
  107. // e2 e2
  108. // e3 e3
  109. int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  110. int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
  111. int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
  112. int ArrLen = laGetArrayLength(&ui->PP);
  113. if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
  114. int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
  115. if(ArrLen==1){
  116. if(IsVertical&&IsExpand) return laGetEnumEntryLen(&ui->PP);
  117. return 1;
  118. }else{
  119. if(IsVertical) return EnumLen;
  120. else return ArrLen;
  121. }
  122. }
  123. int la_ColorPickerGetHeight(laUiItem *ui){
  124. if(!ui->Extra->HeightCoeff) ui->Extra->HeightCoeff=7;
  125. return ui->Extra->HeightCoeff;
  126. }
  127. int la_SymbolGetHeight(laUiItem *ui){
  128. //if (!ui->State)
  129. //{
  130. // ui->State = (int)_ICON_SYMBOL_SIZE[ui->SymbolID - ICON_SYMBOL_START] * 1.4 + 1;
  131. //}
  132. return ui->State;
  133. }
  134. int la_GroupGetHeight(laUiItem *ui){
  135. if (ui->State == LA_UI_ACTIVE) return 0;
  136. return LA_RH;
  137. }
  138. int la_StringPropGetHeight(laUiItem *ui){
  139. laBoxedTheme *bt = *ui->Type->Theme;
  140. if(!(ui->Flags&LA_TEXT_LINE_WRAP)) return 1;
  141. char _buf[LA_RAW_CSTR_MAX_LEN]={0}; char* buf=_buf;
  142. laGetString(&ui->PP, _buf, &buf); int rows=0;
  143. int strw=tnsStringGetDimension(buf, 0, 0, ui->TR-ui->TL, &rows, ui->Flags&LA_TEXT_MONO);
  144. return rows;
  145. }
  146. int la_MultiStringHeight(laUiItem *ui){
  147. laGeneralUiExtraData *e = ui->Extra;
  148. return e->HeightCoeff;
  149. }
  150. int la_LabelHeight(laUiItem *ui){
  151. int Wrap=ui->Flags&LA_TEXT_LINE_WRAP;
  152. if(!Wrap) return 1;
  153. int rows;
  154. tnsStringGetDimension(ui->Display->Ptr, 0, 0, ui->TR-ui->TL, &rows, ui->Flags&LA_TEXT_MONO);
  155. return rows;
  156. }
  157. int la_SocketGetHeight(laUiItem *ui){
  158. if(ui->Flags&(LA_UI_SOCKET_LABEL_N|LA_UI_SOCKET_LABEL_S))return 2; return 1;
  159. }
  160. int la_ColorSelectorGetMinWidth(laUiItem *ui){
  161. return 5*LA_RH;
  162. }
  163. int la_ValueGetMinWidth(laUiItem *ui){
  164. int ExtraW=0;
  165. if(ui->Flags&LA_UI_FLAGS_EXPAND){ ExtraW+=tnsStringGetWidth(ui->PP.LastPs->p->Name,0,0); }
  166. return LA_RH*4+ExtraW;
  167. }
  168. int la_LabelGetMinWidth(laUiItem *ui){
  169. laBoxedTheme *bt = *ui->Type->Theme;
  170. int strw=tnsStringGetWidth(ui->Display->Ptr, 0, ui->Flags&LA_TEXT_MONO);
  171. if(ui->Type==_LA_UI_MENU_ROOT && strw<LA_RH)strw=LA_RH;
  172. return (strw + bt->LM + bt->RM);
  173. }
  174. int la_StringPropGetMinWidth(laUiItem *ui){
  175. laBoxedTheme *bt = *ui->Type->Theme;
  176. char _buf[LA_RAW_CSTR_MAX_LEN]={0}; int ExtraW=0; char* buf=_buf;
  177. if(ui->Type == _LA_UI_STRING_MULTI){ExtraW=2*LA_RH+bt->LM;}
  178. laGetString(&ui->PP, _buf, &buf); int rows=0;
  179. int strw=tnsStringGetDimension(buf, 0, 0, 0, &rows, ui->Flags&LA_TEXT_MONO);
  180. int Plain = ui->Flags&LA_UI_FLAGS_PLAIN;
  181. if((!Plain)&&strw<LA_RH*4){strw=LA_RH*4;}
  182. return (strw + bt->LM + bt->RM+ExtraW);
  183. }
  184. int la_EnumGetMinWidth(laUiItem *ui){
  185. laBoxedTheme *bt = *ui->Type->Theme;
  186. laEnumProp *ep = ui->PP.LastPs->p;
  187. laEnumItem *i;
  188. int W = 0; int tW;
  189. int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  190. int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
  191. int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
  192. int IsIcon = ui->Flags&LA_UI_FLAGS_ICON;
  193. int Highlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
  194. int SharedWidth;
  195. if(!IsIcon){
  196. SharedWidth = bt->LM + bt->RM + ((IsCycle||IsExpand)?0:LA_RH); int HasIcon=0;
  197. if(Highlight){
  198. if (ui->ExtraInstructions){
  199. if (ui->Type->OperatorType->ParseArgs){
  200. int ico; char buf[256]; buf[0]=0;
  201. ui->Type->OperatorType->ParseArgs(ui->Instructions, &ico, buf);
  202. tW = tnsStringGetWidth(buf, 0, ui->Flags&LA_TEXT_MONO) + SharedWidth;
  203. }
  204. }else{
  205. tW = tnsStringGetWidth(ep->Base.Name, 0, ui->Flags&LA_TEXT_MONO) + SharedWidth;
  206. }
  207. if (tW > W) W = tW;
  208. }else{
  209. for (i = ep->Items.pFirst; i; i = i->Item.pNext){
  210. tW = tnsStringGetWidth(i->Name, 0, ui->Flags&LA_TEXT_MONO) + SharedWidth;
  211. if (i->IconID){ HasIcon=1; }
  212. if (tW > W) W = tW;
  213. }
  214. if(HasIcon) W+=bt->LM+LA_RH;
  215. }
  216. }else{
  217. W = LA_RH;
  218. }
  219. int ArrLen = laGetArrayLength(&ui->PP);
  220. if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
  221. int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
  222. if(ArrLen==1){
  223. if(!IsVertical) return W*EnumLen;
  224. return W;
  225. }else{
  226. if(IsVertical) return ArrLen*W;
  227. return EnumLen*W;
  228. }
  229. return W;
  230. }
  231. int la_ButtonGetMinWidth(laUiItem *ui){
  232. laBoxedTheme *bt = *ui->Type->Theme;
  233. uint32_t IconID;
  234. char buf[LA_RAW_CSTR_MAX_LEN]={0};
  235. char *label;
  236. laOperatorProp *ap;
  237. int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
  238. if(IconOnly) return LA_RH;
  239. if (ui->PP.LastPs && ui->PP.LastPs->p){
  240. ap = ui->PP.LastPs->p;
  241. label = ap->Base.Name;
  242. IconID = ap->Base.IconID ? ap->Base.IconID : ap->OperatorType->IconID;
  243. if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
  244. }else{
  245. label = ui->AT->Name;
  246. IconID = ui->AT->IconID;
  247. }
  248. if (ui->ExtraInstructions){
  249. if (ui->AT && ui->AT->ParseArgs){
  250. ui->AT->ParseArgs(ui->Instructions, &IconID, buf);
  251. if (buf[0]) label = buf;
  252. }else if (ui->PP.LastPs->p->PropertyType == LA_PROP_OPERATOR){
  253. laOperatorProp *ap = ui->PP.LastPs->p;
  254. if (ap->OperatorType && ap->OperatorType->ParseArgs){
  255. ap->OperatorType->ParseArgs(ui->Instructions, &IconID, buf);
  256. if (buf[0]) label = buf;
  257. }
  258. }
  259. }
  260. int strw=tnsStringGetWidth(label, 0, ui->Flags&LA_TEXT_MONO);
  261. if(strw){ strw+=bt->RM+bt->LM; }
  262. return ((IconID ? (LA_RH) : 0) + strw);
  263. }
  264. int la_ColumnViewerGetMinWidth(laUiItem *ui){
  265. return 350;
  266. }
  267. int la_ColorPickerGetMinWidth(laUiItem *ui){
  268. return LA_RH * 9;
  269. }
  270. int la_SocketGetMinWidth(laUiItem *ui){
  271. if(ui->Flags&(LA_UI_SOCKET_LABEL_W|LA_UI_SOCKET_LABEL_E))return LA_RH*3; return LA_RH;
  272. }
  273. void la_SingleLineStringDrawSelection(laUiItem *ui, int Begin, int U, laBoxedTheme *bt, uint32_t *str, laStringEdit *se);
  274. void la_CollectionSelectorDraw(laUiItem *ui, int h){
  275. char temp[128] = {0};
  276. laBoxedTheme *bt = (*ui->Type->Theme);
  277. real Color[16] = {0};
  278. tnsVector4d Transp = {0};
  279. int CrossDraw = 0;
  280. if (!ui->State) ui->State = LA_UI_NORMAL;
  281. tnsUseNoTexture();
  282. tnsColor4dv(laThemeColor(bt,ui->State));
  283. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  284. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  285. tnsPackAs(GL_TRIANGLE_FAN);
  286. CrossDraw = laGetActiveInstanceStrict(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance) ? 1 : 0;
  287. if (CrossDraw){
  288. tnsVectorCopy4d(laThemeColor(bt,LA_BT_BORDER), Transp);
  289. Transp[3] = 0;
  290. tnsMakeLinerGradient4dv(Color, 2, Transp, laThemeColor(bt,LA_BT_BORDER));
  291. tnsMakeLinerGradient4dv(&Color[8], 2, Transp, laThemeColor(bt,LA_BT_BORDER));
  292. //tnsMakeLinerGradient4dv(&Color[8], 2, laThemeColor(bt, LA_BT_BORDER), Transp);
  293. tnsVertex2d(ui->R - LA_RH, ui->U);
  294. tnsVertex2d(ui->R, ui->U);
  295. tnsVertex2d(ui->R - LA_RH, ui->B);
  296. tnsVertex2d(ui->R, ui->B);
  297. tnsColorArray4d(Color, 4);
  298. tnsPackAs(GL_TRIANGLE_STRIP);
  299. }
  300. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  301. tnsVertex2d(ui->L, ui->U);
  302. tnsVertex2d(ui->R, ui->U);
  303. tnsVertex2d(ui->R, ui->B);
  304. tnsVertex2d(ui->L, ui->B);
  305. tnsPackAs(GL_LINE_LOOP);
  306. if (CrossDraw){
  307. tnsDrawStringAuto("🧹", laThemeColor(bt,ui->State|LA_BT_TEXT), ui->R - LA_RH, ui->R, ui->U, 0);
  308. }
  309. }
  310. void la_EmptyDraw(laUiItem *ui, int h){
  311. char temp[128] = {0};
  312. laBoxedTheme *bt = (*ui->Type->Theme);
  313. if (!ui->State) ui->State = LA_UI_NORMAL;
  314. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  315. if(!NoDecal){
  316. tnsUseNoTexture();
  317. tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
  318. tnsVertex2d(ui->L, ui->U);
  319. tnsVertex2d(ui->R, ui->U);
  320. tnsVertex2d(ui->R, ui->B);
  321. tnsVertex2d(ui->L, ui->B);
  322. tnsPackAs(GL_TRIANGLE_FAN);
  323. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  324. tnsVertex2d(ui->L, ui->U);
  325. tnsVertex2d(ui->R, ui->U);
  326. tnsVertex2d(ui->R, ui->B);
  327. tnsVertex2d(ui->L, ui->B);
  328. tnsPackAs(GL_LINE_LOOP);
  329. }
  330. }
  331. void la_GroupDraw(laUiItem *ui, int h){
  332. char temp[128] = {0};
  333. laBoxedTheme *bt = (*ui->Type->Theme);
  334. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  335. if(!NoDecal){
  336. tnsUseNoTexture();
  337. tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
  338. tnsVertex2d(ui->L, ui->U);
  339. tnsVertex2d(ui->R, ui->U);
  340. tnsVertex2d(ui->R, ui->B);
  341. tnsVertex2d(ui->L, ui->B);
  342. tnsPackAs(GL_TRIANGLE_FAN);
  343. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  344. tnsVertex2d(ui->L, ui->U);
  345. tnsVertex2d(ui->R, ui->U);
  346. tnsVertex2d(ui->R, ui->B);
  347. tnsVertex2d(ui->L, ui->B);
  348. tnsPackAs(GL_LINE_LOOP);
  349. }
  350. if (ui->State != LA_UI_ACTIVE){
  351. tnsDrawStringAuto(ui->Page ? transLate(ui->Page->TabName->Ptr) : transLate("No Page"),
  352. laThemeColor(bt,ui->State|LA_BT_TEXT), ui->L+bt->LM, ui->R+bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
  353. }
  354. }
  355. void la_TabDraw(laUiItem *ui, int h){
  356. char temp[128] = {0};
  357. laBoxedTheme *bt = (*ui->Type->Theme);
  358. laUiList *uil;
  359. int count = 0;
  360. int w; // = (ui->R - ui->L) / count;
  361. int page = 0;
  362. int l = ui->L;
  363. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
  364. count++;
  365. }
  366. w = (ui->R - ui->L) / (count == 0 ? 1 : count);
  367. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  368. if(!NoDecal){
  369. tnsUseNoTexture();
  370. tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
  371. tnsVertex2d(ui->L, ui->U);
  372. tnsVertex2d(ui->R, ui->U);
  373. tnsVertex2d(ui->R, ui->B);
  374. tnsVertex2d(ui->L, ui->B);
  375. tnsPackAs(GL_TRIANGLE_FAN);
  376. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  377. tnsVertex2d(ui->L, ui->U + h);
  378. tnsVertex2d(ui->L, ui->B);
  379. tnsVertex2d(ui->R, ui->B);
  380. tnsVertex2d(ui->R, ui->U + h);
  381. tnsPackAs(GL_LINE_LOOP);
  382. }
  383. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
  384. l = page * w;
  385. if (uil != ui->Page){
  386. tnsUseNoTexture();
  387. tnsColor4dv(laThemeColor(bt,LA_BT_ACTIVE));
  388. tnsVertex2d(ui->L + l, ui->U);
  389. tnsVertex2d(ui->L + l + w, ui->U);
  390. tnsVertex2d(ui->L + l + w, ui->U + h);
  391. tnsVertex2d(ui->L + l, ui->U + h);
  392. tnsPackAs(GL_TRIANGLE_FAN);
  393. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  394. tnsVertex2d(ui->L + l, ui->U + h);
  395. tnsVertex2d(ui->L + l, ui->U);
  396. tnsVertex2d(ui->L + l + w, ui->U);
  397. tnsVertex2d(ui->L + l + w, ui->U + h);
  398. tnsPackAs(GL_LINE_STRIP);
  399. tnsDrawStringAuto(transLate(uil->TabName->Ptr), laThemeColor(bt,LA_BT_TEXT), ui->L+l+bt->LM, ui->L+l+w-bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
  400. }else{
  401. tnsUseNoTexture();
  402. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  403. tnsVertex2d(ui->L + l, ui->U);
  404. tnsVertex2d(ui->L + l + w, ui->U);
  405. tnsVertex2d(ui->L + l + w, ui->U + h);
  406. tnsVertex2d(ui->L + l, ui->U + h);
  407. tnsPackAs(GL_TRIANGLE_FAN);
  408. tnsDrawStringAuto(transLate(uil->TabName->Ptr), laThemeColor(bt,LA_BT_TEXT_ACTIVE), ui->L+l+bt->LM, ui->L+l+w-bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
  409. }
  410. page++;
  411. }
  412. tnsFlush();
  413. }
  414. void la_SymbolDraw(laUiItem *ui, int h){
  415. return;
  416. //char temp[128] = {0};
  417. //laBoxedTheme *bt = (*ui->Type->Theme);
  418. //tnsFontSingleCharacter *fsc = tfntFetchVectorGraphTextureIDW(ui->SymbolID);
  419. //int VOffset = (ui->B - ui->U - (fsc->height)) / 2;
  420. //int HOffset = (ui->R - ui->L - (fsc->width)) / 2;
  421. //
  422. //if (strArgumentMatch(ui->Instructions, "mode", "invert"))
  423. //{
  424. // tnsUseNoTexture();
  425. // //tnsColor4dv(laThemeColor(bt, ui->State));
  426. // //tnsVertex2d(ui->L, ui->U);
  427. // //tnsVertex2d(ui->R, ui->U);
  428. // //tnsVertex2d(ui->R, ui->B);
  429. // //tnsVertex2d(ui->L, ui->B);
  430. // //tnsPackAs(GL_TRIANGLE_FAN);
  431. //
  432. // tnsUseNoTexture();
  433. // tnsColor4dv(LA_THEME_GET(bt, LA_UI_NORMAL)->BorderColor->RGBA);
  434. // tnsVertex2d(ui->L, ui->U);
  435. // tnsVertex2d(ui->R, ui->U);
  436. // tnsVertex2d(ui->R, ui->B);
  437. // tnsVertex2d(ui->L, ui->B);
  438. // tnsPackAs(GL_TRIANGLE_FAN);
  439. //
  440. // // tnsDrawVectorGraphPackage(ui->SymbolID, LA_THEME_GET(bt, LA_THEME_INTERPOLATING), ui->L + HOffset, ui->R, ui->U + VOffset, ui->B, 0, 0);
  441. //}
  442. //else
  443. //{
  444. // //if (!ui->State) ui->State = LA_UI_NORMAL;
  445. //
  446. // /*tnsUseNoTexture();
  447. // tnsColor4dv(laThemeColor(bt, ui->State));
  448. // tnsVertex2d(ui->L, ui->U);
  449. // tnsVertex2d(ui->R, ui->U);
  450. // tnsVertex2d(ui->R, ui->B);
  451. // tnsVertex2d(ui->L, ui->B);
  452. // tnsPackAs(GL_TRIANGLE_FAN);*/
  453. //
  454. // //tnsUseNoTexture();
  455. //tnsColor4dv(LA_THEME_GET(bt, LA_UI_NORMAL)->BorderColor->RGBA);
  456. //tnsVertex2d(ui->L, ui->U);
  457. //tnsVertex2d(ui->R, ui->U);
  458. //tnsVertex2d(ui->R, ui->B);
  459. //tnsVertex2d(ui->L, ui->B);
  460. //tnsPackAs(GL_LINE_LOOP);
  461. //
  462. // // tnsDrawVectorGraphPackage(ui->SymbolID, LA_THEME_GET(bt, LA_UI_NORMAL), ui->L + HOffset, ui->R, ui->U + VOffset, ui->B, 0, 0);
  463. //}
  464. }
  465. void la_IntDraw(laUiItem *ui, int h){
  466. laBoxedTheme *bt = (*ui->Type->Theme);
  467. int Data[32];
  468. int Len, i, Seg, W;
  469. char buf[48] = {0};
  470. char buf2[48] = {0};
  471. char prefix[8][64] = {0};
  472. int Original;
  473. int Ranged;
  474. int min, max;
  475. int s, State;
  476. int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  477. int IsIcon=ui->Flags&LA_UI_FLAGS_ICON;
  478. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  479. if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
  480. laGetIntArray(&ui->PP, Data);
  481. Len = laGetArrayLength(&ui->PP);
  482. laGetPrefixP(&ui->PP, prefix);
  483. Ranged = laGetIntRange(&ui->PP, &min, &max);
  484. for (i = 0; i < Len; i++){
  485. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  486. if(IsVertical){
  487. Seg = ui->R - ui->L;
  488. _U = ui->U + i * LA_RH; _B = _U+LA_RH;
  489. }else{
  490. Seg = (ui->R - ui->L) / Len;
  491. _L = ui->L + i * Seg; _R=_L+Seg;
  492. }
  493. if(IsIcon){
  494. sprintf(buf, "%lc", laGetInt(&ui->PP));
  495. }else{
  496. buf[0] = L'\0';
  497. strPrintIntAfter(buf, 48, Data[i]);
  498. strAppend(buf, ui->PP.LastPs->p->Unit ? transLate(ui->PP.LastPs->p->Unit) : "");
  499. buf2[0] = L'\0'; if(Len==1){ strcat(buf2, transLate(ui->PP.LastPs->p->Name)); }
  500. if(i<8)strcat(buf2, &prefix[i]);
  501. }
  502. if (ui->Extra && ui->Extra->On == i + 1){
  503. Original = ui->State;
  504. ui->State = LA_UI_ACTIVE;
  505. }
  506. if(!NoDecal){
  507. tnsUseNoTexture();
  508. tnsColor4dv(laThemeColor(bt,ui->State));
  509. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  510. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  511. tnsPackAs(GL_TRIANGLE_FAN);
  512. if (Ranged){
  513. int L1 = _L;
  514. int R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(Seg) + L1;
  515. tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
  516. tnsColor4d(LA_COLOR3(color),0.3);
  517. tnsVertex2d(L1, _U); tnsVertex2d(R1, _U);
  518. tnsVertex2d(R1, _B); tnsVertex2d(L1, _B);
  519. tnsPackAs(GL_TRIANGLE_FAN);
  520. }
  521. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  522. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  523. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  524. tnsPackAs(GL_LINE_LOOP);
  525. }
  526. if (ui->Extra->On == i + 1 && ui->Extra->Edit){
  527. uint32_t *buf = strGetCursorLine(ui->Extra->Edit, 0)->Buf;
  528. int LL = _L + (Seg - tnsStringGetWidthU(buf, 0, ui->Flags&LA_TEXT_MONO)) / 2;
  529. tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
  530. la_SingleLineStringDrawSelection(ui, _L, _U, bt, buf, ui->Extra->Edit);
  531. tnsDrawStringM(0, buf, laThemeColor(bt, LA_BT_TEXT_ACTIVE), _L + bt->LM, _R - bt->RM, _U, ui->Flags);
  532. }else{
  533. tnsDrawStringWithPriority(buf2, buf, laThemeColor(bt, LA_BT_TEXT|ui->State), bt->TextAlign, _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
  534. }
  535. if (ui->Extra && ui->Extra->On == i + 1) ui->State = Original;
  536. }
  537. tnsFlush();
  538. }
  539. void la_FloatDraw(laUiItem *ui, int h){
  540. laBoxedTheme *bt = (*ui->Type->Theme);
  541. real Data[32];
  542. int Len, i, W, Seg;
  543. char buf[48] = {0};
  544. char buf2[48] = {0};
  545. char prefix[8][64] = {0};
  546. int Original;
  547. int Ranged;
  548. real min, max;
  549. int s, State;
  550. int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  551. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  552. int IsRad=ui->PP.LastPs->p->IsRadAngle;
  553. if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
  554. laGetFloatArray(&ui->PP, Data);
  555. Len = laGetArrayLength(&ui->PP);
  556. laGetPrefixP(&ui->PP, prefix);
  557. Ranged = laGetFloatRange(&ui->PP, &min, &max);
  558. for (i = 0; i < Len; i++){
  559. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  560. if(IsVertical){
  561. Seg = ui->R - ui->L;
  562. _U = ui->U + i * LA_RH; _B = _U+LA_RH;
  563. }else{
  564. Seg = (ui->R - ui->L) / Len;
  565. _L = ui->L + i * Seg; _R=_L+Seg;
  566. }
  567. buf[0] = L'\0'; if(i<8)strcat(buf, &prefix[i]);
  568. strPrintFloatAfter(buf, 48, 3, IsRad?deg(Data[i]):Data[i]);
  569. strAppend(buf, ui->PP.LastPs->p->Unit ? transLate(ui->PP.LastPs->p->Unit) : "");
  570. buf2[0] = L'\0'; if(Len==1){ strcat(buf2, transLate(ui->PP.LastPs->p->Name)); }
  571. if (ui->Extra && ui->Extra->On == i + 1){
  572. Original = ui->State;
  573. ui->State = LA_UI_ACTIVE;
  574. }
  575. if(!NoDecal){
  576. tnsUseNoTexture();
  577. tnsColor4dv(laThemeColor(bt,ui->State));
  578. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  579. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  580. tnsPackAs(GL_TRIANGLE_FAN);
  581. if (Ranged){
  582. int L1 = _L;
  583. int R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(Seg) + L1;
  584. tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
  585. tnsColor4d(LA_COLOR3(color),0.3);
  586. tnsVertex2d(L1, _U); tnsVertex2d(R1, _U);
  587. tnsVertex2d(R1, _B); tnsVertex2d(L1, _B);
  588. tnsPackAs(GL_TRIANGLE_FAN);
  589. }
  590. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  591. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  592. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  593. tnsPackAs(GL_LINE_LOOP);
  594. }
  595. if (ui->Extra->On == i + 1 && ui->Extra->Edit){
  596. uint32_t *buf = strGetCursorLine(ui->Extra->Edit,0)->Buf;
  597. int LL = _L + (Seg - tnsStringGetWidthU(buf, 0, ui->Flags&LA_TEXT_MONO)) / 2;
  598. tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
  599. la_SingleLineStringDrawSelection(ui, _L, _U, bt, buf, ui->Extra->Edit);
  600. tnsDrawStringM(0, buf, laThemeColor(bt, LA_BT_TEXT_ACTIVE), _L + bt->LM, _R - bt->RM, _U, ui->Flags);
  601. }else{
  602. tnsDrawStringWithPriority(buf2, buf, laThemeColor(bt, LA_BT_TEXT|ui->State), bt->TextAlign, _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
  603. }
  604. if (ui->Extra && ui->Extra->On == i + 1) ui->State = Original;
  605. }
  606. tnsFlush();
  607. }
  608. void la_FloatArrayColorDraw(laUiItem *ui, int h){
  609. laBoxedTheme *bt = (*ui->Type->Theme);
  610. real Data[32];
  611. int Len, i, Y = ui->U;
  612. laGetFloatArray(&ui->PP, Data);
  613. Len = laGetArrayLength(&ui->PP);
  614. tnsUseNoTexture();
  615. tnsColor4d(Data[0], Data[1], Data[2], /*Len>3?Data[4]:*/ 1);
  616. tnsVertex2d(ui->L, Y);
  617. tnsVertex2d(ui->R, Y);
  618. tnsVertex2d(ui->R, Y + h);
  619. tnsVertex2d(ui->L, Y + h);
  620. tnsPackAs(GL_TRIANGLE_FAN);
  621. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  622. tnsVertex2d(ui->L, Y);
  623. tnsVertex2d(ui->R, Y);
  624. tnsVertex2d(ui->R, Y + h);
  625. tnsVertex2d(ui->L, Y + h);
  626. tnsPackAs(GL_LINE_LOOP);
  627. tnsFlush();
  628. }
  629. void la_EnumSelectorDraw(laUiItem *ui, int h){
  630. laEnumItem *Data[32], Len;
  631. laBoxedTheme *bt = (*ui->Type->Theme);
  632. char buf[48] = {0};
  633. char buf2[48] = {0};
  634. char prefix[8][64]= {0};
  635. laEnumProp *ep = ui->PP.LastPs->p;
  636. int HasIcon = laEnumHasIcon(&ui->PP);
  637. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  638. int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
  639. int NoEvent=ui->Flags&LA_UI_FLAGS_NO_EVENT;
  640. int Highlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
  641. // norm e1
  642. // expand e1 e2 e3
  643. // expand vertical (vertical)
  644. // arr expand e1 e1 e3
  645. // e2 e2 e3
  646. // arr exp+vert e1 e1
  647. // e2 e2
  648. // e3 e3
  649. tnsUseNoTexture();
  650. laGetEnumArray(&ui->PP,Data);
  651. laEnumItem* ei, *use_ei;
  652. int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  653. int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
  654. int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
  655. int ArrLen = laGetArrayLength(&ui->PP);
  656. if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
  657. int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
  658. if(Highlight&&ArrLen!=1){laGetPrefixP(&ui->PP, prefix);}
  659. if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
  660. int _L,_R,_U,_B, _W=ui->R - ui->L;
  661. if(IsVertical){
  662. if(IsExpand){ _W/=ArrLen; }
  663. }else{
  664. if(IsExpand){ _W/=EnumLen; }
  665. else{ _W/=ArrLen; }
  666. }
  667. for(int i=0;i<ArrLen;i++){
  668. _L=ui->L; _R=ui->R; _U=ui->U; _B=ui->B; ei = ep->Items.pFirst;
  669. for(int j=0;j<EnumLen;j++){ buf[0]=0;
  670. if(IsVertical){
  671. if(IsExpand){ _U=ui->U+j*LA_RH; _L=ui->L+i*_W; }
  672. else{ _U=ui->U+i*LA_RH; _L=ui->L; }
  673. }else{
  674. if(IsExpand){ _U=ui->U+i*LA_RH; _L=ui->L+j*_W; }
  675. else{ _U=ui->U; _L=ui->L+i*_W; }
  676. }
  677. _B=_U+LA_RH; _R=_L+_W;
  678. int ExtraState=ui->State;
  679. if(IsExpand&&!IsCycle){ use_ei = ei; ei=ei->Item.pNext; ExtraState=(use_ei==Data[i])?LA_BT_ACTIVE:0; }
  680. else{ use_ei = Data[i]; if(Highlight && Data[i]->Index!=0){ ExtraState=LA_BT_ACTIVE; } }
  681. if(!NoDecal){
  682. tnsUseNoTexture();
  683. tnsColor4dv(laThemeColor(bt, ExtraState));
  684. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  685. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  686. tnsPackAs(GL_TRIANGLE_FAN);
  687. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  688. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  689. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  690. tnsPackAs(GL_LINE_LOOP);
  691. }
  692. if(!Highlight){
  693. if (ui->ExtraInstructions){
  694. if (ui->Type->OperatorType->ParseArgs){
  695. int ico; buf[0]=0; ui->Type->OperatorType->ParseArgs(ui->Instructions, &ico, buf);
  696. }
  697. }
  698. if(!buf[0]) strcpy(buf, transLate(use_ei->Name));
  699. }
  700. else{ if(ArrLen==1) strcpy(buf, transLate(ui->PP.LastPs->p->Name)); else{ if(i<8)strcat(buf, &prefix[i]); } }
  701. int iconR; if(IconOnly)iconR=TNS_MAX2(_L+LA_RH,_R);else{ iconR=TNS_MIN2(_L+LA_RH,_R); }
  702. if (use_ei->IconID) tnsDrawIcon(use_ei->IconID, laThemeColor(bt, LA_BT_TEXT|ExtraState), _L,iconR, _U, LA_TEXT_ALIGN_CENTER);
  703. if(!IconOnly){
  704. int UseFlags=ui->Flags; if(!HasIcon && IsExpand){ if(!(UseFlags&LA_TEXT_ALIGN)); UseFlags|=LA_TEXT_ALIGN_CENTER; }
  705. tnsDrawStringAuto(buf, laThemeColor(bt, LA_BT_TEXT|ExtraState), _L+bt->LM+(HasIcon?LA_RH:0), _R-bt->RM, _U, UseFlags);
  706. }
  707. if (!IsExpand && !IsVertical && !IconOnly && !IsCycle && !NoEvent){
  708. tnsDrawIcon(L'▼', laThemeColor(bt, LA_BT_TEXT|ExtraState), _R-LA_RH, _R, _U, ui->Flags);
  709. }
  710. }
  711. }
  712. tnsFlush();
  713. }
  714. void la_ButtonDraw(laUiItem *ui, int h){
  715. laBoxedTheme *bt = (*ui->Type->Theme);
  716. char buf[LA_RAW_CSTR_MAX_LEN] = {0};
  717. char *label = 0;
  718. uint32_t IconID=0;
  719. int L;
  720. char *Identifier;
  721. laOperatorProp *ap = 0;
  722. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  723. int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
  724. int IsHighlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
  725. if (ui->PP.LastPs && ui->PP.LastPs->p){
  726. ap = ui->PP.LastPs->p;
  727. label = transLate(ap->Base.Name);
  728. if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
  729. IconID = ap->Base.IconID ? ap->Base.IconID : ap->OperatorType->IconID;
  730. }else{
  731. label = transLate(ui->AT->Name);
  732. IconID = ui->AT->IconID;
  733. }
  734. if (ui->AT && (!laOperatorAvailableP(ui->AT, 0, ui->Instructions)))
  735. ui->State = LA_UI_DISABLED;
  736. elif (ap && ap->OperatorType && (!laOperatorAvailablePSafe(ap->OperatorType, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->Instructions))) ui->State = LA_UI_DISABLED;
  737. else if (ui->State == LA_UI_DISABLED) ui->State = LA_UI_NORMAL;
  738. if(!NoDecal){
  739. tnsUseNoTexture();
  740. tnsColor4dv(ui->State==LA_UI_NORMAL?(IsHighlight?laAccentColor(LA_BT_NORMAL):laThemeColor(bt, ui->State)):laThemeColor(bt, ui->State));
  741. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  742. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  743. tnsPackAs(GL_TRIANGLE_FAN);
  744. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  745. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  746. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  747. tnsPackAs(GL_LINE_LOOP);
  748. }
  749. if (ui->ExtraInstructions){
  750. uint32_t tIconID=0;
  751. if (ui->AT && ui->AT->ParseArgs){
  752. ui->AT->ParseArgs(ui->Instructions, &tIconID, buf);
  753. if (buf[0]) label = buf;
  754. if (tIconID) IconID=tIconID;
  755. }else if (ui->PP.LastPs->p->PropertyType == LA_PROP_OPERATOR){
  756. laOperatorProp *ap = ui->PP.LastPs->p;
  757. if (ap->OperatorType && ap->OperatorType->ParseArgs){
  758. ap->OperatorType->ParseArgs(ui->Instructions, &tIconID, buf);
  759. if (buf[0]) label = buf;
  760. if (tIconID) IconID=tIconID;
  761. }
  762. }
  763. }
  764. if (IconID) L = ui->L + bt->LM + h;
  765. else L = ui->L + bt->LM;
  766. if (IconID) tnsDrawIcon(IconID, laThemeColor(bt, ui->State|LA_BT_TEXT), ui->L, ui->L+LA_RH, ui->U, LA_TEXT_ALIGN_CENTER);
  767. if (!IconOnly) tnsDrawStringAuto(label, laThemeColor(bt, ui->State|LA_BT_TEXT), L, ui->R-bt->RM, ui->U, ui->Flags);
  768. }
  769. void la_LabelDraw(laUiItem *ui, int h){
  770. laBoxedTheme *bt = (*ui->Type->Theme);
  771. int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
  772. int IsHighlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
  773. if (!ui->State) ui->State = LA_UI_NORMAL;
  774. if (ui->ExtraInstructions && !ui->Instructions){
  775. strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
  776. }
  777. //int State = ui->Instructions ? (strArgumentMatch(ui->Instructions, "disabled", "true") ? LA_THEME_DISABLED : LA_UI_NORMAL) : LA_UI_NORMAL;
  778. tnsDrawStringAuto(transLate(ui->Display->Ptr),
  779. IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):(IsHighlight?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT)),
  780. ui->L, ui->R, ui->U, ui->Flags);
  781. }
  782. void la_SingleLineStringDrawSelection(laUiItem *ui, int Begin, int U, laBoxedTheme *bt, uint32_t *str, laStringEdit *se){
  783. tnsUseNoTexture();
  784. if (!strHasSelection(se)){
  785. tnsColor4dv(laAccentColor(LA_BT_TEXT));
  786. int L = (se->CursorBefore ? tnsStringGetWidthU(str, se->CursorBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
  787. tnsVertex2d(L-1, U + LA_RH - bt->BM);
  788. tnsVertex2d(L-1, U + bt->TM);
  789. tnsVertex2d(L+2, U + bt->TM);
  790. tnsVertex2d(L+2, U + LA_RH - bt->BM);
  791. tnsPackAs(GL_TRIANGLE_FAN);
  792. }else{
  793. int L = (se->BeginBefore ? tnsStringGetWidthU(str, se->BeginBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
  794. int R = (se->EndBefore ? tnsStringGetWidthU(str, se->EndBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
  795. tnsColor4dv(laAccentColor(LA_BT_NORMAL));
  796. tnsVertex2d(L, U + bt->TM);
  797. tnsVertex2d(L, U + LA_RH - bt->BM);
  798. tnsVertex2d(R, U + LA_RH - bt->TM);
  799. tnsVertex2d(R, U + bt->BM);
  800. tnsPackAs(GL_TRIANGLE_FAN);
  801. }
  802. }
  803. void la_SingleLineStringDraw(laUiItem *ui, int h){
  804. laBoxedTheme *bt = (*ui->Type->Theme);
  805. char* _temp[LA_RAW_CSTR_MAX_LEN] = {0}; char* temp=_temp;
  806. uint32_t* line=0;
  807. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  808. if (!ui->State) ui->State = LA_UI_NORMAL;
  809. if(!NoDecal){
  810. tnsUseNoTexture();
  811. tnsColor4dv(laThemeColor(bt, ui->State));
  812. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  813. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  814. tnsPackAs(GL_TRIANGLE_FAN);
  815. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  816. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  817. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  818. tnsPackAs(GL_LINE_LOOP);
  819. }
  820. if (ui->Extra && ui->Extra->Edit){
  821. line=strGetCursorLine(ui->Extra->Edit,0)->Buf;
  822. }else{
  823. laGetString(&ui->PP, _temp, &temp);
  824. }
  825. if (line) la_SingleLineStringDrawSelection(ui, ui->L+(NoDecal?0:bt->LM), ui->U, bt, line, ui->Extra->Edit);
  826. tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
  827. tnsDrawStringAutoM(line?0:temp, line, laThemeColor(bt, LA_BT_TEXT), ui->L+(NoDecal?0:bt->LM), ui->R-(NoDecal?0:bt->RM), ui->U, ui->Flags);
  828. }
  829. void la_MultiStringDraw(laUiItem *ui, int h){
  830. laBoxedTheme *bt = (*ui->Type->Theme);
  831. char _temp[LA_RAW_CSTR_MAX_LEN] = {0}; char* temp=_temp;
  832. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  833. if (!ui->State) ui->State = LA_UI_NORMAL;
  834. int NumberWidth=bt->LM;
  835. if(!ui->Extra->Edit){
  836. laGetString(&ui->PP, _temp, &temp);
  837. strBeginEdit(&ui->Extra->Edit, temp);
  838. }
  839. laStringEdit* se=ui->Extra->Edit;
  840. int MonoWidth=tnsGetMonoFontAdvance(); int Count=se->TotalLines;
  841. while(Count){ Count/=10; NumberWidth+=MonoWidth; }
  842. if (ui->State!=LA_UI_ACTIVE){
  843. strSetEditViewRange(ui->Extra->Edit,
  844. ui->Extra->HeightCoeff>0?ui->Extra->HeightCoeff:((ui->B-ui->U)/LA_RH),(ui->R-ui->L-NumberWidth-bt->LM*2-bt->RM)/MonoWidth);
  845. }
  846. if(!NoDecal){
  847. tnsUseNoTexture();
  848. tnsColor4dv(laThemeColor(bt, ui->State));
  849. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  850. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  851. tnsPackAs(GL_TRIANGLE_FAN);
  852. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  853. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  854. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  855. tnsPackAs(GL_LINE_LOOP);
  856. tnsColor4d(LA_COLOR3(laThemeColor(bt,LA_BT_BORDER)),0.8);
  857. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->L+NumberWidth, ui->U);
  858. tnsVertex2d(ui->L, ui->B); tnsVertex2d(ui->L+NumberWidth, ui->B);
  859. tnsPackAs(GL_QUADS);
  860. if(!(se->CursorLine<se->ViewStartLine||se->CursorLine>se->ViewStartLine+se->ViewHeight)){
  861. int LineU=(se->CursorLine-se->ViewStartLine)*LA_RH+ui->U;
  862. tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_NORMAL):laThemeColor(bt,LA_BT_BORDER));
  863. tnsVertex2d(ui->L, LineU); tnsVertex2d(ui->R, LineU);
  864. tnsVertex2d(ui->L, LineU+LA_RH); tnsVertex2d(ui->R, LineU+LA_RH);
  865. tnsPackAs(GL_LINES);
  866. tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT_NORMAL));
  867. tnsVertex2d(ui->L, LineU); tnsVertex2d(ui->L+NumberWidth, LineU);
  868. tnsVertex2d(ui->L, LineU+LA_RH); tnsVertex2d(ui->L+NumberWidth, LineU+LA_RH);
  869. tnsPackAs(GL_QUADS);
  870. }
  871. }else{
  872. NumberWidth=bt->LM;
  873. }
  874. tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
  875. int Line=0, Skip=0, _L=ui->L+NumberWidth+bt->LM; char num[10]={0};
  876. for(laStringLine* sl=se->Lines.pFirst;sl;sl=sl->Item.pNext){
  877. int UseLine=Line+Skip;
  878. if(UseLine<se->ViewStartLine){ Skip++; continue; }
  879. if(UseLine>=se->ViewHeight+se->ViewStartLine){ break; }
  880. int slen=strlenU(sl->Buf);
  881. sprintf(num,"%d", UseLine+1); int LineU=ui->U+Line*LA_RH;
  882. tnsDrawStringM(num, 0, laThemeColor(bt, ((UseLine==se->CursorLine)?LA_BT_NORMAL:LA_BT_TEXT)),
  883. _L-bt->LM -(tnsStringGetWidth(num, 0, ui->Flags&LA_TEXT_MONO)), ui->R, LineU, ui->Flags);
  884. if(slen>=se->ViewStartCol){
  885. tnsDrawStringM(0, &sl->Buf[se->ViewStartCol], laThemeColor(bt, ui->State|LA_BT_TEXT), _L, ui->R, LineU, ui->Flags|LA_TEXT_OVERFLOW_ARROW);
  886. }
  887. if(UseLine>=se->BeginLine&&UseLine<=se->EndLine){
  888. int BeginC=UseLine==se->BeginLine?se->BeginBefore:0; int EndC=UseLine==se->EndLine?se->EndBefore:slen;
  889. BeginC-=se->ViewStartCol; EndC-=se->ViewStartCol; if(EndC>se->ViewWidth)EndC=se->ViewWidth;
  890. tnsUseNoTexture();
  891. tnsVertex2d(BeginC*MonoWidth+_L, LineU); tnsVertex2d(EndC*MonoWidth+_L, LineU);
  892. tnsVertex2d(EndC*MonoWidth+_L, LineU+LA_RH); tnsVertex2d(BeginC*MonoWidth+_L, LineU+LA_RH);
  893. tnsColor4dv(laAccentColor(LA_BT_NORMAL));
  894. tnsPackAs(GL_TRIANGLE_FAN);
  895. }
  896. int len=strlenU(sl->Buf);
  897. if(UseLine==se->CursorLine){
  898. int Dist=se->CursorBefore==0?0:tnsStringGetWidthU(sl->Buf,se->CursorBefore,ui->Flags&LA_TEXT_MONO);
  899. tnsUseNoTexture(); int d=se->ViewStartCol*MonoWidth;
  900. tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT_NORMAL));
  901. tnsVertex2d(_L+Dist-d, LineU); tnsVertex2d(_L+Dist+3-d, LineU);
  902. tnsVertex2d(_L+Dist-d, LineU+LA_RH); tnsVertex2d(_L+Dist+3-d, LineU+LA_RH);
  903. tnsPackAs(GL_QUADS);
  904. }
  905. Line++;
  906. tnsFlush();
  907. }
  908. if(ui->Extra->HeightCoeff>=0)
  909. tnsDrawStringAuto("◿",laThemeColor(bt,LA_BT_BORDER),ui->R-LA_RH, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
  910. if(!NoDecal){
  911. char buf[100]={0}; sprintf(buf, "%d,%d | %d Lines", se->CursorLine+1, se->CursorBefore+1, se->TotalLines);
  912. tnsDrawStringAuto(buf,laThemeColor(bt,LA_BT_BORDER),ui->L, ui->R-LA_RH, ui->B-bt->BM-LA_RH, LA_TEXT_MONO|LA_TEXT_ALIGN_RIGHT);
  913. }
  914. //if (ui->Extra && ui->Extra->Edit) la_SingleLineStringDrawSelection(ui, ui->L, ui->U, bt, temp, ui->Extra->Edit);
  915. tnsFlush();
  916. }
  917. void la_UiSeperatorDraw(laUiItem *ui, int h){
  918. laBoxedTheme *bt = (*ui->Type->Theme);
  919. if (!bt) return;
  920. if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){
  921. char str[]="🞄";
  922. int strw=tnsStringGetWidth(str,0, 0);
  923. tnsDrawStringM(str, 0, laThemeColor(bt,LA_BT_BORDER), ui->L+(ui->R-ui->L-strw)/2, ui->R, ui->U, 0);
  924. }else{
  925. tnsUseNoTexture();
  926. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  927. tnsVertex2d(ui->L, ui->U);
  928. tnsVertex2d(ui->R, ui->U);
  929. tnsPackAs(GL_LINES);
  930. }
  931. }
  932. void la_ColorCircleDrawHCY(laUiItem *ui, int h){
  933. laBoxedTheme *bt = (*ui->Type->Theme);
  934. real c = (real)((ui->R + ui->L) / 2) - h / 2; /*- bt->RM*/
  935. ;
  936. real r = (ui->B - ui->U - bt->TP - bt->BP) / 2;
  937. int i = 0;
  938. real colors[584]={0}; //4*72*2+4*2
  939. real verts[292]={0}; //72*2*2+2*2
  940. real hcy[3] = {0, 1, 1};
  941. real step = 1.0 / 72.0f;
  942. real RealColor[4] = {0};
  943. real PickerPos[2];
  944. real pi_4;
  945. GLuint index[26];
  946. real v, cv, sv;
  947. laGetFloatArray(&ui->PP, RealColor);
  948. tnsRGB2HCY(RealColor, hcy);
  949. PickerPos[0] = c + cos(hcy[0] * TNS_PI * 2) * hcy[1] * r;
  950. PickerPos[1] = ui->U + r + sin(hcy[0] * TNS_PI * 2) * hcy[1] * r;
  951. hcy[0] = 0;
  952. hcy[1] = 1;
  953. for (i; i < 72; i += 1){
  954. int beg = i * 8;
  955. hcy[0]+=step; tnsVectorSet3v(&colors[beg],hcy); colors[beg+3]=1;
  956. tnsVectorSet4v(&colors[beg+4],&colors[beg]); colors[beg+5]=0;
  957. }
  958. tnsFlush();
  959. tnsUseNoTexture();
  960. tnsVectorSet4(&colors[576],1,1,hcy[2],1);
  961. tnsVectorSet4(&colors[580],1,0,hcy[2],1);
  962. tnsColorArray4d(colors, 146);
  963. tnsMakeCircle2d(verts, 72, c, ui->U + r, r, 1);
  964. for(int i=0;i<73;i++){ tnsVectorSet2(&verts[2+i*4],c,ui->U + r); }
  965. tnsVectorSet4v(&verts[288],&verts[0]);
  966. tnsVectorSet4v(&verts[290],&verts[2]);
  967. tnsVertexArray2d(verts, 146);
  968. tnsPackAs(GL_TRIANGLE_STRIP);
  969. tnsUniformColorMode(T->immShader,1);
  970. tnsFlush();
  971. tnsUniformColorMode(T->immShader,0);
  972. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  973. tnsMakeCircle2d(verts, 72, c, ui->U + r, r, 0);
  974. tnsVertexArray2d(verts, 72);
  975. tnsPackAs(GL_LINE_LOOP);
  976. tnsColor4dv(RealColor);
  977. tnsMakeCircle2d(verts, 16, PickerPos[0], PickerPos[1], 8,0);
  978. tnsVertexArray2d(verts, 16);
  979. tnsPackAs(GL_TRIANGLE_FAN);
  980. tnsColor4d(1, 1, 1, 1);
  981. tnsVertexArray2d(verts, 16);
  982. tnsPackAs(GL_LINE_LOOP);
  983. tnsMakeCircle2d(verts, 16, PickerPos[0], PickerPos[1], 7,0);
  984. tnsColor4d(0.1, 0.1, 0.1, 1);
  985. tnsVertexArray2d(verts, 16);
  986. tnsPackAs(GL_LINE_LOOP);
  987. pi_4 = TNS_PI / 4;
  988. tnsMakeArc2d(&verts[26], 12, c, ui->U + r, r + bt->LM + h, pi_4, -pi_4);
  989. tnsMakeArc2d(verts, 12, c, ui->U + r, r + bt->LM, pi_4, -pi_4);
  990. tnsMakeLinerGradient4d(&colors[52], 13, 0, 0, 0, 1, 1, 1, 1, 1);
  991. tnsMakeLinerGradient4d(colors, 13, 0, 0, 0, 1, 1, 1, 1, 1);
  992. tnsMakeBridgedIndex(index, 13, 0, 0);
  993. tnsColorArray4d(colors, 26);
  994. tnsVertexArray2d(verts, 26);
  995. tnsIndexArray(index, 26);
  996. tnsPackAs(GL_QUAD_STRIP);
  997. tnsMakeArc2d(&verts[26], 12, c, ui->U + r, r + bt->LM + h, -pi_4, pi_4);
  998. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  999. tnsVertexArray2d(verts, 26);
  1000. tnsPackAs(GL_LINE_LOOP);
  1001. v = -hcy[2] + 0.5;
  1002. cv = cos(v / 2 * TNS_PI);
  1003. sv = sin(v / 2 * TNS_PI);
  1004. verts[0] = cv * r + c;
  1005. verts[1] = sv * r + ui->U + r;
  1006. verts[2] = cv * (r + h) + c;
  1007. verts[3] = sv * (r + h) + ui->U + r;
  1008. tnsColor4d(1, 1, 1, 1);
  1009. tnsVertexArray2d(verts, 2);
  1010. tnsPackAs(GL_LINES);
  1011. if(ui->Extra->HeightCoeff>=0)
  1012. tnsDrawStringAuto("◿",laThemeColor(bt,LA_BT_BORDER),ui->R-LA_RH, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
  1013. tnsFlush();
  1014. }
  1015. void la_MenuItemDraw(laUiItem *ui, int h){
  1016. laBoxedTheme *bt = (*ui->Type->Theme);
  1017. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  1018. if(!NoDecal){
  1019. tnsUseNoTexture();
  1020. tnsColor4dv(laThemeColor(bt, ui->State));
  1021. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1022. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1023. tnsPackAs(GL_TRIANGLE_FAN);
  1024. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  1025. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1026. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1027. tnsPackAs(GL_LINE_LOOP);
  1028. }
  1029. tnsDrawStringAuto(transLate(ui->Display->Ptr), laThemeColor(bt, LA_BT_TEXT|ui->State), ui->L+bt->LM, ui->R, ui->U, ui->Flags);
  1030. }
  1031. void la_ConditionToggleDraw(laUiItem *ui, int h){
  1032. laBoxedTheme *bt = (*ui->Type->Theme);
  1033. char temp[128] = {0};
  1034. char *buf[LA_RAW_CSTR_MAX_LEN];
  1035. uint32_t IconID;
  1036. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  1037. if (!ui->State) ui->State = LA_UI_NORMAL;
  1038. int UseState=ui->State;
  1039. if (!(ui->Flags&LA_TEXT_ALIGN)) ui->Flags|=LA_TEXT_ALIGN_CENTER;
  1040. if(!NoDecal){
  1041. tnsUseNoTexture();
  1042. tnsColor4dv(laThemeColor(bt, ui->State));
  1043. tnsVertex2d(ui->L, ui->U);
  1044. tnsVertex2d(ui->R, ui->U);
  1045. tnsVertex2d(ui->R, ui->B);
  1046. tnsVertex2d(ui->L, ui->B);
  1047. tnsPackAs(GL_TRIANGLE_FAN);
  1048. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  1049. tnsVertex2d(ui->L, ui->U);
  1050. tnsVertex2d(ui->R, ui->U);
  1051. tnsVertex2d(ui->R, ui->B);
  1052. tnsVertex2d(ui->L, ui->B);
  1053. tnsPackAs(GL_LINE_LOOP);
  1054. }else{
  1055. UseState=LA_UI_NORMAL;
  1056. }
  1057. buf[0] = 0;
  1058. if (ui->ExtraInstructions){
  1059. if (ui->Type->OperatorType->ParseArgs){
  1060. ui->Type->OperatorType->ParseArgs(ui->Instructions, &IconID, buf);
  1061. }
  1062. }
  1063. if (buf[0]) tnsDrawStringAuto(transLate(buf), laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
  1064. else
  1065. tnsDrawStringAuto(ui->State == LA_UI_ACTIVE ? "⯆" : "⯈", laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
  1066. }
  1067. void la_DrawColumnAdjusterRecursive(int U, int B, laColumn *c, int W, tnsVector3d color, int LeftMost){
  1068. if (c->LS){
  1069. la_DrawColumnAdjusterRecursive(U, B, c->LS, W, color, LeftMost);
  1070. la_DrawColumnAdjusterRecursive(U, B, c->RS, W, color, LeftMost);
  1071. }else{
  1072. if(c->IL==LeftMost) return;
  1073. tnsDrawStringAuto("❘", color, c->IL-LA_RH, c->IL+LA_RH, U, LA_TEXT_ALIGN_CENTER);
  1074. }
  1075. }
  1076. void la_ColumnAdjusterDraw(laUiItem *ui, int h){
  1077. laBoxedTheme *bt = (*ui->Type->Theme);
  1078. tnsUseNoTexture();
  1079. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1080. la_DrawColumnAdjusterRecursive(ui->U, ui->U + LA_RH, ui->C, (bt->LM+bt->RM)/2, laThemeColor(bt, LA_BT_BORDER), ui->C->IL);
  1081. }
  1082. void la_ColumnViewerDraw(laUiItem *ui, int h){
  1083. laBoxedTheme *bt = (*ui->Type->Theme);
  1084. laColumn *c = ui->PP.EndInstance;
  1085. int W = ui->R - ui->L - bt->LM - bt->RM;
  1086. //if (c->IR == c->IL)
  1087. // return;
  1088. int T = c->Top->IR - c->Top->IL;
  1089. int L = (int)((real)(c->IL - c->Top->IL) * W / T) + ui->L + bt->LM,
  1090. R = (int)((real)(c->IR - c->Top->IL) * W / T) + ui->L + bt->LM;
  1091. tnsUseNoTexture();
  1092. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1093. tnsVertex2d(L, ui->U + bt->TM);
  1094. tnsVertex2d(R, ui->U + bt->TM);
  1095. tnsVertex2d(R, ui->B - bt->BM);
  1096. tnsVertex2d(L, ui->B - bt->BM);
  1097. tnsPackAs(GL_TRIANGLE_FAN);
  1098. }
  1099. void la_NodeSocketDraw(laUiItem *ui, int h){
  1100. laBoxedTheme *bt = (*ui->Type->Theme);
  1101. char* label=0; char* icon;
  1102. laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
  1103. real* ColorBkg=0,*ColorSocket;
  1104. if(pc==LA_PC_SOCKET_IN) { laNodeInSocket*s=ui->PP.EndInstance; ColorSocket=laThemeColor(bt,LA_BT_TEXT); ColorBkg=laThemeColor(bt, LA_BT_NORMAL); label=s->Label?s->Label->Ptr:""; }
  1105. elif(pc==LA_PC_SOCKET_OUT){ laNodeOutSocket*s=ui->PP.EndInstance; ColorSocket=laThemeColor(bt,LA_BT_TEXT_ACTIVE); ColorBkg=laThemeColor(bt, LA_BT_ACTIVE); label=s->Label?s->Label->Ptr:""; }
  1106. int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
  1107. tnsUseNoTexture();
  1108. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1109. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1110. tnsColor4dv(ColorBkg);
  1111. tnsPackAs(GL_TRIANGLE_FAN);
  1112. int tl,tr,tu,sl,sr,su;
  1113. if(ui->Flags&LA_UI_SOCKET_LABEL_N){ tl=ui->L; tu=ui->U; tr=ui->R; sl=ui->L; sr=ui->R; su=ui->U+LA_RH; }
  1114. elif(ui->Flags&LA_UI_SOCKET_LABEL_S){ tl=ui->L; tu=ui->U+LA_RH; tr=ui->R; sl=ui->L; sr=ui->R; su=ui->U; }
  1115. elif(ui->Flags&LA_UI_SOCKET_LABEL_W){ tl=ui->L; tu=ui->U; tr=tl+LA_2RH; sl=ui->L+LA_2RH; sr=ui->R; su=ui->U; }
  1116. elif(ui->Flags&LA_UI_SOCKET_LABEL_E){ tu=ui->U; tr=ui->R; tl=tr-LA_2RH; sl=ui->L; sr=tl; su=ui->U; }
  1117. else{ sl=ui->L; su=ui->U; sr=ui->R; label=0; }
  1118. tnsDrawStringAuto("⭗", IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):ColorSocket, sl, sr, su, LA_TEXT_ALIGN_CENTER);
  1119. if(label) tnsDrawStringAuto(label, IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):ColorSocket, tl, tr, tu, LA_TEXT_ALIGN_CENTER|LA_TEXT_MONO);
  1120. }
  1121. void la_HeightAdjusterDraw(laUiItem *ui, int h){
  1122. laBoxedTheme *bt = (*ui->Type->Theme);
  1123. char* str="☰";
  1124. if(ui->State==LA_BT_ACTIVE){ str="🡙"; }
  1125. tnsDrawStringAuto(str, laThemeColor(bt,LA_BT_TEXT), ui->L-1000, ui->R+1000, ui->U, LA_TEXT_ALIGN_CENTER);
  1126. }
  1127. void la_RawPropDraw(laUiItem *ui, int h){
  1128. laBoxedTheme *bt = (*ui->Type->Theme);
  1129. int s=0;
  1130. //void* data=laGetRaw(&ui->PP, &s);
  1131. //char* buf[128]; sprintf(buf,"%d bytes of raw data at 0x%0x", s, data);
  1132. tnsDrawStringAuto("RAW DATA", laThemeColor(bt,LA_BT_TEXT), ui->L, ui->R, ui->U, ui->Flags|LA_TEXT_MONO);
  1133. }
  1134. void la_ValueMeterDraw(laUiItem *ui, int h){
  1135. laBoxedTheme *bt = (*ui->Type->Theme);
  1136. int DataI[8]; real Data[8];
  1137. int Len, i, W; real Seg;
  1138. char buf[48] = {0};
  1139. char buf2[48] = {0};
  1140. char prefix[8][64] = {0};
  1141. int Original;
  1142. int Imin=-100, Imax=100;
  1143. real min=-100, max=100;
  1144. int s, State; int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  1145. int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
  1146. Len = laGetArrayLength(&ui->PP);
  1147. laGetPrefixP(&ui->PP, prefix);
  1148. if(IsInt){
  1149. laGetIntArray(&ui->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
  1150. laGetIntRange(&ui->PP, &Imin, &Imax); min=Imin; max=Imax;
  1151. }else{
  1152. laGetFloatArray(&ui->PP, Data);
  1153. laGetFloatRange(&ui->PP,&min,&max);
  1154. }
  1155. for (i = 0; i < Len; i++){
  1156. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  1157. if(IsVertical){
  1158. Seg = (real)(ui->R-ui->L)/Len;
  1159. _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
  1160. }else{
  1161. Seg = (real)(ui->B-ui->U)/Len;
  1162. _U = ui->U + i * Seg; _B=_U+Seg;
  1163. }
  1164. tnsUseNoTexture();
  1165. tnsColor4dv(laThemeColor(bt,ui->State));
  1166. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1167. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1168. tnsPackAs(GL_TRIANGLE_FAN);
  1169. int R1=_R,U1=_U;
  1170. if(IsVertical){ U1 = (real)(max - Data[i]) / (real)(max - min) * (real)(_B-_U) + _U; }
  1171. else{ R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(_R-_L) + _L; }
  1172. tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
  1173. tnsColor4d(LA_COLOR3(color),0.4);
  1174. tnsVertex2d(_L, U1); tnsVertex2d(R1, U1);
  1175. tnsVertex2d(R1, _B); tnsVertex2d(_L, _B);
  1176. tnsPackAs(GL_TRIANGLE_FAN);
  1177. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1178. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1179. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1180. tnsPackAs(GL_LINE_LOOP);
  1181. if(Len==1){ sprintf(buf,ui->PP.LastPs->p->Name); } else{ if(i<8)sprintf(buf,prefix[i]); }
  1182. tnsDrawStringAuto(buf, laThemeColor(bt, LA_BT_TEXT), _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
  1183. }
  1184. tnsFlush();
  1185. }
  1186. void la_ValueMeter2DDraw(laUiItem *ui, int h){
  1187. laBoxedTheme *bt = (*ui->Type->Theme);
  1188. int DataI[8]; real Data[8];
  1189. int Len, i, W; real Seg;
  1190. char buf[48] = {0};
  1191. char buf2[48] = {0};
  1192. char prefix[8][64] = {0};
  1193. int Original;
  1194. int Imin=-100, Imax=100;
  1195. real min=-100, max=100;
  1196. int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
  1197. Len = laGetArrayLength(&ui->PP);
  1198. laGetPrefixP(&ui->PP, prefix);
  1199. if(IsInt){
  1200. laGetIntArray(&ui->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
  1201. laGetIntRange(&ui->PP, &Imin, &Imax); min=Imin; max=Imax;
  1202. }else{
  1203. laGetFloatArray(&ui->PP, Data);
  1204. laGetFloatRange(&ui->PP,&min,&max);
  1205. }
  1206. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  1207. tnsUseNoTexture();
  1208. tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
  1209. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1210. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1211. tnsPackAs(GL_TRIANGLE_FAN);
  1212. real CL=(real)(Data[0] - min) / (real)(max - min) * (real)(_R-_L) + _L;
  1213. real CU=(real)(max - Data[1]) / (real)(max - min) * (real)(_B-_U) + _U;
  1214. real HW=((real)_R-(real)_L)/4; real HH=((real)_B-(real)_U)/4;
  1215. real ML=((real)_R+(real)_L)/2; real MU=((real)_B+(real)_U)/2;
  1216. tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
  1217. tnsColor4d(LA_COLOR3(color),0.4);
  1218. tnsVertex2d(ML+HW, MU+HH); tnsVertex2d(ML-HW, MU+HH);
  1219. tnsVertex2d(ML-HW, MU-HH); tnsVertex2d(ML+HW, MU-HH);
  1220. tnsPackAs(GL_LINE_LOOP);
  1221. tnsVertex2d(_L,_U); tnsVertex2d(_R,_B);
  1222. tnsVertex2d(_R,_U); tnsVertex2d(_L,_B);
  1223. tnsVertex2d(ML,_U); tnsVertex2d(ML,_B);
  1224. tnsVertex2d(_R,MU); tnsVertex2d(_L,MU);
  1225. tnsPackAs(GL_LINES);
  1226. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1227. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1228. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1229. tnsPackAs(GL_LINE_LOOP);
  1230. tnsFlush();
  1231. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
  1232. tnsVertex2d(_L, CU); tnsVertex2d(_R, CU);
  1233. tnsVertex2d(CL, _U); tnsVertex2d(CL, _B);
  1234. tnsPackAs(GL_LINES);
  1235. real circle[48];
  1236. tnsMakeCircle2d(circle,24,CL,CU,LA_RH2,0);
  1237. tnsVertexArray2d(circle,24);
  1238. tnsPackAs(GL_LINE_LOOP);
  1239. glLineWidth(2);
  1240. tnsFlush();
  1241. glLineWidth(1);
  1242. }
  1243. void la_ConditionNodeFreeRecursive(laUiConditionNode *ucn);
  1244. void la_GeneralUiInit(laUiItem *ui){
  1245. ui->Extra = memAcquireSimple(sizeof(laGeneralUiExtraData));
  1246. ui->Extra->ui=ui;
  1247. }
  1248. void la_GeneralUiDestroy(laUiItem *ui){
  1249. if(ui->Extra && ui->Extra->Edit){ strEndEdit(&ui->Extra->Edit, 1); }
  1250. memFree(ui->Extra);
  1251. }
  1252. void la_ConditionUiDestroy(laUiItem *ui){
  1253. laConditionUiExtraData *cued = ui->Extra;
  1254. la_ConditionNodeFreeRecursive(cued->Expression);
  1255. FreeMem(ui->Extra);
  1256. }
  1257. void la_MultiStringInit(laUiItem *ui){
  1258. laGeneralUiExtraData *e = ui->Extra;
  1259. if (!e) e = memAcquireSimple(sizeof(laGeneralUiExtraData));
  1260. ui->Extra = e;
  1261. e->HeightCoeff = 10;
  1262. }
  1263. void la_RegisterUiTypesBasic(){
  1264. laKeyMapper* km;
  1265. laPropContainer* pc;
  1266. LA_WIDGET_INT->Type=LA_WIDGET_INT_PLAIN->Type=
  1267. _LA_UI_INT = la_RegisterUiType("LA_int_array_horizon", LA_PROP_INT | LA_PROP_ARRAY, "LA_int_array_h_operator",
  1268. &_LA_THEME_VALUATOR, la_IntDraw, la_ValueGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1269. _LA_UI_INT->GetMinWidth=la_ValueGetMinWidth;
  1270. LA_WIDGET_VALUE_METER->Type=
  1271. _LA_UI_VALUE_METER = la_RegisterUiType("LA_value_meter", LA_PROP_INT | LA_PROP_ARRAY, 0, &_LA_THEME_VALUATOR, la_ValueMeterDraw, la_ValueMeterGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1272. LA_WIDGET_VALUE_METER_2D->Type=
  1273. _LA_UI_VALUE_METER_2D = la_RegisterUiType("LA_value_meter_2d", LA_PROP_INT | LA_PROP_ARRAY, 0, &_LA_THEME_VALUATOR, la_ValueMeter2DDraw, la_ValueMeter2DGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1274. LA_WIDGET_FLOAT->Type=LA_WIDGET_FLOAT_PLAIN->Type=
  1275. _LA_UI_FLOAT = la_RegisterUiType("LA_real_array_horizon", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_array_h_operator",
  1276. &_LA_THEME_VALUATOR, la_FloatDraw, la_ValueGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1277. _LA_UI_FLOAT->GetMinWidth=la_ValueGetMinWidth;
  1278. LA_WIDGET_FLOAT_COLOR->Type=
  1279. _LA_UI_FLOAT_COLOR = la_RegisterUiType("LA_real_color", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_color_operator",
  1280. &_LA_THEME_VALUATOR, la_FloatArrayColorDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1281. _LA_UI_FLOAT_COLOR->GetMinWidth=la_ColorSelectorGetMinWidth;
  1282. LA_WIDGET_FLOAT_COLOR_HCY->Type=
  1283. _LA_UI_FLOAT_COLOR_HCY = la_RegisterUiType("LA_real_hcy", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_hcy_operator",
  1284. &_LA_THEME_VALUATOR, la_ColorCircleDrawHCY, la_ColorPickerGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1285. _LA_UI_FLOAT_COLOR_HCY->GetMinWidth = la_ColorPickerGetMinWidth;
  1286. LA_WIDGET_ENUM_SELECTOR->Type=LA_WIDGET_ENUM_SELECTOR_ICON->Type=LA_WIDGET_ENUM_CYCLE->Type=LA_WIDGET_ENUM_HIGHLIGHT->Type=
  1287. _LA_UI_ENUM_SELECTOR = la_RegisterUiType("LA_enum_selector", LA_PROP_ENUM, "LA_enum_selector_operator",
  1288. &_LA_THEME_SELECTOR, la_EnumSelectorDraw, la_EnumGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1289. _LA_UI_ENUM_SELECTOR->GetMinWidth = la_EnumGetMinWidth;
  1290. LA_WIDGET_FIXED_GROUP->Type=
  1291. _LA_UI_FIXED_GROUP = la_RegisterUiType("LA_group_default", 0, 0,
  1292. &_LA_THEME_COLLECTION_GROUP, la_GroupDraw, la_GroupGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1293. _LA_UI_FIXED_GROUP->Tag|=LA_UI_TAG_SCISSOR;
  1294. LA_WIDGET_COLLECTION->Type=
  1295. _LA_UI_COLLECTION = la_RegisterUiType("LA_collection_default", LA_PROP_SUB, "LA_collection_operator",
  1296. &_LA_THEME_COLLECTION_GROUP, la_EmptyDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1297. LA_WIDGET_COLLECTION_SELECTOR->Type=
  1298. _LA_UI_COLLECTION_SELECTOR = la_RegisterUiType("LA_collection_selector_default", LA_PROP_SUB, "LA_collection_selector_operator",
  1299. &_LA_THEME_COLLECTION_SELECTOR, la_CollectionSelectorDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1300. LA_WIDGET_COLLECTION_SINGLE->Type=
  1301. _LA_UI_COLLECTION_SINGLE = la_RegisterUiType("LA_collection_single", LA_PROP_SUB, "LA_collection_operator",
  1302. &_LA_THEME_COLLECTION_GROUP, la_EmptyDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1303. LA_WIDGET_TAB->Type=
  1304. _LA_UI_TAB = la_RegisterUiType("LA_tab_default", 0, "LA_tab_operator",
  1305. &_LA_THEME_TAB, la_TabDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1306. LA_WIDGET_BUTTON->Type=LA_WIDGET_BUTTON_NO_CONFIRM->Type=
  1307. _LA_UI_BUTTON = la_RegisterUiType("LA_button_default", LA_PROP_OPERATOR, "LA_button_operator",
  1308. &_LA_THEME_BUTTON, la_ButtonDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1309. _LA_UI_BUTTON->GetMinWidth = la_ButtonGetMinWidth;
  1310. LA_WIDGET_BUTTON_NO_CONFIRM->Flags|=LA_UI_FLAGS_NO_CONFIRM;
  1311. pc=laUiHasExtraProps(_LA_UI_BUTTON, sizeof(laGeneralUiExtraData),0);
  1312. LA_WIDGET_LABEL->Type=
  1313. _LA_UI_LABEL = la_RegisterUiType("LA_label_default", LA_PROP_OPERATOR, 0,
  1314. &_LA_THEME_LABEL, la_LabelDraw, la_LabelHeight, 0, 0);
  1315. _LA_UI_LABEL->GetMinWidth = la_LabelGetMinWidth;
  1316. LA_WIDGET_MENU_ROOT->Type=
  1317. _LA_UI_MENU_ROOT = la_RegisterUiType("LA_menu_default", LA_PROP_OPERATOR, "LA_menu_root_operator",
  1318. &_LA_THEME_BUTTON, la_MenuItemDraw, 0, 0, 0);
  1319. _LA_UI_MENU_ROOT->GetMinWidth=la_LabelGetMinWidth;
  1320. LA_WIDGET_CONDITION_TOGGLE->Type=
  1321. _LA_UI_CONDITION_TOGGLE = la_RegisterUiType("LA_condition_toggle_default", LA_PROP_SELF_CONDITION, "LA_condition_toggle_operator",
  1322. &_LA_THEME_BUTTON, la_ConditionToggleDraw, 0, 0, la_ConditionUiDestroy);
  1323. LA_WIDGET_STRING->Type=LA_WIDGET_STRING_PLAIN->Type=LA_WIDGET_STRING_MONO_PLAIN->Type=
  1324. _LA_UI_STRING = la_RegisterUiType("LA_string_default", LA_PROP_STRING, "LA_string_operator",
  1325. &_LA_THEME_STRING, la_SingleLineStringDraw, la_StringPropGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1326. _LA_UI_STRING->GetMinWidth = la_StringPropGetMinWidth;
  1327. km=&_LA_UI_STRING->KeyMapper;
  1328. laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'c', 0);
  1329. laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
  1330. pc=laUiHasExtraProps(_LA_UI_STRING, sizeof(laGeneralUiExtraData), 0);{
  1331. laAddOperatorProperty(pc, "copy_selection", "Copy Selection", "Copy selected string into clipboard", "LA_edit_string_copy",0,0);
  1332. }
  1333. LA_WIDGET_STRING_MULTI->Type=
  1334. _LA_UI_STRING_MULTI = la_RegisterUiType("LA_string_multiline", LA_PROP_STRING, "LA_string_multi",
  1335. &_LA_THEME_STRING, la_MultiStringDraw, la_MultiStringHeight, la_MultiStringInit, la_GeneralUiDestroy);
  1336. _LA_UI_STRING_MULTI->GetMinWidth = la_StringPropGetMinWidth;
  1337. km=&_LA_UI_STRING_MULTI->KeyMapper;
  1338. laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'c', 0);
  1339. laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
  1340. pc=laUiHasExtraProps(_LA_UI_STRING_MULTI, sizeof(laGeneralUiExtraData), 0);{
  1341. laAddOperatorProperty(pc, "copy_selection", "Copy Selection", "Copy selected string into clipboard", "LA_edit_string_copy",0,0);
  1342. }
  1343. LA_WIDGET_ALIGN->Type=
  1344. _LA_UI_ALIGN = la_RegisterUiType("LA_colum_align_default", 0, 0,
  1345. &_LA_THEME_BUTTON, la_UiSeperatorDraw, 0, 0, 0);
  1346. LA_WIDGET_COLUMN_ADJUSTER->Type=
  1347. _LA_UI_COLUMN_ADJUSTER = la_RegisterUiType("LA_column_adjuster_default", 0, "LA_column_adjuster",
  1348. &_LA_THEME_BUTTON, la_ColumnAdjusterDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1349. _LA_UI_COLUMN_ADJUSTER->TargetSub = "ui_column";
  1350. LA_WIDGET_COLUMN_VIEWER->Type=
  1351. _LA_UI_COLUMN_VIEWER = la_RegisterUiType("LA_column_viewer_default", 0, 0,
  1352. &_LA_THEME_BUTTON, la_ColumnViewerDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1353. _LA_UI_COLUMN_VIEWER->TargetSub = "ui_column";
  1354. _LA_UI_COLUMN_VIEWER->GetMinWidth = la_ColumnViewerGetMinWidth;
  1355. _LA_UI_CONDITION_ELSE.Theme = &_LA_THEME_BUTTON;
  1356. la_UDFAppendSharedTypePointer("LA_condition_else", &_LA_UI_CONDITION_ELSE);
  1357. _LA_UI_CONDITION.Destroy = _LA_UI_CONDITION_ELSE.Destroy = _LA_UI_CONDITION_END.Destroy =la_ConditionUiDestroy;
  1358. _LA_UI_CONDITION.Theme = &_LA_THEME_BUTTON;
  1359. la_UDFAppendSharedTypePointer("LA_condition", &_LA_UI_CONDITION);
  1360. _LA_UI_CONDITION_END.Theme = &_LA_THEME_BUTTON;
  1361. la_UDFAppendSharedTypePointer("LA_condition_end", &_LA_UI_CONDITION_END);
  1362. LA_WIDGET_SYMBOL->Type=
  1363. _LA_UI_SYMBOL = la_RegisterUiType("LA_symbol_default", 0, 0, &_LA_THEME_BUTTON, la_SymbolDraw, la_SymbolGetHeight, 0, 0);
  1364. LA_WIDGET_NODE_SOCKET->Type=
  1365. _LA_UI_NODE_SOCKET = la_RegisterUiType("LA_node_socket_default", 0, "LA_node_socket", &_LA_THEME_SOCKET, la_NodeSocketDraw, la_SocketGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1366. _LA_UI_NODE_SOCKET->GetMinWidth=la_SocketGetMinWidth;
  1367. LA_WIDGET_HEIGHT_ADJUSTER->Type=
  1368. _LA_UI_HEIGHT_ADJUSTER = la_RegisterUiType("LA_height_adjuster_default", 0, "LA_height_adjuster", &_LA_THEME_COLLECTION_GROUP, la_HeightAdjusterDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1369. _LA_UI_HEIGHT_ADJUSTER->ForType = LA_PROP_INT;
  1370. LA_WIDGET_RAW->Type=
  1371. _LA_UI_RAW = la_RegisterUiType("LA_raw_prop_default", 0, 0, &_LA_THEME_COLLECTION_GROUP, la_RawPropDraw, 0, 0, 0);
  1372. _LA_UI_RAW->ForType = LA_PROP_RAW;
  1373. _LA_UI_ROW_BEGIN.Theme=&_LA_THEME_BUTTON;
  1374. _LA_UI_ROW_END.Theme=&_LA_THEME_BUTTON;
  1375. }
  1376. // ============================================================ [Operators]
  1377. void la_DefaultEnumPanel(laUiList *uil, laPropPack *This, laPropPack *OperatorProps, laColumn *UNUSED){
  1378. laColumn *c = laFirstColumn(uil);
  1379. laShowItem(uil, c, This, 0)->Flags=(LA_UI_FLAGS_TRANSPOSE|LA_UI_FLAGS_EXPAND);
  1380. }
  1381. int la_DetectRow(laUiItem *ui, int LocalY){
  1382. return (LocalY - ui->U) / LA_RH;
  1383. }
  1384. int la_DetectColumn(laUiItem *ui, int LocalX, int Total){
  1385. return (int)((real)(LocalX - ui->L) / (real)(ui->R - ui->L) * (real)Total);
  1386. }
  1387. laColumn *la_DetectSplit(laColumn *Root, int LocalX){
  1388. laColumn *result = 0;
  1389. if (!Root->LS) return 0;
  1390. if (LocalX - Root->LS->IR < LA_SCROLL_W && Root->LS->IR - LocalX < LA_SCROLL_W &&
  1391. !Root->LS->MaxW && !Root->RS->MaxW){
  1392. return Root;
  1393. }
  1394. result = la_DetectSplit(Root->LS, LocalX);
  1395. if (result) return result;
  1396. else
  1397. return la_DetectSplit(Root->RS, LocalX);
  1398. }
  1399. void la_AdjustColumnSplit(laColumn *c, int PxLeftPositive){
  1400. if (!c->LS || c->LS->MaxW || c->RS->MaxW) return;
  1401. if (PxLeftPositive < 0 && c->LS->IR - c->LS->IL <= LA_SCROLL_W*2) return;
  1402. if (PxLeftPositive > 0 && c->RS->IR - c->RS->IL <= LA_SCROLL_W*2) return;
  1403. c->LS->IR += PxLeftPositive;
  1404. c->RS->IL += PxLeftPositive;
  1405. c->LS->SP = (real)(c->LS->IR - c->LS->IL) / (real)(c->IR - c->IL);
  1406. c->RS->SP = c->LS->SP;
  1407. }
  1408. int OPCHK_EditStringCopySelection(laPropPack *This, laStringSplitor *Instructions){
  1409. laGeneralUiExtraData *uit = This->EndInstance; if(!uit) return 0;
  1410. if(!uit->Edit || !strHasSelection(uit->Edit)) return 0;
  1411. return 1;
  1412. }
  1413. int OPINV_EditStringCopySelection(laOperator *a, laEvent *e){
  1414. laGeneralUiExtraData *uit = a->This->EndInstance; if(!uit) return LA_FINISHED;
  1415. if(!uit->Edit || !strHasSelection(uit->Edit)) return LA_FINISHED;
  1416. char* str=strGetEditString(uit->Edit, 1);
  1417. laCopyToClipboard(str); free(str);
  1418. return LA_FINISHED;
  1419. }
  1420. int la_ProcessTextEdit(laEvent *e, laStringEdit *se, laUiItem* ui){
  1421. int Select=e->SpecialKeyBit&LA_KEY_SHIFT;
  1422. int _L, MonoWidth;
  1423. switch (e->Type){
  1424. case LA_INPUT:
  1425. switch (e->Input){
  1426. case 0x08: if(strHasSelection(se)) strClearSelection(se); else strBackspace(se); return 1;
  1427. case 0x7f: if(strHasSelection(se)) strClearSelection(se); else { strMoveCursor(se,0,0); strBackspace(se); } return 1;
  1428. case 0x09: strInsertChar(se, ' ');strInsertChar(se, ' ');strInsertChar(se, ' ');strInsertChar(se, ' '); return 1;
  1429. case 0x1B: case 0x0D: return 0;
  1430. default: strInsertChar(se, e->Input); return 1;
  1431. }
  1432. break;
  1433. case LA_KEY_DOWN:
  1434. switch (e->key){
  1435. case LA_KEY_ENTER: strInsertChar(se, '\n'); return 1;
  1436. case LA_KEY_ARRLEFT: strMoveCursor(se, 1, Select); return 1;
  1437. case LA_KEY_ARRRIGHT: strMoveCursor(se, 0, Select); return 1;
  1438. case LA_KEY_ARRUP: strMoveCursorLine(se, 1, Select); return 1;
  1439. case LA_KEY_ARRDOWN: strMoveCursorLine(se, 0, Select); return 1;
  1440. }
  1441. break;
  1442. case LA_L_MOUSE_DOWN:
  1443. case LA_MOUSEMOVE:
  1444. if(!ui) return 0;
  1445. MonoWidth=tnsGetMonoFontAdvance(); _L=(*ui->Type->Theme)->LM;
  1446. int Count=se->TotalLines; while(Count){ Count/=10; _L+=MonoWidth; }
  1447. if(e->Type==LA_L_MOUSE_DOWN){
  1448. strSetCursor(se, (e->y-ui->U)/LA_RH+se->ViewStartLine, (e->x-_L-MonoWidth/2)/MonoWidth); strCancelSelect(se); strLazySelect(se);
  1449. se->MouseSelecting=1; se->CursorPreferBefore=se->CursorBefore; return 1;
  1450. }else{
  1451. if(!se->MouseSelecting) return 0;
  1452. MonoWidth=tnsGetMonoFontAdvance(); _L=(*ui->Type->Theme)->LM;
  1453. int Count=se->TotalLines; while(Count){ Count/=10; _L+=MonoWidth; }
  1454. strSetCursor(se, (e->y-ui->U)/LA_RH+se->ViewStartLine, (e->x-_L-MonoWidth/2)/MonoWidth); strEndSelect(se);
  1455. se->CursorPreferBefore=se->CursorBefore; return 1;
  1456. }return 0;
  1457. case LA_L_MOUSE_UP:
  1458. se->MouseSelecting=0;
  1459. }
  1460. return 0;
  1461. }
  1462. int OPINV_UiItem(laOperator *a, laEvent *e){
  1463. laUiItem *ui = a->Instance;
  1464. a->CustomData = ui->Extra;
  1465. return LA_RUNNING;
  1466. }
  1467. int OPINV_Tab(laOperator *a, laEvent *e){
  1468. laUiList *uil;
  1469. laUiItem *ui = a->Instance;
  1470. laGeneralUiExtraData *uit;
  1471. int count = 0;
  1472. //if (e->Type == LA_L_MOUSE_DOWN) {
  1473. //}
  1474. a->CustomData = ui->Extra;
  1475. uit = a->CustomData;
  1476. uit->TargetIndexVali = count;
  1477. return LA_RUNNING;
  1478. }
  1479. int OPEXT_UiItem(laOperator *a, int ExitCode){
  1480. laUiItem *ui = a->Instance;
  1481. return 0;
  1482. }
  1483. int OPMOD_IntArrayHorizon(laOperator *a, laEvent *e){
  1484. laUiItem *ui = a->Instance;
  1485. laBoxedTheme *bt = (*ui->Type->Theme);
  1486. laGeneralUiExtraData *uit = a->CustomData;
  1487. laIntProp *ip = ui->PP.LastPs->p;
  1488. int Away = 0;
  1489. int TmpArr[32];
  1490. int Len = laGetArrayLength(&ui->PP);
  1491. int IsVertical=(ui->Flags&LA_UI_FLAGS_TRANSPOSE)!=0;
  1492. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  1493. if (!laIsInUiItem(ui, e->x, e->y) && !ui->Extra->On){
  1494. ui->State = LA_UI_NORMAL;
  1495. if (ui->Extra) ui->Extra->On = 0;
  1496. laRedrawCurrentPanel();
  1497. return LA_FINISHED_PASS;
  1498. }
  1499. if (e->Type == LA_TIME_IDLE && !uit->On && !uit->Edit){
  1500. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  1501. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  1502. return LA_RUNNING;
  1503. }
  1504. if(NoEvent){ return LA_RUNNING_PASS; }
  1505. if (e->Type == LA_L_MOUSE_DOWN){
  1506. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  1507. if (uit->Edit){
  1508. if (!laIsInUiItem(ui, e->x, e->y)){
  1509. strEndEdit(&uit->Edit, 1);
  1510. uit->On = 0;
  1511. laRedrawCurrentPanel();
  1512. return LA_FINISHED;
  1513. }
  1514. if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
  1515. else strSelectLineAll(uit->Edit);
  1516. return LA_RUNNING;
  1517. }
  1518. uit->LastX = e->x;
  1519. uit->LastY = e->y;
  1520. ui->Extra->On = (IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
  1521. if (ui->Extra->On > Len) return LA_RUNNING;
  1522. laGetIntArray(&ui->PP, &TmpArr);
  1523. uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
  1524. laRedrawCurrentPanel();
  1525. return LA_RUNNING;
  1526. }
  1527. if (e->Type == LA_MOUSEMOVE && ui->Extra->On){
  1528. if(ui->Extra->Edit){ return LA_RUNNING; }
  1529. int dist=abs(e->x - uit->LastX);
  1530. if (dist > MAIN.ValuatorThreshold || uit->Dragging){
  1531. int min,max,Ranged = laGetIntRange(&ui->PP, &min, &max); real step=ip->Step; if(Ranged){ step=(real)(max-min)/(ui->R-ui->L); }
  1532. //laGetIntArray(&ui->PP, &TmpArr);
  1533. //uit->TargetIndexVali = TmpArr[ui->Extra->On - 1];
  1534. int delta=e->x-uit->LastX; if(!uit->Dragging) delta=delta>0?1:-1;
  1535. uit->TargetIndexValf += delta*step;
  1536. laSetIntArraySingle(&ui->PP, ui->Extra->On - 1, uit->TargetIndexValf);
  1537. uit->LastX = e->x;
  1538. uit->LastY = e->y;
  1539. uit->Dragging = 1;
  1540. laRedrawCurrentPanel();
  1541. }
  1542. return LA_RUNNING;
  1543. }
  1544. if (e->Type == LA_L_MOUSE_UP){
  1545. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  1546. if (uit->Dragging){
  1547. if (ui->Extra->On){
  1548. ui->Extra->On = 0;
  1549. laConfirmInt(a, uit->TargetIndexVali, LA_CONFIRM_DATA);
  1550. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  1551. }
  1552. }else if(ui->Extra->On){
  1553. int SelectOn=(IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
  1554. if ((!uit->Edit) || (uit->Edit && (SelectOn != ui->Extra->On))){
  1555. char buf[32] = {0};
  1556. uit->On=SelectOn;
  1557. laGetIntArray(&ui->PP, &TmpArr);
  1558. uit->TargetIndexVali = TmpArr[ui->Extra->On - 1];
  1559. strPrintIntAfter(buf, 32, uit->TargetIndexVali);
  1560. strBeginEdit(&uit->Edit,buf);
  1561. strSelectLineAll(uit->Edit);
  1562. }
  1563. }
  1564. uit->Dragging = 0;
  1565. laRedrawCurrentPanel();
  1566. return LA_RUNNING;
  1567. }
  1568. if(e->Type ==LA_KEY_DOWN){
  1569. if (e->key == LA_KEY_ENTER && uit->Edit){
  1570. char* buf=strEndEdit(&uit->Edit, 0);
  1571. int Result; sscanf(buf, "%d", &Result); free(buf);
  1572. laSetIntArraySingle(&ui->PP, ui->Extra->On - 1, Result);
  1573. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  1574. ui->State = LA_UI_NORMAL;
  1575. uit->Dragging = 0;
  1576. uit->On = 0;
  1577. laRedrawCurrentPanel();
  1578. return LA_FINISHED_PASS;
  1579. }
  1580. }
  1581. if (uit->Edit){
  1582. if (la_ProcessTextEdit(e, uit->Edit, ui)){
  1583. laRedrawCurrentPanel();
  1584. return LA_RUNNING;
  1585. }
  1586. }
  1587. if (e->Type == LA_R_MOUSE_DOWN){
  1588. int GX = e->x, GY = e->y;
  1589. ui->PP.LastIndex = la_DetectColumn(ui, e->x, Len);
  1590. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  1591. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  1592. return LA_RUNNING;
  1593. }
  1594. return LA_RUNNING_PASS;
  1595. }
  1596. int OPMOD_FloatArrayHorizon(laOperator *a, laEvent *e){
  1597. laUiItem *ui = a->Instance;
  1598. laBoxedTheme *bt = (*ui->Type->Theme);
  1599. laGeneralUiExtraData *uit = a->CustomData;
  1600. laFloatProp *fp = ui->PP.LastPs->p;
  1601. int Away = 0;
  1602. real TmpArr[32];
  1603. int Len = laGetArrayLength(&ui->PP);
  1604. int IsVertical=(ui->Flags&LA_UI_FLAGS_TRANSPOSE)!=0;
  1605. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  1606. int IsRad=ui->PP.LastPs->p->IsRadAngle;
  1607. if (!laIsInUiItem(ui, e->x, e->y) && !ui->Extra->On){
  1608. ui->State = LA_UI_NORMAL;
  1609. ui->Extra->On = 0;
  1610. laRedrawCurrentPanel();
  1611. return LA_FINISHED_PASS;
  1612. }
  1613. if (e->Type == LA_TIME_IDLE && !uit->On && !uit->Edit){
  1614. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  1615. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  1616. return LA_RUNNING;
  1617. }
  1618. if(NoEvent){ return LA_RUNNING_PASS; }
  1619. if (e->Type == LA_L_MOUSE_DOWN){
  1620. if (uit->Edit){
  1621. if (!laIsInUiItem(ui, e->x, e->y)){
  1622. strEndEdit(&uit->Edit, 1);
  1623. uit->On = 0;
  1624. laRedrawCurrentPanel();
  1625. return LA_FINISHED;
  1626. }
  1627. if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
  1628. else strSelectLineAll(uit->Edit);
  1629. return LA_RUNNING;
  1630. }
  1631. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  1632. uit->LastX = e->x;
  1633. uit->LastY = e->y;
  1634. ui->Extra->On = (IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
  1635. if (ui->Extra->On > Len) return LA_RUNNING;
  1636. laGetFloatArray(&ui->PP, &TmpArr);
  1637. uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
  1638. laRedrawCurrentPanel();
  1639. return LA_RUNNING;
  1640. }
  1641. if (e->Type == LA_MOUSEMOVE && ui->Extra->On){
  1642. if(uit->Edit){ return LA_RUNNING; }
  1643. int dist=abs(e->x - uit->LastX);
  1644. if (dist > MAIN.ValuatorThreshold || uit->Dragging){
  1645. real min,max; int Ranged = laGetFloatRange(&ui->PP, &min, &max); real step=fp->Step; if(Ranged){ step=(max-min)/(ui->R-ui->L); }
  1646. laGetFloatArray(&ui->PP, &TmpArr);
  1647. uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
  1648. int delta=e->x-uit->LastX; if(!uit->Dragging) delta=delta>0?1:-1;
  1649. uit->TargetIndexValf += delta*step;
  1650. laSetFloatArraySingle(&ui->PP, ui->Extra->On - 1, uit->TargetIndexValf);
  1651. uit->LastX = e->x;
  1652. uit->LastY = e->y;
  1653. uit->Dragging = 1;
  1654. laRedrawCurrentPanel();
  1655. }
  1656. return LA_RUNNING;
  1657. }
  1658. if (e->Type == LA_L_MOUSE_UP){
  1659. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  1660. if (uit->Dragging){
  1661. if (ui->Extra->On){
  1662. ui->Extra->On = 0;
  1663. laConfirmFloat(a, uit->TargetIndexValf, LA_CONFIRM_DATA);
  1664. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  1665. }
  1666. }else if(ui->Extra->On){
  1667. int SelectOn=(IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
  1668. if ((!uit->Edit) || (uit->Edit && (SelectOn != ui->Extra->On))){
  1669. char buf[32] = {0};
  1670. uit->On=SelectOn;
  1671. laGetFloatArray(&ui->PP, &TmpArr);
  1672. uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
  1673. strPrintFloatAfter(buf, 32, 5, IsRad?deg(uit->TargetIndexValf):uit->TargetIndexValf);
  1674. strBeginEdit(&uit->Edit,buf);
  1675. strSelectLineAll(uit->Edit);
  1676. }
  1677. }
  1678. uit->Dragging = 0;
  1679. laRedrawCurrentPanel();
  1680. return LA_RUNNING;
  1681. }
  1682. if(e->Type ==LA_KEY_DOWN){
  1683. if (e->key == LA_KEY_ENTER && uit->Edit){
  1684. char* buf=strEndEdit(&uit->Edit, 0);
  1685. real Result; sscanf(buf, "%lf", &Result); free(buf);
  1686. if(IsRad) Result=rad(Result);
  1687. laSetFloatArraySingle(&ui->PP, ui->Extra->On - 1, Result);
  1688. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  1689. uit->Dragging = 0;
  1690. uit->On = 0;
  1691. laRedrawCurrentPanel();
  1692. return LA_FINISHED_PASS;
  1693. }
  1694. }
  1695. if (uit->Edit){
  1696. if (la_ProcessTextEdit(e, uit->Edit, ui)){
  1697. laRedrawCurrentPanel();
  1698. return LA_RUNNING;
  1699. }
  1700. }
  1701. if (e->Type == LA_R_MOUSE_DOWN){
  1702. int GX = e->x, GY = e->y;
  1703. ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
  1704. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  1705. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  1706. return LA_RUNNING;
  1707. }
  1708. return LA_RUNNING_PASS;
  1709. }
  1710. int OPMOD_FloatColor(laOperator *a, laEvent *e){
  1711. laUiItem *ui = a->Instance;
  1712. laBoxedTheme *bt = (*ui->Type->Theme);
  1713. laGeneralUiExtraData *uit = a->CustomData;
  1714. int Away = 0;
  1715. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  1716. if (!laIsInUiItem(ui, e->x, e->y)){
  1717. return LA_FINISHED_PASS;
  1718. }
  1719. if (e->Type == LA_TIME_IDLE){
  1720. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  1721. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  1722. return LA_RUNNING;
  1723. }
  1724. if(NoEvent){ return LA_RUNNING_PASS; }
  1725. if (e->Type == LA_L_MOUSE_DOWN){
  1726. laUiList *uil;
  1727. laColumn *col;
  1728. laPanel *p;
  1729. int GX = ui->L, GY = ui->B;
  1730. ui->State = LA_UI_ACTIVE;
  1731. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  1732. p = laEnableEmptyPropertyPanel(a->ToPanel, a, GX, GX + 150, GY, 500, e);{
  1733. uil = &p->UI;
  1734. col = laFirstColumn(uil);
  1735. laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_FLOAT_COLOR_HCY, 0, 0, 0);
  1736. laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_FLOAT, 0, 0, 0)->Flags=LA_UI_FLAGS_TRANSPOSE;
  1737. laEnclosePanelContent(p, uil);
  1738. }
  1739. return LA_RUNNING;
  1740. }
  1741. if (e->Type == LA_R_MOUSE_DOWN){
  1742. int GX = e->x, GY = e->y;
  1743. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  1744. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  1745. return LA_RUNNING;
  1746. }
  1747. return LA_RUNNING_PASS;
  1748. }
  1749. int OPMOD_ColorHCY(laOperator *a, laEvent *e){
  1750. laUiItem *ui = a->Instance;
  1751. laBoxedTheme *bt = (*ui->Type->Theme);
  1752. laGeneralUiExtraData *es = a->CustomData;
  1753. int Away = 0;
  1754. int i = 0;
  1755. real hcy[3] = {0};
  1756. real Color[4] = {0};
  1757. real PickerPos[2];
  1758. real abso;
  1759. if (!laIsInUiItem(ui, e->x, e->y) && !es->Dragging){
  1760. return LA_FINISHED_PASS;
  1761. }
  1762. if(e->Type == LA_L_MOUSE_DOWN && es->HeightCoeff>=0 && e->x>ui->R-bt->RM-LA_RH && e->y>ui->B-bt->BM-LA_RH){
  1763. es->Dragging=3; es->LastX=e->x; es->LastY=e->y; es->TargetIndexVali=es->HeightCoeff; return LA_RUNNING;
  1764. }
  1765. if(es->Dragging==3){
  1766. if(e->Type==LA_MOUSEMOVE){ es->HeightCoeff=es->TargetIndexVali+((real)e->y-es->LastY+0.5)/LA_RH;
  1767. if(es->HeightCoeff<1)es->HeightCoeff=1; laRecalcCurrentPanel();}
  1768. elif(e->Type==LA_L_MOUSE_UP){ es->Dragging=0; }
  1769. elif(e->Type==LA_R_MOUSE_DOWN){
  1770. es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel(); }
  1771. return LA_RUNNING;
  1772. }
  1773. real c = (real)((ui->R + ui->L) / 2) - LA_RH / 2; /*- bt->RM;*/
  1774. real r = (ui->B - ui->U - bt->TP - bt->BP) / 2;
  1775. real dx = e->x - c, dy = e->y - (ui->U + r + bt->TP);
  1776. real dist = sqrt(dx * dx + dy * dy);
  1777. if (e->Type == LA_L_MOUSE_DOWN){ ui->State = LA_UI_ACTIVE; laRedrawCurrentPanel(); es->Dragging=(dist<=r)?1:2; }
  1778. if (e->Type == LA_L_MOUSE_UP){ ui->State = LA_UI_NORMAL; es->Dragging=0; laRedrawCurrentPanel(); return LA_RUNNING_PASS; }
  1779. if (e->Type & LA_MOUSE_EVENT && es->Dragging){
  1780. laGetFloatArray(&ui->PP, Color);
  1781. tnsRGB2HCY(Color, hcy);
  1782. if (es->Dragging==1){
  1783. abso = fabs(atan((real)dy / (real)dx));
  1784. hcy[0] = abso / TNS_PI / 2;
  1785. if (dx > 0){
  1786. if (dy < 0) hcy[0] = 1 - hcy[0];
  1787. }else{
  1788. if (dy > 0){
  1789. hcy[0] = 0.5 - hcy[0];
  1790. }else{
  1791. hcy[0] += 0.5;
  1792. }
  1793. }
  1794. hcy[1] = dist / r; TNS_CLAMP(hcy[1],0,1);
  1795. }else if (dist < r + LA_RH * 2 && dx > 0){
  1796. abso = -atan((real)dy / (real)dx) / TNS_PI * 2 + 0.5;
  1797. hcy[2] = abso; TNS_CLAMP(hcy[2],0,1);
  1798. }
  1799. tnsHCY2RGB(hcy, Color);
  1800. laSetFloatArrayAllArray(&ui->PP, Color);
  1801. laRedrawCurrentPanel();
  1802. return LA_RUNNING;
  1803. }
  1804. return LA_RUNNING_PASS;
  1805. }
  1806. int OPMOD_EnumSelector(laOperator *a, laEvent *e){
  1807. laUiItem *ui = a->Instance;
  1808. laBoxedTheme *bt = (*ui->Type->Theme);
  1809. laGeneralUiExtraData *uit = a->CustomData;
  1810. laEnumItem *ei;
  1811. laEnumProp *ep = ui->PP.LastPs->p;
  1812. int at = 0;
  1813. laEnumItem *Data[32];
  1814. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  1815. // norm e1
  1816. // expand e1 e2 e3
  1817. // expand vertical (vertical)
  1818. // arr expand e1 e1 e3
  1819. // e2 e2 e3
  1820. // arr exp+vert e1 e1
  1821. // e2 e2
  1822. // e3 e3
  1823. if (a->ConfirmData /* && a->ConfirmData->Mode == LA_CONFIRM_DATA*/){
  1824. ui->State = LA_UI_NORMAL;
  1825. laRedrawCurrentPanel();
  1826. return LA_RUNNING;
  1827. }
  1828. if (!laIsInUiItem(ui, e->x, e->y)){ return LA_FINISHED_PASS; }
  1829. if (e->Type == LA_TIME_IDLE){
  1830. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  1831. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  1832. return LA_RUNNING;
  1833. }
  1834. if(NoEvent){ return LA_RUNNING_PASS; }
  1835. if (e->Type == LA_L_MOUSE_DOWN){
  1836. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  1837. int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  1838. int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
  1839. int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
  1840. int ArrLen = laGetArrayLength(&ui->PP);
  1841. if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
  1842. int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
  1843. int _L,_R,_U,_B, _W=ui->R - ui->L, _Col=1;
  1844. if(IsVertical){
  1845. if(IsExpand){ _Col=ArrLen; }
  1846. }else{
  1847. if(IsExpand){ _Col=EnumLen; } else { _Col=ArrLen; }
  1848. }
  1849. int row = la_DetectRow(ui, e->y);
  1850. int col = la_DetectColumn(ui, e->x, _Col);
  1851. int ArrTarget=0, EnumTarget=0, ShowMenu=0;
  1852. if(IsVertical){
  1853. if(IsExpand){ EnumTarget=row; ArrTarget=col; } else { EnumTarget=col; }
  1854. }else{
  1855. if(IsExpand){ EnumTarget=col; ArrTarget=row; } else { if(!IsCycle) ShowMenu=1; }
  1856. }
  1857. if(ShowMenu){
  1858. int GX = ui->L, GY = ui->B, GR = ui->R, t = 0;
  1859. ui->State = LA_UI_ACTIVE;
  1860. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  1861. laLocalToWindow(a, a->ToPanel, &GR, &t);
  1862. laEnablePropertyPanel(a->ToPanel, a, 0, la_DefaultEnumPanel, 0, &ui->PP, GX, GR, GY, 200, 300, e);
  1863. laRedrawCurrentPanel();
  1864. }elif(IsCycle){
  1865. laEnumItem* ei=laGetEnumArrayIndexed(&ui->PP, ArrTarget);
  1866. ei = ei->Item.pNext?ei->Item.pNext:((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst;
  1867. laSetEnumArrayIndexed(&ui->PP, ArrTarget, ei->Index);
  1868. laConfirmInt(a,EnumTarget,LA_CONFIRM_DATA);
  1869. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  1870. }else{
  1871. if(ArrTarget>=ArrLen){ArrTarget=ArrLen-1;}
  1872. if(EnumTarget>=EnumLen){EnumTarget=EnumLen-1;}
  1873. laSetEnumArrayIndexedExternal(&ui->PP, ArrTarget, EnumTarget);
  1874. laConfirmInt(a,EnumTarget,LA_CONFIRM_DATA);
  1875. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  1876. return LA_RUNNING_PASS;
  1877. }
  1878. return LA_RUNNING;
  1879. }
  1880. if(e->Type==LA_R_MOUSE_DOWN){
  1881. int GX = e->x, GY = e->y;
  1882. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  1883. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  1884. return LA_RUNNING;
  1885. }
  1886. return LA_RUNNING_PASS;
  1887. }
  1888. int OPMOD_Button(laOperator *a, laEvent *e){
  1889. laUiItem *ui = a->Instance;
  1890. laBoxedTheme *bt = (*ui->Type->Theme);
  1891. int lx, ly;
  1892. int Away = 0;
  1893. if (e->Type == LA_TIME_IDLE && !ui->State){
  1894. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  1895. laPanel *p = laEnableIdlePanel(a->ToPanel, a, &ui->ExtraPP, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  1896. return LA_RUNNING;
  1897. }
  1898. if (laConfirmSameDataIfAny(a)) return LA_RUNNING_PASS;
  1899. if (e->Type == LA_ESCAPE_DOWN || e->Type == LA_INPUT) return LA_FINISHED; //debug
  1900. if (!laIsInUiItem(ui, e->x, e->y) /*&& ui->State!= LA_UI_ACTIVE*/){
  1901. ui->State = LA_UI_NORMAL;
  1902. laRedrawCurrentPanel();
  1903. return LA_FINISHED_PASS;
  1904. }
  1905. if (e->Type == LA_L_MOUSE_DOWN){
  1906. ui->State = LA_UI_ACTIVE;
  1907. laRedrawCurrentPanel();
  1908. return LA_RUNNING;
  1909. }
  1910. char *str;
  1911. if (e->Type == LA_L_MOUSE_UP && ui->State!=LA_UI_NORMAL){
  1912. ui->State = LA_UI_NORMAL;
  1913. if (ui->AT){
  1914. if (!ui->Instructions){
  1915. if (ui->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
  1916. if (ui->AT->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->AT->ExtraInstructions);
  1917. }
  1918. if (!laOperatorAvailableP(ui->AT, 0, ui->Instructions)) return LA_RUNNING;
  1919. lx = e->x;
  1920. ly = e->y;
  1921. laLocalToWindow(a, a->ToPanel, &e->x, &e->y);
  1922. e->Localized = 0;
  1923. laInvokeP(0, ui->AT, e, 0, ui->ExtraInstructions ? ui->ExtraInstructions->Ptr : 0, 0);
  1924. e->x = lx;
  1925. e->y = ly;
  1926. e->Localized = 1;
  1927. }else{
  1928. laOperatorProp *ap = ui->PP.LastPs->p;
  1929. if (ap->OperatorID){
  1930. if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
  1931. if (!ui->Instructions){
  1932. if (ui->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
  1933. if (ap->OperatorType) strMakeInstructions(&ui->Instructions, ap->OperatorType->ExtraInstructions);
  1934. }
  1935. if (!laOperatorAvailablePSafe(ap->OperatorType, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->Instructions)) return LA_RUNNING;
  1936. lx = e->x;
  1937. ly = e->y;
  1938. laLocalToWindow(a, a->ToPanel, &e->x, &e->y);
  1939. e->Localized = 0;
  1940. laInvokePCreateThis(0, ap->OperatorType, e, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->ExtraInstructions ? ui->ExtraInstructions->Ptr : 0, ap->Base.ExtraInstructions);
  1941. if(a->StopNow) return LA_FINISHED;
  1942. laRetriggerOperators();
  1943. e->x = lx;
  1944. e->y = ly;
  1945. e->Localized = 1;
  1946. }
  1947. }
  1948. if (str = strGetArgumentString(ui->Instructions, "feedback")){
  1949. if (strSame(str, "CONFIRM")) laConfirmInt(a, 0, LA_CONFIRM_OK);
  1950. elif (strSame(str, "CANCEL")) laConfirmInt(a, 0, LA_CONFIRM_CANCEL);
  1951. else { laConfirmString(a, str, LA_CONFIRM_CUSTOM_STRING); }
  1952. }elif(!(ui->Flags&LA_UI_FLAGS_NO_CONFIRM)){
  1953. laConfirmInt(a, 0, LA_CONFIRM_OK);
  1954. }
  1955. laRedrawCurrentPanel();
  1956. return LA_RUNNING_PASS;
  1957. }
  1958. return LA_RUNNING_PASS;
  1959. }
  1960. int OPMOD_MenuItem(laOperator *a, laEvent *e){
  1961. laUiItem *ui = a->Instance;
  1962. laPanel *p;
  1963. laBoxedTheme *bt = (*ui->Type->Theme);
  1964. laGeneralUiExtraData *uit = a->CustomData;
  1965. int Away = 0;
  1966. if (a->ConfirmData){
  1967. ui->State = LA_UI_NORMAL;
  1968. laConfirmInt(a, a->ConfirmData->IData, a->ConfirmData->Mode);
  1969. laRedrawCurrentPanel();
  1970. return LA_RUNNING_PASS;
  1971. }
  1972. if (!laIsInUiItem(ui, e->x, e->y) && ui->State != LA_UI_ACTIVE){
  1973. ui->State = LA_UI_NORMAL;
  1974. laRedrawCurrentPanel();
  1975. return LA_FINISHED_PASS;
  1976. }
  1977. if (e->Type == LA_L_MOUSE_DOWN){
  1978. int GX = ui->L, GY = ui->B;
  1979. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  1980. ui->State = LA_UI_ACTIVE;
  1981. p = laEnableMenuPanel(a->ToPanel, a, ui->Subs.pFirst, &ui->PP, GX, GX + 300, GY, 600, 200, e);
  1982. laShowPanelWithDropDownEffect(p);
  1983. laRedrawCurrentPanel();
  1984. return LA_RUNNING;
  1985. }
  1986. return LA_RUNNING_PASS;
  1987. }
  1988. int OPMOD_ConditionToggle(laOperator *a, laEvent *e){
  1989. laUiItem *ui = a->Instance;
  1990. laBoxedTheme *bt = (*ui->Type->Theme);
  1991. laGeneralUiExtraData *uit = a->CustomData;
  1992. int Away = 0;
  1993. if (!laIsInUiItem(ui, e->x, e->y) /*&& ui->State!= LA_UI_ACTIVE*/){
  1994. return LA_FINISHED_PASS;
  1995. }
  1996. if (e->Type == LA_L_MOUSE_DOWN){
  1997. ui->State = ui->State == LA_UI_ACTIVE ? LA_UI_NORMAL : LA_UI_ACTIVE;
  1998. laRecalcCurrentPanel();
  1999. return LA_RUNNING;
  2000. }
  2001. return LA_RUNNING_PASS;
  2002. }
  2003. int OPMOD_SingleLineString(laOperator *a, laEvent *e){
  2004. laUiItem *ui = a->Instance;
  2005. laBoxedTheme *bt = (*ui->Type->Theme);
  2006. laGeneralUiExtraData *uit = a->CustomData;
  2007. laStringEdit *se = uit->Edit;
  2008. int Away = 0;
  2009. char _buf[LA_RAW_CSTR_MAX_LEN] = {0}; char* buf=_buf;
  2010. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2011. if (!laIsInUiItem(ui, e->x, e->y)){
  2012. if (ui->State != LA_UI_EDITING){
  2013. ui->State = LA_UI_NORMAL;
  2014. laRedrawCurrentPanel();
  2015. return LA_FINISHED_PASS;
  2016. }else if ((e->Type & LA_MOUSEDOWN) == LA_MOUSEDOWN){
  2017. buf=strEndEdit(&uit->Edit, 0);
  2018. laSetString(&ui->PP, buf); free(buf);
  2019. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2020. ui->State = LA_UI_NORMAL;
  2021. laRedrawCurrentPanel();
  2022. return LA_FINISHED_PASS;
  2023. }
  2024. }
  2025. if (e->Type == LA_TIME_IDLE && !ui->State){
  2026. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2027. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2028. return LA_RUNNING;
  2029. }
  2030. if(NoEvent){ return LA_RUNNING_PASS; }
  2031. if(e->Type ==LA_KEY_DOWN){
  2032. if (e->key == LA_KEY_ENTER){
  2033. buf=strEndEdit(&uit->Edit, 0);
  2034. laSetString(&ui->PP, buf); free(buf);
  2035. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2036. ui->State = LA_UI_NORMAL;
  2037. laRedrawCurrentPanel();
  2038. return LA_FINISHED_PASS;
  2039. }else if (e->key == LA_KEY_ESCAPE && ui->State != LA_UI_NORMAL){
  2040. ui->State = LA_UI_NORMAL;
  2041. laRedrawCurrentPanel();
  2042. return LA_FINISHED;
  2043. }
  2044. }
  2045. if(laKeyMapExecuteEventEx(a, &ui->ExtraPP, &ui->Type->KeyMapper, e)) return LA_RUNNING;
  2046. if (ui->State == LA_UI_EDITING){
  2047. laRedrawCurrentPanel();
  2048. if (la_ProcessTextEdit(e, se, ui)) return LA_RUNNING;
  2049. }
  2050. if (e->Type == LA_L_MOUSE_DOWN){
  2051. if (ui->State == LA_UI_NORMAL){
  2052. if(laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING;
  2053. ui->State = LA_UI_EDITING;
  2054. laGetString(&ui->PP, _buf, &buf);
  2055. strBeginEdit(&uit->Edit,buf);
  2056. strSelectLineAll(uit->Edit);
  2057. }elif (ui->State == LA_UI_EDITING){
  2058. if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
  2059. else strSelectLineAll(uit->Edit);
  2060. }
  2061. laRedrawCurrentPanel();
  2062. return LA_RUNNING;
  2063. }
  2064. if (e->Type == LA_R_MOUSE_DOWN){
  2065. int GX = e->x, GY = e->y;
  2066. ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
  2067. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2068. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, ui->State==LA_UI_EDITING?&ui->ExtraPP:0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2069. return LA_RUNNING;
  2070. }
  2071. if (ui->State != LA_UI_EDITING) return LA_RUNNING_PASS;
  2072. else
  2073. return LA_RUNNING;
  2074. }
  2075. void la_SetMultistringViewRange(laUiItem* ui, laStringEdit* se, laBoxedTheme* bt){
  2076. int NumberWidth=0; int MonoWidth=tnsGetMonoFontAdvance(); int Count=se->TotalLines;
  2077. while(Count){ Count/=10; NumberWidth+=MonoWidth; }
  2078. strSetEditViewRange(ui->Extra->Edit,
  2079. ui->Extra->HeightCoeff>0?ui->Extra->HeightCoeff:((ui->B-ui->U)/LA_RH),(ui->R-ui->L-NumberWidth-bt->LM*2-bt->RM)/MonoWidth);
  2080. }
  2081. int OPMOD_MultiString(laOperator *a, laEvent *e){
  2082. laUiItem *ui = a->Instance;
  2083. laBoxedTheme *bt = (*ui->Type->Theme);
  2084. laGeneralUiExtraData *es = a->CustomData;
  2085. laStringEdit *se = es->Edit;
  2086. int Away = 0;
  2087. char _buf[LA_RAW_CSTR_MAX_LEN] = {0}; char* buf=&_buf;
  2088. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2089. if (!laIsInUiItem(ui, e->x, e->y) && !es->Dragging){
  2090. if ((e->Type & LA_MOUSEDOWN) == LA_MOUSEDOWN){
  2091. buf=strGetEditString(es->Edit, 0); laSetString(&ui->PP, buf); free(buf);
  2092. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2093. ui->State = LA_UI_NORMAL;
  2094. laRedrawCurrentPanel();
  2095. return LA_FINISHED_PASS;
  2096. }
  2097. if(ui->State!=LA_UI_ACTIVE) return LA_FINISHED_PASS;
  2098. }
  2099. if (e->Type == LA_TIME_IDLE && ui->State!=LA_UI_ACTIVE){
  2100. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2101. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2102. return LA_RUNNING;
  2103. }
  2104. if(NoEvent){ return LA_RUNNING_PASS; }
  2105. if(e->Type ==LA_KEY_DOWN){
  2106. if (e->key == LA_KEY_ESCAPE){
  2107. if(ui->State != LA_UI_NORMAL){
  2108. buf=strGetEditString(es->Edit, 0); laSetString(&ui->PP, buf); free(buf);
  2109. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2110. ui->State = LA_UI_NORMAL; laRedrawCurrentPanel();la_SetMultistringViewRange(ui,es->Edit,bt);
  2111. }
  2112. if(es->Dragging){ es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel();la_SetMultistringViewRange(ui,es->Edit,bt); }
  2113. return LA_FINISHED;
  2114. }
  2115. }
  2116. if(laKeyMapExecuteEventEx(a, &ui->ExtraPP, &ui->Type->KeyMapper, e)) return LA_RUNNING;
  2117. if(e->Type == LA_L_MOUSE_DOWN && es->HeightCoeff>=0 && e->x>ui->R-bt->RM-LA_RH && e->y>ui->B-bt->BM-LA_RH){
  2118. es->Dragging=1; es->LastX=e->x; es->LastY=e->y; es->TargetIndexVali=es->HeightCoeff;
  2119. return LA_RUNNING;
  2120. }
  2121. if(es->Dragging){
  2122. if(e->Type==LA_MOUSEMOVE){ es->HeightCoeff=es->TargetIndexVali+((real)e->y-es->LastY+0.5)/LA_RH;
  2123. if(es->HeightCoeff<1)es->HeightCoeff=1; laRecalcCurrentPanel(); la_SetMultistringViewRange(ui,es->Edit,bt);}
  2124. elif(e->Type==LA_L_MOUSE_UP){ es->Dragging=0; }
  2125. elif(e->Type==LA_R_MOUSE_DOWN){
  2126. es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel();la_SetMultistringViewRange(ui,se,bt); }
  2127. return LA_RUNNING;
  2128. }
  2129. if (ui->State == LA_UI_ACTIVE){
  2130. laRedrawCurrentPanel();
  2131. if (la_ProcessTextEdit(e, se, ui)) return LA_RUNNING;
  2132. }
  2133. if(e->Type==LA_MOUSE_WHEEL_DOWN){ strMoveView(se, MAIN.ScrollingSpeed, 0); laRedrawCurrentPanel(); return LA_RUNNING; }
  2134. elif(e->Type==LA_MOUSE_WHEEL_UP){ strMoveView(se, -MAIN.ScrollingSpeed, 0); laRedrawCurrentPanel(); return LA_RUNNING; }
  2135. if (e->Type == LA_L_MOUSE_DOWN){
  2136. if (ui->State == LA_UI_NORMAL){
  2137. ui->State = LA_UI_ACTIVE;
  2138. laGetString(&ui->PP, _buf, &buf);
  2139. strBeginEdit(&es->Edit,buf);la_SetMultistringViewRange(ui,es->Edit,bt);
  2140. }
  2141. laRedrawCurrentPanel();
  2142. return LA_RUNNING;
  2143. }
  2144. if (e->Type == LA_R_MOUSE_DOWN){
  2145. int GX = e->x, GY = e->y;
  2146. ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
  2147. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2148. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, ui->State==LA_UI_ACTIVE?&ui->ExtraPP:0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2149. return LA_RUNNING;
  2150. }
  2151. if (ui->State != LA_UI_ACTIVE) return LA_RUNNING_PASS;
  2152. else return LA_RUNNING;
  2153. }
  2154. int OPMOD_TabSelector(laOperator *a, laEvent *e){
  2155. laUiItem *ui = a->Instance;
  2156. laBoxedTheme *bt = (*ui->Type->Theme);
  2157. laGeneralUiExtraData *uit = a->CustomData;
  2158. laUiList *uil;
  2159. int Away = 0;
  2160. int count = 0;
  2161. int it = 0;
  2162. int page;
  2163. if (!laIsInUiItem(ui, e->x, e->y) || laIsInBound(e->x, e->y, ui->Page->L, ui->Page->R, ui->Page->U, ui->Page->B)){
  2164. return LA_FINISHED_PASS;
  2165. }
  2166. if (e->Type == LA_L_MOUSE_DOWN){
  2167. if (ui->Page->HeightCoeff && ui->R - e->x < LA_RH + bt->RM) return LA_RUNNING_PASS;
  2168. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
  2169. count++;
  2170. }
  2171. page = la_DetectColumn(ui, e->x, count);
  2172. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
  2173. if (it == page){
  2174. laRecalcCurrentPanel();
  2175. ui->Page = uil;
  2176. return LA_RUNNING;
  2177. }else
  2178. it++;
  2179. }
  2180. }
  2181. return LA_RUNNING_PASS;
  2182. }
  2183. int OPMOD_Collection(laOperator *a, laEvent *e){
  2184. laUiItem *ui = a->Instance;
  2185. laGeneralUiExtraData *uit = a->CustomData;
  2186. laListHandle Locals = {0};
  2187. laUiList *uil;
  2188. int lx = e->x, ly = e->y;
  2189. int at = 0;
  2190. laUiList* ToUil = a->ToPanel->MenuRefer?a->ToPanel->MenuRefer:&a->ToPanel->UI;
  2191. if (!laIsInUiItem(ui, e->x, e->y) /* || e->y>(ui->Subs.pFirst?((laUiList*)ui->Subs.pFirst)->HeightCoeff:10000)*/){
  2192. return LA_FINISHED_PASS;
  2193. }
  2194. laLocalToPanel(a, &lx, &ly); if(a->ToPanel && ly<a->ToPanel->TitleBar.B){ return LA_FINISHED_PASS; }
  2195. uil = la_DetectUiListRecursive(ToUil, lx, ly, 10000, 0, 0, 0, 0, 0);
  2196. if (uil != ((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target){
  2197. printf("EXIT\n");
  2198. return LA_FINISHED;
  2199. }
  2200. if (e->Type & LA_MOUSE_EVENT){
  2201. laUiList *sub;
  2202. laUiItem *tui;
  2203. int LimHeight = 10000;
  2204. int UIB = ui->B, UIU = ui->U;
  2205. int t = 0;
  2206. void *Active = ui->PP.EndInstance;
  2207. if (ui->Subs.pFirst) LimHeight = (int)((laUiList *)ui->Subs.pFirst)->HeightCoeff;
  2208. if (LimHeight > 0) UIB = LimHeight;
  2209. laPanelToLocal(a, &t, &UIB);
  2210. for (sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext){
  2211. ui->PP.EndInstance = sub->Instance;
  2212. if ((tui = la_DetectUiItemRecursive(sub, e->x, e->y, UIB, &Locals, 0))){
  2213. if (tui && !a->Child && tui->Type->OperatorType){
  2214. //printf("invui %d\n", tui);
  2215. laSetOperatorLocalizer(a->ToPanel);
  2216. laInvokeUiP(a, tui->Type->OperatorType, e, tui, &Locals, 0);
  2217. }
  2218. }
  2219. lstClearPointer(&Locals);
  2220. }
  2221. ui->PP.EndInstance = Active;
  2222. }
  2223. if (e->Type == LA_L_MOUSE_DOWN){
  2224. laUiList *uil;
  2225. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
  2226. if (a->ConfirmData) return LA_RUNNING;
  2227. if (laIsInBound(e->x, e->y, uil->L, uil->R, uil->U, uil->B)){
  2228. laRecalcCurrentPanel();
  2229. laPropPack PP={0}; la_CopyPropPack(&ui->PP, &PP); //needed because layout can be switched after set active.
  2230. laSetActiveInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, uil->Instance);
  2231. laRecordAndPushProp(&PP,0); laMarkPropChanged(&PP);
  2232. char* cmd; if ((!(cmd = strGetArgumentString(ui->Instructions, "feedback")))||(!strSame(cmd,"NONE"))){
  2233. laConfirmInt(a, 0, LA_CONFIRM_DATA);
  2234. }
  2235. return LA_RUNNING_PASS;
  2236. }
  2237. }
  2238. return LA_RUNNING;
  2239. }
  2240. elif (e->Type == LA_R_MOUSE_DOWN) {
  2241. laUiList* uil;
  2242. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext) {
  2243. if (laIsInBound(e->x, e->y, uil->L, uil->R, uil->U, uil->B)) {
  2244. ui->PP.EndInstance=uil->Instance; lx=e->x, ly=e->y; laLocalToWindow(a,a->ToPanel,&lx,&ly);
  2245. laEnablePropertyPanel(a->ToPanel,a,0,0,laui_IdentifierOnly,&ui->PP,lx,lx,ly,0,0,e);
  2246. }
  2247. }
  2248. return LA_RUNNING;
  2249. }
  2250. return LA_RUNNING_PASS;
  2251. }
  2252. int OPMOD_CollectionSelector(laOperator *a, laEvent *e){
  2253. laUiItem *ui = a->Instance;
  2254. laBoxedTheme *bt = (*ui->Type->Theme);
  2255. laGeneralUiExtraData *uit = a->CustomData;
  2256. laEnumItem *ei;
  2257. laEnumProp *ep = ui->PP.LastPs->p;
  2258. int at = 0;
  2259. if (a->ConfirmData /* && a->ConfirmData->Mode == LA_CONFIRM_DATA*/){
  2260. ui->State = LA_UI_NORMAL;
  2261. laRecalcCurrentPanel();
  2262. return LA_RUNNING;
  2263. }
  2264. if (!laIsInUiItem(ui, e->x, e->y)){
  2265. return LA_FINISHED;
  2266. }
  2267. if (e->Type == LA_TIME_IDLE && !ui->State){
  2268. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2269. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2270. return LA_RUNNING;
  2271. }
  2272. if (e->Type == LA_L_MOUSE_DOWN){
  2273. laUiList *uil;
  2274. laColumn *col;
  2275. laPanel *p;
  2276. int GX = ui->L, GY = ui->B, GR = ui->R, t = 0;
  2277. if ((!laIsPropertyReadOnly(&ui->PP)) && e->x >= TNS_MAX2(ui->R - LA_RH,(ui->R+ui->L)/2) && e->x < ui->R){
  2278. laSetActiveInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, 0);
  2279. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2280. return LA_FINISHED;
  2281. }
  2282. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2283. laLocalToWindow(a, a->ToPanel, &GR, &t);
  2284. laRedrawCurrentPanel();
  2285. ui->State = LA_UI_ACTIVE;
  2286. p = laEnableEmptyPropertyPanel(a->ToPanel, a, GX, GR, GY, 500, e);{
  2287. int MinWidth;
  2288. uil = &p->UI;
  2289. col = laFirstColumn(uil);
  2290. laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_COLLECTION, 0, ui->Template, 0)->SymbolID = ui->SymbolID;
  2291. laEnclosePanelContent(p, &p->UI);
  2292. }
  2293. return LA_RUNNING;
  2294. }
  2295. return LA_RUNNING_PASS;
  2296. }
  2297. int OPMOD_ColumnAdjuster(laOperator *a, laEvent *e){
  2298. laUiItem *ui = a->Instance;
  2299. laBoxedTheme *bt = (*ui->Type->Theme);
  2300. laGeneralUiExtraData *uit = a->CustomData;
  2301. laColumn *c = uit->Ptr1;
  2302. c = uit->Ptr1 ? uit->Ptr1 : la_DetectSplit(ui->C, e->x);
  2303. if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y)||!c)){
  2304. printf("done\n");
  2305. return LA_FINISHED_PASS;
  2306. }
  2307. if (e->Type == LA_L_MOUSE_DOWN){
  2308. uit->Ptr1 = c;
  2309. uit->LastX = e->x;
  2310. uit->Dragging=1;
  2311. return LA_RUNNING;
  2312. }
  2313. if (uit->Dragging && uit->Ptr1 && e->Type == LA_MOUSEMOVE){
  2314. la_AdjustColumnSplit(c, e->x - uit->LastX);
  2315. uit->LastX = e->x;
  2316. laRecalcCurrentPanel();
  2317. return LA_RUNNING;
  2318. }
  2319. if (uit->Dragging && (e->Type == LA_L_MOUSE_UP || e->Type == LA_R_MOUSE_DOWN || e->key == LA_KEY_ESCAPE)){
  2320. uit->Ptr1 = 0; uit->Dragging=0;
  2321. return LA_RUNNING;
  2322. }
  2323. return LA_RUNNING;
  2324. }
  2325. int OPMOD_NodeSocket(laOperator *a, laEvent *e){
  2326. laUiItem *ui = a->Instance;
  2327. laBoxedTheme *bt = (*ui->Type->Theme);
  2328. laGeneralUiExtraData *uit = a->CustomData;
  2329. int lx=e->x,ly=e->y;
  2330. laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
  2331. laPropContainer* PCFind;
  2332. if(pc==LA_PC_SOCKET_IN) { PCFind=LA_PC_SOCKET_OUT; }
  2333. elif(pc==LA_PC_SOCKET_OUT){ PCFind=LA_PC_SOCKET_IN; }
  2334. if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
  2335. if (e->Type == LA_L_MOUSE_DOWN){
  2336. uit->Dragging=1; MAIN.NextWireColor+=3;
  2337. if(pc==LA_PC_SOCKET_IN) {
  2338. laNodeInSocket* s=ui->PP.EndInstance;
  2339. uit->Ptr2 = s->Source;
  2340. if(!s->Source){
  2341. s->ColorId=MAIN.NextWireColor; s->Source=&MAIN.tNodeOut; latouched_NodeInSocket(0,0);
  2342. MAIN.tNodeOut.RuntimeX=MAIN.tNodeOut.RuntimeY=MAIN.tNodeOut.RuntimePX=MAIN.tNodeOut.RuntimePY=0;
  2343. }else{
  2344. MAIN.tNodeIn.Source = s->Source;
  2345. MAIN.tNodeIn.RuntimeX=MAIN.tNodeIn.RuntimeY=MAIN.tNodeIn.RuntimePX=MAIN.tNodeIn.RuntimePY=0;
  2346. MAIN.tNodeIn.RuntimePX=-(s->Source->RuntimeX+s->Source->RuntimePX)+(s->RuntimeX+s->RuntimePX);
  2347. MAIN.tNodeIn.RuntimePY=-(s->Source->RuntimeY+s->Source->RuntimePY)+(s->RuntimeY+s->RuntimePY);
  2348. s->Source=0; MAIN.tNodeIn.ColorId=s->ColorId; latouched_NodeInSocket(0,0);
  2349. }
  2350. }
  2351. elif(pc==LA_PC_SOCKET_OUT){ MAIN.tNodeIn.Source=ui->PP.EndInstance; latouched_NodeInSocket(0,0);
  2352. MAIN.tNodeIn.RuntimeX=MAIN.tNodeIn.RuntimeY=MAIN.tNodeIn.RuntimePX=MAIN.tNodeIn.RuntimePY=0;
  2353. MAIN.tNodeIn.ColorId=MAIN.NextWireColor; }
  2354. uit->LastX = e->x; uit->LastY = e->y;
  2355. laRedrawCurrentPanel();
  2356. return LA_RUNNING;
  2357. }
  2358. if (uit->Dragging && e->Type == LA_MOUSEMOVE){
  2359. laPanel* p=MAIN.CurrentPanel;
  2360. laLocalToPanel(a, &lx, &ly);
  2361. laUiItem* tui=la_DetectSocketRecursive(&p->UI,lx,ly,100000,uit->Ptr2?LA_PC_SOCKET_IN:PCFind); uit->Ptr1=tui;
  2362. if(pc==LA_PC_SOCKET_IN){
  2363. if(!uit->Ptr2){MAIN.tNodeOut.RuntimeX=e->x-uit->LastX;MAIN.tNodeOut.RuntimeY=e->y-uit->LastY;}
  2364. else { MAIN.tNodeIn.RuntimeX=e->x-uit->LastX;MAIN.tNodeIn.RuntimeY=e->y-uit->LastY; } }
  2365. elif(pc==LA_PC_SOCKET_OUT){ MAIN.tNodeIn.RuntimeX=e->x-uit->LastX; MAIN.tNodeIn.RuntimeY=e->y-uit->LastY; }
  2366. laRedrawCurrentPanel();
  2367. return LA_RUNNING;
  2368. }
  2369. if (uit->Dragging && (e->Type == LA_L_MOUSE_UP || e->Type == LA_R_MOUSE_DOWN || e->key == LA_KEY_ESCAPE)){
  2370. uit->Dragging=0; MAIN.tNodeIn.Source=0;
  2371. laRecalcCurrentPanel();
  2372. laUiItem* tui=uit->Ptr1; void* soc=tui?tui->PP.EndInstance:0;
  2373. if(pc == LA_PC_SOCKET_IN){
  2374. if(!uit->Ptr2){ if(!tui){ laNodeInSocket* s=ui->PP.EndInstance; s->Source=0; return LA_RUNNING; }
  2375. laNodeInSocket* s=ui->PP.EndInstance; s->Source=0; memAssignRef(s,&s->Source,soc); latouched_NodeInSocket(0,0);
  2376. s->ColorId=MAIN.NextWireColor; laRecordAndPushProp(&ui->PP, 0); laMarkPropChanged(&ui->PP);
  2377. }else{
  2378. if(!tui){
  2379. laNodeInSocket* s=ui->PP.EndInstance; s->Source=uit->Ptr2; memAssignRef(s,&s->Source,0); latouched_NodeInSocket(0,0);
  2380. laRecordAndPushProp(&ui->PP, 0); laMarkPropChanged(&ui->PP);
  2381. }else{
  2382. laNodeInSocket* s=soc; if(s->Source){ uit->Ptr2=0; return LA_RUNNING; } latouched_NodeInSocket(0,0);
  2383. memAssignRef(s,&s->Source,uit->Ptr2); s->ColorId=((laNodeInSocket*)ui->PP.EndInstance)->ColorId;
  2384. laRecordDifferences(&ui->PP,0); laRecordDifferences(&tui->PP,0); laPushDifferences("Socket status changed", 0);
  2385. laMarkPropChanged(&tui->PP); laMarkPropChanged(&ui->PP);
  2386. }
  2387. }
  2388. }
  2389. else{
  2390. if(!tui){ return LA_RUNNING; }
  2391. laNodeInSocket* s=soc; s->Source=0; memAssignRef(s,&s->Source,ui->PP.EndInstance); latouched_NodeInSocket(0,0);
  2392. s->ColorId=MAIN.NextWireColor; laRecordAndPushProp(&tui->PP, 0); laMarkPropChanged(&tui->PP);
  2393. }
  2394. uit->Ptr2=0;
  2395. return LA_RUNNING;
  2396. }
  2397. return LA_RUNNING_PASS;
  2398. }
  2399. int OPMOD_HeightAdjuster(laOperator *a, laEvent *e){
  2400. laUiItem *ui = a->Instance;
  2401. laBoxedTheme *bt = (*ui->Type->Theme);
  2402. laGeneralUiExtraData *uit = a->CustomData;
  2403. int lx=e->x,ly=e->y;
  2404. int ClickedVal=0;
  2405. if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
  2406. if (e->Type == LA_L_MOUSE_DOWN || e->Type==LA_R_MOUSE_DOWN){
  2407. uit->Dragging=1; uit->LastY=e->y; uit->On=0; uit->TargetIndexVali=e->Type==LA_L_MOUSE_DOWN?(ui->State==LA_BT_ACTIVE?2:1):2; uit->HeightCoeff=1;
  2408. return LA_RUNNING;
  2409. }
  2410. if(e->Type==LA_L_MOUSE_UP && uit->HeightCoeff){ ui->State=(ui->State==LA_BT_ACTIVE)?LA_BT_NORMAL:LA_BT_ACTIVE; laRedrawCurrentPanel(); }
  2411. if (uit->Dragging && e->Type == LA_MOUSEMOVE){
  2412. int diff=e->y-uit->LastY; diff=((real)diff+0.5)/(ui->B-ui->U); int delta=uit->TargetIndexVali;
  2413. if(diff!=uit->On){ uit->HeightCoeff=0; int d=diff-uit->On; uit->On=diff; while(d){ laSetInt(&ui->PP, d>0?delta:-delta); d-=(d>0?1:-1); }; laRecalcCurrentPanel(); }
  2414. return LA_RUNNING;
  2415. }
  2416. if (uit->Dragging && (e->Type == LA_L_MOUSE_UP || e->Type == LA_R_MOUSE_UP || e->key == LA_KEY_ESCAPE)){
  2417. uit->Dragging=0; return LA_RUNNING_PASS;
  2418. }
  2419. return LA_RUNNING_PASS;
  2420. }
  2421. void la_RegisterUiOperatorsBasic(){
  2422. laPropContainer *pc, *p;
  2423. laOperatorType *at;
  2424. laEnumProp *ep;
  2425. laCreateOperatorType("LA_edit_string_copy", "Copy Selection", "Copy selected string to clip board",
  2426. OPCHK_EditStringCopySelection, 0, 0, OPINV_EditStringCopySelection, 0, L'🗍', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2427. laCreateOperatorType("LA_int_array_h_operator", "Int(Horizon) UiItem Operator", "Do Array Valuator Stuff",
  2428. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_IntArrayHorizon, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2429. laCreateOperatorType("LA_real_array_h_operator", "Float(Horizon) UiItem Operator", "Do Array Valuator Stuff",
  2430. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_FloatArrayHorizon, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2431. laCreateOperatorType("LA_real_color_operator", "Color(Float) Display UiItem Operator", "Color Display,Click To Set Color",
  2432. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_FloatColor, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2433. laCreateOperatorType("LA_real_hcy_operator", "HCY Color Picker UiItem Operator", "HCY Color Picker,Click To Set Color",
  2434. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ColorHCY, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2435. laCreateOperatorType("LA_enum_selector_operator", "Enum Selector UiItem Operator", "Do Selector Stuff",
  2436. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_EnumSelector, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2437. laCreateOperatorType("LA_button_operator", "Button UiItem Operator", "Execute an Operator",
  2438. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_Button, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2439. laCreateOperatorType("LA_menu_root_operator", "Menu Root UiItem Operator", "Drop A Menu",
  2440. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_MenuItem, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2441. laCreateOperatorType("LA_condition_toggle_operator", "Condition +/- Button Operator", "Do Self Condition Function",
  2442. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ConditionToggle, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2443. laCreateOperatorType("LA_string_operator", "Single Line String Operator", "Do String Modifying Function",
  2444. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_SingleLineString, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2445. laCreateOperatorType("LA_string_multi", "Multi Line String Operator", "Do String Modifying Function",
  2446. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_MultiString, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2447. laCreateOperatorType("LA_tab_operator", "Tab Switcher Operator", "Change The Page In The Tab Group",
  2448. 0, 0, OPEXT_UiItem, OPINV_Tab, OPMOD_TabSelector, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2449. laCreateOperatorType("LA_collection_operator", "Collection UiItem Operator", "Activate/Deactivate Collection Item(s)",
  2450. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_Collection, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2451. laCreateOperatorType("LA_collection_selector_operator", "Collection Dropdown Selector Operator", "Do Selector Stuff",
  2452. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_CollectionSelector, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2453. laCreateOperatorType("LA_column_adjuster", "Column Width Adjuster", "Drag To Set Width of Columns",
  2454. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ColumnAdjuster, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2455. laCreateOperatorType("LA_node_socket", "Node Socket Operator", "Drag to connect node sockets",
  2456. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_NodeSocket, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2457. laCreateOperatorType("LA_height_adjuster", "Height Adjuster Operator", "Drag to adjust heights of an instance",
  2458. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_HeightAdjuster, L'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2459. }