*/}}

la_widgets.c 111 KB

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