*/}}

la_widgets.c 151 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582
  1. /*
  2. * LaGUI: A graphical application framework.
  3. * Copyright (C) 2022-2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "../la_5.h"
  19. extern LA MAIN;
  20. extern tnsMain* T;
  21. laWidget _LA_WIDGET_FIXED_GROUP={0};
  22. laWidget _LA_WIDGET_TAB={0};
  23. laWidget _LA_WIDGET_COLLECTION={0};
  24. laWidget _LA_WIDGET_COLLECTION_ITEM={0};
  25. laWidget _LA_WIDGET_COLLECTION_SELECTOR={0};
  26. laWidget _LA_WIDGET_COLLECTION_SINGLE={0};
  27. laWidget _LA_WIDGET_CONDITION_TOGGLE={0};
  28. laWidget _LA_WIDGET_COLUMN_ADJUSTER={0,LA_UI_FLAGS_NO_HEIGHT};
  29. laWidget _LA_WIDGET_COLUMN_VIEWER={0};
  30. laWidget _LA_WIDGET_BUTTON={0};
  31. laWidget _LA_WIDGET_BUTTON_NO_CONFIRM={0};
  32. laWidget _LA_WIDGET_LABEL={0};
  33. laWidget _LA_WIDGET_INT={0};
  34. laWidget _LA_WIDGET_INT_PLAIN={0, LA_UI_FLAGS_PLAIN};
  35. laWidget _LA_WIDGET_INT_PLAIN_ICON={0, LA_UI_FLAGS_INT_ICON};
  36. laWidget _LA_WIDGET_METER_TYPE1={0,LA_TEXT_ALIGN_CENTER};
  37. laWidget _LA_WIDGET_METER_TYPE2={0,LA_TEXT_ALIGN_CENTER};
  38. laWidget _LA_WIDGET_VALUE_METER_2D={0,LA_TEXT_ALIGN_CENTER};
  39. laWidget _LA_WIDGET_FLOAT={0};
  40. laWidget _LA_WIDGET_FLOAT_PLAIN={0, LA_UI_FLAGS_PLAIN};
  41. laWidget _LA_WIDGET_FLOAT_COLOR={0};
  42. laWidget _LA_WIDGET_FLOAT_COLOR_HCY={0};
  43. laWidget _LA_WIDGET_ENUM_SELECTOR={0};
  44. laWidget _LA_WIDGET_ENUM_SELECTOR_ICON={0, LA_UI_FLAGS_ICON};
  45. laWidget _LA_WIDGET_ENUM_CYCLE={0, LA_UI_FLAGS_CYCLE};
  46. laWidget _LA_WIDGET_ENUM_CYCLE_ICON={0, LA_UI_FLAGS_CYCLE|LA_UI_FLAGS_ICON};
  47. laWidget _LA_WIDGET_ENUM_ICON_PLAIN={0, LA_UI_FLAGS_PLAIN|LA_UI_FLAGS_ICON};
  48. laWidget _LA_WIDGET_ENUM_HIGHLIGHT={0, LA_UI_FLAGS_HIGHLIGHT|LA_UI_FLAGS_CYCLE|LA_TEXT_ALIGN_CENTER};
  49. laWidget _LA_WIDGET_STRING={0};
  50. laWidget _LA_WIDGET_STRING_PLAIN={0, LA_UI_FLAGS_PLAIN};
  51. laWidget _LA_WIDGET_STRING_MONO_PLAIN={0, LA_TEXT_MONO|LA_UI_FLAGS_PLAIN};
  52. laWidget _LA_WIDGET_STRING_MULTI={0, LA_TEXT_MONO};
  53. laWidget _LA_WIDGET_MENU_ROOT={0};
  54. laWidget _LA_WIDGET_ALIGN={0};
  55. laWidget _LA_WIDGET_3D_VIEW={0};
  56. laWidget _LA_WIDGET_2D_VIEW={0};
  57. laWidget _LA_WIDGET_SYMBOL={0};
  58. laWidget _LA_WIDGET_NODE_SOCKET={0};
  59. laWidget _LA_WIDGET_HEIGHT_ADJUSTER={0};
  60. laWidget _LA_WIDGET_RAW={0};
  61. laWidget _LA_WIDGET_MAPPER={0};
  62. laWidget _LA_WIDGET_IMAGE={0};
  63. laWidget _LA_WIDGET_SCOPE={0};
  64. laWidget _LA_WIDGET_KNOB={0,LA_UI_FLAGS_KNOB};
  65. laWidget *LA_WIDGET_FIXED_GROUP=&_LA_WIDGET_FIXED_GROUP;
  66. laWidget *LA_WIDGET_TAB=&_LA_WIDGET_TAB;
  67. laWidget *LA_WIDGET_COLLECTION=&_LA_WIDGET_COLLECTION;
  68. laWidget *LA_WIDGET_COLLECTION_ITEM=&_LA_WIDGET_COLLECTION_ITEM;
  69. laWidget *LA_WIDGET_COLLECTION_SELECTOR=&_LA_WIDGET_COLLECTION_SELECTOR;
  70. laWidget *LA_WIDGET_COLLECTION_SINGLE=&_LA_WIDGET_COLLECTION_SINGLE;
  71. laWidget *LA_WIDGET_CONDITION_TOGGLE=&_LA_WIDGET_CONDITION_TOGGLE;
  72. laWidget *LA_WIDGET_COLUMN_ADJUSTER=&_LA_WIDGET_COLUMN_ADJUSTER;
  73. laWidget *LA_WIDGET_COLUMN_VIEWER=&_LA_WIDGET_COLUMN_VIEWER;
  74. laWidget *LA_WIDGET_BUTTON=&_LA_WIDGET_BUTTON;
  75. laWidget *LA_WIDGET_BUTTON_NO_CONFIRM=&_LA_WIDGET_BUTTON_NO_CONFIRM;
  76. laWidget *LA_WIDGET_LABEL=&_LA_WIDGET_LABEL;
  77. laWidget *LA_WIDGET_INT=&_LA_WIDGET_INT;
  78. laWidget *LA_WIDGET_INT_PLAIN=&_LA_WIDGET_INT_PLAIN;
  79. laWidget *LA_WIDGET_INT_PLAIN_ICON=&_LA_WIDGET_INT_PLAIN_ICON;
  80. laWidget *LA_WIDGET_METER_TYPE1=&_LA_WIDGET_METER_TYPE1;
  81. laWidget *LA_WIDGET_METER_TYPE2=&_LA_WIDGET_METER_TYPE2;
  82. laWidget *LA_WIDGET_VALUE_METER_2D=&_LA_WIDGET_VALUE_METER_2D;
  83. laWidget *LA_WIDGET_FLOAT=&_LA_WIDGET_FLOAT;
  84. laWidget *LA_WIDGET_FLOAT_PLAIN=&_LA_WIDGET_FLOAT_PLAIN;
  85. laWidget *LA_WIDGET_FLOAT_COLOR=&_LA_WIDGET_FLOAT_COLOR;
  86. laWidget *LA_WIDGET_FLOAT_COLOR_HCY=&_LA_WIDGET_FLOAT_COLOR_HCY;
  87. laWidget *LA_WIDGET_ENUM_SELECTOR=&_LA_WIDGET_ENUM_SELECTOR;
  88. laWidget *LA_WIDGET_ENUM_SELECTOR_ICON=&_LA_WIDGET_ENUM_SELECTOR_ICON;
  89. laWidget *LA_WIDGET_ENUM_CYCLE=&_LA_WIDGET_ENUM_CYCLE;
  90. laWidget *LA_WIDGET_ENUM_CYCLE_ICON=&_LA_WIDGET_ENUM_CYCLE_ICON;
  91. laWidget *LA_WIDGET_ENUM_ICON_PLAIN=&_LA_WIDGET_ENUM_ICON_PLAIN;
  92. laWidget *LA_WIDGET_ENUM_HIGHLIGHT=&_LA_WIDGET_ENUM_HIGHLIGHT;
  93. laWidget *LA_WIDGET_STRING=&_LA_WIDGET_STRING;
  94. laWidget *LA_WIDGET_STRING_PLAIN=&_LA_WIDGET_STRING_PLAIN;
  95. laWidget *LA_WIDGET_STRING_MULTI=&_LA_WIDGET_STRING_MULTI;
  96. laWidget *LA_WIDGET_STRING_MONO_PLAIN=&_LA_WIDGET_STRING_MONO_PLAIN;
  97. laWidget *LA_WIDGET_MENU_ROOT=&_LA_WIDGET_MENU_ROOT;
  98. laWidget *LA_WIDGET_ALIGN=&_LA_WIDGET_ALIGN;
  99. laWidget *LA_WIDGET_3D_VIEW=&_LA_WIDGET_3D_VIEW;
  100. laWidget *LA_WIDGET_2D_VIEW=&_LA_WIDGET_2D_VIEW;
  101. laWidget *LA_WIDGET_SYMBOL=&_LA_WIDGET_SYMBOL;
  102. laWidget *LA_WIDGET_NODE_SOCKET=&_LA_WIDGET_NODE_SOCKET;
  103. laWidget *LA_WIDGET_HEIGHT_ADJUSTER=&_LA_WIDGET_HEIGHT_ADJUSTER;
  104. laWidget *LA_WIDGET_RAW=&_LA_WIDGET_RAW;
  105. laWidget *LA_WIDGET_MAPPER=&_LA_WIDGET_MAPPER;
  106. laWidget *LA_WIDGET_IMAGE=&_LA_WIDGET_IMAGE;
  107. laWidget *LA_WIDGET_SCOPE=&_LA_WIDGET_SCOPE;
  108. laWidget *LA_WIDGET_KNOB=&_LA_WIDGET_KNOB;
  109. //============================================== [Draw]
  110. int la_ArrayGetHeight(laUiItem *ui){
  111. return laGetArrayLength(&ui->PP);
  112. }
  113. int la_ValueGetHeight(laUiItem*ui){
  114. int rows = ui->Extra->HeightCoeff; TNS_CLAMP(rows,1,4);
  115. if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){ return la_ArrayGetHeight(ui)*rows; }
  116. return rows;
  117. }
  118. int la_ValueMeterGetHeight(laUiItem*ui){
  119. if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){ return ui->Extra->HeightCoeff?ui->Extra->HeightCoeff:6; }
  120. return laGetArrayLength(&ui->PP);
  121. }
  122. int la_ValueMeter2DGetHeight(laUiItem*ui){
  123. return ui->Extra->HeightCoeff?ui->Extra->HeightCoeff:(ui->Extra->HeightCoeff=(ui->TR-ui->TL)/LA_RH);
  124. }
  125. int la_CanvasGetHeight(laUiItem *ui){
  126. return ui->Expand;
  127. }
  128. int la_EnumGetHeight(laUiItem *ui){
  129. // norm e1
  130. // expand e1 e2 e3
  131. // expand vertical (vertical)
  132. // arr expand e1 e2 e3
  133. // e1 e2 e3
  134. // arr exp+vert e1 e1
  135. // e2 e2
  136. // e3 e3
  137. int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  138. int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
  139. int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
  140. int ArrLen = laGetArrayLength(&ui->PP);
  141. if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
  142. int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
  143. if(ArrLen==1){
  144. if(IsVertical&&IsExpand) return laGetEnumEntryLen(&ui->PP);
  145. return 1;
  146. }else{
  147. if(IsVertical) return EnumLen;
  148. else return ArrLen;
  149. }
  150. }
  151. int la_ColorPickerGetHeight(laUiItem *ui){
  152. if(!ui->Extra->HeightCoeff) ui->Extra->HeightCoeff=7;
  153. return ui->Extra->HeightCoeff;
  154. }
  155. int la_SymbolGetHeight(laUiItem *ui){
  156. //if (!ui->State)
  157. //{
  158. // ui->State = (int)_ICON_SYMBOL_SIZE[ui->SymbolID - ICON_SYMBOL_START] * 1.4 + 1;
  159. //}
  160. return ui->State;
  161. }
  162. int la_GroupGetHeight(laUiItem *ui){
  163. if (ui->State == LA_UI_ACTIVE) return 0;
  164. return LA_RH;
  165. }
  166. int la_StringPropGetHeight(laUiItem *ui){
  167. laBoxedTheme *bt = *ui->Type->Theme;
  168. if(!(ui->Flags&LA_TEXT_LINE_WRAP)) return 1;
  169. char _buf[LA_RAW_CSTR_MAX_LEN]={0}; char* buf=_buf;
  170. laGetString(&ui->PP, _buf, &buf); int rows=0;
  171. int strw=tnsStringGetDimension(buf, 0, 0, ui->TR-ui->TL, &rows, ui->Flags&LA_TEXT_MONO);
  172. return rows;
  173. }
  174. int la_MultiStringHeight(laUiItem *ui){
  175. laGeneralUiExtraData *e = ui->Extra;
  176. return e->HeightCoeff;
  177. }
  178. int la_LabelHeight(laUiItem *ui){
  179. int Wrap=ui->Flags&(LA_TEXT_USE_NEWLINE|LA_TEXT_LINE_WRAP);
  180. if(!Wrap) return 1;
  181. int rows;
  182. tnsStringGetDimension(transLate(ui->Display->Ptr), 0, 0, ui->TR-ui->TL, &rows, ui->Flags&LA_TEXT_MONO);
  183. return rows;
  184. }
  185. int la_SocketGetHeight(laUiItem *ui){
  186. if(ui->Flags&(LA_UI_SOCKET_LABEL_N|LA_UI_SOCKET_LABEL_S))return 2; return 1;
  187. }
  188. int la_ImageGetHeight(laUiItem *ui){
  189. tnsImage* im=ui->Extra;
  190. if(ui->Flags&LA_UI_IMAGE_FULL_W){
  191. if(!im->Texture){ return 1; }
  192. int W=im->Texture->Width, H=im->Texture->Height;
  193. real CW=MAIN.CurrentWindow->CW-LA_RH*4, CH=MAIN.CurrentWindow->CH-LA_RH*4;
  194. real ra=1;
  195. if(W>CW){ real r=W/CW; ra=TNS_MAX2(r,ra); }
  196. if(H>CH){ real r=H/CH; ra=TNS_MAX2(r,ra); }
  197. W/=ra; H/=ra;
  198. return H/LA_RH+1;
  199. }
  200. if(ui->SymbolID) return ui->SymbolID;
  201. return 1;
  202. }
  203. int la_ColorSelectorGetMinWidth(laUiItem *ui){
  204. if(ui->Flags&LA_UI_FLAGS_ICON) return LA_RH;
  205. return 5*LA_RH;
  206. }
  207. int la_ValueGetMinWidth(laUiItem *ui){
  208. int ExtraW=0;
  209. if(ui->Flags&LA_UI_FLAGS_NO_LABEL){ return LA_RH; }
  210. if(ui->Flags&LA_UI_FLAGS_KNOB){ return LA_RH*TNS_MAX2(1,ui->Extra->HeightCoeff); }
  211. if((ui->Flags&LA_UI_FLAGS_EXPAND)&&(!(ui->Flags&LA_UI_FLAGS_NO_LABEL))){
  212. ExtraW+=tnsStringGetWidth(transLate(ui->PP.LastPs->p->Name),0,0);
  213. }
  214. return LA_RH*4+ExtraW;
  215. }
  216. int la_LabelGetMinWidth(laUiItem *ui){
  217. laBoxedTheme *bt = *ui->Type->Theme;
  218. if(ui->Flags&LA_UI_MIN_WIDTH){ return LA_RH; }
  219. int strw=tnsStringGetWidth(transLate(SSTR(ui->Display)), 0, ui->Flags&LA_TEXT_MONO);
  220. if(ui->Type==_LA_UI_MENU_ROOT && strw<LA_RH)strw=LA_RH;
  221. return (strw + bt->LM + bt->RM);
  222. }
  223. int la_StringPropGetMinWidth(laUiItem *ui){
  224. laBoxedTheme *bt = *ui->Type->Theme;
  225. if(ui->Flags&LA_UI_MIN_WIDTH){ return LA_RH; }
  226. char _buf[LA_RAW_CSTR_MAX_LEN]={0}; int ExtraW=0; char* buf=_buf;
  227. if(ui->Type == _LA_UI_STRING_MULTI){ExtraW=2*LA_RH+bt->LM;}
  228. laGetString(&ui->PP, _buf, &buf); int rows=0;
  229. int strw=tnsStringGetDimension(buf, 0, 0, 0, &rows, ui->Flags&LA_TEXT_MONO);
  230. int Plain = ui->Flags&LA_UI_FLAGS_PLAIN;
  231. if((!Plain)&&strw<LA_RH*4){strw=LA_RH*4;}
  232. return (strw + bt->LM + bt->RM+ExtraW);
  233. }
  234. int la_EnumGetMinWidth(laUiItem *ui){
  235. laBoxedTheme *bt = *ui->Type->Theme;
  236. laEnumProp *ep = ui->PP.LastPs->p;
  237. laEnumItem *i;
  238. int W = 0; int tW;
  239. int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  240. int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
  241. int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
  242. int IsIcon = ui->Flags&LA_UI_FLAGS_ICON;
  243. int Highlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
  244. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  245. int SharedWidth;
  246. if(!IsIcon){
  247. SharedWidth = bt->LM + bt->RM + ((IsCycle||IsExpand||NoDecal)?0:LA_RH); int HasIcon=0;
  248. if(Highlight){ int ico=0;
  249. if (ui->ExtraInstructions){
  250. if (ui->Type->OperatorType->ParseArgs){
  251. char buf[256]; buf[0]=0;
  252. ui->Type->OperatorType->ParseArgs(ui->Instructions, &ico, buf);
  253. tW = tnsStringGetWidth(transLate(buf), 0, ui->Flags&LA_TEXT_MONO) + SharedWidth;
  254. }
  255. }else{
  256. for (i = ep->Items.pFirst; i; i = i->Item.pNext){ if (i->IconID){ HasIcon=1; } }
  257. tW = tnsStringGetWidth(transLate(ep->Base.Name), 0, ui->Flags&LA_TEXT_MONO) + SharedWidth;
  258. }
  259. if (tW > W) W = tW;
  260. if(HasIcon||ico) W+=bt->LM+LA_RH;
  261. }else{
  262. for (i = ep->Items.pFirst; i; i = i->Item.pNext){
  263. tW = tnsStringGetWidth(transLate(i->Name), 0, ui->Flags&LA_TEXT_MONO) + SharedWidth;
  264. if (i->IconID){ HasIcon=1; }
  265. if (tW > W) W = tW;
  266. }
  267. if(HasIcon) W+=bt->LM+LA_RH;
  268. }
  269. }else{
  270. W = LA_RH;
  271. }
  272. int ArrLen = laGetArrayLength(&ui->PP);
  273. if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
  274. int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
  275. if(ArrLen==1){
  276. if(!IsVertical) return W*EnumLen;
  277. return W;
  278. }else{
  279. if(IsVertical) return ArrLen*W;
  280. return EnumLen*W;
  281. }
  282. return W;
  283. }
  284. int la_ButtonGetMinWidth(laUiItem *ui){
  285. laBoxedTheme *bt = *ui->Type->Theme;
  286. uint32_t IconID;
  287. char buf[LA_RAW_CSTR_MAX_LEN]={0};
  288. char *label;
  289. laOperatorProp *ap;
  290. int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
  291. if(IconOnly) return LA_RH;
  292. if (ui->PP.LastPs && ui->PP.LastPs->p){
  293. ap = ui->PP.LastPs->p;
  294. label = transLate(ap->Base.Name);
  295. if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
  296. IconID = ap->Base.IconID ? ap->Base.IconID : ap->OperatorType->IconID;
  297. }else{
  298. label = transLate(ui->AT->Name);
  299. IconID = ui->AT->IconID;
  300. }
  301. if (ui->ExtraInstructions){
  302. if (ui->AT && ui->AT->ParseArgs){
  303. ui->AT->ParseArgs(ui->Instructions, &IconID, buf);
  304. if (buf[0]) label = transLate(buf);
  305. }else if (ui->PP.LastPs->p->PropertyType == LA_PROP_OPERATOR){
  306. laOperatorProp *ap = ui->PP.LastPs->p;
  307. if (ap->OperatorType && ap->OperatorType->ParseArgs){
  308. ap->OperatorType->ParseArgs(ui->Instructions, &IconID, buf);
  309. if (buf[0]) label = transLate(buf);
  310. }
  311. }
  312. }
  313. int strw=tnsStringGetWidth(label, 0, ui->Flags&LA_TEXT_MONO);
  314. if(strw){ strw+=bt->RM+bt->LM; }
  315. return ((IconID ? (LA_RH) : 0) + strw);
  316. }
  317. int la_CollectionSimpleGetMinWidth(laUiItem *ui){
  318. laBoxedTheme *bt = *ui->Type->Theme;
  319. int Simple=ui->Flags&LA_UI_COLLECTION_SIMPLE_SELECTOR;
  320. int Expand=ui->Expand||(ui->Flags&LA_UI_FLAGS_EXPAND);
  321. int w=LA_RH+((Simple&&Expand)?(tnsStringGetWidth("Select",0,0)+bt->RM+bt->LM):0);
  322. return w;
  323. }
  324. int la_ColumnViewerGetMinWidth(laUiItem *ui){
  325. return 350;
  326. }
  327. int la_ColorPickerGetMinWidth(laUiItem *ui){
  328. return LA_RH * 9;
  329. }
  330. int la_SocketGetMinWidth(laUiItem *ui){
  331. if(ui->Flags&(LA_UI_SOCKET_LABEL_W|LA_UI_SOCKET_LABEL_E))return LA_RH*3;
  332. if(ui->Flags&(LA_UI_SOCKET_LABEL_S|LA_UI_SOCKET_LABEL_N))return LA_RH*2;
  333. return LA_RH;
  334. }
  335. int la_ImageGetMinWidth(laUiItem *ui){
  336. tnsImage* im=ui->Extra;
  337. if(!im->Texture) return LA_RH;
  338. int W=im->Texture->Width, H=im->Texture->Height;
  339. int UseW=LA_RH;
  340. if(ui->Flags&LA_UI_IMAGE_FULL_W) UseW=W;
  341. else UseW=(int)((real)LA_RH*ui->SymbolID/H*W);
  342. real CW=MAIN.CurrentWindow->CW-LA_RH*4, CH=MAIN.CurrentWindow->CH-LA_RH*4;
  343. real ra=1;
  344. if(UseW>CW){ real r=UseW/CW; ra=TNS_MAX2(r,ra); }
  345. if(H>CH){ real r=H/CH; ra=TNS_MAX2(r,ra); }
  346. UseW/=ra; H/=ra;
  347. return UseW;
  348. }
  349. void la_SingleLineStringDrawSelection(laUiItem *ui, int Begin, int U, laBoxedTheme *bt, uint32_t *str, laStringEdit *se);
  350. void la_CollectionSelectorDraw(laUiItem *ui, int h){
  351. char temp[128] = {0};
  352. laBoxedTheme *bt = (*ui->Type->Theme);
  353. real Color[16] = {0};
  354. tnsVector4d Transp = {0};
  355. int CrossDraw = 0;
  356. int Simple=ui->Flags&LA_UI_COLLECTION_SIMPLE_SELECTOR;
  357. if(Simple){ CrossDraw=0; }
  358. if (!ui->State) ui->State = LA_UI_NORMAL;
  359. tnsUseNoTexture();
  360. tnsColor4dv(laThemeColor(bt,ui->State));
  361. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  362. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  363. tnsPackAs(GL_TRIANGLE_FAN);
  364. if(!Simple){
  365. CrossDraw = laGetActiveInstanceStrict(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance) ? 1 : 0;
  366. }
  367. if (CrossDraw){
  368. tnsVectorCopy4d(laThemeColor(bt,LA_BT_BORDER), Transp);
  369. Transp[3] = 0;
  370. tnsMakeLinerGradient4dv(Color, 2, Transp, laThemeColor(bt,LA_BT_BORDER));
  371. tnsMakeLinerGradient4dv(&Color[8], 2, Transp, laThemeColor(bt,LA_BT_BORDER));
  372. //tnsMakeLinerGradient4dv(&Color[8], 2, laThemeColor(bt, LA_BT_BORDER), Transp);
  373. tnsVertex2d(ui->R - LA_RH, ui->U); tnsVertex2d(ui->R, ui->U);
  374. tnsVertex2d(ui->R - LA_RH, ui->B); tnsVertex2d(ui->R, ui->B);
  375. tnsColorArray4d(Color, 4);
  376. tnsPackAs(GL_TRIANGLE_STRIP);
  377. }
  378. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  379. tnsVertex2d(ui->L, ui->U);
  380. tnsVertex2d(ui->R, ui->U);
  381. tnsVertex2d(ui->R, ui->B);
  382. tnsVertex2d(ui->L, ui->B);
  383. tnsPackAs(GL_LINE_LOOP);
  384. if (CrossDraw){
  385. tnsDrawStringAuto("🧹", laThemeColor(bt,ui->State|LA_BT_TEXT), ui->R - LA_RH, ui->R, ui->U, 0);
  386. }
  387. if(Simple){
  388. int R=ui->R; if(ui->Expand || (ui->Flags&LA_UI_FLAGS_EXPAND)){
  389. R=ui->L+LA_RH; tnsDrawStringAuto(transLate("Select"), laThemeColor(bt,ui->State|LA_BT_TEXT), R+bt->LM, ui->R, ui->U, 0);
  390. }
  391. tnsDrawStringAuto("⯆", laThemeColor(bt,ui->State|LA_BT_TEXT), ui->L, R, ui->U, LA_TEXT_ALIGN_CENTER);
  392. }
  393. }
  394. void la_EmptyDraw(laUiItem *ui, int h){
  395. char temp[128] = {0};
  396. laBoxedTheme *bt = (*ui->Type->Theme);
  397. if (!ui->State) ui->State = LA_UI_NORMAL;
  398. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  399. if(!NoDecal){
  400. tnsUseNoTexture();
  401. tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
  402. tnsVertex2d(ui->L, ui->U);
  403. tnsVertex2d(ui->R, ui->U);
  404. tnsVertex2d(ui->R, ui->B);
  405. tnsVertex2d(ui->L, ui->B);
  406. tnsPackAs(GL_TRIANGLE_FAN);
  407. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  408. tnsVertex2d(ui->L, ui->U);
  409. tnsVertex2d(ui->R, ui->U);
  410. tnsVertex2d(ui->R, ui->B);
  411. tnsVertex2d(ui->L, ui->B);
  412. tnsPackAs(GL_LINE_LOOP);
  413. }
  414. }
  415. void la_GroupDraw(laUiItem *ui, int h){
  416. char temp[128] = {0};
  417. laBoxedTheme *bt = (*ui->Type->Theme);
  418. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  419. if(!NoDecal){
  420. tnsUseNoTexture();
  421. tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
  422. tnsVertex2d(ui->L, ui->U);
  423. tnsVertex2d(ui->R, ui->U);
  424. tnsVertex2d(ui->R, ui->B);
  425. tnsVertex2d(ui->L, ui->B);
  426. tnsPackAs(GL_TRIANGLE_FAN);
  427. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  428. tnsVertex2d(ui->L, ui->U);
  429. tnsVertex2d(ui->R, ui->U);
  430. tnsVertex2d(ui->R, ui->B);
  431. tnsVertex2d(ui->L, ui->B);
  432. tnsPackAs(GL_LINE_LOOP);
  433. }
  434. if (ui->State != LA_UI_ACTIVE){
  435. tnsDrawStringAuto(ui->Page ? transLate(ui->Page->TabName->Ptr) : transLate("No Page"),
  436. laThemeColor(bt,ui->State|LA_BT_TEXT), ui->L+bt->LM, ui->R+bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
  437. }
  438. }
  439. void la_TabDraw(laUiItem *ui, int h){
  440. char temp[128] = {0};
  441. laBoxedTheme *bt = (*ui->Type->Theme);
  442. laUiList *uil; int count = 0, page = 0;real w, l = ui->L;
  443. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){ count++; }
  444. w = (real)(ui->R - ui->L) / (count == 0 ? 1 : count);
  445. real* bkg=laThemeColor(bt,LA_BT_NORMAL);
  446. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  447. if(!NoDecal){
  448. tnsUseNoTexture();
  449. tnsColor4d(LA_COLOR3(bkg),bkg[3]*0.7);
  450. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  451. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  452. tnsPackAs(GL_TRIANGLE_FAN);
  453. real* bc=laThemeColor(bt,LA_BT_BORDER); real bcolor[24];
  454. tnsVectorCopy4d(bc,bcolor); tnsVectorSet4(&bcolor[4],bc[0],bc[1],bc[2],bc[3]*0.6);
  455. tnsVectorCopy4d(&bcolor[4],&bcolor[8]);
  456. tnsVectorCopy4d(&bcolor[4],&bcolor[12]);
  457. tnsVectorCopy4d(&bcolor[4],&bcolor[16]);
  458. tnsVectorCopy4d(bcolor,&bcolor[20]);
  459. tnsVertex2d(ui->L, ui->U + h); tnsVertex2d(ui->L, TNS_MIN2(ui->U+h*3,ui->B)); tnsVertex2d(ui->L, ui->B);
  460. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->R, TNS_MIN2(ui->U+h*3,ui->B)); tnsVertex2d(ui->R, ui->U + h);
  461. tnsColorArray4d(bcolor,6);
  462. tnsPackAs(GL_LINE_STRIP);
  463. }
  464. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
  465. l = page*w; int IsThisPage=(uil==ui->Page);
  466. tnsUseNoTexture();
  467. if(!IsThisPage){
  468. tnsColor4dv(laThemeColor(bt,LA_BT_ACTIVE));
  469. tnsVertex2d(ui->L + l, ui->U); tnsVertex2d(ui->L + l + w, ui->U);
  470. tnsVertex2d(ui->L + l + w, ui->U + h); tnsVertex2d(ui->L + l, ui->U + h);
  471. tnsPackAs(GL_TRIANGLE_FAN);
  472. }
  473. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  474. tnsVertex2d(ui->L + l, ui->U + h); tnsVertex2d(ui->L + l, ui->U);
  475. tnsVertex2d(ui->L + l + w, ui->U); tnsVertex2d(ui->L + l + w, ui->U + h);
  476. tnsPackAs(IsThisPage?GL_LINE_STRIP:GL_LINE_LOOP);
  477. tnsDrawStringAuto(transLate(uil->TabName->Ptr), laThemeColor(bt,IsThisPage?LA_BT_BORDER:LA_BT_TEXT), ui->L+l+bt->LM, ui->L+l+w-bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
  478. page++;
  479. }
  480. tnsFlush();
  481. }
  482. void la_SymbolDraw(laUiItem *ui, int h){
  483. return;
  484. //char temp[128] = {0};
  485. //laBoxedTheme *bt = (*ui->Type->Theme);
  486. //tnsFontSingleCharacter *fsc = tfntFetchVectorGraphTextureIDW(ui->SymbolID);
  487. //int VOffset = (ui->B - ui->U - (fsc->height)) / 2;
  488. //int HOffset = (ui->R - ui->L - (fsc->width)) / 2;
  489. //
  490. //if (strArgumentMatch(ui->Instructions, "mode", "invert"))
  491. //{
  492. // tnsUseNoTexture();
  493. // //tnsColor4dv(laThemeColor(bt, ui->State));
  494. // //tnsVertex2d(ui->L, ui->U);
  495. // //tnsVertex2d(ui->R, ui->U);
  496. // //tnsVertex2d(ui->R, ui->B);
  497. // //tnsVertex2d(ui->L, ui->B);
  498. // //tnsPackAs(GL_TRIANGLE_FAN);
  499. //
  500. // tnsUseNoTexture();
  501. // tnsColor4dv(LA_THEME_GET(bt, LA_UI_NORMAL)->BorderColor->RGBA);
  502. // tnsVertex2d(ui->L, ui->U);
  503. // tnsVertex2d(ui->R, ui->U);
  504. // tnsVertex2d(ui->R, ui->B);
  505. // tnsVertex2d(ui->L, ui->B);
  506. // tnsPackAs(GL_TRIANGLE_FAN);
  507. //
  508. // // tnsDrawVectorGraphPackage(ui->SymbolID, LA_THEME_GET(bt, LA_THEME_INTERPOLATING), ui->L + HOffset, ui->R, ui->U + VOffset, ui->B, 0, 0);
  509. //}
  510. //else
  511. //{
  512. // //if (!ui->State) ui->State = LA_UI_NORMAL;
  513. //
  514. // /*tnsUseNoTexture();
  515. // tnsColor4dv(laThemeColor(bt, ui->State));
  516. // tnsVertex2d(ui->L, ui->U);
  517. // tnsVertex2d(ui->R, ui->U);
  518. // tnsVertex2d(ui->R, ui->B);
  519. // tnsVertex2d(ui->L, ui->B);
  520. // tnsPackAs(GL_TRIANGLE_FAN);*/
  521. //
  522. // //tnsUseNoTexture();
  523. //tnsColor4dv(LA_THEME_GET(bt, LA_UI_NORMAL)->BorderColor->RGBA);
  524. //tnsVertex2d(ui->L, ui->U);
  525. //tnsVertex2d(ui->R, ui->U);
  526. //tnsVertex2d(ui->R, ui->B);
  527. //tnsVertex2d(ui->L, ui->B);
  528. //tnsPackAs(GL_LINE_LOOP);
  529. //
  530. // // tnsDrawVectorGraphPackage(ui->SymbolID, LA_THEME_GET(bt, LA_UI_NORMAL), ui->L + HOffset, ui->R, ui->U + VOffset, ui->B, 0, 0);
  531. //}
  532. }
  533. void la_IntDraw(laUiItem *ui, int h){
  534. laBoxedTheme *bt = (*ui->Type->Theme);
  535. int Data[32];
  536. int Len, i, Seg, W;
  537. char buf[48] = {0};
  538. char buf2[48] = {0};
  539. char prefix[8][64] = {0};
  540. int Original;
  541. int Ranged;
  542. int min, max;
  543. int s, State;
  544. int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  545. int IsIcon=ui->Flags&LA_UI_FLAGS_ICON;
  546. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  547. int NoLabel=ui->Flags&LA_UI_FLAGS_NO_LABEL;
  548. int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
  549. int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
  550. if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
  551. laGetIntArray(&ui->PP, Data);
  552. Len = laGetArrayLength(&ui->PP);
  553. laGetPrefixP(&ui->PP, prefix);
  554. Ranged = laGetIntRange(&ui->PP, &min, &max);
  555. for (i = 0; i < Len; i++){
  556. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  557. if(IsVertical){
  558. Seg = ui->R - ui->L;
  559. _U = ui->U + i * LA_RH; _B = _U+LA_RH;
  560. }else{
  561. Seg = (ui->R - ui->L) / Len;
  562. _L = ui->L + i * Seg; _R=_L+Seg;
  563. }
  564. if(IsIcon){
  565. sprintf(buf, "%lc", laGetInt(&ui->PP));
  566. }else{
  567. buf[0] = '\0'; buf2[0] = '\0';
  568. if(Len==1){ strcat(buf2, transLate(ui->PP.LastPs->p->Name)); }
  569. if(i<8)strcat(Len==1?buf:buf2,&prefix[i]);
  570. strPrintIntAfter(buf, 48, Data[i]);
  571. strAppend(buf, ui->PP.LastPs->p->Unit ? transLate(ui->PP.LastPs->p->Unit) : "");
  572. }
  573. if (ui->Extra && ui->Extra->On == i + 1){
  574. Original = ui->State;
  575. ui->State = LA_UI_ACTIVE;
  576. }
  577. if(IsKnob && !ui->Extra->Edit){
  578. real ctrx = (real)(_L+_R)/2.0f, ctry=(real)(_U+_B)/2.0f, radius=TNS_MIN2((_B-_U)/2.0f,(_R-_L)/2.0f);
  579. tnsUseNoTexture();
  580. real dgx=0,dgy=0;
  581. if(radius*2>(_B-_U)-LA_RH/5){ dgx = radius/1.5; }
  582. if(radius*2>(_R-_L)-LA_RH/5){ dgy = radius/1.5; }
  583. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  584. tnsVertex2d(_L, ctry-dgy); tnsVertex2d(_L, _U); tnsVertex2d(ctrx-dgx, _U); tnsPackAs(GL_LINE_STRIP);
  585. tnsVertex2d(_R, ctry-dgy); tnsVertex2d(_R, _U); tnsVertex2d(ctrx+dgx, _U); tnsPackAs(GL_LINE_STRIP);
  586. tnsVertex2d(_R, ctry+dgy); tnsVertex2d(_R, _B); tnsVertex2d(ctrx+dgx, _B); tnsPackAs(GL_LINE_STRIP);
  587. tnsVertex2d(_L, ctry+dgy); tnsVertex2d(_L, _B); tnsVertex2d(ctrx-dgx, _B); tnsPackAs(GL_LINE_STRIP);
  588. real verts[52];//24*2+ctr+overlap
  589. tnsMakeCircle2d(&verts[2],24,ctrx,ctry,radius,0);
  590. tnsVectorCopy2d(&verts[2],&verts[50]);
  591. verts[0]=ctrx; verts[1]=ctry;
  592. tnsColor4dv(laThemeColor(bt,ui->State));
  593. tnsVertexArray2d(verts,26); tnsPackAs(GL_TRIANGLE_FAN);
  594. tnsMakeCircle2d(verts,24,ctrx,ctry,radius,0);
  595. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  596. tnsVertexArray2d(verts,24); tnsPackAs(GL_LINE_LOOP);
  597. if(Ranged){
  598. real arc[52]; int arcindex[26]; // 12 slices 13 ends
  599. real range = (real)(Data[i] - min) / (real)(max - min) * TNS_PI * 1.5;
  600. tnsMakeArc2d(arc,12,ctrx,ctry,radius,TNS_PI*2.75, TNS_PI*2.75 + range);
  601. tnsMakeArc2d(&arc[26],12,ctrx,ctry,radius*0.6,TNS_PI*2.75, TNS_PI*2.75 + range);
  602. tnsMakeBridgedIndex(arcindex, 13, 0, 0);
  603. real *color = laThemeColor(bt,LA_BT_TEXT|ui->State); //tnsColor4d(LA_COLOR3(color),0.3);
  604. tnsColor4dv(color);
  605. tnsVertexArray2d(arc,26); tnsIndexArray(arcindex,26); tnsPackAs(GL_TRIANGLE_STRIP);
  606. tnsMakeArc2d(&arc[2],12,ctrx,ctry,radius*0.6,TNS_PI*2.75, TNS_PI*4.25);
  607. tnsVertexArray2d(&arc[2],13);
  608. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  609. tnsPackAs(GL_LINE_STRIP);
  610. }
  611. }else{
  612. if(!NoDecal){
  613. tnsUseNoTexture();
  614. tnsColor4dv(laThemeColor(bt,ui->State));
  615. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  616. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  617. tnsPackAs(GL_TRIANGLE_FAN);
  618. if (Ranged){
  619. int L1 = _L;
  620. int R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(Seg) + L1;
  621. tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
  622. tnsColor4d(LA_COLOR3(color),0.3);
  623. tnsVertex2d(L1, _U); tnsVertex2d(R1, _U);
  624. tnsVertex2d(R1, _B); tnsVertex2d(L1, _B);
  625. tnsPackAs(GL_TRIANGLE_FAN);
  626. }
  627. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  628. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  629. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  630. tnsPackAs(GL_LINE_LOOP);
  631. }
  632. if (ui->Extra->On == i + 1 && ui->Extra->Edit){
  633. uint32_t *buf = strGetCursorLine(ui->Extra->Edit, 0)->Buf;
  634. int LL = _L + (Seg - tnsStringGetWidthU(buf, 0, ui->Flags&LA_TEXT_MONO)) / 2;
  635. tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
  636. la_SingleLineStringDrawSelection(ui, _L, _U, bt, buf, ui->Extra->Edit);
  637. tnsDrawStringM(0, buf, laThemeColor(bt, LA_BT_TEXT_ACTIVE), _L + bt->LM, _R - bt->RM, _U, ui->Flags);
  638. }else{
  639. tnsDrawStringWithPriority(NoLabel?0:buf2, buf,
  640. IsDisabled?laThemeColor(bt, LA_BT_DISABLED):laThemeColor(bt, LA_BT_TEXT|ui->State), bt->TextAlign, _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
  641. }
  642. }
  643. if (ui->Extra && ui->Extra->On == i + 1) ui->State = Original;
  644. }
  645. tnsFlush();
  646. }
  647. void la_FloatDraw(laUiItem *ui, int h){
  648. laBoxedTheme *bt = (*ui->Type->Theme);
  649. real Data[32];
  650. int Len, i, W, Seg;
  651. char buf[48] = {0};
  652. char buf2[48] = {0};
  653. char prefix[8][64] = {0};
  654. int Original;
  655. int Ranged;
  656. real min, max;
  657. int s, State;
  658. int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  659. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  660. int IsRad=ui->PP.LastPs->p->IsRadAngle;
  661. int NoLabel=ui->Flags&LA_UI_FLAGS_NO_LABEL;
  662. int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
  663. int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
  664. if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
  665. laGetFloatArray(&ui->PP, Data);
  666. Len = laGetArrayLength(&ui->PP);
  667. laGetPrefixP(&ui->PP, prefix);
  668. Ranged = laGetFloatRange(&ui->PP, &min, &max);
  669. for (i = 0; i < Len; i++){
  670. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  671. if(IsVertical){
  672. Seg = ui->R - ui->L;
  673. _U = ui->U + i * LA_RH; _B = _U+LA_RH;
  674. }else{
  675. Seg = (ui->R - ui->L) / Len;
  676. _L = ui->L + i * Seg; _R=_L+Seg;
  677. }
  678. buf[0] = '\0'; buf2[0] = '\0';
  679. if(Len==1){ strcat(buf2, transLate(ui->PP.LastPs->p->Name)); }
  680. if(i<8)strcat(Len==1?buf:buf2, &prefix[i]);
  681. strPrintFloatAfter(buf, 48, 3, IsRad?deg(Data[i]):Data[i]);
  682. strAppend(buf, ui->PP.LastPs->p->Unit ? transLate(ui->PP.LastPs->p->Unit) : "");
  683. if (ui->Extra && ui->Extra->On == i + 1){
  684. Original = ui->State;
  685. ui->State = LA_UI_ACTIVE;
  686. }
  687. if(IsKnob && !ui->Extra->Edit){
  688. real ctrx = (real)(_L+_R)/2.0f, ctry=(real)(_U+_B)/2.0f, radius=TNS_MIN2((_B-_U)/2.0f,(_R-_L)/2.0f);
  689. tnsUseNoTexture();
  690. real dgx=0,dgy=0;
  691. if(radius*2>(_B-_U)-LA_RH/5){ dgx = radius/1.5; }
  692. if(radius*2>(_R-_L)-LA_RH/5){ dgy = radius/1.5; }
  693. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  694. tnsVertex2d(_L, ctry-dgy); tnsVertex2d(_L, _U); tnsVertex2d(ctrx-dgx, _U); tnsPackAs(GL_LINE_STRIP);
  695. tnsVertex2d(_R, ctry-dgy); tnsVertex2d(_R, _U); tnsVertex2d(ctrx+dgx, _U); tnsPackAs(GL_LINE_STRIP);
  696. tnsVertex2d(_R, ctry+dgy); tnsVertex2d(_R, _B); tnsVertex2d(ctrx+dgx, _B); tnsPackAs(GL_LINE_STRIP);
  697. tnsVertex2d(_L, ctry+dgy); tnsVertex2d(_L, _B); tnsVertex2d(ctrx-dgx, _B); tnsPackAs(GL_LINE_STRIP);
  698. real verts[52];//24*2+ctr+overlap
  699. tnsMakeCircle2d(&verts[2],24,ctrx,ctry,radius,0);
  700. tnsVectorCopy2d(&verts[2],&verts[50]);
  701. verts[0]=ctrx; verts[1]=ctry;
  702. tnsColor4dv(laThemeColor(bt,ui->State));
  703. tnsVertexArray2d(verts,26); tnsPackAs(GL_TRIANGLE_FAN);
  704. tnsMakeCircle2d(verts,24,ctrx,ctry,radius,0);
  705. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  706. tnsVertexArray2d(verts,24); tnsPackAs(GL_LINE_LOOP);
  707. if(Ranged){
  708. real arc[52]; int arcindex[26]; // 12 slices 13 ends
  709. real range,rstart;
  710. if(min<0&&max>0){ rstart=TNS_PI*3.5; range = (real)(Data[i]) / (real)(max) * TNS_PI * 1.5 * max/(max-min);}
  711. else{ rstart=TNS_PI*2.75; range = (real)(Data[i] - min) / (real)(max - min) * TNS_PI * 1.5; }
  712. tnsMakeArc2d(arc,12,ctrx,ctry,radius,rstart, rstart + range);
  713. tnsMakeArc2d(&arc[26],12,ctrx,ctry,radius*0.6,rstart, rstart + range);
  714. tnsMakeBridgedIndex(arcindex, 13, 0, 0);
  715. real *color = laThemeColor(bt,LA_BT_TEXT|ui->State); //tnsColor4d(LA_COLOR3(color),0.3);
  716. tnsColor4dv(color);
  717. tnsVertexArray2d(arc,26); tnsIndexArray(arcindex,26); tnsPackAs(GL_TRIANGLE_STRIP);
  718. tnsMakeArc2d(&arc[2],12,ctrx,ctry,radius*0.6,TNS_PI*2.75, TNS_PI*4.25);
  719. arc[0] = ctrx + cos(TNS_PI*2.75) * radius; arc[1] = ctry + sin(TNS_PI*2.75) * radius;
  720. arc[28] =ctrx + cos(TNS_PI*4.25) * radius; arc[29] =ctry + sin(TNS_PI*4.25) * radius;
  721. tnsVertexArray2d(arc,15);
  722. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  723. tnsPackAs(GL_LINE_STRIP);
  724. }
  725. }else{
  726. if(!NoDecal){
  727. tnsUseNoTexture();
  728. tnsColor4dv(laThemeColor(bt,ui->State));
  729. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  730. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  731. tnsPackAs(GL_TRIANGLE_FAN);
  732. if (Ranged){
  733. int L1 = _L;
  734. int R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(Seg) + L1;
  735. tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
  736. tnsColor4d(LA_COLOR3(color),0.3);
  737. tnsVertex2d(L1, _U); tnsVertex2d(R1, _U);
  738. tnsVertex2d(R1, _B); tnsVertex2d(L1, _B);
  739. tnsPackAs(GL_TRIANGLE_FAN);
  740. }
  741. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  742. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  743. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  744. tnsPackAs(GL_LINE_LOOP);
  745. }
  746. if (ui->Extra->On == i + 1 && ui->Extra->Edit){
  747. uint32_t *buf = strGetCursorLine(ui->Extra->Edit,0)->Buf;
  748. int LL = _L + (Seg - tnsStringGetWidthU(buf, 0, ui->Flags&LA_TEXT_MONO)) / 2;
  749. tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
  750. la_SingleLineStringDrawSelection(ui, _L, _U, bt, buf, ui->Extra->Edit);
  751. tnsDrawStringM(0, buf, laThemeColor(bt, LA_BT_TEXT_ACTIVE), _L + bt->LM, _R - bt->RM, _U, ui->Flags);
  752. }else{
  753. tnsDrawStringWithPriority(NoLabel?0:buf2, buf,
  754. IsDisabled?laThemeColor(bt, LA_BT_DISABLED):laThemeColor(bt, LA_BT_TEXT|ui->State), bt->TextAlign, _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
  755. }
  756. }
  757. if (ui->Extra && ui->Extra->On == i + 1) ui->State = Original;
  758. }
  759. tnsFlush();
  760. }
  761. void la_FloatArrayColorDraw(laUiItem *ui, int h){
  762. laBoxedTheme *bt = (*ui->Type->Theme);
  763. real Data[32];
  764. int Len, i;
  765. int IsColorful=ui->Flags&LA_UI_FLAGS_COLORFUL;
  766. laGetFloatArray(&ui->PP, Data);
  767. Len = laGetArrayLength(&ui->PP);
  768. if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LogsRGB(Data); }
  769. tnsUseNoTexture();
  770. if(IsColorful){
  771. int sw=(ui->R-ui->L)/2;
  772. tnsColor4d(Data[0], Data[1], Data[2], 1);
  773. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->L+sw, ui->U);
  774. tnsVertex2d(ui->L+sw, ui->B); tnsVertex2d(ui->L, ui->B);
  775. tnsPackAs(GL_TRIANGLE_FAN);
  776. tnsColor4d(Data[0], Data[1], Data[2], Len>3?Data[3]:1);
  777. tnsVertex2d(ui->L+sw, ui->U); tnsVertex2d(ui->R, ui->U);
  778. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L+sw, ui->B);
  779. tnsUseHalftone(1.0); tnsPackAs(GL_TRIANGLE_FAN); tnsUseHalftone(0.0);
  780. }else{
  781. tnsColor4d(Data[0], Data[1], Data[2], 1);
  782. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  783. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  784. tnsPackAs(GL_TRIANGLE_FAN);
  785. }
  786. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  787. if(!NoDecal){
  788. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  789. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  790. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  791. tnsPackAs(GL_LINE_LOOP);
  792. }
  793. tnsFlush();
  794. }
  795. void la_EnumSelectorDraw(laUiItem *ui, int h){
  796. laEnumItem *Data[32], Len;
  797. laBoxedTheme *bt = (*ui->Type->Theme);
  798. char buf[48] = {0};
  799. char buf2[48] = {0};
  800. char prefix[8][64]= {0};
  801. laEnumProp *ep = ui->PP.LastPs->p;
  802. int HasIcon = laEnumHasIcon(&ui->PP);
  803. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  804. int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
  805. int NoEvent=ui->Flags&LA_UI_FLAGS_NO_EVENT;
  806. int Highlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
  807. int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
  808. // norm e1
  809. // expand e1 e2 e3
  810. // expand vertical (vertical)
  811. // arr expand e1 e1 e3
  812. // e2 e2 e3
  813. // arr exp+vert e1 e1
  814. // e2 e2
  815. // e3 e3
  816. tnsUseNoTexture();
  817. laGetEnumArray(&ui->PP,Data);
  818. laEnumItem* ei, *use_ei;
  819. int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  820. int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
  821. int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
  822. int ArrLen = laGetArrayLength(&ui->PP);
  823. if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
  824. int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
  825. if(Highlight&&ArrLen!=1){laGetPrefixP(&ui->PP, prefix);}
  826. if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
  827. int _L,_R,_U,_B, _W=ui->R - ui->L;
  828. if(IsVertical){
  829. if(IsExpand){ _W/=ArrLen; }
  830. }else{
  831. if(IsExpand){ _W/=EnumLen; }
  832. else{ _W/=ArrLen; }
  833. }
  834. int UseIco=0,ico=0; char buft[48]={0}; int HasText=0;
  835. if (ui->ExtraInstructions){
  836. if (ui->Type->OperatorType->ParseArgs){
  837. ui->Type->OperatorType->ParseArgs(ui->Instructions, &UseIco, buft);
  838. }
  839. sprintf(buf,"%s",transLate(buft)); HasText=1;
  840. }
  841. for(int i=0;i<ArrLen;i++){
  842. if(!Data[i]){ Data[i]=((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst; }
  843. _L=ui->L; _R=ui->R; _U=ui->U; _B=ui->B; ei = ep->Items.pFirst;
  844. for(int j=0;j<EnumLen;j++){ if(!HasText)buf[0]=0;
  845. ico=UseIco;
  846. if(IsVertical){
  847. if(IsExpand){ _U=ui->U+j*LA_RH; _L=ui->L+i*_W; }
  848. else{ _U=ui->U+i*LA_RH; _L=ui->L; }
  849. }else{
  850. if(IsExpand){ _U=ui->U+i*LA_RH; _L=ui->L+j*_W; }
  851. else{ _U=ui->U; _L=ui->L+i*_W; }
  852. }
  853. _B=_U+LA_RH; _R=_L+_W;
  854. int ExtraState=IsDisabled?LA_BT_DISABLED:ui->State;
  855. if(IsExpand&&!IsCycle){ use_ei = ei; ei=ei->Item.pNext; ExtraState=(use_ei==Data[i])?LA_BT_ACTIVE:ExtraState; }
  856. else{ use_ei = Data[i]; if(Highlight && Data[i]->Index!=0){ ExtraState=LA_BT_ACTIVE; } }
  857. if(!NoDecal){
  858. tnsUseNoTexture();
  859. tnsColor4dv(laThemeColor(bt, ExtraState));
  860. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  861. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  862. tnsPackAs(GL_TRIANGLE_FAN);
  863. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  864. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  865. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  866. tnsPackAs(GL_LINE_LOOP);
  867. }
  868. if(Highlight){ if(!HasText && ArrLen==1) strcpy(buf, transLate(ui->PP.LastPs->p->Name)); else{ if(i<8)strcat(buf, &prefix[i]); } }
  869. if((!HasText) && (!buf[0])) strcpy(buf, transLate(use_ei->Name));
  870. int iconR; if(IconOnly)iconR=TNS_MAX2(_L+LA_RH,_R);else{ iconR=TNS_MIN2(_L+LA_RH,_R); }
  871. if (use_ei->IconID && !ico){ ico=use_ei->IconID; }
  872. if (ico) tnsDrawIcon(ico, laThemeColor(bt, LA_BT_TEXT|ExtraState), _L,iconR, _U, LA_TEXT_ALIGN_CENTER);
  873. if(!IconOnly){
  874. int UseFlags=ui->Flags; if(!HasIcon && IsExpand){ if(!(UseFlags&LA_TEXT_ALIGN)); UseFlags|=LA_TEXT_ALIGN_CENTER; }
  875. tnsDrawStringAuto(buf, laThemeColor(bt, LA_BT_TEXT|ExtraState), _L+bt->LM+(HasIcon?LA_RH:0), _R-bt->RM, _U, UseFlags);
  876. }
  877. if (!IsExpand && !IsVertical && !IconOnly && !IsCycle && !NoEvent){
  878. tnsDrawIcon(U'🔻', laThemeColor(bt, LA_BT_TEXT|ExtraState), _R-LA_RH, _R, _U, ui->Flags);
  879. }
  880. }
  881. }
  882. tnsFlush();
  883. }
  884. void la_ButtonDraw(laUiItem *ui, int h){
  885. laBoxedTheme *bt = (*ui->Type->Theme);
  886. char buf[LA_RAW_CSTR_MAX_LEN] = {0};
  887. char *label = 0;
  888. uint32_t IconID=0;
  889. int L;
  890. char *Identifier;
  891. laOperatorProp *ap = 0;
  892. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  893. int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
  894. int IsHighlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
  895. int IsWarning=ui->Flags&LA_UI_FLAGS_WARNING;
  896. if (ui->PP.LastPs && ui->PP.LastPs->p){
  897. ap = ui->PP.LastPs->p;
  898. label = transLate(ap->Base.Name);
  899. if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
  900. IconID = ap->Base.IconID ? ap->Base.IconID : ap->OperatorType->IconID;
  901. }else{
  902. label = transLate(ui->AT->Name);
  903. IconID = ui->AT->IconID;
  904. }
  905. if (ui->AT && (!laOperatorAvailableP(ui->AT, 0, ui->Instructions)))
  906. ui->State = LA_UI_DISABLED;
  907. elif (ap && ap->OperatorType && (!laOperatorAvailablePSafe(ap->OperatorType, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->Instructions))) ui->State = LA_UI_DISABLED;
  908. else if (ui->State == LA_UI_DISABLED) ui->State = LA_UI_NORMAL;
  909. if(!NoDecal){
  910. tnsUseNoTexture();
  911. tnsColor4dv(ui->State==LA_UI_NORMAL?(
  912. IsHighlight?laAccentColor(LA_BT_NORMAL):(IsWarning?laAccentColor(LA_BT_WARNING):laThemeColor(bt, ui->State)))
  913. :laThemeColor(bt, ui->State));
  914. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  915. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  916. tnsPackAs(GL_TRIANGLE_FAN);
  917. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  918. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  919. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  920. tnsPackAs(GL_LINE_LOOP);
  921. }
  922. if (ui->ExtraInstructions){
  923. uint32_t tIconID=0;
  924. if (ui->AT && ui->AT->ParseArgs){
  925. ui->AT->ParseArgs(ui->Instructions, &tIconID, buf);
  926. if (buf[0]) label = transLate(buf);
  927. if (tIconID) IconID=tIconID;
  928. }else if (ui->PP.LastPs->p->PropertyType == LA_PROP_OPERATOR){
  929. laOperatorProp *ap = ui->PP.LastPs->p;
  930. if (ap->OperatorType && ap->OperatorType->ParseArgs){
  931. ap->OperatorType->ParseArgs(ui->Instructions, &tIconID, buf);
  932. if (buf[0]) label = transLate(buf);
  933. if (tIconID) IconID=tIconID;
  934. }
  935. }
  936. }
  937. if (IconID) L = ui->L + bt->LM + h;
  938. else L = ui->L + bt->LM;
  939. if (IconID) tnsDrawIcon(IconID, laThemeColor(bt, ui->State|LA_BT_TEXT), ui->L, IconOnly?(ui->R):(ui->L+LA_RH), ui->U, LA_TEXT_ALIGN_CENTER);
  940. if (!IconOnly) tnsDrawStringAuto(label, laThemeColor(bt, ui->State|LA_BT_TEXT), L, ui->R-bt->RM, ui->U, ui->Flags);
  941. }
  942. void la_LabelDraw(laUiItem *ui, int h){
  943. laBoxedTheme *bt = (*ui->Type->Theme);
  944. int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
  945. int IsHighlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
  946. int IsWarning=ui->Flags&LA_UI_FLAGS_WARNING;
  947. if (!ui->State) ui->State = LA_UI_NORMAL;
  948. if (ui->ExtraInstructions && !ui->Instructions){
  949. strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
  950. }
  951. //int State = ui->Instructions ? (strArgumentMatch(ui->Instructions, "disabled", "true") ? LA_THEME_DISABLED : LA_UI_NORMAL) : LA_UI_NORMAL;
  952. tnsDrawStringAuto(transLate(SSTR(ui->Display)),
  953. IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):
  954. (IsHighlight?laAccentColor(LA_BT_TEXT):
  955. (IsWarning?laAccentColor(LA_BT_WARNING):laThemeColor(bt,LA_BT_TEXT))),
  956. ui->L, ui->R, ui->U, ui->Flags);
  957. }
  958. void la_SingleLineStringDrawSelection(laUiItem *ui, int Begin, int U, laBoxedTheme *bt, uint32_t *str, laStringEdit *se){
  959. tnsUseNoTexture();
  960. if (!strHasSelection(se)){
  961. tnsColor4dv(laAccentColor(LA_BT_TEXT));
  962. int L = (se->CursorBefore ? tnsStringGetWidthU(str, se->CursorBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
  963. tnsVertex2d(L-1, U + LA_RH - bt->BM);
  964. tnsVertex2d(L-1, U + bt->TM);
  965. tnsVertex2d(L+2, U + bt->TM);
  966. tnsVertex2d(L+2, U + LA_RH - bt->BM);
  967. tnsPackAs(GL_TRIANGLE_FAN);
  968. }else{
  969. int L = (se->BeginBefore ? tnsStringGetWidthU(str, se->BeginBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
  970. int R = (se->EndBefore ? tnsStringGetWidthU(str, se->EndBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
  971. tnsColor4dv(laAccentColor(LA_BT_NORMAL));
  972. tnsVertex2d(L, U + bt->TM);
  973. tnsVertex2d(L, U + LA_RH - bt->BM);
  974. tnsVertex2d(R, U + LA_RH - bt->TM);
  975. tnsVertex2d(R, U + bt->BM);
  976. tnsPackAs(GL_TRIANGLE_FAN);
  977. }
  978. }
  979. void la_SingleLineStringDraw(laUiItem *ui, int h){
  980. laBoxedTheme *bt = (*ui->Type->Theme);
  981. char* _temp[LA_RAW_CSTR_MAX_LEN] = {0}; char* temp=_temp;
  982. uint32_t* line=0;
  983. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  984. int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
  985. if (!ui->State) ui->State = LA_UI_NORMAL;
  986. if(!NoDecal){
  987. tnsUseNoTexture();
  988. tnsColor4dv(laThemeColor(bt, ui->State));
  989. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  990. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  991. tnsPackAs(GL_TRIANGLE_FAN);
  992. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  993. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  994. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  995. tnsPackAs(GL_LINE_LOOP);
  996. }
  997. if (ui->Extra && ui->Extra->Edit){
  998. line=strGetCursorLine(ui->Extra->Edit,0)->Buf;
  999. }else{
  1000. laGetString(&ui->PP, _temp, &temp);
  1001. }
  1002. if (line) la_SingleLineStringDrawSelection(ui, ui->L+(NoDecal?0:bt->LM), ui->U, bt, line, ui->Extra->Edit);
  1003. if(ui->PP.LastPs->p->CanTranslate){ temp=transLate(temp); }
  1004. tnsDrawStringAutoM(line?0:temp, line, IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):laThemeColor(bt,LA_BT_TEXT), ui->L+(NoDecal?0:bt->LM), ui->R-(NoDecal?0:bt->RM), ui->U, ui->Flags);
  1005. }
  1006. void la_MultiStringDraw(laUiItem *ui, int h){
  1007. laBoxedTheme *bt = (*ui->Type->Theme);
  1008. char _temp[LA_RAW_CSTR_MAX_LEN] = {0}; char* temp=_temp;
  1009. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  1010. if (!ui->State) ui->State = LA_UI_NORMAL;
  1011. int NumberWidth=bt->LM;
  1012. if((!ui->Extra->Edit) || (ui->Extra->Ptr1!=ui->PP.EndInstance)){
  1013. laGetString(&ui->PP, _temp, &temp);
  1014. strBeginEdit(&ui->Extra->Edit, temp);
  1015. ui->Extra->Ptr1=ui->PP.EndInstance;
  1016. }
  1017. laStringEdit* se=ui->Extra->Edit;
  1018. real MonoWidth=tnsGetMonoFontAdvance(); int Count=se->TotalLines;
  1019. while(Count){ Count/=10; NumberWidth+=MonoWidth; }
  1020. if (ui->State!=LA_UI_ACTIVE){
  1021. strSetEditViewRange(ui->Extra->Edit,
  1022. ui->Extra->HeightCoeff>0?ui->Extra->HeightCoeff:((ui->B-ui->U)/LA_RH),(ui->R-ui->L-NumberWidth-bt->LM*2-bt->RM)/MonoWidth);
  1023. }
  1024. if(!NoDecal){
  1025. tnsUseNoTexture();
  1026. tnsColor4dv(laThemeColor(bt, ui->State));
  1027. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1028. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1029. tnsPackAs(GL_TRIANGLE_FAN);
  1030. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  1031. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1032. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1033. tnsPackAs(GL_LINE_LOOP);
  1034. tnsColor4d(LA_COLOR3(laThemeColor(bt,LA_BT_BORDER)),0.8);
  1035. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->L+NumberWidth, ui->U);
  1036. tnsVertex2d(ui->L, ui->B); tnsVertex2d(ui->L+NumberWidth, ui->B);
  1037. tnsPackAs(GL_QUADS);
  1038. if(!(se->CursorLine<se->ViewStartLine||se->CursorLine>se->ViewStartLine+se->ViewHeight)){
  1039. int LineU=(se->CursorLine-se->ViewStartLine)*LA_RH+ui->U;
  1040. tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_NORMAL):laThemeColor(bt,LA_BT_BORDER));
  1041. tnsVertex2d(ui->L, LineU); tnsVertex2d(ui->R, LineU);
  1042. tnsVertex2d(ui->L, LineU+LA_RH); tnsVertex2d(ui->R, LineU+LA_RH);
  1043. tnsPackAs(GL_LINES);
  1044. tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT_NORMAL));
  1045. tnsVertex2d(ui->L, LineU); tnsVertex2d(ui->L+NumberWidth, LineU);
  1046. tnsVertex2d(ui->L, LineU+LA_RH); tnsVertex2d(ui->L+NumberWidth, LineU+LA_RH);
  1047. tnsPackAs(GL_QUADS);
  1048. }
  1049. }else{
  1050. NumberWidth=bt->LM;
  1051. }
  1052. tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
  1053. int Line=0, Skip=0, _L=ui->L+NumberWidth+bt->LM; char num[10]={0};
  1054. for(laStringLine* sl=se->Lines.pFirst;sl;sl=sl->Item.pNext){
  1055. int UseLine=Line+Skip;
  1056. if(UseLine<se->ViewStartLine){ Skip++; continue; }
  1057. if(UseLine>=se->ViewHeight+se->ViewStartLine){ break; }
  1058. int slen=strlenU(sl->Buf);
  1059. sprintf(num,"%d", UseLine+1); int LineU=ui->U+Line*LA_RH;
  1060. tnsDrawStringM(num, 0, laThemeColor(bt, ((UseLine==se->CursorLine)?LA_BT_NORMAL:LA_BT_TEXT)),
  1061. _L-bt->LM -(tnsStringGetWidth(num, 0, ui->Flags&LA_TEXT_MONO)), ui->R, LineU, ui->Flags);
  1062. if(slen>=se->ViewStartCol){
  1063. tnsDrawStringM(0, &sl->Buf[se->ViewStartCol], laThemeColor(bt, ui->State|LA_BT_TEXT), _L, ui->R, LineU, ui->Flags|LA_TEXT_OVERFLOW_ARROW);
  1064. }
  1065. if(UseLine>=se->BeginLine&&UseLine<=se->EndLine){
  1066. int BeginC=UseLine==se->BeginLine?se->BeginBefore:0; int EndC=UseLine==se->EndLine?se->EndBefore:slen;
  1067. BeginC-=se->ViewStartCol; EndC-=se->ViewStartCol; if(EndC>se->ViewWidth)EndC=se->ViewWidth;
  1068. tnsUseNoTexture();
  1069. tnsVertex2d(BeginC*MonoWidth+_L, LineU); tnsVertex2d(EndC*MonoWidth+_L, LineU);
  1070. tnsVertex2d(EndC*MonoWidth+_L, LineU+LA_RH); tnsVertex2d(BeginC*MonoWidth+_L, LineU+LA_RH);
  1071. tnsColor4dv(laAccentColor(LA_BT_NORMAL));
  1072. tnsPackAs(GL_TRIANGLE_FAN);
  1073. }
  1074. int len=strlenU(sl->Buf);
  1075. if(UseLine==se->CursorLine){
  1076. int Dist=se->CursorBefore==0?0:tnsStringGetWidthU(sl->Buf,se->CursorBefore,ui->Flags&LA_TEXT_MONO);
  1077. tnsUseNoTexture(); int d=se->ViewStartCol*MonoWidth; real w2=LA_RH/12;
  1078. tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT_NORMAL));
  1079. tnsVertex2d(_L+Dist-w2-d, LineU); tnsVertex2d(_L+Dist+w2-d, LineU);
  1080. tnsVertex2d(_L+Dist-w2-d, LineU+LA_RH); tnsVertex2d(_L+Dist+w2-d, LineU+LA_RH);
  1081. tnsPackAs(GL_QUADS);
  1082. }
  1083. Line++;
  1084. tnsFlush();
  1085. }
  1086. if(ui->Extra->HeightCoeff>=0)
  1087. tnsDrawStringAuto("◿",laThemeColor(bt,LA_BT_BORDER),ui->R-LA_RH, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
  1088. if(!NoDecal){
  1089. char buf[100]={0}; sprintf(buf, "%d,%d | %d Lines", se->CursorLine+1, se->CursorBefore+1, se->TotalLines);
  1090. 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);
  1091. }
  1092. //if (ui->Extra && ui->Extra->Edit) la_SingleLineStringDrawSelection(ui, ui->L, ui->U, bt, temp, ui->Extra->Edit);
  1093. tnsFlush();
  1094. }
  1095. void la_UiSeperatorDraw(laUiItem *ui, int h){
  1096. laBoxedTheme *bt = (*ui->Type->Theme);
  1097. if (!bt) return;
  1098. if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){
  1099. char str[]="🞄";
  1100. int strw=tnsStringGetWidth(str,0, 0);
  1101. tnsDrawStringM(str, 0, laThemeColor(bt,LA_BT_BORDER), ui->L+(ui->R-ui->L-strw)/2, ui->R, ui->U, 0);
  1102. }else{
  1103. tnsUseNoTexture();
  1104. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1105. real u=(ui->U+ui->B)/2; tnsVertex2d(ui->L, u); tnsVertex2d(ui->R, (ui->U+ui->B)/2);
  1106. tnsPackAs(GL_LINES);
  1107. }
  1108. }
  1109. void la_ColorCircleDrawHCY(laUiItem *ui, int h){
  1110. laBoxedTheme *bt = (*ui->Type->Theme);
  1111. real c = (real)((ui->R + ui->L) / 2) - h / 2; /*- bt->RM*/
  1112. real r = (ui->B - ui->U - bt->TP - bt->BP) / 2;
  1113. int i = 0;
  1114. real colors[584]={0}; //4*72*2+4*2
  1115. real verts[292]={0}; //72*2*2+2*2
  1116. real hcy[3] = {0, 1, 1};
  1117. real step = 1.0 / 72.0f;
  1118. real RealColor[4] = {0,0,0,1};
  1119. real PickerPos[2];
  1120. real pi_4;
  1121. GLuint index[26];
  1122. real v, cv, sv;
  1123. real lw = (float)(ui->B-ui->U)/LA_RH/5; if(lw<1.0f) lw=1.0f;
  1124. laGetFloatArray(&ui->PP, RealColor);
  1125. if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LogsRGB(RealColor); }
  1126. tnsRGB2HCY(RealColor, hcy);
  1127. PickerPos[0] = c + cos(hcy[0] * TNS_PI * 2) * pow(hcy[1],1.0f/MAIN.ColorPickerGamma) * r;
  1128. PickerPos[1] = ui->U + r + sin(hcy[0] * TNS_PI * 2) * pow(hcy[1],1.0f/MAIN.ColorPickerGamma) * r;
  1129. hcy[0] = 0;
  1130. hcy[1] = 1;
  1131. for (i; i < 72; i += 1){
  1132. int beg = i * 8;
  1133. hcy[0]+=step; tnsVectorSet3v(&colors[beg],hcy); colors[beg+3]=1;
  1134. tnsVectorSet4v(&colors[beg+4],&colors[beg]); colors[beg+5]=0;
  1135. }
  1136. tnsFlush();
  1137. int IsClay=ui->Flags&LA_UI_FLAGS_COLOR_SPACE_CLAY;
  1138. int ShowInfo=0;
  1139. if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_SRGB && (!IsClay)){
  1140. tnsUniformShowColorOverflowStripes(T->immShader,1);
  1141. }
  1142. if(IsClay){
  1143. tnsUniformInputColorSpace(T->immShader,TNS_COLOR_SPACE_CLAY);
  1144. if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_CLAY) ShowInfo=1;
  1145. }else{
  1146. tnsUniformInputColorSpace(T->immShader,TNS_COLOR_SPACE_SRGB);
  1147. }
  1148. tnsUseNoTexture();
  1149. tnsVectorSet4(&colors[576],1,1,hcy[2],1);
  1150. tnsVectorSet4(&colors[580],1,0,hcy[2],1);
  1151. tnsColorArray4d(colors, 146);
  1152. tnsMakeCircle2d(verts, 72, c, ui->U + r, r, 1);
  1153. for(int i=0;i<73;i++){ tnsVectorSet2(&verts[2+i*4],c,ui->U + r); }
  1154. tnsVectorSet2v(&verts[288],&verts[0]);
  1155. tnsVectorSet2v(&verts[290],&verts[2]);
  1156. tnsVertexArray2d(verts, 146);
  1157. tnsPackAs(GL_TRIANGLE_STRIP);
  1158. tnsUniformColorMode(T->immShader,1); tnsUniformHCYGamma(T->immShader,MAIN.ColorPickerGamma);
  1159. tnsFlush();
  1160. tnsUniformColorMode(T->immShader,0);
  1161. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1162. tnsMakeCircle2d(verts, 72, c, ui->U + r, r, 0);
  1163. tnsVertexArray2d(verts, 72);
  1164. tnsPackAs(GL_LINE_LOOP);
  1165. pi_4 = TNS_PI / 4;
  1166. tnsMakeArc2d(&verts[26], 12, c, ui->U + r, r + bt->LM + h, pi_4, -pi_4);
  1167. tnsMakeArc2d(verts, 12, c, ui->U + r, r + bt->LM, pi_4, -pi_4);
  1168. tnsMakeLinerGradient4d(&colors[52], 13, 0, 0, 0, 1, 1, 1, 1, 1);
  1169. tnsMakeLinerGradient4d(colors, 13, 0, 0, 0, 1, 1, 1, 1, 1);
  1170. tnsMakeBridgedIndex(index, 13, 0, 0);
  1171. tnsColorArray4d(colors, 26);
  1172. tnsVertexArray2d(verts, 26);
  1173. tnsIndexArray(index, 26);
  1174. tnsPackAs(GL_QUAD_STRIP);
  1175. tnsMakeArc2d(&verts[26], 12, c, ui->U + r, r + bt->LM + h, -pi_4, pi_4);
  1176. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1177. tnsVertexArray2d(verts, 26);
  1178. tnsPackAs(GL_LINE_LOOP);
  1179. v = -hcy[2] + 0.5;
  1180. cv = cos(v / 2 * TNS_PI);
  1181. sv = sin(v / 2 * TNS_PI);
  1182. tnsLineWidth(lw);
  1183. verts[0] = cv * r + c; verts[1] = sv * r + ui->U + r;
  1184. verts[2] = cv * (r + h) + c; verts[3] = sv * (r + h) + ui->U + r;
  1185. tnsColor4d(1, 1, 1, 1);
  1186. tnsVertexArray2d(verts, 2);
  1187. tnsPackAs(GL_LINES);
  1188. verts[1]+=lw; verts[3]+=lw;
  1189. tnsColor4d(0, 0, 0, 1);
  1190. tnsVertexArray2d(verts, 2);
  1191. tnsPackAs(GL_LINES);
  1192. real circleR=lw*8;
  1193. tnsColor4dv(RealColor);
  1194. tnsMakeCircle2d(verts, 16, PickerPos[0], PickerPos[1], circleR,0);
  1195. tnsVertexArray2d(verts, 16);
  1196. tnsPackAs(GL_TRIANGLE_FAN);
  1197. tnsColor4d(1, 1, 1, 1);
  1198. tnsVertexArray2d(verts, 16);
  1199. tnsPackAs(GL_LINE_LOOP);
  1200. tnsMakeCircle2d(verts, 16, PickerPos[0], PickerPos[1], circleR-lw,0);
  1201. tnsColor4d(0.1, 0.1, 0.1, 1);
  1202. tnsVertexArray2d(verts, 16);
  1203. tnsPackAs(GL_LINE_LOOP);
  1204. tnsLineWidth(1);
  1205. if(ui->Extra->HeightCoeff>=0) tnsDrawStringAuto("◿",laThemeColor(bt,LA_BT_BORDER),ui->R-LA_RH, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
  1206. if(IsClay) tnsDrawStringAuto("Clay",laThemeColor(bt,LA_BT_BORDER),ui->L, c-r+LA_RH, ui->U+bt->TM, LA_TEXT_ALIGN_RIGHT|LA_TEXT_MONO);
  1207. if(ShowInfo) tnsDrawStringAuto("🛈",laThemeColor(bt,LA_BT_TEXT),c-r, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_LEFT);
  1208. tnsFlush();
  1209. tnsUniformShowColorOverflowStripes(T->immShader,0);
  1210. tnsUniformInputColorSpace(T->immShader,0);
  1211. }
  1212. void la_MenuItemDraw(laUiItem *ui, int h){
  1213. laBoxedTheme *bt = (*ui->Type->Theme);
  1214. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  1215. if(!NoDecal){
  1216. tnsUseNoTexture();
  1217. tnsColor4dv(laThemeColor(bt, ui->State));
  1218. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1219. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1220. tnsPackAs(GL_TRIANGLE_FAN);
  1221. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  1222. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1223. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1224. tnsPackAs(GL_LINE_LOOP);
  1225. }
  1226. tnsDrawStringAuto(transLate(ui->Display->Ptr), laThemeColor(bt, LA_BT_TEXT|ui->State), ui->L+bt->LM, ui->R, ui->U, ui->Flags);
  1227. }
  1228. void la_ConditionToggleDraw(laUiItem *ui, int h){
  1229. laBoxedTheme *bt = (*ui->Type->Theme);
  1230. char temp[128] = {0};
  1231. char *buf[LA_RAW_CSTR_MAX_LEN];
  1232. uint32_t IconID;
  1233. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  1234. if (!ui->State) ui->State = LA_UI_NORMAL;
  1235. int UseState=ui->State;
  1236. if (!(ui->Flags&LA_TEXT_ALIGN)) ui->Flags|=LA_TEXT_ALIGN_CENTER;
  1237. if(!NoDecal){
  1238. tnsUseNoTexture();
  1239. tnsColor4dv(laThemeColor(bt, ui->State));
  1240. tnsVertex2d(ui->L, ui->U);
  1241. tnsVertex2d(ui->R, ui->U);
  1242. tnsVertex2d(ui->R, ui->B);
  1243. tnsVertex2d(ui->L, ui->B);
  1244. tnsPackAs(GL_TRIANGLE_FAN);
  1245. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  1246. tnsVertex2d(ui->L, ui->U);
  1247. tnsVertex2d(ui->R, ui->U);
  1248. tnsVertex2d(ui->R, ui->B);
  1249. tnsVertex2d(ui->L, ui->B);
  1250. tnsPackAs(GL_LINE_LOOP);
  1251. }else{
  1252. UseState=LA_UI_NORMAL;
  1253. }
  1254. buf[0] = 0;
  1255. if (ui->ExtraInstructions){
  1256. if (ui->Type->OperatorType->ParseArgs){
  1257. ui->Type->OperatorType->ParseArgs(ui->Instructions, &IconID, buf);
  1258. }
  1259. }
  1260. if (buf[0]) tnsDrawStringAuto(transLate(buf), laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
  1261. else
  1262. tnsDrawStringAuto(ui->State == LA_UI_ACTIVE ? "⯆" : "⯈", laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
  1263. }
  1264. void la_DrawColumnAdjusterRecursive(int U, int B, laColumn *c, int W, tnsVector3d color, int LeftMost){
  1265. if (c->LS){
  1266. la_DrawColumnAdjusterRecursive(U, B, c->LS, W, color, LeftMost);
  1267. la_DrawColumnAdjusterRecursive(U, B, c->RS, W, color, LeftMost);
  1268. }else{
  1269. if(c->IL==LeftMost) return;
  1270. tnsDrawStringAuto("⌉⌈", color, c->IL-LA_RH, c->IL+LA_RH, U, LA_TEXT_ALIGN_CENTER);
  1271. }
  1272. }
  1273. void la_ColumnAdjusterDraw(laUiItem *ui, int h){
  1274. laBoxedTheme *bt = (*ui->Type->Theme);
  1275. tnsUseNoTexture();
  1276. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
  1277. la_DrawColumnAdjusterRecursive(ui->U, ui->U + LA_RH, ui->C, (bt->LM+bt->RM)/2, laThemeColor(bt, LA_BT_TEXT), ui->C->IL);
  1278. }
  1279. void la_ColumnViewerDraw(laUiItem *ui, int h){
  1280. laBoxedTheme *bt = (*ui->Type->Theme);
  1281. laColumn *c = ui->PP.EndInstance;
  1282. int W = ui->R - ui->L - bt->LM - bt->RM;
  1283. //if (c->IR == c->IL)
  1284. // return;
  1285. int T = c->Top->IR - c->Top->IL;
  1286. int L = (int)((real)(c->IL - c->Top->IL) * W / T) + ui->L + bt->LM,
  1287. R = (int)((real)(c->IR - c->Top->IL) * W / T) + ui->L + bt->LM;
  1288. tnsUseNoTexture();
  1289. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1290. tnsVertex2d(L, ui->U + bt->TM);
  1291. tnsVertex2d(R, ui->U + bt->TM);
  1292. tnsVertex2d(R, ui->B - bt->BM);
  1293. tnsVertex2d(L, ui->B - bt->BM);
  1294. tnsPackAs(GL_TRIANGLE_FAN);
  1295. }
  1296. void la_NodeSocketDraw(laUiItem *ui, int h){
  1297. laBoxedTheme *bt = (*ui->Type->Theme);
  1298. char* label=0; char* icon;
  1299. laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
  1300. real* ColorBkg=0,*ColorSocket;
  1301. 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:""; }
  1302. 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:""; }
  1303. int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
  1304. tnsUseNoTexture();
  1305. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1306. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1307. tnsColor4dv(ColorBkg);
  1308. tnsPackAs(GL_TRIANGLE_FAN);
  1309. int tl,tr,tu,sl,sr,su;
  1310. 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; }
  1311. 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; }
  1312. 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; }
  1313. 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; }
  1314. else{ sl=ui->L; su=ui->U; sr=ui->R; label=0; }
  1315. tnsDrawStringAuto("⭗", IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):ColorSocket, sl, sr, su, LA_TEXT_ALIGN_CENTER);
  1316. if(label) tnsDrawStringAuto(label, IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):ColorSocket, tl, tr, tu, LA_TEXT_ALIGN_CENTER|LA_TEXT_MONO);
  1317. }
  1318. void la_HeightAdjusterDraw(laUiItem *ui, int h){
  1319. laBoxedTheme *bt = (*ui->Type->Theme);
  1320. char* str="☰";
  1321. if(ui->State==LA_BT_ACTIVE){ str="🡙"; }
  1322. tnsDrawStringAuto(str, laThemeColor(bt,LA_BT_TEXT), ui->L-1000, ui->R+1000, ui->U, LA_TEXT_ALIGN_CENTER);
  1323. }
  1324. void la_RawPropDraw(laUiItem *ui, int h){
  1325. laBoxedTheme *bt = (*ui->Type->Theme);
  1326. int s=0;
  1327. //void* data=laGetRaw(&ui->PP, &s);
  1328. //char* buf[128]; sprintf(buf,"%d bytes of raw data at 0x%0x", s, data);
  1329. tnsDrawStringAuto("RAW DATA", laThemeColor(bt,LA_BT_TEXT), ui->L, ui->R, ui->U, ui->Flags|LA_TEXT_MONO);
  1330. }
  1331. void la_MapperDraw(laUiItem *ui, int h){
  1332. laBoxedTheme *bt = (*ui->Type->Theme);
  1333. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  1334. if(!NoDecal){
  1335. tnsUseNoTexture();
  1336. tnsColor4dv(laThemeColor(bt, LA_BT_NORMAL));
  1337. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1338. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1339. tnsPackAs(GL_TRIANGLE_FAN);
  1340. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  1341. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1342. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1343. tnsPackAs(GL_LINE_LOOP);
  1344. }
  1345. laPropContainer* pc=la_EnsureSubTarget(ui->PP.LastPs->p,ui->PP.EndInstance);
  1346. if(!pc || pc!=LA_PC_MAPPER || !ui->PP.EndInstance){
  1347. tnsDrawStringAuto("Property is not a la_value_mapper.",0,ui->L+bt->LM,ui->R-bt->RM,bt->TM,LA_TEXT_LINE_WRAP); return;
  1348. }
  1349. laValueMapper* vm=ui->PP.EndInstance; int any=0;
  1350. tnsColor4dv(laAccentColor(LA_BT_TEXT));
  1351. for(laValueMapperPoint* vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
  1352. tnsVertex2d(tnsInterpolate(ui->L,ui->R,vmp->x),tnsInterpolate(ui->B,ui->U,vmp->y)); any++;
  1353. } tnsPackAs(GL_LINE_STRIP);
  1354. for(laValueMapperPoint* vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
  1355. tnsVertex2d(tnsInterpolate(ui->L,ui->R,vmp->x),tnsInterpolate(ui->B,ui->U,vmp->y));
  1356. } tnsPackAs(GL_POINTS);
  1357. if(any){ glLineWidth(2); glPointSize(5); tnsFlush(); glPointSize(1); glLineWidth(1); }
  1358. }
  1359. void la_ImageDraw(laUiItem *ui, int h){
  1360. laBoxedTheme *bt = (*ui->Type->Theme);
  1361. tnsImage* im=ui->Extra;
  1362. if(!im->Texture) { tns_ImageToTexture(im); }
  1363. if(!im->Texture) {
  1364. tnsUseNoTexture();
  1365. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1366. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1367. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1368. tnsPackAs(GL_LINE_LOOP);
  1369. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->B);
  1370. tnsVertex2d(ui->R, ui->U); tnsVertex2d(ui->L, ui->B);
  1371. tnsPackAs(GL_LINES);
  1372. return;
  1373. }
  1374. int W=im->Texture->Width, H=im->Texture->Height;
  1375. int Full=ui->Flags&LA_UI_IMAGE_FULL_W;
  1376. real r=(real)(ui->R-ui->L)/W; if(r<1){W*=r;H*=r;}
  1377. real UseW=Full?(W):((real)LA_RH*ui->SymbolID/H*W);
  1378. real L=(ui->R-ui->L-UseW)/2,U=0,UseH=Full?H:(ui->B-ui->U);
  1379. if(Full){ U=(ui->B-ui->U-H)/2; }
  1380. if(ui->Flags&LA_TEXT_ALIGN_CENTER){ L=0; }
  1381. elif(ui->Flags&LA_TEXT_ALIGN_RIGHT){ L=ui->R-ui->L-UseW; }
  1382. tnsDraw2DTextureDirectly(im->Texture,ui->L+L,ui->U+U,UseW,UseH);
  1383. tnsFlush();
  1384. }
  1385. void la_ValueMeterType1Draw(laUiItem *ui, int h){
  1386. laBoxedTheme *bt = (*ui->Type->Theme);
  1387. int DataI[8]; real Data[8];
  1388. int Len, i, W; real Seg;
  1389. char buf[48] = {0};
  1390. char buf2[48] = {0};
  1391. char prefix[8][64] = {0};
  1392. int Original;
  1393. int Imin=-100, Imax=100;
  1394. real min=-100, max=100;
  1395. int s, State; int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  1396. int NoLabel=ui->Flags&LA_UI_FLAGS_NO_LABEL;
  1397. int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
  1398. Len = laGetArrayLength(&ui->PP);
  1399. laGetPrefixP(&ui->PP, prefix);
  1400. if(IsInt){
  1401. laGetIntArray(&ui->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
  1402. laGetIntRange(&ui->PP, &Imin, &Imax); min=Imin; max=Imax;
  1403. }else{
  1404. laGetFloatArray(&ui->PP, Data);
  1405. laGetFloatRange(&ui->PP,&min,&max);
  1406. }
  1407. for (i = 0; i < Len; i++){
  1408. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  1409. if(IsVertical){
  1410. Seg = (real)(ui->R-ui->L)/Len;
  1411. _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
  1412. }else{
  1413. Seg = (real)(ui->B-ui->U)/Len;
  1414. _U = ui->U + i * Seg; _B=_U+Seg;
  1415. }
  1416. tnsUseNoTexture();
  1417. tnsColor4dv(laThemeColor(bt,ui->State));
  1418. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1419. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1420. tnsPackAs(GL_TRIANGLE_FAN);
  1421. int oflow=0,ofhigh=0;
  1422. if(Data[i]<min){ oflow=1; Data[i]=min; }
  1423. if(Data[i]>max){ ofhigh=1; Data[i]=max; }
  1424. int R1=_R,U1=_U;
  1425. if(IsVertical){ U1 = (real)(max - Data[i]) / (real)(max - min) * (real)(_B-_U) + _U; }
  1426. else{ R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(_R-_L) + _L; }
  1427. tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
  1428. tnsColor4d(LA_COLOR3(color),0.4);
  1429. tnsVertex2d(_L, U1); tnsVertex2d(R1, U1);
  1430. tnsVertex2d(R1, _B); tnsVertex2d(_L, _B);
  1431. tnsPackAs(GL_TRIANGLE_FAN);
  1432. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1433. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1434. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1435. tnsPackAs(GL_LINE_LOOP);
  1436. if(!NoLabel){
  1437. if(Len==1){ sprintf(buf,ui->PP.LastPs->p->Name); } else{ if(i<8)sprintf(buf,prefix[i]); }
  1438. if(buf[0]) tnsDrawStringAuto(buf, laThemeColor(bt, LA_BT_TEXT), _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
  1439. }
  1440. if(IsVertical){
  1441. if(oflow){ tnsDrawStringAuto("⯆",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_CENTER); }
  1442. elif(ofhigh){ tnsDrawStringAuto("⯅",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _B-LA_RH, LA_TEXT_ALIGN_CENTER); }
  1443. }else{
  1444. if(oflow){ tnsDrawStringAuto("⯇",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_LEFT); }
  1445. elif(ofhigh){ tnsDrawStringAuto("⯈",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_RIGHT); }
  1446. }
  1447. }
  1448. int trisize=LA_RH/3.0f;
  1449. for(laCompoundPP* CPP=ui->CompoundPPs.pFirst;CPP;CPP=CPP->Item.pNext){
  1450. IsInt=(CPP->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
  1451. Len = laGetArrayLength(&CPP->PP);
  1452. laGetPrefixP(&CPP->PP, prefix);
  1453. if(IsInt){
  1454. laGetIntArray(&CPP->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
  1455. laGetIntRange(&CPP->PP, &Imin, &Imax); min=Imin; max=Imax;
  1456. }else{
  1457. laGetFloatArray(&CPP->PP, Data);
  1458. laGetFloatRange(&CPP->PP,&min,&max);
  1459. }
  1460. if(CPP->Slot <= LA_SLOT_MARKER_4){
  1461. for (i = 0; i < Len; i++){
  1462. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  1463. if(IsVertical){
  1464. Seg = (real)(ui->R-ui->L)/Len;
  1465. _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
  1466. }else{
  1467. Seg = (real)(ui->B-ui->U)/Len;
  1468. _U = ui->U + i * Seg; _B=_U+Seg;
  1469. }
  1470. int R1=_R,U1=_U;
  1471. if(IsVertical){ U1 = (real)(max - Data[i]) / (real)(max - min) * (real)(_B-_U) + _U; }
  1472. else{ R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(_R-_L) + _L; }
  1473. tnsUseNoTexture();
  1474. tnsColor4dv(laAccentColor(LA_BT_TEXT));
  1475. if(IsVertical){ tnsVertex2d(_L, U1); tnsVertex2d(R1, U1); }
  1476. else{ tnsVertex2d(R1, U1); tnsVertex2d(R1, _B); }
  1477. tnsPackAs(GL_LINES);
  1478. if(IsVertical){
  1479. if(! CPP->Slot % 2){ tnsVertex2d(_L, U1+trisize); tnsVertex2d(_L+trisize, U1); tnsVertex2d(_L, U1-trisize); }
  1480. else{ tnsVertex2d(_R, U1+trisize); tnsVertex2d(_R-trisize, U1); tnsVertex2d(_R, U1-trisize); }
  1481. }
  1482. else{
  1483. if(! CPP->Slot % 2){ tnsVertex2d(R1-trisize, _B); tnsVertex2d(R1, _B-trisize); tnsVertex2d(R1+trisize, _B); }
  1484. else{ tnsVertex2d(R1-trisize, U1); tnsVertex2d(R1, U1+trisize); tnsVertex2d(R1+trisize, U1); }
  1485. }
  1486. tnsPackAs(GL_TRIANGLES);
  1487. }
  1488. }
  1489. }
  1490. tnsFlush();
  1491. }
  1492. void la_ValueMeterType2Draw(laUiItem *ui, int h){
  1493. laBoxedTheme *bt = (*ui->Type->Theme);
  1494. int DataI[8]; real Data[8]; int SDataI[8]; real SData[8]; int Len, i, W; real Seg;
  1495. char buf[48] = {0}; char buf2[48] = {0};char prefix[16][64] = {0};char limits[2][64]={0};
  1496. int Original;
  1497. int Imin=-100, Imax=100; real min=-100, max=100;
  1498. int s, State; int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  1499. int NoLabel=ui->Flags&LA_UI_FLAGS_NO_LABEL;
  1500. int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
  1501. Len = laGetArrayLength(&ui->PP);
  1502. laGetPrefixP(&ui->PP, prefix);
  1503. if(IsInt){
  1504. laGetIntArray(&ui->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
  1505. laGetIntRange(&ui->PP, &Imin, &Imax); min=Imin; max=Imax;
  1506. sprintf(limits[0],"%d",Imin); sprintf(limits[1],"%d",Imax);
  1507. }else{
  1508. laGetFloatArray(&ui->PP, Data);
  1509. laGetFloatRange(&ui->PP,&min,&max);
  1510. sprintf(limits[0],"%lf",min); sprintf(limits[1],"%lf",max);
  1511. }
  1512. int sl = TNS_MAX2(abs(ui->SymbolID),5);
  1513. int ScaleLen = sl * LA_RH;
  1514. real seg = abs(ui->TemplateContext)/100;
  1515. int times=1,times10=0;
  1516. while((max-min)/seg > ScaleLen/10){
  1517. seg*=10;
  1518. }
  1519. if(seg>100){ int sseg=seg; while(sseg>=100){ sseg/=10; times*=10; times10++; } }
  1520. for (i = 0; i < Len; i++){
  1521. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  1522. if(IsVertical){
  1523. Seg = (real)(ui->R-ui->L)/Len;
  1524. _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
  1525. }else{
  1526. Seg = (real)(ui->B-ui->U)/Len;
  1527. _U = ui->U + i * Seg; _B=_U+Seg;
  1528. }
  1529. real cx=(_L+_R)/2,cy=(_U+_B)/2,cw=(_R-_L),ch=(_B-_U);
  1530. tnsPushStringClip(_L,_R,_U,_B);
  1531. tnsUseNoTexture();
  1532. tnsColor4dv(laThemeColor(bt,ui->State));
  1533. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1534. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1535. tnsPackAs(GL_TRIANGLE_FAN);
  1536. int oflow=0,ofhigh=0;
  1537. if(Data[i]<min){ oflow=1; Data[i]=min; }
  1538. if(Data[i]>max){ ofhigh=1; Data[i]=max; }
  1539. real fac = (real)(Data[i]-min) / (real)(max - min);
  1540. int SL,SR,SU,SB,_SL,_SR,_SU,_SB,Move = fac*ScaleLen;
  1541. if(IsVertical){ SL=_L; SR=_R; SB=_SB=cy+Move; SU=_SU=SB-ScaleLen; TNS_CLAMP(SB,_U,_B); TNS_CLAMP(SU,_U,_B); }
  1542. else{ SL=_SL=cx-Move; SR=_SR=SL+ScaleLen; SB=_B; SU=_U; TNS_CLAMP(SL,_L,_R); TNS_CLAMP(SR,_L,_R); }
  1543. tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
  1544. tnsColor4d(LA_COLOR3(color),0.3);
  1545. tnsVertex2d(SL, SU); tnsVertex2d(SR, SU);
  1546. tnsVertex2d(SR, SB); tnsVertex2d(SL, SB);
  1547. tnsPackAs(GL_TRIANGLE_FAN);
  1548. tnsColor4d(LA_COLOR3(color),0.7);
  1549. int scalelow=min/seg-1, scalehigh=max/seg+1;
  1550. for(int si=scalelow;si<=scalehigh;si++){
  1551. for(int ssi=0;ssi<10;ssi++){
  1552. real val=si*seg + ssi*0.1*seg; if(val<min) continue; if(val>max) break;
  1553. real sfac = (real)(val-min) / (max - min); int smove=Move-sfac*ScaleLen;
  1554. real lfac = ssi==0?(si==ssi?0.5:0.3):(ssi==5?0.2:0.1);
  1555. if(IsVertical){ int scaleb=cy+smove; if(scaleb>_B || scaleb<_U) continue;
  1556. tnsVertex2d(cx-cw*lfac,scaleb); tnsVertex2d(cx+cw*lfac,scaleb);
  1557. }else{ int scalel=cx-smove; if(scalel<_L || scalel>_R) continue;
  1558. tnsVertex2d(scalel,cy+ch*lfac); tnsVertex2d(scalel,cy-ch*lfac);
  1559. }
  1560. }
  1561. }
  1562. tnsPackAs(GL_LINES);
  1563. if(!NoLabel){
  1564. for(int si=scalelow;si<=scalehigh;si++){
  1565. real val=si*seg; if(val<min) continue; if(val>max) break;
  1566. real sfac = (real)(val-min) / (max - min); int smove=Move-sfac*ScaleLen;
  1567. if(IsInt) sprintf(buf,"%.0lf",val/times); else sprintf(buf,"%.2lf",val/times);
  1568. if(IsVertical){ int scaleb=cy+smove; if(scaleb>_B+LA_RH2 || scaleb<_U-LA_RH2) continue;
  1569. tnsDrawStringAuto(buf,laThemeColor(bt,LA_BT_TEXT),_L+bt->LM,_R-bt->RM,scaleb-LA_RH2,ui->Flags);
  1570. }else{ int scalel=cx-smove; if(scalel<_L-100 || scalel>_R+100) continue;
  1571. tnsDrawStringAuto(buf,laThemeColor(bt,LA_BT_TEXT),scalel-100,scalel+100,_U,ui->Flags);
  1572. }
  1573. }
  1574. if(IsVertical){
  1575. tnsDrawStringAuto(limits[0],laThemeColor(bt,LA_BT_TEXT|ui->State),_L+bt->LM,_R-bt->RM,_SB,ui->Flags);
  1576. tnsDrawStringAuto(limits[1],laThemeColor(bt,LA_BT_TEXT|ui->State),_L+bt->LM,_R-bt->RM,_SU-LA_RH,ui->Flags);
  1577. }else{
  1578. tnsDrawStringAuto(limits[0],laThemeColor(bt,LA_BT_TEXT|ui->State),_SL-100,_SL-bt->LM,_B-LA_RH,LA_TEXT_ALIGN_RIGHT);
  1579. tnsDrawStringAuto(limits[1],laThemeColor(bt,LA_BT_TEXT|ui->State),_SR+bt->RM,_SR+100,_B-LA_RH,LA_TEXT_ALIGN_LEFT);
  1580. }
  1581. }
  1582. tnsUseNoTexture();
  1583. tnsColor4dv(laAccentColor(LA_BT_BORDER));
  1584. if(IsVertical){tnsVertex2d(_L,cy); tnsVertex2d(_R,cy);}
  1585. else{tnsVertex2d(cx,_U); tnsVertex2d(cx,_B);}
  1586. tnsPackAs(GL_LINES);
  1587. if(times!=1){ sprintf(buf,"%d",times10);
  1588. if(IsVertical && cw>LA_RH) tnsDrawStringAuto(buf,laAccentColor(LA_BT_BORDER),_L+bt->LM,_R-bt->RM,cy,LA_TEXT_MONO|LA_TEXT_ALIGN_RIGHT);
  1589. elif(ch>LA_RH) tnsDrawStringAuto(buf,laAccentColor(LA_BT_BORDER),cx+bt->LM,cx+100,_U,LA_TEXT_MONO|LA_TEXT_ALIGN_LEFT);
  1590. }
  1591. tnsUseNoTexture();
  1592. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1593. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1594. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1595. tnsPackAs(GL_LINE_LOOP);
  1596. //if(IsVertical){
  1597. // if(oflow){ tnsDrawStringAuto("⯆",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_CENTER); }
  1598. // elif(ofhigh){ tnsDrawStringAuto("⯅",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _B-LA_RH, LA_TEXT_ALIGN_CENTER); }
  1599. //}else{
  1600. // if(oflow){ tnsDrawStringAuto("⯇",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_LEFT); }
  1601. // elif(ofhigh){ tnsDrawStringAuto("⯈",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_RIGHT); }
  1602. //}
  1603. tnsPopStringClip();
  1604. }
  1605. int trisize=LA_RH/3.0f;
  1606. for(laCompoundPP* CPP=ui->CompoundPPs.pFirst;CPP;CPP=CPP->Item.pNext){
  1607. IsInt=(CPP->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
  1608. Len = laGetArrayLength(&CPP->PP);
  1609. laGetPrefixP(&CPP->PP, prefix);
  1610. if(IsInt){
  1611. laGetIntArray(&CPP->PP, SDataI); for(int i=0;i<Len;i++){ SData[i]=SDataI[i]; }
  1612. //laGetIntRange(&CPP->PP, &Imin, &Imax); min=Imin; max=Imax;
  1613. }else{
  1614. laGetFloatArray(&CPP->PP, SData);
  1615. //laGetFloatRange(&CPP->PP,&min,&max);
  1616. }
  1617. if(CPP->Slot <= LA_SLOT_MARKER_4){
  1618. for (i = 0; i < Len; i++){
  1619. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  1620. if(IsVertical){
  1621. Seg = (real)(ui->R-ui->L)/Len;
  1622. _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
  1623. }else{
  1624. Seg = (real)(ui->B-ui->U)/Len;
  1625. _U = ui->U + i * Seg; _B=_U+Seg;
  1626. }
  1627. real cx=(_L+_R)/2,cy=(_U+_B)/2,cw=(_R-_L),ch=(_B-_U);
  1628. real sfac = (real)(SData[i]-min) / (real)(max - min);
  1629. real fac = (real)(Data[i]-min) / (real)(max - min);
  1630. int SL,SR,SU,SB,_SL,_SR,_SU,_SB, Move = fac*ScaleLen,SMove=sfac*ScaleLen;
  1631. if(IsVertical){ _SB=SB=cy+Move-SMove; TNS_CLAMP(SB,_U,_B); }
  1632. else{ SL=_SL=cx-Move+SMove; TNS_CLAMP(SL,_L,_R); }
  1633. tnsUseNoTexture();
  1634. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT|LA_BT_ACTIVE));
  1635. if(IsVertical){ tnsVertex2d(_L, SB); tnsVertex2d(_R, SB); }
  1636. else{ tnsVertex2d(SL, _U); tnsVertex2d(SL, _B); }
  1637. tnsPackAs(GL_LINES);
  1638. if(IsVertical){
  1639. if(! CPP->Slot % 2){ tnsVertex2d(_L, SB); tnsVertex2d(_L+trisize, SB); tnsVertex2d(_L, SB-trisize); }
  1640. else{ tnsVertex2d(_R, SB+trisize); tnsVertex2d(_R-trisize, SB); tnsVertex2d(_R, SB); }
  1641. if(SB==_SB){ tnsPackAs(GL_TRIANGLES); }else{ tnsPackAs(GL_LINE_LOOP); }
  1642. }
  1643. else{
  1644. if(! CPP->Slot % 2){ tnsVertex2d(SL, _B); tnsVertex2d(SL, _B-trisize); tnsVertex2d(SL+trisize, _B); }
  1645. else{ tnsVertex2d(SL-trisize, _U); tnsVertex2d(SL, _U+trisize); tnsVertex2d(SL, _U); }
  1646. if(SL==_SL){ tnsPackAs(GL_TRIANGLES); }else{ tnsPackAs(GL_LINE_LOOP); }
  1647. }
  1648. }
  1649. }
  1650. }
  1651. tnsFlush();
  1652. }
  1653. void la_ValueMeter2DDraw(laUiItem *ui, int h){
  1654. laBoxedTheme *bt = (*ui->Type->Theme);
  1655. int DataI[8]; real Data[8];
  1656. int Len, i, W; real Seg;
  1657. char buf[48] = {0};
  1658. char buf2[48] = {0};
  1659. char prefix[8][64] = {0};
  1660. int Original;
  1661. int Imin=-100, Imax=100;
  1662. real min=-100, max=100;
  1663. int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
  1664. Len = laGetArrayLength(&ui->PP);
  1665. laGetPrefixP(&ui->PP, prefix);
  1666. if(IsInt){
  1667. laGetIntArray(&ui->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
  1668. laGetIntRange(&ui->PP, &Imin, &Imax); min=Imin; max=Imax;
  1669. }else{
  1670. laGetFloatArray(&ui->PP, Data);
  1671. laGetFloatRange(&ui->PP,&min,&max);
  1672. }
  1673. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  1674. tnsUseNoTexture();
  1675. tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
  1676. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1677. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1678. tnsPackAs(GL_TRIANGLE_FAN);
  1679. real CL=(real)(Data[0] - min) / (real)(max - min) * (real)(_R-_L) + _L;
  1680. real CU=(real)(max - Data[1]) / (real)(max - min) * (real)(_B-_U) + _U;
  1681. real HW=((real)_R-(real)_L)/4; real HH=((real)_B-(real)_U)/4;
  1682. real ML=((real)_R+(real)_L)/2; real MU=((real)_B+(real)_U)/2;
  1683. tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
  1684. tnsColor4d(LA_COLOR3(color),0.4);
  1685. tnsVertex2d(ML+HW, MU+HH); tnsVertex2d(ML-HW, MU+HH);
  1686. tnsVertex2d(ML-HW, MU-HH); tnsVertex2d(ML+HW, MU-HH);
  1687. tnsPackAs(GL_LINE_LOOP);
  1688. tnsVertex2d(_L,_U); tnsVertex2d(_R,_B);
  1689. tnsVertex2d(_R,_U); tnsVertex2d(_L,_B);
  1690. tnsVertex2d(ML,_U); tnsVertex2d(ML,_B);
  1691. tnsVertex2d(_R,MU); tnsVertex2d(_L,MU);
  1692. tnsPackAs(GL_LINES);
  1693. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1694. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1695. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1696. tnsPackAs(GL_LINE_LOOP);
  1697. tnsFlush();
  1698. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
  1699. tnsVertex2d(_L, CU); tnsVertex2d(_R, CU);
  1700. tnsVertex2d(CL, _U); tnsVertex2d(CL, _B);
  1701. tnsPackAs(GL_LINES);
  1702. real circle[48];
  1703. tnsMakeCircle2d(circle,24,CL,CU,LA_RH2,0);
  1704. tnsVertexArray2d(circle,24);
  1705. tnsPackAs(GL_LINE_LOOP);
  1706. glLineWidth(2);
  1707. tnsFlush();
  1708. glLineWidth(1);
  1709. }
  1710. void la_ScopeDraw(laUiItem *ui, int h){
  1711. laBoxedTheme *bt = (*ui->Type->Theme); laSynthNodeScope* s=ui->PP.EndInstance;
  1712. if(!s) return;
  1713. real* lcolor=laAccentColor(LA_BT_TEXT); int plen=LA_SYNTH_PLEN;
  1714. int cl=ui->L+2, cr=ui->R-2, cu=ui->U+2, cb=ui->B-2; real cc=(real)(cu+cb)/2;
  1715. real yfac1=(real)(1<<(s->Gain1+1))/4.0f, yfac2=(real)(1<<(s->Gain2+1))/4.0f; yfac1/=10; yfac2/=10;
  1716. real off1=s->Offset1/20*(cb-cu), off2=s->Offset2/20*(cb-cu);
  1717. real arrx[LA_SYNTH_PLEN];
  1718. real arru1[LA_SYNTH_PLEN],arrb1[LA_SYNTH_PLEN];
  1719. real arru2[LA_SYNTH_PLEN],arrb2[LA_SYNTH_PLEN];
  1720. tnsFlush(); tnsUseNoTexture();
  1721. tnsColor4d(0,0,0,0.8);
  1722. tnsVertex2d(ui->L,ui->U); tnsVertex2d(ui->R,ui->U);
  1723. tnsVertex2d(ui->R,ui->B); tnsVertex2d(ui->L,ui->B);
  1724. tnsPackAs(GL_TRIANGLE_FAN);
  1725. tnsFlush(); tnsLineWidth(3.0);
  1726. laSpinLock(&s->Lock);
  1727. real b1=s->Brightness1, b2=s->Brightness2; real hcy[3]; tnsRGB2HCY(lcolor,hcy); hcy[2]=0.75;
  1728. real c1[3]; tnsHCY2RGB(hcy,c1);
  1729. for(int i=0;i<plen;i++){
  1730. arrx[i]=tnsInterpolate(cl,cr,((real)i)/plen);
  1731. arru1[i]=tnsInterpolate(cc,cu,yfac1*s->Display1[i])-off1;
  1732. arrb1[i]=tnsInterpolate(cc,cu,yfac1*s->Display1[i+plen])-off1;
  1733. TNS_CLAMP(arru1[i],cu,cb); TNS_CLAMP(arrb1[i],cu,cb);
  1734. tnsVertex2d(arrx[i],arru1[i]); tnsVertex2d(arrx[i],arrb1[i]);
  1735. }
  1736. tnsColor4d(LA_COLOR3(c1),b1*0.4);
  1737. tnsPackAs(GL_TRIANGLE_STRIP); tnsFlush();
  1738. for(int i=0;i<plen;i++){
  1739. arru2[i]=tnsInterpolate(cc,cu,yfac2*s->Display2[i])-off2;
  1740. arrb2[i]=tnsInterpolate(cc,cu,yfac2*s->Display2[i+plen])-off2;
  1741. TNS_CLAMP(arru2[i],cu,cb); TNS_CLAMP(arrb2[i],cu,cb);
  1742. tnsVertex2d(arrx[i],arru2[i]); tnsVertex2d(arrx[i],arrb2[i]);
  1743. }
  1744. tnsColor4d(LA_COLOR3(c1),b2*0.6);
  1745. tnsPackAs(GL_TRIANGLE_STRIP); tnsFlush();
  1746. for(int i=0;i<plen;i++){ tnsVertex2d(arrx[i],arru1[i]); }
  1747. tnsColor4d(LA_COLOR3(c1),b1);
  1748. tnsPackAs(GL_LINE_STRIP);
  1749. for(int i=0;i<plen;i++){ tnsVertex2d(arrx[i],arrb1[i]); }
  1750. tnsColor4d(LA_COLOR3(c1),b1);
  1751. tnsPackAs(GL_LINE_STRIP);
  1752. for(int i=0;i<plen;i++){ tnsVertex2d(arrx[i],arru2[i]); }
  1753. tnsColor4d(LA_COLOR3(c1),b2);
  1754. tnsPackAs(GL_LINE_STRIP);
  1755. for(int i=0;i<plen;i++){ tnsVertex2d(arrx[i],arrb2[i]); }
  1756. tnsColor4d(LA_COLOR3(c1),b2);
  1757. tnsPackAs(GL_LINE_STRIP);
  1758. laSpinUnlock(&s->Lock);
  1759. tnsFlush(); tnsLineWidth(1.0);
  1760. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1761. tnsVertex2d(ui->L,ui->U); tnsVertex2d(ui->R,ui->U);
  1762. tnsVertex2d(ui->R,ui->B); tnsVertex2d(ui->L,ui->B);
  1763. tnsPackAs(GL_LINE_LOOP);
  1764. if(s->FromSynth && laget_SynthPlaying(s->FromSynth)){ laDeferredRedraw(MAIN.CurrentPanel); }
  1765. }
  1766. void la_ConditionNodeFreeRecursive(laUiConditionNode *ucn);
  1767. void la_GeneralUiInit(laUiItem *ui){
  1768. ui->Extra = memAcquireSimple(sizeof(laGeneralUiExtraData));
  1769. ui->Extra->ui=ui;
  1770. }
  1771. void la_GeneralUiDestroy(laUiItem *ui){
  1772. if(ui->Extra && ui->Extra->Edit){ strEndEdit(&ui->Extra->Edit, 1); }
  1773. memFree(ui->Extra);
  1774. }
  1775. void la_ConditionUiDestroy(laUiItem *ui){
  1776. laConditionUiExtraData *cued = ui->Extra;
  1777. la_ConditionNodeFreeRecursive(cued->Expression);
  1778. FreeMem(ui->Extra);
  1779. }
  1780. void la_MultiStringInit(laUiItem *ui){
  1781. laGeneralUiExtraData *e = ui->Extra;
  1782. if (!e) e = memAcquireSimple(sizeof(laGeneralUiExtraData));
  1783. ui->Extra = e;
  1784. e->HeightCoeff = 10;
  1785. }
  1786. void la_ImageUiInit(laUiItem *ui){
  1787. tnsImage* im=ui->Extra;
  1788. #ifdef LA_WITH_PNG
  1789. tnsUseImage(im);
  1790. #endif
  1791. }
  1792. void la_ImageUiDestroy(laUiItem *ui){
  1793. tnsImage* im=ui->Extra;
  1794. #ifdef LA_WITH_PNG
  1795. tnsStopUsingImage(im);
  1796. #endif
  1797. //memAssignRef(ui, &ui->Extra, 0);
  1798. }
  1799. void la_MeterUiInit(laUiItem *ui){
  1800. la_GeneralUiInit(ui); ui->SymbolID = 20; ui->TemplateContext = 1000;
  1801. }
  1802. void la_RegisterUiTypesBasic(){
  1803. laKeyMapper* km;
  1804. laPropContainer* pc;
  1805. LA_WIDGET_INT->Type=LA_WIDGET_INT_PLAIN->Type=
  1806. _LA_UI_INT = la_RegisterUiType("LA_int_array_horizon", LA_PROP_INT | LA_PROP_ARRAY, "LA_int_array_h_operator",
  1807. &_LA_THEME_VALUATOR, la_IntDraw, la_ValueGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1808. _LA_UI_INT->GetMinWidth=la_ValueGetMinWidth;
  1809. LA_WIDGET_METER_TYPE1->Type=
  1810. _LA_UI_METER_TYPE1 = la_RegisterUiType("LA_meter_type1", 0, 0, &_LA_THEME_VALUATOR, la_ValueMeterType1Draw, la_ValueMeterGetHeight, la_MeterUiInit, la_GeneralUiDestroy);
  1811. _LA_UI_METER_TYPE1->GetMinWidth=la_ValueGetMinWidth;
  1812. LA_WIDGET_METER_TYPE2->Type=
  1813. _LA_UI_METER_TYPE2 = la_RegisterUiType("LA_meter_type2", 0, 0, &_LA_THEME_VALUATOR, la_ValueMeterType2Draw, la_ValueMeterGetHeight, la_MeterUiInit, la_GeneralUiDestroy);
  1814. _LA_UI_METER_TYPE2->GetMinWidth=la_ValueGetMinWidth;
  1815. LA_WIDGET_VALUE_METER_2D->Type=
  1816. _LA_UI_VALUE_METER_2D = la_RegisterUiType("LA_value_meter_2d", 0, 0, &_LA_THEME_VALUATOR, la_ValueMeter2DDraw, la_ValueMeter2DGetHeight, la_MeterUiInit, la_GeneralUiDestroy);
  1817. LA_WIDGET_FLOAT->Type=LA_WIDGET_FLOAT_PLAIN->Type=
  1818. _LA_UI_FLOAT = la_RegisterUiType("LA_real_array_horizon", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_array_h_operator",
  1819. &_LA_THEME_VALUATOR, la_FloatDraw, la_ValueGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1820. _LA_UI_FLOAT->GetMinWidth=la_ValueGetMinWidth;
  1821. LA_WIDGET_FLOAT_COLOR->Type=
  1822. _LA_UI_FLOAT_COLOR = la_RegisterUiType("LA_real_color", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_color_operator",
  1823. &_LA_THEME_VALUATOR, la_FloatArrayColorDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1824. _LA_UI_FLOAT_COLOR->GetMinWidth=la_ColorSelectorGetMinWidth;
  1825. LA_WIDGET_FLOAT_COLOR_HCY->Type=
  1826. _LA_UI_FLOAT_COLOR_HCY = la_RegisterUiType("LA_real_hcy", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_hcy_operator",
  1827. &_LA_THEME_VALUATOR, la_ColorCircleDrawHCY, la_ColorPickerGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1828. _LA_UI_FLOAT_COLOR_HCY->GetMinWidth = la_ColorPickerGetMinWidth;
  1829. LA_WIDGET_ENUM_SELECTOR->Type=LA_WIDGET_ENUM_SELECTOR_ICON->Type=LA_WIDGET_ENUM_CYCLE->Type=LA_WIDGET_ENUM_HIGHLIGHT->Type=
  1830. _LA_UI_ENUM_SELECTOR = la_RegisterUiType("LA_enum_selector", LA_PROP_ENUM, "LA_enum_selector_operator",
  1831. &_LA_THEME_SELECTOR, la_EnumSelectorDraw, la_EnumGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1832. _LA_UI_ENUM_SELECTOR->GetMinWidth = la_EnumGetMinWidth;
  1833. LA_WIDGET_FIXED_GROUP->Type=
  1834. _LA_UI_FIXED_GROUP = la_RegisterUiType("LA_group_default", 0, 0,
  1835. &_LA_THEME_COLLECTION_GROUP, la_GroupDraw, la_GroupGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1836. _LA_UI_FIXED_GROUP->Tag|=LA_UI_TAG_SCISSOR;
  1837. LA_WIDGET_COLLECTION->Type=
  1838. _LA_UI_COLLECTION = la_RegisterUiType("LA_collection_default", LA_PROP_SUB, "LA_collection_operator",
  1839. &_LA_THEME_COLLECTION_GROUP, la_EmptyDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1840. LA_WIDGET_COLLECTION_SELECTOR->Type=
  1841. _LA_UI_COLLECTION_SELECTOR = la_RegisterUiType("LA_collection_selector_default", LA_PROP_SUB, "LA_collection_selector_operator",
  1842. &_LA_THEME_COLLECTION_SELECTOR, la_CollectionSelectorDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1843. _LA_UI_COLLECTION_SELECTOR->GetMinWidth = la_CollectionSimpleGetMinWidth;
  1844. LA_WIDGET_COLLECTION_SINGLE->Type=
  1845. _LA_UI_COLLECTION_SINGLE = la_RegisterUiType("LA_collection_single", LA_PROP_SUB, "LA_collection_operator",
  1846. &_LA_THEME_COLLECTION_GROUP, la_EmptyDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1847. LA_WIDGET_TAB->Type=
  1848. _LA_UI_TAB = la_RegisterUiType("LA_tab_default", 0, "LA_tab_operator",
  1849. &_LA_THEME_TAB, la_TabDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1850. LA_WIDGET_BUTTON->Type=LA_WIDGET_BUTTON_NO_CONFIRM->Type=
  1851. _LA_UI_BUTTON = la_RegisterUiType("LA_button_default", LA_PROP_OPERATOR, "LA_button_operator",
  1852. &_LA_THEME_BUTTON, la_ButtonDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1853. _LA_UI_BUTTON->GetMinWidth = la_ButtonGetMinWidth;
  1854. LA_WIDGET_BUTTON_NO_CONFIRM->Flags|=LA_UI_FLAGS_NO_CONFIRM;
  1855. pc=laUiHasExtraProps(_LA_UI_BUTTON, sizeof(laGeneralUiExtraData),0);
  1856. LA_WIDGET_LABEL->Type=
  1857. _LA_UI_LABEL = la_RegisterUiType("LA_label_default", LA_PROP_OPERATOR, 0,
  1858. &_LA_THEME_LABEL, la_LabelDraw, la_LabelHeight, 0, 0);
  1859. _LA_UI_LABEL->GetMinWidth = la_LabelGetMinWidth;
  1860. LA_WIDGET_MENU_ROOT->Type=
  1861. _LA_UI_MENU_ROOT = la_RegisterUiType("LA_menu_default", LA_PROP_OPERATOR, "LA_menu_root_operator",
  1862. &_LA_THEME_BUTTON, la_MenuItemDraw, 0, 0, 0);
  1863. _LA_UI_MENU_ROOT->GetMinWidth=la_LabelGetMinWidth;
  1864. LA_WIDGET_CONDITION_TOGGLE->Type=
  1865. _LA_UI_CONDITION_TOGGLE = la_RegisterUiType("LA_condition_toggle_default", LA_PROP_SELF_CONDITION, "LA_condition_toggle_operator",
  1866. &_LA_THEME_BUTTON, la_ConditionToggleDraw, 0, 0, la_ConditionUiDestroy);
  1867. LA_WIDGET_STRING->Type=LA_WIDGET_STRING_PLAIN->Type=LA_WIDGET_STRING_MONO_PLAIN->Type=
  1868. _LA_UI_STRING = la_RegisterUiType("LA_string_default", LA_PROP_STRING, "LA_string_operator",
  1869. &_LA_THEME_STRING, la_SingleLineStringDraw, la_StringPropGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1870. _LA_UI_STRING->GetMinWidth = la_StringPropGetMinWidth;
  1871. km=&_LA_UI_STRING->KeyMapper;
  1872. laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'c', 0);
  1873. laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'x', "mode=CUT");
  1874. laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
  1875. pc=laUiHasExtraProps(_LA_UI_STRING, sizeof(laGeneralUiExtraData), 0);{
  1876. laAddOperatorProperty(pc, "copy_selection", "Copy Selection", "Copy selected string into clipboard", "LA_edit_string_copy",0,0);
  1877. }
  1878. LA_WIDGET_STRING_MULTI->Type=
  1879. _LA_UI_STRING_MULTI = la_RegisterUiType("LA_string_multiline", LA_PROP_STRING, "LA_string_multi",
  1880. &_LA_THEME_STRING, la_MultiStringDraw, la_MultiStringHeight, la_MultiStringInit, la_GeneralUiDestroy);
  1881. _LA_UI_STRING_MULTI->GetMinWidth = la_StringPropGetMinWidth;
  1882. km=&_LA_UI_STRING_MULTI->KeyMapper;
  1883. laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'c', 0);
  1884. laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'x', "mode=CUT");
  1885. laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
  1886. pc=laUiHasExtraProps(_LA_UI_STRING_MULTI, sizeof(laGeneralUiExtraData), 0);{
  1887. laAddOperatorProperty(pc, "copy_selection", "Copy Selection", "Copy selected string into clipboard", "LA_edit_string_copy",0,0);
  1888. }
  1889. LA_WIDGET_ALIGN->Type=
  1890. _LA_UI_ALIGN = la_RegisterUiType("LA_colum_align_default", 0, 0,
  1891. &_LA_THEME_BUTTON, la_UiSeperatorDraw, 0, 0, 0);
  1892. LA_WIDGET_COLUMN_ADJUSTER->Type=
  1893. _LA_UI_COLUMN_ADJUSTER = la_RegisterUiType("LA_column_adjuster_default", 0, "LA_column_adjuster",
  1894. &_LA_THEME_BUTTON, la_ColumnAdjusterDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1895. _LA_UI_COLUMN_ADJUSTER->TargetSub = "ui_column";
  1896. LA_WIDGET_COLUMN_VIEWER->Type=
  1897. _LA_UI_COLUMN_VIEWER = la_RegisterUiType("LA_column_viewer_default", 0, 0,
  1898. &_LA_THEME_BUTTON, la_ColumnViewerDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1899. _LA_UI_COLUMN_VIEWER->TargetSub = "ui_column";
  1900. _LA_UI_COLUMN_VIEWER->GetMinWidth = la_ColumnViewerGetMinWidth;
  1901. _LA_UI_CONDITION_ELSE.Theme = &_LA_THEME_BUTTON;
  1902. la_UDFAppendSharedTypePointer("LA_condition_else", &_LA_UI_CONDITION_ELSE);
  1903. _LA_UI_CONDITION.Destroy = _LA_UI_CONDITION_ELSE.Destroy = _LA_UI_CONDITION_END.Destroy =la_ConditionUiDestroy;
  1904. _LA_UI_CONDITION.Theme = &_LA_THEME_BUTTON;
  1905. la_UDFAppendSharedTypePointer("LA_condition", &_LA_UI_CONDITION);
  1906. _LA_UI_CONDITION_END.Theme = &_LA_THEME_BUTTON;
  1907. la_UDFAppendSharedTypePointer("LA_condition_end", &_LA_UI_CONDITION_END);
  1908. LA_WIDGET_SYMBOL->Type=
  1909. _LA_UI_SYMBOL = la_RegisterUiType("LA_symbol_default", 0, 0, &_LA_THEME_BUTTON, la_SymbolDraw, la_SymbolGetHeight, 0, 0);
  1910. LA_WIDGET_NODE_SOCKET->Type=
  1911. _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);
  1912. _LA_UI_NODE_SOCKET->GetMinWidth=la_SocketGetMinWidth;
  1913. LA_WIDGET_HEIGHT_ADJUSTER->Type=
  1914. _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);
  1915. _LA_UI_HEIGHT_ADJUSTER->ForType = LA_PROP_INT;
  1916. LA_WIDGET_RAW->Type=
  1917. _LA_UI_RAW = la_RegisterUiType("LA_raw_prop_default", 0, 0, &_LA_THEME_COLLECTION_GROUP, la_RawPropDraw, 0, 0, 0);
  1918. _LA_UI_RAW->ForType = LA_PROP_RAW;
  1919. LA_WIDGET_MAPPER->Type=
  1920. _LA_UI_MAPPER = la_RegisterUiType("LA_mapper_default", 0, "LA_value_mapper", &_LA_THEME_COLLECTION_GROUP, la_MapperDraw, la_ColorPickerGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1921. LA_WIDGET_IMAGE->Type=
  1922. _LA_UI_IMAGE = la_RegisterUiType("LA_image_default", 0, 0, &_LA_THEME_COLLECTION_GROUP, la_ImageDraw, la_ImageGetHeight, la_ImageUiInit, la_ImageUiDestroy);
  1923. _LA_UI_IMAGE->GetMinWidth=la_ImageGetMinWidth;
  1924. LA_WIDGET_SCOPE->Type=
  1925. _LA_UI_SCOPE = la_RegisterUiType("LA_scope_default", 0, "LA_synth_scope", &_LA_THEME_BUTTON, la_ScopeDraw, la_ColorPickerGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1926. _LA_UI_INVISIBLE.Theme=&_LA_THEME_BUTTON;
  1927. _LA_UI_ROW_BEGIN.Theme=&_LA_THEME_BUTTON;
  1928. _LA_UI_ROW_END.Theme=&_LA_THEME_BUTTON;
  1929. }
  1930. // ============================================================ [Operators]
  1931. void la_DefaultEnumPanel(laUiList *uil, laPropPack *This, laPropPack *OperatorProps, laColumn *UNUSED){
  1932. laColumn *c = laFirstColumn(uil);
  1933. laShowItem(uil, c, This, 0)->Flags=(LA_UI_FLAGS_TRANSPOSE|LA_UI_FLAGS_EXPAND);
  1934. }
  1935. int la_DetectRow(laUiItem *ui, int LocalY){
  1936. return (LocalY - ui->U) / LA_RH;
  1937. }
  1938. int la_DetectColumn(laUiItem *ui, int LocalX, int Total){
  1939. return (int)((real)(LocalX - ui->L) / (real)(ui->R - ui->L) * (real)Total);
  1940. }
  1941. laColumn *la_DetectSplit(laColumn *Root, int LocalX){
  1942. laColumn *result = 0;
  1943. if (!Root->LS) return 0;
  1944. if (LocalX - Root->LS->IR < LA_SCROLL_W && Root->LS->IR - LocalX < LA_SCROLL_W &&
  1945. !Root->LS->MaxW && !Root->RS->MaxW){
  1946. return Root;
  1947. }
  1948. result = la_DetectSplit(Root->LS, LocalX);
  1949. if (result) return result;
  1950. else
  1951. return la_DetectSplit(Root->RS, LocalX);
  1952. }
  1953. void la_AdjustColumnSplit(laColumn *c, int PxLeftPositive){
  1954. if (!c->LS || c->LS->MaxW || c->RS->MaxW) return;
  1955. if (PxLeftPositive < 0 && c->LS->IR - c->LS->IL <= LA_SCROLL_W*2) return;
  1956. if (PxLeftPositive > 0 && c->RS->IR - c->RS->IL <= LA_SCROLL_W*2) return;
  1957. c->LS->IR += PxLeftPositive;
  1958. c->RS->IL += PxLeftPositive;
  1959. c->LS->SP = (real)(c->LS->IR - c->LS->IL) / (real)(c->IR - c->IL);
  1960. c->RS->SP = c->LS->SP;
  1961. }
  1962. int OPCHK_EditStringCopySelection(laPropPack *This, laStringSplitor *Instructions){
  1963. laGeneralUiExtraData *uit = This->EndInstance; if(!uit) return 0;
  1964. if(!uit->Edit || !strHasSelection(uit->Edit)) return 0;
  1965. return 1;
  1966. }
  1967. int OPINV_EditStringCopySelection(laOperator *a, laEvent *e){
  1968. laGeneralUiExtraData *uit = a->This->EndInstance; if(!uit) return LA_FINISHED;
  1969. if(!uit->Edit || !strHasSelection(uit->Edit)) return LA_FINISHED;
  1970. char* mode=strGetArgumentString(a->ExtraInstructionsP,"mode");
  1971. char* str=strGetEditString(uit->Edit, 1);
  1972. laCopyToClipboard(str); free(str);
  1973. if(strSame(mode,"CUT")){ strClearSelection(&uit->Edit); }
  1974. return LA_FINISHED;
  1975. }
  1976. int la_ProcessTextEdit(laEvent *e, laStringEdit *se, laUiItem* ui){
  1977. int Select=e->SpecialKeyBit&LA_KEY_SHIFT;
  1978. real _L, MonoWidth;
  1979. switch (e->type){
  1980. case LA_INPUT:
  1981. switch (e->Input){
  1982. case 0x08: if(strHasSelection(se)) strClearSelection(se); else strBackspace(se); return 1;
  1983. case 0x7f: if(strHasSelection(se)) strClearSelection(se); else { strMoveCursor(se,0,0); strBackspace(se); } return 1;
  1984. case 0x09: strInsertChar(se, ' ');strInsertChar(se, ' ');strInsertChar(se, ' ');strInsertChar(se, ' '); return 1;
  1985. case 0x1B: case 0x0D: return 0;
  1986. default: strInsertChar(se, e->Input); return 1;
  1987. }
  1988. break;
  1989. case LA_KEY_DOWN:
  1990. switch (e->key){
  1991. case LA_KEY_ENTER: strInsertChar(se, '\n'); return 1;
  1992. case LA_KEY_ARRLEFT: strMoveCursor(se, 1, Select); return 1;
  1993. case LA_KEY_ARRRIGHT: strMoveCursor(se, 0, Select); return 1;
  1994. case LA_KEY_ARRUP: strMoveCursorLine(se, 1, Select); return 1;
  1995. case LA_KEY_ARRDOWN: strMoveCursorLine(se, 0, Select); return 1;
  1996. }
  1997. break;
  1998. case LA_L_MOUSE_DOWN:
  1999. case LA_MOUSEMOVE:
  2000. if(!ui) return 0;
  2001. MonoWidth=tnsGetMonoFontAdvance(); _L=(*ui->Type->Theme)->LM*2+ui->L;
  2002. int Count=se->TotalLines; while(Count){ Count/=10; _L+=MonoWidth; }
  2003. if(e->type==LA_L_MOUSE_DOWN){
  2004. strSetCursor(se, (e->y-ui->U)/LA_RH+se->ViewStartLine, (real)se->ViewStartCol+((real)e->x-_L)/MonoWidth+0.5); strCancelSelect(se); strLazySelect(se);
  2005. se->MouseSelecting=1; se->CursorPreferBefore=se->CursorBefore; return 1;
  2006. }else{
  2007. if(!se->MouseSelecting) return 0;
  2008. strSetCursor(se, (e->y-ui->U)/LA_RH+se->ViewStartLine, (real)se->ViewStartCol+((real)e->x-_L)/MonoWidth+0.5); strEndSelect(se);
  2009. se->CursorPreferBefore=se->CursorBefore; return 1;
  2010. }return 0;
  2011. case LA_L_MOUSE_UP:
  2012. se->MouseSelecting=0;
  2013. }
  2014. return 0;
  2015. }
  2016. int OPINV_UiItem(laOperator *a, laEvent *e){
  2017. laUiItem *ui = a->Instance;
  2018. a->CustomData = ui->Extra;
  2019. return LA_RUNNING;
  2020. }
  2021. int OPINV_Tab(laOperator *a, laEvent *e){
  2022. laUiList *uil;
  2023. laUiItem *ui = a->Instance;
  2024. laGeneralUiExtraData *uit;
  2025. int count = 0;
  2026. //if (e->Type == LA_L_MOUSE_DOWN) {
  2027. //}
  2028. a->CustomData = ui->Extra;
  2029. uit = a->CustomData;
  2030. uit->TargetIndexVali = count;
  2031. return LA_RUNNING;
  2032. }
  2033. int OPEXT_UiItem(laOperator *a, int ExitCode){
  2034. laUiItem *ui = a->Instance;
  2035. return 0;
  2036. }
  2037. int OPMOD_IntArrayHorizon(laOperator *a, laEvent *e){
  2038. laUiItem *ui = a->Instance;
  2039. laBoxedTheme *bt = (*ui->Type->Theme);
  2040. laGeneralUiExtraData *uit = a->CustomData;
  2041. laIntProp *ip = ui->PP.LastPs->p;
  2042. int Away = 0;
  2043. int TmpArr[32];
  2044. int Len = laGetArrayLength(&ui->PP);
  2045. int IsVertical=(ui->Flags&LA_UI_FLAGS_TRANSPOSE)!=0;
  2046. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2047. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2048. int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
  2049. if (!laIsInUiItem(ui, e->x, e->y) && !ui->Extra->On){
  2050. ui->State = LA_UI_NORMAL;
  2051. if (ui->Extra) ui->Extra->On = 0;
  2052. laRedrawCurrentPanel();
  2053. return LA_FINISHED_PASS;
  2054. }
  2055. if (e->type == LA_TIME_IDLE && !uit->On && !uit->Edit && !NoTooltip){
  2056. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2057. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2058. return LA_RUNNING;
  2059. }
  2060. if(NoEvent){ return LA_RUNNING_PASS; }
  2061. if (e->type == LA_L_MOUSE_DOWN){
  2062. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  2063. if (uit->Edit){
  2064. if (!laIsInUiItem(ui, e->x, e->y)){
  2065. strEndEdit(&uit->Edit, 1);
  2066. uit->On = 0;
  2067. laRedrawCurrentPanel();
  2068. return LA_FINISHED;
  2069. }
  2070. if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
  2071. else strSelectLineAll(uit->Edit);
  2072. return LA_RUNNING;
  2073. }
  2074. uit->LastX = e->x;
  2075. uit->LastY = e->y;
  2076. ui->Extra->On = (IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
  2077. if (ui->Extra->On > Len) return LA_RUNNING;
  2078. laGetIntArray(&ui->PP, &TmpArr);
  2079. uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
  2080. laRedrawCurrentPanel();
  2081. return LA_RUNNING;
  2082. }
  2083. if (e->type == LA_MOUSEMOVE && ui->Extra->On){
  2084. if(ui->Extra->Edit){ return LA_RUNNING; }
  2085. int dist=abs(e->x - uit->LastX + uit->LastY - e->y);
  2086. if (dist > MAIN.ValuatorThreshold || uit->Dragging){
  2087. int min,max,Ranged = laGetIntRange(&ui->PP, &min, &max); real step=ip->Step; if(Ranged&&!IsKnob){ step=(real)(max-min)/(ui->R-ui->L); }
  2088. if(Ranged){ TNS_CLAMP(step,(max-min)/500,INT_MAX); }
  2089. //laGetIntArray(&ui->PP, &TmpArr);
  2090. //uit->TargetIndexVali = TmpArr[ui->Extra->On - 1];
  2091. int delta=e->x-uit->LastX; if(IsKnob){ int dy=uit->LastY-e->y; delta=delta+dy; } if(!uit->Dragging) delta=delta>0?1:-1;
  2092. uit->TargetIndexValf += delta*step;
  2093. laSetIntArraySingle(&ui->PP, ui->Extra->On - 1, uit->TargetIndexValf);
  2094. uit->LastX = e->x;
  2095. uit->LastY = e->y;
  2096. uit->Dragging = 1;
  2097. laRedrawCurrentPanel();
  2098. }
  2099. return LA_RUNNING;
  2100. }
  2101. if (e->type == LA_L_MOUSE_UP){
  2102. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  2103. if (uit->Dragging){
  2104. if (ui->Extra->On){
  2105. ui->Extra->On = 0;
  2106. laConfirmInt(a, uit->TargetIndexVali, LA_CONFIRM_DATA);
  2107. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2108. }
  2109. }else if(ui->Extra->On){
  2110. int SelectOn=(IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
  2111. if ((!uit->Edit) || (uit->Edit && (SelectOn != ui->Extra->On))){
  2112. char buf[32] = {0};
  2113. uit->On=SelectOn;
  2114. laGetIntArray(&ui->PP, &TmpArr);
  2115. uit->TargetIndexVali = TmpArr[ui->Extra->On - 1];
  2116. strPrintIntAfter(buf, 32, uit->TargetIndexVali);
  2117. strBeginEdit(&uit->Edit,buf);
  2118. strSelectLineAll(uit->Edit);
  2119. }
  2120. }
  2121. uit->Dragging = 0;
  2122. laRedrawCurrentPanel();
  2123. return LA_RUNNING;
  2124. }
  2125. if(e->type ==LA_KEY_DOWN){
  2126. if (e->key == LA_KEY_ENTER && uit->Edit){
  2127. char* buf=strEndEdit(&uit->Edit, 0);
  2128. int Result; sscanf(buf, "%d", &Result); free(buf);
  2129. laSetIntArraySingle(&ui->PP, ui->Extra->On - 1, Result);
  2130. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2131. ui->State = LA_UI_NORMAL;
  2132. uit->Dragging = 0;
  2133. uit->On = 0;
  2134. laRedrawCurrentPanel();
  2135. return LA_FINISHED_PASS;
  2136. }
  2137. }
  2138. if (e->type == LA_R_MOUSE_DOWN){
  2139. int GX = e->x, GY = e->y;
  2140. ui->PP.LastIndex = la_DetectColumn(ui, e->x, Len);
  2141. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2142. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2143. return LA_RUNNING;
  2144. }
  2145. if (uit->Edit){
  2146. if (la_ProcessTextEdit(e, uit->Edit, ui)) laRedrawCurrentPanel();
  2147. return LA_RUNNING;
  2148. }
  2149. return LA_RUNNING_PASS;
  2150. }
  2151. int OPMOD_FloatArrayHorizon(laOperator *a, laEvent *e){
  2152. laUiItem *ui = a->Instance;
  2153. laBoxedTheme *bt = (*ui->Type->Theme);
  2154. laGeneralUiExtraData *uit = a->CustomData;
  2155. laFloatProp *fp = ui->PP.LastPs->p;
  2156. int Away = 0;
  2157. real TmpArr[32];
  2158. int Len = laGetArrayLength(&ui->PP);
  2159. int IsVertical=(ui->Flags&LA_UI_FLAGS_TRANSPOSE)!=0;
  2160. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2161. int IsRad=ui->PP.LastPs->p->IsRadAngle;
  2162. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2163. int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
  2164. if (!laIsInUiItem(ui, e->x, e->y) && !ui->Extra->On && !NoTooltip){
  2165. ui->State = LA_UI_NORMAL;
  2166. ui->Extra->On = 0;
  2167. laRedrawCurrentPanel();
  2168. return LA_FINISHED_PASS;
  2169. }
  2170. if (e->type == LA_TIME_IDLE && !uit->On && !uit->Edit){
  2171. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2172. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2173. return LA_RUNNING;
  2174. }
  2175. if(NoEvent){ return LA_RUNNING_PASS; }
  2176. if (e->type == LA_L_MOUSE_DOWN){
  2177. if (uit->Edit){
  2178. if (!laIsInUiItem(ui, e->x, e->y)){
  2179. strEndEdit(&uit->Edit, 1);
  2180. uit->On = 0;
  2181. laRedrawCurrentPanel();
  2182. return LA_FINISHED;
  2183. }
  2184. if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
  2185. else strSelectLineAll(uit->Edit);
  2186. return LA_RUNNING;
  2187. }
  2188. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  2189. uit->LastX = e->x;
  2190. uit->LastY = e->y;
  2191. ui->Extra->On = (IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
  2192. if (ui->Extra->On > Len) return LA_RUNNING;
  2193. laGetFloatArray(&ui->PP, &TmpArr);
  2194. uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
  2195. laRedrawCurrentPanel();
  2196. return LA_RUNNING;
  2197. }
  2198. if (e->type == LA_MOUSEMOVE && ui->Extra->On){
  2199. if(uit->Edit){ return LA_RUNNING; }
  2200. int dist=abs(e->x - uit->LastX - e->y + uit->LastY);
  2201. if (dist > MAIN.ValuatorThreshold || uit->Dragging){
  2202. real min,max; int Ranged = laGetFloatRange(&ui->PP, &min, &max); real step=fp->Step; if(Ranged&&!IsKnob){ step=(max-min)/(ui->R-ui->L); }
  2203. if(Ranged){ TNS_CLAMP(step,(max-min)/500,INT_MAX); }
  2204. laGetFloatArray(&ui->PP, &TmpArr);
  2205. uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
  2206. int delta=e->x-uit->LastX; if(IsKnob){ int dy=uit->LastY-e->y; delta=delta+dy; } if(!uit->Dragging) delta=delta>0?1:-1;
  2207. uit->TargetIndexValf += delta*step;
  2208. laSetFloatArraySingle(&ui->PP, ui->Extra->On - 1, uit->TargetIndexValf);
  2209. uit->LastX = e->x;
  2210. uit->LastY = e->y;
  2211. uit->Dragging = 1;
  2212. laRedrawCurrentPanel();
  2213. }
  2214. return LA_RUNNING;
  2215. }
  2216. if (e->type == LA_L_MOUSE_UP){
  2217. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  2218. if (uit->Dragging){
  2219. if (ui->Extra->On){
  2220. ui->Extra->On = 0;
  2221. laConfirmFloat(a, uit->TargetIndexValf, LA_CONFIRM_DATA);
  2222. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2223. }
  2224. }else if(ui->Extra->On){
  2225. int SelectOn=(IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
  2226. if ((!uit->Edit) || (uit->Edit && (SelectOn != ui->Extra->On))){
  2227. char buf[32] = {0};
  2228. uit->On=SelectOn;
  2229. laGetFloatArray(&ui->PP, &TmpArr);
  2230. uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
  2231. strPrintFloatAfter(buf, 32, 5, IsRad?deg(uit->TargetIndexValf):uit->TargetIndexValf);
  2232. strBeginEdit(&uit->Edit,buf);
  2233. strSelectLineAll(uit->Edit);
  2234. }
  2235. }
  2236. uit->Dragging = 0;
  2237. laRedrawCurrentPanel();
  2238. return LA_RUNNING;
  2239. }
  2240. if(e->type ==LA_KEY_DOWN){
  2241. if (e->key == LA_KEY_ENTER && uit->Edit){
  2242. char* buf=strEndEdit(&uit->Edit, 0);
  2243. real Result; sscanf(buf, "%lf", &Result); free(buf);
  2244. if(IsRad) Result=rad(Result);
  2245. laSetFloatArraySingle(&ui->PP, ui->Extra->On - 1, Result);
  2246. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2247. uit->Dragging = 0;
  2248. uit->On = 0;
  2249. laRedrawCurrentPanel();
  2250. return LA_FINISHED_PASS;
  2251. }
  2252. }
  2253. if (e->type == LA_R_MOUSE_DOWN){
  2254. int GX = e->x, GY = e->y;
  2255. ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
  2256. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2257. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2258. return LA_RUNNING;
  2259. }
  2260. if (uit->Edit){
  2261. if (la_ProcessTextEdit(e, uit->Edit, ui)) laRedrawCurrentPanel();
  2262. return LA_RUNNING;
  2263. }
  2264. return LA_RUNNING_PASS;
  2265. }
  2266. int OPMOD_FloatColor(laOperator *a, laEvent *e){
  2267. laUiItem *ui = a->Instance;
  2268. laBoxedTheme *bt = (*ui->Type->Theme);
  2269. laGeneralUiExtraData *uit = a->CustomData;
  2270. int Away = 0;
  2271. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2272. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2273. if (!laIsInUiItem(ui, e->x, e->y)){
  2274. return LA_FINISHED_PASS;
  2275. }
  2276. if (e->type == LA_TIME_IDLE && !NoTooltip){
  2277. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2278. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2279. return LA_RUNNING;
  2280. }
  2281. if(NoEvent){ return LA_RUNNING_PASS; }
  2282. if (e->type == LA_L_MOUSE_DOWN){
  2283. laUiList *uil;
  2284. laColumn *col;
  2285. laPanel *p;
  2286. int GX = ui->L, GY = ui->B;
  2287. ui->State = LA_UI_ACTIVE;
  2288. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2289. p = laEnableEmptyPropertyPanel(a->ToPanel, a, GX, GX + 150, GY, 500, e);{
  2290. uil = &p->UI;
  2291. col = laFirstColumn(uil);
  2292. laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_FLOAT_COLOR_HCY, 0, 0, 0);
  2293. laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_FLOAT, 0, 0, 0)->Flags=LA_UI_FLAGS_TRANSPOSE;
  2294. laEnclosePanelContent(p, uil);
  2295. }
  2296. return LA_RUNNING;
  2297. }
  2298. if (e->type == LA_R_MOUSE_DOWN){
  2299. int GX = e->x, GY = e->y;
  2300. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2301. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2302. return LA_RUNNING;
  2303. }
  2304. return LA_RUNNING_PASS;
  2305. }
  2306. int OPMOD_ColorHCY(laOperator *a, laEvent *e){
  2307. laUiItem *ui = a->Instance;
  2308. laBoxedTheme *bt = (*ui->Type->Theme);
  2309. laGeneralUiExtraData *es = a->CustomData;
  2310. int Away = 0;
  2311. int i = 0;
  2312. real hcy[3] = {0};
  2313. real Color[4] = {0};
  2314. real PickerPos[2];
  2315. real abso;
  2316. if (!laIsInUiItem(ui, e->x, e->y) && !es->Dragging){
  2317. return LA_FINISHED_PASS;
  2318. }
  2319. 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){
  2320. es->Dragging=3; es->LastX=e->x; es->LastY=e->y; es->TargetIndexVali=es->HeightCoeff; return LA_RUNNING;
  2321. }
  2322. if(es->Dragging==3){
  2323. if(e->type==LA_MOUSEMOVE){ es->HeightCoeff=es->TargetIndexVali+((real)e->y-es->LastY+0.5)/LA_RH;
  2324. if(es->HeightCoeff<1)es->HeightCoeff=1; laRecalcCurrentPanel();}
  2325. elif(e->type==LA_L_MOUSE_UP){ es->Dragging=0; }
  2326. elif(e->type==LA_R_MOUSE_DOWN){
  2327. es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel(); }
  2328. return LA_RUNNING;
  2329. }
  2330. real c = (real)((ui->R + ui->L) / 2) - LA_RH / 2; /*- bt->RM;*/
  2331. real r = (ui->B - ui->U - bt->TP - bt->BP) / 2;
  2332. real dx = e->x - c, dy = e->y - (ui->U + r + bt->TP);
  2333. real dist = sqrt(dx * dx + dy * dy);
  2334. if (e->type == LA_L_MOUSE_DOWN){ ui->State = LA_UI_ACTIVE; laRedrawCurrentPanel(); es->Dragging=(dist<=r)?1:2; }
  2335. if (e->type == LA_L_MOUSE_UP){
  2336. ui->State = LA_UI_NORMAL; es->Dragging=0; laRedrawCurrentPanel();
  2337. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2338. return LA_RUNNING_PASS;
  2339. }
  2340. if (e->type & LA_MOUSE_EVENT && es->Dragging){
  2341. laGetFloatArray(&ui->PP, Color);
  2342. if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LogsRGB(Color); }
  2343. tnsRGB2HCY(Color, hcy);
  2344. if (es->Dragging==1){
  2345. abso = fabs(atan((real)dy / (real)dx));
  2346. hcy[0] = abso / TNS_PI / 2;
  2347. if (dx > 0){
  2348. if (dy < 0) hcy[0] = 1 - hcy[0];
  2349. }else{
  2350. if (dy > 0){
  2351. hcy[0] = 0.5 - hcy[0];
  2352. }else{
  2353. hcy[0] += 0.5;
  2354. }
  2355. }
  2356. hcy[1] = dist / r; TNS_CLAMP(hcy[1],0,1);
  2357. hcy[1]=pow(hcy[1],MAIN.ColorPickerGamma);
  2358. }else if (dist < r + LA_RH * 2 && dx > 0){
  2359. abso = -atan((real)dy / (real)dx) / TNS_PI * 2 + 0.5;
  2360. hcy[2] = abso; TNS_CLAMP(hcy[2],0,1);
  2361. }
  2362. tnsHCY2RGB(hcy, Color);
  2363. if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LinearsRGB(Color); }
  2364. laSetFloatArrayAllArray(&ui->PP, Color);
  2365. laRedrawCurrentPanel();
  2366. return LA_RUNNING;
  2367. }
  2368. return LA_RUNNING_PASS;
  2369. }
  2370. int OPMOD_EnumSelector(laOperator *a, laEvent *e){
  2371. laUiItem *ui = a->Instance;
  2372. laBoxedTheme *bt = (*ui->Type->Theme);
  2373. laGeneralUiExtraData *uit = a->CustomData;
  2374. laEnumItem *ei;
  2375. laEnumProp *ep = ui->PP.LastPs->p;
  2376. int at = 0;
  2377. laEnumItem *Data[32];
  2378. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2379. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2380. int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
  2381. int IsMomentary = IsCycle && ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
  2382. int NoConfirm = ui->Flags&LA_UI_FLAGS_NO_CONFIRM;
  2383. // norm e1
  2384. // expand e1 e2 e3
  2385. // expand vertical (vertical)
  2386. // arr expand e1 e1 e3
  2387. // e2 e2 e3
  2388. // arr exp+vert e1 e1
  2389. // e2 e2
  2390. // e3 e3
  2391. if (a->ConfirmData /* && a->ConfirmData->Mode == LA_CONFIRM_DATA*/){
  2392. ui->State = LA_UI_NORMAL;
  2393. laRedrawCurrentPanel();
  2394. return LA_RUNNING;
  2395. }
  2396. if (!laIsInUiItem(ui, e->x, e->y) && !uit->On){ return LA_FINISHED_PASS; }
  2397. if (e->type == LA_TIME_IDLE && !NoTooltip && !uit->On){
  2398. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2399. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2400. return LA_RUNNING;
  2401. }
  2402. if(NoEvent){ return LA_RUNNING_PASS; }
  2403. if (e->type == LA_L_MOUSE_DOWN || (IsMomentary && e->type == LA_L_MOUSE_UP)){
  2404. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  2405. int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  2406. int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
  2407. int ArrLen = laGetArrayLength(&ui->PP);
  2408. if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
  2409. int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
  2410. int _L,_R,_U,_B, _W=ui->R - ui->L, _Col=1;
  2411. if(IsVertical){
  2412. if(IsExpand){ _Col=ArrLen; }
  2413. }else{
  2414. if(IsExpand){ _Col=EnumLen; } else { _Col=ArrLen; }
  2415. }
  2416. int row = la_DetectRow(ui, e->y);
  2417. int col = la_DetectColumn(ui, e->x, _Col);
  2418. int ArrTarget=0, EnumTarget=0, ShowMenu=0;
  2419. if(IsVertical){
  2420. if(IsExpand){ EnumTarget=row; ArrTarget=col; } else { EnumTarget=col; }
  2421. }else{
  2422. if(IsExpand){ EnumTarget=col; ArrTarget=row; } else { if(!IsCycle) ShowMenu=1; }
  2423. }
  2424. if(ShowMenu){
  2425. int GX = ui->L, GY = ui->B, GR = ui->R, t = 0;
  2426. ui->State = LA_UI_ACTIVE;
  2427. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2428. laLocalToWindow(a, a->ToPanel, &GR, &t);
  2429. laEnablePropertyPanel(a->ToPanel, a, 0, la_DefaultEnumPanel, 0, &ui->PP, GX, GR, GY, MAIN.CurrentWindow->CH-LA_2RH, 0, e);
  2430. laRedrawCurrentPanel();
  2431. }elif(IsCycle){
  2432. laEnumItem* ei=laGetEnumArrayIndexed(&ui->PP, ArrTarget);
  2433. if(!ei){ ei=((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst; }
  2434. ei = ei->Item.pNext?ei->Item.pNext:((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst;
  2435. if(IsMomentary){ uit->On = 1; if(e->type==LA_L_MOUSE_UP){ ei = ei=((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst; uit->On = 0;} }
  2436. laSetEnumArrayIndexed(&ui->PP, ArrTarget, ei->Index);
  2437. if(!NoConfirm){ laConfirmInt(a,EnumTarget,LA_CONFIRM_DATA); }
  2438. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2439. if(ui->Flags&LA_UI_FLAGS_EXIT_WHEN_TRIGGERED) return LA_FINISHED;
  2440. }else{
  2441. if(ArrTarget>=ArrLen){ArrTarget=ArrLen-1;}
  2442. if(EnumTarget>=EnumLen){EnumTarget=EnumLen-1;}
  2443. laSetEnumArrayIndexedExternal(&ui->PP, ArrTarget, EnumTarget);
  2444. if(!NoConfirm){ laConfirmInt(a,EnumTarget,LA_CONFIRM_DATA); }
  2445. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2446. return LA_RUNNING_PASS;
  2447. }
  2448. return LA_RUNNING;
  2449. }
  2450. if(e->type==LA_R_MOUSE_DOWN){
  2451. int GX = e->x, GY = e->y;
  2452. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2453. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2454. return LA_RUNNING;
  2455. }
  2456. return LA_RUNNING_PASS;
  2457. }
  2458. int OPMOD_Button(laOperator *a, laEvent *e){
  2459. laUiItem *ui = a->Instance;
  2460. laBoxedTheme *bt = (*ui->Type->Theme);
  2461. int lx, ly;
  2462. int Away = 0;
  2463. if (e->type == LA_TIME_IDLE && !ui->State){
  2464. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2465. laPanel *p = laEnableIdlePanel(a->ToPanel, a, &ui->ExtraPP, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2466. return LA_RUNNING;
  2467. }
  2468. if (laConfirmSameDataIfAny(a)) return LA_RUNNING_PASS;
  2469. if (e->type == LA_ESCAPE_DOWN || e->type == LA_INPUT) return LA_FINISHED; //debug
  2470. if (!laIsInUiItem(ui, e->x, e->y) /*&& ui->State!= LA_UI_ACTIVE*/){
  2471. ui->State = LA_UI_NORMAL;
  2472. laRedrawCurrentPanel();
  2473. return LA_FINISHED_PASS;
  2474. }
  2475. if (e->type == LA_L_MOUSE_DOWN){
  2476. ui->State = LA_UI_ACTIVE;
  2477. laRedrawCurrentPanel();
  2478. return LA_RUNNING;
  2479. }
  2480. char *str;
  2481. int call_ret=0;
  2482. if (e->type == LA_L_MOUSE_UP && ui->State!=LA_UI_NORMAL){
  2483. ui->State = LA_UI_NORMAL;
  2484. if (ui->AT){
  2485. if (!ui->Instructions){
  2486. if (ui->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
  2487. if (ui->AT->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->AT->ExtraInstructions);
  2488. }
  2489. if (!laOperatorAvailableP(ui->AT, 0, ui->Instructions)) return LA_RUNNING;
  2490. lx = e->x;
  2491. ly = e->y;
  2492. laLocalToWindow(a, a->ToPanel, &e->x, &e->y);
  2493. e->Localized = 0;
  2494. call_ret=laInvokeP(0, ui->AT, e, 0, ui->ExtraInstructions ? ui->ExtraInstructions->Ptr : 0, 0);
  2495. e->x = lx;
  2496. e->y = ly;
  2497. e->Localized = 1;
  2498. }else{
  2499. laOperatorProp *ap = ui->PP.LastPs->p;
  2500. if (ap->OperatorID){
  2501. if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
  2502. if (!ui->Instructions){
  2503. if (ui->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
  2504. if (ap->OperatorType) strMakeInstructions(&ui->Instructions, ap->OperatorType->ExtraInstructions);
  2505. }
  2506. if (!laOperatorAvailablePSafe(ap->OperatorType, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->Instructions)) return LA_RUNNING;
  2507. lx = e->x;
  2508. ly = e->y;
  2509. laLocalToWindow(a, a->ToPanel, &e->x, &e->y);
  2510. e->Localized = 0;
  2511. call_ret=laInvokePCreateThis(0, ap->OperatorType, e, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->ExtraInstructions ? ui->ExtraInstructions->Ptr : 0, ap->Base.ExtraInstructions);
  2512. if(a->StopNow) return LA_FINISHED;
  2513. laRetriggerOperators();
  2514. e->x = lx;
  2515. e->y = ly;
  2516. e->Localized = 1;
  2517. }
  2518. }
  2519. if(MAIN.InvokeConfirmData){
  2520. a->ConfirmData=MAIN.InvokeConfirmData; laConfirmSameDataIfAny(a); a->ConfirmData=0;
  2521. }else{
  2522. if (str = strGetArgumentString(ui->Instructions, "feedback")){
  2523. if (strSame(str, "CONFIRM")) laConfirmInt(a, 0, LA_CONFIRM_OK);
  2524. elif (strSame(str, "CANCEL")) laConfirmInt(a, 0, LA_CONFIRM_CANCEL);
  2525. else { laConfirmString(a, str, LA_CONFIRM_CUSTOM_STRING); }
  2526. }elif(!(ui->Flags&LA_UI_FLAGS_NO_CONFIRM)){
  2527. laConfirmInt(a, 0, LA_CONFIRM_OK);
  2528. }
  2529. }
  2530. if(call_ret==LA_OPERATOR_CALLS_SHUTOFF) return LA_OPERATOR_CALLS_SHUTOFF;
  2531. laRedrawCurrentPanel();
  2532. if(ui->Flags&LA_UI_FLAGS_EXIT_WHEN_TRIGGERED) return LA_FINISHED_PASS;
  2533. return LA_RUNNING_PASS;
  2534. }
  2535. return LA_RUNNING_PASS;
  2536. }
  2537. int OPMOD_MenuItem(laOperator *a, laEvent *e){
  2538. laUiItem *ui = a->Instance;
  2539. laPanel *p;
  2540. laBoxedTheme *bt = (*ui->Type->Theme);
  2541. laGeneralUiExtraData *uit = a->CustomData;
  2542. int Away = 0;
  2543. if (a->ConfirmData){
  2544. ui->State = LA_UI_NORMAL;
  2545. laConfirmInt(a, a->ConfirmData->IData, a->ConfirmData->Mode);
  2546. laRedrawCurrentPanel();
  2547. return LA_RUNNING_PASS;
  2548. }
  2549. if (!laIsInUiItem(ui, e->x, e->y) && ui->State != LA_UI_ACTIVE){
  2550. ui->State = LA_UI_NORMAL;
  2551. laRedrawCurrentPanel();
  2552. return LA_FINISHED_PASS;
  2553. }
  2554. if (e->type == LA_L_MOUSE_DOWN){
  2555. int GX = ui->L, GY = ui->B;
  2556. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2557. ui->State = LA_UI_ACTIVE;
  2558. p = laEnableMenuPanel(a->ToPanel, a, ui->Subs.pFirst, &ui->PP, GX, GX + 300, GY, MAIN.CurrentWindow->CH-LA_2RH, 0, e);
  2559. laShowPanelWithDropDownEffect(p);
  2560. laRedrawCurrentPanel();
  2561. return LA_RUNNING;
  2562. }
  2563. return LA_RUNNING_PASS;
  2564. }
  2565. int OPMOD_ConditionToggle(laOperator *a, laEvent *e){
  2566. laUiItem *ui = a->Instance;
  2567. laBoxedTheme *bt = (*ui->Type->Theme);
  2568. laGeneralUiExtraData *uit = a->CustomData;
  2569. int Away = 0;
  2570. if (!laIsInUiItem(ui, e->x, e->y) /*&& ui->State!= LA_UI_ACTIVE*/){
  2571. return LA_FINISHED_PASS;
  2572. }
  2573. if (e->type == LA_L_MOUSE_DOWN){
  2574. ui->State = ui->State == LA_UI_ACTIVE ? LA_UI_NORMAL : LA_UI_ACTIVE;
  2575. laRecalcCurrentPanel();
  2576. return LA_RUNNING;
  2577. }
  2578. return LA_RUNNING_PASS;
  2579. }
  2580. int OPMOD_SingleLineString(laOperator *a, laEvent *e){
  2581. laUiItem *ui = a->Instance;
  2582. laBoxedTheme *bt = (*ui->Type->Theme);
  2583. laGeneralUiExtraData *uit = a->CustomData;
  2584. laStringEdit *se = uit->Edit;
  2585. int Away = 0;
  2586. char _buf[LA_RAW_CSTR_MAX_LEN] = {0}; char* buf=_buf;
  2587. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2588. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2589. int IsTerminal=ui->Flags&LA_UI_FLAGS_TERMINAL_INPUT;
  2590. int ImmediateInput=ui->Flags&LA_UI_FLAGS_IMMEDIATE_INPUT;
  2591. if (!laIsInUiItem(ui, e->x, e->y)){
  2592. if (ui->State != LA_UI_EDITING){
  2593. ui->State = LA_UI_NORMAL;
  2594. laRedrawCurrentPanel();
  2595. return LA_FINISHED_PASS;
  2596. }else{
  2597. if(IsTerminal && (e->type&LA_KEY_MOUSE_SCROLL)){ return LA_RUNNING_PASS; }
  2598. if ((e->type & LA_MOUSEDOWN) == LA_MOUSEDOWN){
  2599. buf=strEndEdit(&uit->Edit, 0);
  2600. laSetString(&ui->PP, buf); free(buf);
  2601. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2602. ui->State = LA_UI_NORMAL;
  2603. laRedrawCurrentPanel();
  2604. return LA_FINISHED_PASS;
  2605. }
  2606. }
  2607. }
  2608. if (e->type == LA_TIME_IDLE && !ui->State && !NoTooltip){
  2609. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2610. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2611. return LA_RUNNING;
  2612. }
  2613. if(NoEvent){ return LA_RUNNING_PASS; }
  2614. if(e->type ==LA_KEY_DOWN){
  2615. if (e->key == LA_KEY_ENTER){
  2616. buf=IsTerminal?strGetEditString(uit->Edit,0):strEndEdit(&uit->Edit, 0);
  2617. if(IsTerminal){ MAIN.IsTerminalEnter=1; }
  2618. laSetString(&ui->PP, buf); free(buf);
  2619. laRedrawCurrentPanel();
  2620. if(!IsTerminal){
  2621. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2622. ui->State = LA_UI_NORMAL;
  2623. return LA_FINISHED_PASS;
  2624. }else{
  2625. laGetString(&ui->PP, _buf, &buf);
  2626. strBeginEdit(&uit->Edit,buf);
  2627. MAIN.IsTerminalEnter=0;
  2628. return LA_RUNNING;
  2629. }
  2630. }else if (e->key == LA_KEY_ESCAPE && ui->State != LA_UI_NORMAL){
  2631. ui->State = LA_UI_NORMAL;
  2632. laRedrawCurrentPanel();
  2633. return LA_FINISHED;
  2634. }
  2635. }
  2636. if(laKeyMapExecuteEventEx(a, &ui->ExtraPP, &ui->Type->KeyMapper, e)) return LA_RUNNING;
  2637. if (e->type == LA_L_MOUSE_DOWN){
  2638. if (ui->State == LA_UI_NORMAL){
  2639. if(laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING;
  2640. ui->State = LA_UI_EDITING;
  2641. laGetString(&ui->PP, _buf, &buf);
  2642. strBeginEdit(&uit->Edit,buf);
  2643. strSelectLineAll(uit->Edit);
  2644. }elif (ui->State == LA_UI_EDITING){
  2645. if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
  2646. else strSelectLineAll(uit->Edit);
  2647. }
  2648. laRedrawCurrentPanel();
  2649. return LA_RUNNING;
  2650. }
  2651. if (e->type == LA_R_MOUSE_DOWN){
  2652. int GX = e->x, GY = e->y;
  2653. ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
  2654. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2655. 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);
  2656. return LA_RUNNING;
  2657. }
  2658. if (ui->State == LA_UI_EDITING){
  2659. if (la_ProcessTextEdit(e, se, ui)){
  2660. laRedrawCurrentPanel();
  2661. if(ImmediateInput){
  2662. buf=strGetEditString(uit->Edit,0); laSetString(&ui->PP, buf); free(buf);
  2663. }
  2664. }
  2665. return LA_RUNNING;
  2666. }
  2667. if (ui->State != LA_UI_EDITING) return LA_RUNNING_PASS;
  2668. else return LA_RUNNING;
  2669. }
  2670. void la_SetMultistringViewRange(laUiItem* ui, laStringEdit* se, laBoxedTheme* bt){
  2671. int NumberWidth=0; int MonoWidth=tnsGetMonoFontAdvance(); int Count=se->TotalLines;
  2672. while(Count){ Count/=10; NumberWidth+=MonoWidth; }
  2673. strSetEditViewRange(ui->Extra->Edit,
  2674. ui->Extra->HeightCoeff>0?ui->Extra->HeightCoeff:((ui->B-ui->U)/LA_RH),(ui->R-ui->L-NumberWidth-bt->LM*2-bt->RM)/MonoWidth);
  2675. }
  2676. int OPMOD_MultiString(laOperator *a, laEvent *e){
  2677. laUiItem *ui = a->Instance;
  2678. laBoxedTheme *bt = (*ui->Type->Theme);
  2679. laGeneralUiExtraData *es = a->CustomData;
  2680. laStringEdit *se = es->Edit;
  2681. int Away = 0;
  2682. char _buf[LA_RAW_CSTR_MAX_LEN] = {0}; char* buf=&_buf;
  2683. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2684. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2685. if (!laIsInUiItem(ui, e->x, e->y) && !es->Dragging){
  2686. if ((e->type & LA_MOUSEDOWN) == LA_MOUSEDOWN){
  2687. buf=strGetEditString(es->Edit, 0); laSetString(&ui->PP, buf); free(buf);
  2688. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2689. ui->State = LA_UI_NORMAL;
  2690. laRedrawCurrentPanel();
  2691. return LA_FINISHED_PASS;
  2692. }
  2693. if(ui->State!=LA_UI_ACTIVE) return LA_FINISHED_PASS;
  2694. }
  2695. if (e->type == LA_TIME_IDLE && ui->State!=LA_UI_ACTIVE && !NoTooltip){
  2696. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2697. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2698. return LA_RUNNING;
  2699. }
  2700. if(NoEvent){ return LA_RUNNING_PASS; }
  2701. if(e->type ==LA_KEY_DOWN){
  2702. if (e->key == LA_KEY_ESCAPE){
  2703. if(ui->State != LA_UI_NORMAL){
  2704. buf=strGetEditString(es->Edit, 0); laSetString(&ui->PP, buf); free(buf);
  2705. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2706. ui->State = LA_UI_NORMAL; laRedrawCurrentPanel();la_SetMultistringViewRange(ui,es->Edit,bt);
  2707. }
  2708. if(es->Dragging){ es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel();la_SetMultistringViewRange(ui,es->Edit,bt); }
  2709. return LA_FINISHED;
  2710. }
  2711. }
  2712. if(laKeyMapExecuteEventEx(a, &ui->ExtraPP, &ui->Type->KeyMapper, e)) return LA_RUNNING;
  2713. 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){
  2714. es->Dragging=1; es->LastX=e->x; es->LastY=e->y; es->TargetIndexVali=es->HeightCoeff;
  2715. return LA_RUNNING;
  2716. }
  2717. if(es->Dragging){
  2718. if(e->type==LA_MOUSEMOVE){ es->HeightCoeff=es->TargetIndexVali+((real)e->y-es->LastY+0.5)/LA_RH;
  2719. if(es->HeightCoeff<1)es->HeightCoeff=1; laRecalcCurrentPanel(); la_SetMultistringViewRange(ui,es->Edit,bt);}
  2720. elif(e->type==LA_L_MOUSE_UP){ es->Dragging=0; }
  2721. elif(e->type==LA_R_MOUSE_DOWN){
  2722. es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel();la_SetMultistringViewRange(ui,se,bt); }
  2723. return LA_RUNNING;
  2724. }
  2725. int NoInactiveScroll=ui->Flags&LA_UI_FLAGS_NO_SCROLL_INACTIVE;
  2726. if((!NoInactiveScroll) || (ui->State==LA_UI_ACTIVE)){
  2727. if(e->type==LA_MOUSE_WHEEL_DOWN){ strMoveView(se, MAIN.ScrollingSpeed, 0); laRedrawCurrentPanel(); return LA_RUNNING; }
  2728. elif(e->type==LA_MOUSE_WHEEL_UP){ strMoveView(se, -MAIN.ScrollingSpeed, 0); laRedrawCurrentPanel(); return LA_RUNNING; }
  2729. }
  2730. if (e->type == LA_L_MOUSE_DOWN){
  2731. if (ui->State == LA_UI_NORMAL){
  2732. ui->State = LA_UI_ACTIVE;
  2733. laGetString(&ui->PP, _buf, &buf);
  2734. strBeginEdit(&es->Edit,buf);la_SetMultistringViewRange(ui,es->Edit,bt);
  2735. laRedrawCurrentPanel();
  2736. return LA_RUNNING;
  2737. }
  2738. }
  2739. if (e->type == LA_R_MOUSE_DOWN){
  2740. int GX = e->x, GY = e->y;
  2741. ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
  2742. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2743. 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);
  2744. return LA_RUNNING;
  2745. }
  2746. if (ui->State == LA_UI_ACTIVE){
  2747. if (la_ProcessTextEdit(e, se, ui))laRedrawCurrentPanel();
  2748. return LA_RUNNING;
  2749. }
  2750. if (ui->State != LA_UI_ACTIVE) return LA_RUNNING_PASS;
  2751. else return LA_RUNNING;
  2752. }
  2753. int OPMOD_TabSelector(laOperator *a, laEvent *e){
  2754. laUiItem *ui = a->Instance;
  2755. laBoxedTheme *bt = (*ui->Type->Theme);
  2756. laGeneralUiExtraData *uit = a->CustomData;
  2757. laUiList *uil;
  2758. int Away = 0;
  2759. int count = 0;
  2760. int it = 0;
  2761. int page;
  2762. if (!laIsInBound(e->x, e->y, ui->L, ui->R, ui->U, ui->U+LA_RH)){ return LA_FINISHED; }
  2763. if (e->type == LA_L_MOUSE_DOWN){
  2764. if (ui->Page->HeightCoeff && ui->R - e->x < LA_RH + bt->RM) return LA_RUNNING_PASS;
  2765. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){ count++; }
  2766. page = la_DetectColumn(ui, e->x, count);
  2767. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
  2768. if (it == page){
  2769. laRecalcCurrentPanel();
  2770. ui->Page = uil;
  2771. return LA_RUNNING;
  2772. }else
  2773. it++;
  2774. }
  2775. }
  2776. return LA_RUNNING_PASS;
  2777. }
  2778. int OPMOD_Collection(laOperator *a, laEvent *e) {
  2779. laUiItem *ui = a->Instance;
  2780. laGeneralUiExtraData *uit = a->CustomData;
  2781. laListHandle Locals = {0};
  2782. laUiList *uil;
  2783. int lx = e->x, ly = e->y;
  2784. int at = 0;
  2785. laUiList *ToUil =
  2786. a->ToPanel->MenuRefer ? a->ToPanel->MenuRefer : &a->ToPanel->UI;
  2787. if (!laIsInUiItem(ui, e->x, e->y) /* || e->y>(ui->Subs.pFirst?((laUiList*)ui->Subs.pFirst)->HeightCoeff:10000)*/){
  2788. return LA_FINISHED_PASS;
  2789. }
  2790. laLocalToPanel(a, &lx, &ly);
  2791. if (a->ToPanel && ui->U>=a->ToPanel->TitleBar.B && ly < a->ToPanel->TitleBar.B) {
  2792. return LA_FINISHED_PASS;
  2793. }
  2794. uil = la_DetectUiListRecursive(ToUil, lx, ly, 10000, 0, 0, 0, 0, 0);
  2795. if (uil != ((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target) {
  2796. //printf("%d %d EXITC\n",((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target, uil);
  2797. return LA_FINISHED;
  2798. }
  2799. if (e->type & LA_MOUSE_EVENT) {
  2800. laUiList *sub;
  2801. laUiItem *tui;
  2802. int LimHeight = 10000;
  2803. int UIB = ui->B, UIU = ui->U;
  2804. int t = 0;
  2805. void *Active = ui->PP.EndInstance;
  2806. if (ui->Subs.pFirst)
  2807. LimHeight = (int)((laUiList *)ui->Subs.pFirst)->HeightCoeff;
  2808. if (LimHeight > 0)
  2809. UIB = LimHeight;
  2810. laPanelToLocal(a, &t, &UIB);
  2811. for (sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext) {
  2812. ui->PP.EndInstance = sub->Instance;
  2813. if ((tui = la_DetectUiItemRecursive(sub, e->x, e->y, UIB, &Locals, 0))) {
  2814. if (tui && !a->Child && tui->Type->OperatorType) {
  2815. // printf("invui %d\n", tui);
  2816. laSetOperatorLocalizer(a->ToPanel);
  2817. laInvokeUiP(a, tui->Type->OperatorType, e, tui, &Locals, 0);
  2818. }
  2819. }
  2820. lstClearPointer(&Locals);
  2821. }
  2822. ui->PP.EndInstance = Active;
  2823. }
  2824. if (e->type == LA_L_MOUSE_DOWN && (!laIsPropertyReadOnly(&ui->PP)) &&
  2825. ui->Type != _LA_UI_COLLECTION_SINGLE) {
  2826. laUiList *uil;
  2827. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext) {
  2828. if (a->ConfirmData)
  2829. return LA_RUNNING_PASS;
  2830. if (laIsInBound(e->x, e->y, uil->L, uil->R, uil->U, uil->B)) {
  2831. laRecalcCurrentPanel();
  2832. laPropPack PP = {0};
  2833. la_CopyPropPack(
  2834. &ui->PP,
  2835. &PP); // needed because layout can be switched after set active.
  2836. char *cmd;
  2837. if ((!(cmd = strGetArgumentString(ui->Instructions, "feedback"))) ||
  2838. (!strSame(cmd, "NONE"))) {
  2839. laConfirmPointer(a, uil->Instance, la_EnsureSubTarget(ui->PP.LastPs->p, uil->Instance), LA_CONFIRM_DATA);
  2840. }
  2841. laSetActiveInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance,
  2842. uil->Instance);
  2843. laRecordAndPushProp(&PP, 0);
  2844. laMarkPropChanged(&PP);
  2845. return LA_RUNNING_PASS;
  2846. }
  2847. }
  2848. return LA_RUNNING;
  2849. }
  2850. elif (e->type == LA_R_MOUSE_DOWN) {
  2851. laUiList *uil;
  2852. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext) {
  2853. if (laIsInBound(e->x, e->y, uil->L, uil->R, uil->U, uil->B)) {
  2854. ui->PP.EndInstance = uil->Instance;
  2855. lx = e->x, ly = e->y;
  2856. laLocalToWindow(a, a->ToPanel, &lx, &ly);
  2857. laEnablePropertyPanel(a->ToPanel, a, 0, 0, laui_PropOperatorUiDefine, &ui->PP,
  2858. lx, lx, ly, 0, 0, e);
  2859. }
  2860. }
  2861. return LA_RUNNING;
  2862. }
  2863. return LA_RUNNING_PASS;
  2864. }
  2865. int OPMOD_CollectionSelector(laOperator *a, laEvent *e){
  2866. laUiItem *ui = a->Instance;
  2867. laBoxedTheme *bt = (*ui->Type->Theme);
  2868. laGeneralUiExtraData *uit = a->CustomData;
  2869. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2870. int at = 0;
  2871. int ReadOnly=laIsPropertyReadOnly(&ui->PP);
  2872. int Simple=ui->Flags&LA_UI_COLLECTION_SIMPLE_SELECTOR;
  2873. if (a->ConfirmData /* && a->ConfirmData->Mode == LA_CONFIRM_DATA*/){
  2874. ui->State = LA_UI_NORMAL;
  2875. laRecalcCurrentPanel();
  2876. return LA_RUNNING;
  2877. }
  2878. if (!laIsInUiItem(ui, e->x, e->y)){
  2879. return LA_FINISHED;
  2880. }
  2881. int lx = e->x, ly = e->y;
  2882. laUiList *ToUil =
  2883. a->ToPanel->MenuRefer ? a->ToPanel->MenuRefer : &a->ToPanel->UI;
  2884. laUiList* uil = la_DetectUiListRecursive(ToUil, lx, ly, 10000, 0, 0, 0, 0, 0);
  2885. if (uil != ((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target) {
  2886. //printf("%d %d EXIT\n",((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target, uil);
  2887. return LA_FINISHED;
  2888. }
  2889. if (e->type == LA_TIME_IDLE && !ui->State && !NoTooltip){
  2890. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2891. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2892. return LA_RUNNING;
  2893. }
  2894. if (e->type == LA_L_MOUSE_DOWN){
  2895. laUiList *uil;
  2896. laColumn *col;
  2897. laPanel *p;
  2898. int GX = ui->L, GY = ui->B, GR = ui->R, t = 0;
  2899. if(ReadOnly){ return LA_FINISHED; }
  2900. if(!Simple){
  2901. if (e->x >= TNS_MAX2(ui->R - LA_RH,(ui->R+ui->L)/2) && e->x < ui->R){
  2902. laSetActiveInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, 0);
  2903. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2904. return LA_FINISHED;
  2905. }
  2906. }
  2907. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2908. laLocalToWindow(a, a->ToPanel, &GR, &t);
  2909. laRedrawCurrentPanel();
  2910. ui->State = LA_UI_ACTIVE;
  2911. p = laEnableEmptyPropertyPanel(a->ToPanel, a, GX, GR, GY, 500, e);{
  2912. int MinWidth;
  2913. uil = &p->UI;
  2914. col = laFirstColumn(uil);
  2915. laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_COLLECTION, 0, ui->Template, 0)->SymbolID = ui->SymbolID;
  2916. laEnclosePanelContent(p, &p->UI);
  2917. }
  2918. return LA_RUNNING;
  2919. }
  2920. return LA_RUNNING_PASS;
  2921. }
  2922. int OPMOD_ColumnAdjuster(laOperator *a, laEvent *e){
  2923. laUiItem *ui = a->Instance;
  2924. laBoxedTheme *bt = (*ui->Type->Theme);
  2925. laGeneralUiExtraData *uit = a->CustomData;
  2926. laColumn *c = uit->Ptr1;
  2927. c = uit->Ptr1 ? uit->Ptr1 : la_DetectSplit(ui->C, e->x);
  2928. if(c){ laSetWindowCursor(LA_LEFT_AND_RIGHT); }else{ laSetWindowCursor(LA_ARROW); }
  2929. if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y)||!c)){
  2930. //printf("done\n");
  2931. laSetWindowCursor(LA_ARROW);
  2932. return LA_FINISHED_PASS;
  2933. }
  2934. if (e->type == LA_L_MOUSE_DOWN){
  2935. uit->Ptr1 = c;
  2936. uit->LastX = e->x;
  2937. uit->Dragging=1;
  2938. return LA_RUNNING;
  2939. }
  2940. if (uit->Dragging && uit->Ptr1 && e->type == LA_MOUSEMOVE){
  2941. la_AdjustColumnSplit(c, e->x - uit->LastX);
  2942. uit->LastX = e->x;
  2943. laRecalcCurrentPanel();
  2944. return LA_RUNNING;
  2945. }
  2946. if (uit->Dragging && (e->type == LA_L_MOUSE_UP || e->type == LA_R_MOUSE_DOWN || e->key == LA_KEY_ESCAPE)){
  2947. uit->Ptr1 = 0; uit->Dragging=0;
  2948. return LA_RUNNING;
  2949. }
  2950. return LA_RUNNING;
  2951. }
  2952. void la_NodeSocketGetPositionDelta(laUiItem* ui, int ex,int ey,int* dx,int* dy){
  2953. int cx,cy;
  2954. if(ui->Flags&LA_UI_SOCKET_LABEL_E){ cy=(ui->U+ui->B)/2; cx=ui->L+(ui->B-ui->U)/2; }
  2955. elif(ui->Flags&LA_UI_SOCKET_LABEL_W){ cy=(ui->U+ui->B)/2; cx=ui->R-(ui->B-ui->U)/2; }
  2956. elif(ui->Flags&LA_UI_SOCKET_LABEL_N){ cx=(ui->L+ui->R)/2; cy=ui->U+(ui->R-ui->L)*0.75; }
  2957. elif(ui->Flags&LA_UI_SOCKET_LABEL_S){ cx=(ui->L+ui->R)/2; cy=ui->B-(ui->R-ui->L)*0.75; }
  2958. else{ cx=(ui->L+ui->R)/2; cy=(ui->U+ui->B)/2; }
  2959. *dx=cx-ex; *dy=cy-ey;
  2960. }
  2961. int OPMOD_NodeSocket(laOperator *a, laEvent *e){
  2962. laUiItem *ui = a->Instance;
  2963. laBoxedTheme *bt = (*ui->Type->Theme);
  2964. laGeneralUiExtraData *uit = a->CustomData;
  2965. int lx=e->x,ly=e->y;
  2966. laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
  2967. laPropContainer* PCFind;
  2968. if(pc==LA_PC_SOCKET_IN) { PCFind=LA_PC_SOCKET_OUT; }
  2969. elif(pc==LA_PC_SOCKET_OUT){ PCFind=LA_PC_SOCKET_IN; }
  2970. if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
  2971. if (e->type==LA_TIME_IDLE){ return LA_RUNNING_PASS; }
  2972. if (e->type == LA_L_MOUSE_DOWN){
  2973. uit->Dragging=1; MAIN.NextWireColor+=3;
  2974. if(pc==LA_PC_SOCKET_IN) {
  2975. laNodeInSocket* s=ui->PP.EndInstance;
  2976. uit->Ptr2 = s->Source;
  2977. if(!s->Source){
  2978. s->ColorId=MAIN.NextWireColor; s->Source=MAIN.tNodeOut; latouched_NodeInSocket(0,0);
  2979. MAIN.tNodeOut->RuntimeX=MAIN.tNodeOut->RuntimeY=MAIN.tNodeOut->RuntimePX=MAIN.tNodeOut->RuntimePY=0;
  2980. }else{
  2981. MAIN.tNodeIn->Source = s->Source;
  2982. MAIN.tNodeIn->RuntimeX=MAIN.tNodeIn->RuntimeY=MAIN.tNodeIn->RuntimePX=MAIN.tNodeIn->RuntimePY=0;
  2983. MAIN.tNodeIn->RuntimePX=-(s->Source->RuntimeX+s->Source->RuntimePX)+(s->RuntimeX+s->RuntimePX);
  2984. MAIN.tNodeIn->RuntimePY=-(s->Source->RuntimeY+s->Source->RuntimePY)+(s->RuntimeY+s->RuntimePY);
  2985. s->Source=0; MAIN.tNodeIn->ColorId=s->ColorId; latouched_NodeInSocket(0,0);
  2986. }
  2987. }
  2988. elif(pc==LA_PC_SOCKET_OUT){ MAIN.tNodeIn->Source=ui->PP.EndInstance; latouched_NodeInSocket(0,0);
  2989. MAIN.tNodeIn->RuntimeX=MAIN.tNodeIn->RuntimeY=MAIN.tNodeIn->RuntimePX=MAIN.tNodeIn->RuntimePY=0;
  2990. MAIN.tNodeIn->ColorId=MAIN.NextWireColor; }
  2991. int dx,dy; la_NodeSocketGetPositionDelta(ui,e->x,e->y,&dx,&dy); uit->LastX = e->x+dx; uit->LastY = e->y+dy;
  2992. laRedrawCurrentPanel();
  2993. return LA_RUNNING;
  2994. }
  2995. if (uit->Dragging && e->type == LA_MOUSEMOVE){
  2996. laPanel* p=MAIN.CurrentPanel;
  2997. laLocalToPanel(a, &lx, &ly);
  2998. laUiItem* tui=la_DetectSocketRecursive(&p->UI,lx,ly,100000,uit->Ptr2?LA_PC_SOCKET_IN:PCFind); uit->Ptr1=tui;
  2999. if(pc==LA_PC_SOCKET_IN){
  3000. if(!uit->Ptr2){MAIN.tNodeOut->RuntimeX=e->x-uit->LastX;MAIN.tNodeOut->RuntimeY=e->y-uit->LastY;}
  3001. else { MAIN.tNodeIn->RuntimeX=e->x-uit->LastX;MAIN.tNodeIn->RuntimeY=e->y-uit->LastY; } }
  3002. elif(pc==LA_PC_SOCKET_OUT){ MAIN.tNodeIn->RuntimeX=e->x-uit->LastX; MAIN.tNodeIn->RuntimeY=e->y-uit->LastY; }
  3003. laRedrawCurrentPanel();
  3004. return LA_RUNNING;
  3005. }
  3006. if (uit->Dragging && (e->type == LA_L_MOUSE_UP || e->type == LA_R_MOUSE_DOWN || e->key == LA_KEY_ESCAPE)){
  3007. uit->Dragging=0; MAIN.tNodeIn->Source=0;
  3008. laRecalcCurrentPanel();
  3009. laUiItem* tui=uit->Ptr1; void* soc=tui?tui->PP.EndInstance:0;
  3010. if(pc == LA_PC_SOCKET_IN){
  3011. if(!uit->Ptr2){ if(!tui){ laNodeInSocket* s=ui->PP.EndInstance; s->Source=0; return LA_RUNNING; }
  3012. laNodeInSocket* s=ui->PP.EndInstance; s->Source=0; memAssignRef(s,&s->Source,soc); latouched_NodeInSocket(0,0);
  3013. s->ColorId=MAIN.NextWireColor; laRecordAndPushProp(&ui->PP, 0); laMarkPropChanged(&ui->PP);
  3014. }else{
  3015. if(!tui){
  3016. laNodeInSocket* s=ui->PP.EndInstance; s->Source=uit->Ptr2; memAssignRef(s,&s->Source,0); latouched_NodeInSocket(0,0);
  3017. laRecordAndPushProp(&ui->PP, 0); laMarkPropChanged(&ui->PP);
  3018. }else{
  3019. laNodeInSocket* s=soc; if(s->Source){ uit->Ptr2=0; return LA_RUNNING; } latouched_NodeInSocket(0,0);
  3020. memAssignRef(s,&s->Source,uit->Ptr2); s->ColorId=((laNodeInSocket*)ui->PP.EndInstance)->ColorId;
  3021. laRecordDifferences(&ui->PP,0); laRecordDifferences(&tui->PP,0); laPushDifferences("Socket status changed", 0);
  3022. laMarkPropChanged(&tui->PP); laMarkPropChanged(&ui->PP);
  3023. }
  3024. }
  3025. }
  3026. else{
  3027. if(!tui){ return LA_RUNNING; }
  3028. laNodeInSocket* s=soc; s->Source=0; memAssignRef(s,&s->Source,ui->PP.EndInstance); latouched_NodeInSocket(0,0);
  3029. s->ColorId=MAIN.NextWireColor; laRecordAndPushProp(&tui->PP, 0); laMarkPropChanged(&tui->PP);
  3030. }
  3031. uit->Ptr2=0;
  3032. return LA_RUNNING;
  3033. }
  3034. return LA_RUNNING_PASS;
  3035. }
  3036. int OPMOD_HeightAdjuster(laOperator *a, laEvent *e){
  3037. laUiItem *ui = a->Instance;
  3038. laBoxedTheme *bt = (*ui->Type->Theme);
  3039. laGeneralUiExtraData *uit = a->CustomData;
  3040. int lx=e->x,ly=e->y;
  3041. int ClickedVal=0;
  3042. if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
  3043. if (e->type == LA_L_MOUSE_DOWN || e->type==LA_R_MOUSE_DOWN){
  3044. 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;
  3045. return LA_RUNNING;
  3046. }
  3047. if(e->type==LA_L_MOUSE_UP && uit->HeightCoeff){ ui->State=(ui->State==LA_BT_ACTIVE)?LA_BT_NORMAL:LA_BT_ACTIVE; laRedrawCurrentPanel(); }
  3048. if (uit->Dragging && e->type == LA_MOUSEMOVE){
  3049. int diff=e->y-uit->LastY; diff=((real)diff+0.5)/(ui->B-ui->U); int delta=uit->TargetIndexVali;
  3050. 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(); }
  3051. return LA_RUNNING;
  3052. }
  3053. if (uit->Dragging && (e->type == LA_L_MOUSE_UP || e->type == LA_R_MOUSE_UP || e->key == LA_KEY_ESCAPE)){
  3054. uit->Dragging=0; return LA_RUNNING_PASS;
  3055. }
  3056. return LA_RUNNING_PASS;
  3057. }
  3058. void la_ValueMapperSortPoint(laValueMapper* vm){
  3059. laValueMapperPoint* vmp,*ivmp; laListHandle temp={0}; int Inserted=0;
  3060. while(vmp=lstPopItem(&vm->Points)){
  3061. Inserted=0;
  3062. for(ivmp=temp.pLast;ivmp;ivmp=ivmp->Item.pPrev){
  3063. if(ivmp->x<vmp->x){ lstInsertItemAfter(&temp,vmp,ivmp); Inserted=1; break; }
  3064. }
  3065. if(!Inserted){ lstPushItem(&temp,vmp); }
  3066. }
  3067. vm->Points.pFirst=temp.pFirst; vm->Points.pLast=temp.pLast;
  3068. }
  3069. laValueMapperPoint* la_ValueMapperCreatePoint(laValueMapper* vm, real x, real y){
  3070. laValueMapperPoint* vmp=memAcquire(sizeof(laValueMapperPoint));
  3071. vmp->x=x;vmp->y=y; lstAppendItem(&vm->Points,vmp);
  3072. la_ValueMapperSortPoint(vm);
  3073. return vmp;
  3074. }
  3075. laValueMapperPoint* la_ValueMapperGetPoint(laValueMapper* vm, real x, real y){
  3076. laValueMapperPoint* vmp=0,*ClosestVMP=0; real MinD=FLT_MAX;
  3077. if(x<0||x>1||y>1||y<0) return 0;
  3078. const real thres=0.1;
  3079. for(vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
  3080. if(vmp->x>x+thres || vmp->x<x-thres || vmp->y>y+thres || vmp->y<y-thres) continue;
  3081. real d=tnsDistIdv2(x,y,vmp->x,vmp->y);
  3082. if(d<MinD){ ClosestVMP=vmp; MinD=d; }
  3083. }
  3084. vmp=ClosestVMP;
  3085. if(!vmp){ vmp=la_ValueMapperCreatePoint(vm,x,y); }
  3086. return vmp;
  3087. }
  3088. void la_ValueMapperEnsureValidPoints(laValueMapper* vm){
  3089. if(!vm->Points.pFirst){ la_ValueMapperCreatePoint(vm,0,0); }
  3090. if(vm->Points.pFirst==vm->Points.pLast){ la_ValueMapperCreatePoint(vm,1,1); }
  3091. }
  3092. laValueMapper* laValueMapperInit(){
  3093. laValueMapper* vm=memAcquire(sizeof(laValueMapper));
  3094. vm->InRange[0]=0; vm->InRange[1]=1; vm->OutRange[0]=0; vm->OutRange[1]=1;
  3095. la_ValueMapperEnsureValidPoints(vm);
  3096. return vm;
  3097. }
  3098. laValueMapper* laValueMapperDestroy(laValueMapper* vm){
  3099. laValueMapperPoint* vmp;
  3100. while(vmp=lstPopItem(&vm->Points)){ memLeave(vmp); }
  3101. memLeave(vm);
  3102. }
  3103. laValueMapper* laValueMapperCopy(laValueMapper* new_optional, laValueMapper* vm){
  3104. laValueMapper* into=new_optional?new_optional:memAcquire(sizeof(laValueMapper)); laValueMapperPoint* vmp;
  3105. while(vmp=lstPopItem(&into->Points)){ memLeave(vmp); }
  3106. for(vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){ la_ValueMapperCreatePoint(into, vmp->x, vmp->y); }
  3107. tnsVectorSet2v(into->InRange,vm->InRange); tnsVectorSet2v(into->OutRange,vm->OutRange);
  3108. return into;
  3109. }
  3110. real laValueMapperEvaluate(laValueMapper* vm, real x, real* force_InMin, real* force_InMax, real* force_OutMin, real* force_OutMax, int ClampIn, int ClampOut){
  3111. real InMin=vm->InRange[0], InMax=vm->InRange[1], OutMin=vm->OutRange[0], OutMax=vm->OutRange[1];
  3112. if(force_InMin) InMin=*force_InMin; if(force_InMax) InMax=*force_InMax; if(force_OutMin) OutMin=*force_OutMin; if(force_OutMax) OutMax=*force_OutMax;
  3113. if(fabs(InMax-InMin)<1e-7) return 0;
  3114. x=tnsGetRatiod(InMin,InMax,x); if(ClampIn) TNS_CLAMP(x,0,1);
  3115. laValueMapperPoint* vmp,*NextVMP;
  3116. real ey=0;
  3117. for(vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
  3118. NextVMP=vmp->Item.pNext;
  3119. if(NextVMP && (!(vmp->x<=x && NextVMP->x>x))) continue;
  3120. if(!NextVMP){ NextVMP=vmp; vmp=vmp->Item.pPrev; if(!vmp) return 0; }
  3121. if(fabs(vmp->x-NextVMP->x)<1e-7){ ey=vmp->y; break; }
  3122. real ratio=tnsGetRatiod(vmp->x,NextVMP->x,x);
  3123. ey=tnsInterpolate(vmp->y,NextVMP->y,ratio); break;
  3124. }
  3125. real Out=tnsInterpolate(OutMin,OutMax,ey);
  3126. if(ClampOut) TNS_CLAMP(Out,OutMin,OutMax);
  3127. return Out;
  3128. }
  3129. int OPMOD_ValueMapper(laOperator *a, laEvent *e){
  3130. laUiItem *ui = a->Instance;
  3131. laBoxedTheme *bt = (*ui->Type->Theme);
  3132. laGeneralUiExtraData *uit = a->CustomData;
  3133. int w=ui->R-ui->L, h=ui->B-ui->U;
  3134. real x=(real)(e->x-ui->L)/w,y=(real)(ui->B-e->y)/h;
  3135. int ClickedVal=0;
  3136. if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
  3137. laValueMapper* vm=ui->PP.EndInstance;
  3138. if (e->type == LA_L_MOUSE_DOWN){
  3139. uit->Dragging=1; uit->LastX=e->x; uit->LastY=e->y;
  3140. return LA_RUNNING;
  3141. }
  3142. if (uit->Dragging && e->type == LA_MOUSEMOVE){
  3143. laValueMapperPoint* vmp=uit->Ptr1;
  3144. if(uit->Dragging==1 && tnsDistIdv2(e->x,e->y,uit->LastX,uit->LastY)>LA_RH/2){
  3145. uit->Ptr1=la_ValueMapperGetPoint(vm,x,y); if(!uit->Ptr1){ uit->Dragging=0; return LA_RUNNING; }
  3146. uit->Dragging=2;
  3147. }
  3148. elif(uit->Dragging==2){
  3149. if(x<0&&x>-0.05){ x=0; } if(x>1&&x<1.05){ x=1; } TNS_CLAMP(y,0,1);
  3150. vmp->x=x; vmp->y=y; la_ValueMapperSortPoint(vm);
  3151. laNotifyUsersPP(&ui->PP); laRedrawCurrentPanel(); laMarkPropChanged(&ui->PP);
  3152. }
  3153. return LA_RUNNING;
  3154. }
  3155. if (uit->Dragging && (e->type == LA_L_MOUSE_UP || e->type == LA_R_MOUSE_UP || e->key == LA_KEY_ESCAPE)){
  3156. uit->Dragging=0; laValueMapperPoint* vmp=uit->Ptr1; if(!vmp) return LA_RUNNING_PASS;
  3157. if(vmp->x>1||vmp->x<0) {
  3158. lstRemoveItem(&vm->Points,vmp); la_ValueMapperEnsureValidPoints(vm);
  3159. laNotifyUsersPP(&ui->PP); laRedrawCurrentPanel(); laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  3160. }
  3161. return LA_RUNNING_PASS;
  3162. }
  3163. return LA_RUNNING_PASS;
  3164. }
  3165. void la_RegisterUiOperatorsBasic(){
  3166. laPropContainer *pc, *p;
  3167. laOperatorType *at;
  3168. laEnumProp *ep;
  3169. laCreateOperatorType("LA_edit_string_copy", "Copy Selection", "Copy selected string to clip board",
  3170. OPCHK_EditStringCopySelection, 0, 0, OPINV_EditStringCopySelection, 0, U'🗍', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3171. laCreateOperatorType("LA_int_array_h_operator", "Int(Horizon) UiItem Operator", "Do Array Valuator Stuff",
  3172. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_IntArrayHorizon, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3173. laCreateOperatorType("LA_real_array_h_operator", "Float(Horizon) UiItem Operator", "Do Array Valuator Stuff",
  3174. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_FloatArrayHorizon, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3175. laCreateOperatorType("LA_real_color_operator", "Color(Float) Display UiItem Operator", "Color Display,Click To Set Color",
  3176. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_FloatColor, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3177. laCreateOperatorType("LA_real_hcy_operator", "HCY Color Picker UiItem Operator", "HCY Color Picker,Click To Set Color",
  3178. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ColorHCY, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3179. laCreateOperatorType("LA_enum_selector_operator", "Enum Selector UiItem Operator", "Do Selector Stuff",
  3180. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_EnumSelector, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3181. laCreateOperatorType("LA_button_operator", "Button UiItem Operator", "Execute an Operator",
  3182. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_Button, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3183. laCreateOperatorType("LA_menu_root_operator", "Menu Root UiItem Operator", "Drop A Menu",
  3184. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_MenuItem, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3185. laCreateOperatorType("LA_condition_toggle_operator", "Condition +/- Button Operator", "Do Self Condition Function",
  3186. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ConditionToggle, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3187. laCreateOperatorType("LA_string_operator", "Single Line String Operator", "Do String Modifying Function",
  3188. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_SingleLineString, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3189. laCreateOperatorType("LA_string_multi", "Multi Line String Operator", "Do String Modifying Function",
  3190. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_MultiString, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3191. laCreateOperatorType("LA_tab_operator", "Tab Switcher Operator", "Change The Page In The Tab Group",
  3192. 0, 0, OPEXT_UiItem, OPINV_Tab, OPMOD_TabSelector, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3193. laCreateOperatorType("LA_collection_operator", "Collection UiItem Operator", "Activate/Deactivate Collection Item(s)",
  3194. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_Collection, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3195. laCreateOperatorType("LA_collection_selector_operator", "Collection Dropdown Selector Operator", "Do Selector Stuff",
  3196. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_CollectionSelector, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3197. laCreateOperatorType("LA_column_adjuster", "Column Width Adjuster", "Drag To Set Width of Columns",
  3198. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ColumnAdjuster, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3199. laCreateOperatorType("LA_node_socket", "Node Socket Operator", "Drag to connect node sockets",
  3200. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_NodeSocket, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3201. laCreateOperatorType("LA_height_adjuster", "Height Adjuster Operator", "Drag to adjust heights of an instance",
  3202. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_HeightAdjuster, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3203. laCreateOperatorType("LA_value_mapper", "Value mapper Operator", "Drag to set value mapping from input to output",
  3204. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ValueMapper, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3205. }