*/}}

la_widgets.c 151 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579
  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. if (!ui->State) ui->State = LA_UI_NORMAL;
  947. if (ui->ExtraInstructions && !ui->Instructions){
  948. strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
  949. }
  950. //int State = ui->Instructions ? (strArgumentMatch(ui->Instructions, "disabled", "true") ? LA_THEME_DISABLED : LA_UI_NORMAL) : LA_UI_NORMAL;
  951. tnsDrawStringAuto(transLate(SSTR(ui->Display)),
  952. IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):(IsHighlight?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT)),
  953. ui->L, ui->R, ui->U, ui->Flags);
  954. }
  955. void la_SingleLineStringDrawSelection(laUiItem *ui, int Begin, int U, laBoxedTheme *bt, uint32_t *str, laStringEdit *se){
  956. tnsUseNoTexture();
  957. if (!strHasSelection(se)){
  958. tnsColor4dv(laAccentColor(LA_BT_TEXT));
  959. int L = (se->CursorBefore ? tnsStringGetWidthU(str, se->CursorBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
  960. tnsVertex2d(L-1, U + LA_RH - bt->BM);
  961. tnsVertex2d(L-1, U + bt->TM);
  962. tnsVertex2d(L+2, U + bt->TM);
  963. tnsVertex2d(L+2, U + LA_RH - bt->BM);
  964. tnsPackAs(GL_TRIANGLE_FAN);
  965. }else{
  966. int L = (se->BeginBefore ? tnsStringGetWidthU(str, se->BeginBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
  967. int R = (se->EndBefore ? tnsStringGetWidthU(str, se->EndBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
  968. tnsColor4dv(laAccentColor(LA_BT_NORMAL));
  969. tnsVertex2d(L, U + bt->TM);
  970. tnsVertex2d(L, U + LA_RH - bt->BM);
  971. tnsVertex2d(R, U + LA_RH - bt->TM);
  972. tnsVertex2d(R, U + bt->BM);
  973. tnsPackAs(GL_TRIANGLE_FAN);
  974. }
  975. }
  976. void la_SingleLineStringDraw(laUiItem *ui, int h){
  977. laBoxedTheme *bt = (*ui->Type->Theme);
  978. char* _temp[LA_RAW_CSTR_MAX_LEN] = {0}; char* temp=_temp;
  979. uint32_t* line=0;
  980. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  981. int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
  982. if (!ui->State) ui->State = LA_UI_NORMAL;
  983. if(!NoDecal){
  984. tnsUseNoTexture();
  985. tnsColor4dv(laThemeColor(bt, ui->State));
  986. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  987. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  988. tnsPackAs(GL_TRIANGLE_FAN);
  989. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  990. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  991. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  992. tnsPackAs(GL_LINE_LOOP);
  993. }
  994. if (ui->Extra && ui->Extra->Edit){
  995. line=strGetCursorLine(ui->Extra->Edit,0)->Buf;
  996. }else{
  997. laGetString(&ui->PP, _temp, &temp);
  998. }
  999. if (line) la_SingleLineStringDrawSelection(ui, ui->L+(NoDecal?0:bt->LM), ui->U, bt, line, ui->Extra->Edit);
  1000. if(ui->PP.LastPs->p->CanTranslate){ temp=transLate(temp); }
  1001. 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);
  1002. }
  1003. void la_MultiStringDraw(laUiItem *ui, int h){
  1004. laBoxedTheme *bt = (*ui->Type->Theme);
  1005. char _temp[LA_RAW_CSTR_MAX_LEN] = {0}; char* temp=_temp;
  1006. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  1007. if (!ui->State) ui->State = LA_UI_NORMAL;
  1008. int NumberWidth=bt->LM;
  1009. if((!ui->Extra->Edit) || (ui->Extra->Ptr1!=ui->PP.EndInstance)){
  1010. laGetString(&ui->PP, _temp, &temp);
  1011. strBeginEdit(&ui->Extra->Edit, temp);
  1012. ui->Extra->Ptr1=ui->PP.EndInstance;
  1013. }
  1014. laStringEdit* se=ui->Extra->Edit;
  1015. real MonoWidth=tnsGetMonoFontAdvance(); int Count=se->TotalLines;
  1016. while(Count){ Count/=10; NumberWidth+=MonoWidth; }
  1017. if (ui->State!=LA_UI_ACTIVE){
  1018. strSetEditViewRange(ui->Extra->Edit,
  1019. ui->Extra->HeightCoeff>0?ui->Extra->HeightCoeff:((ui->B-ui->U)/LA_RH),(ui->R-ui->L-NumberWidth-bt->LM*2-bt->RM)/MonoWidth);
  1020. }
  1021. if(!NoDecal){
  1022. tnsUseNoTexture();
  1023. tnsColor4dv(laThemeColor(bt, ui->State));
  1024. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1025. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1026. tnsPackAs(GL_TRIANGLE_FAN);
  1027. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  1028. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1029. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1030. tnsPackAs(GL_LINE_LOOP);
  1031. tnsColor4d(LA_COLOR3(laThemeColor(bt,LA_BT_BORDER)),0.8);
  1032. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->L+NumberWidth, ui->U);
  1033. tnsVertex2d(ui->L, ui->B); tnsVertex2d(ui->L+NumberWidth, ui->B);
  1034. tnsPackAs(GL_QUADS);
  1035. if(!(se->CursorLine<se->ViewStartLine||se->CursorLine>se->ViewStartLine+se->ViewHeight)){
  1036. int LineU=(se->CursorLine-se->ViewStartLine)*LA_RH+ui->U;
  1037. tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_NORMAL):laThemeColor(bt,LA_BT_BORDER));
  1038. tnsVertex2d(ui->L, LineU); tnsVertex2d(ui->R, LineU);
  1039. tnsVertex2d(ui->L, LineU+LA_RH); tnsVertex2d(ui->R, LineU+LA_RH);
  1040. tnsPackAs(GL_LINES);
  1041. tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT_NORMAL));
  1042. tnsVertex2d(ui->L, LineU); tnsVertex2d(ui->L+NumberWidth, LineU);
  1043. tnsVertex2d(ui->L, LineU+LA_RH); tnsVertex2d(ui->L+NumberWidth, LineU+LA_RH);
  1044. tnsPackAs(GL_QUADS);
  1045. }
  1046. }else{
  1047. NumberWidth=bt->LM;
  1048. }
  1049. tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
  1050. int Line=0, Skip=0, _L=ui->L+NumberWidth+bt->LM; char num[10]={0};
  1051. for(laStringLine* sl=se->Lines.pFirst;sl;sl=sl->Item.pNext){
  1052. int UseLine=Line+Skip;
  1053. if(UseLine<se->ViewStartLine){ Skip++; continue; }
  1054. if(UseLine>=se->ViewHeight+se->ViewStartLine){ break; }
  1055. int slen=strlenU(sl->Buf);
  1056. sprintf(num,"%d", UseLine+1); int LineU=ui->U+Line*LA_RH;
  1057. tnsDrawStringM(num, 0, laThemeColor(bt, ((UseLine==se->CursorLine)?LA_BT_NORMAL:LA_BT_TEXT)),
  1058. _L-bt->LM -(tnsStringGetWidth(num, 0, ui->Flags&LA_TEXT_MONO)), ui->R, LineU, ui->Flags);
  1059. if(slen>=se->ViewStartCol){
  1060. tnsDrawStringM(0, &sl->Buf[se->ViewStartCol], laThemeColor(bt, ui->State|LA_BT_TEXT), _L, ui->R, LineU, ui->Flags|LA_TEXT_OVERFLOW_ARROW);
  1061. }
  1062. if(UseLine>=se->BeginLine&&UseLine<=se->EndLine){
  1063. int BeginC=UseLine==se->BeginLine?se->BeginBefore:0; int EndC=UseLine==se->EndLine?se->EndBefore:slen;
  1064. BeginC-=se->ViewStartCol; EndC-=se->ViewStartCol; if(EndC>se->ViewWidth)EndC=se->ViewWidth;
  1065. tnsUseNoTexture();
  1066. tnsVertex2d(BeginC*MonoWidth+_L, LineU); tnsVertex2d(EndC*MonoWidth+_L, LineU);
  1067. tnsVertex2d(EndC*MonoWidth+_L, LineU+LA_RH); tnsVertex2d(BeginC*MonoWidth+_L, LineU+LA_RH);
  1068. tnsColor4dv(laAccentColor(LA_BT_NORMAL));
  1069. tnsPackAs(GL_TRIANGLE_FAN);
  1070. }
  1071. int len=strlenU(sl->Buf);
  1072. if(UseLine==se->CursorLine){
  1073. int Dist=se->CursorBefore==0?0:tnsStringGetWidthU(sl->Buf,se->CursorBefore,ui->Flags&LA_TEXT_MONO);
  1074. tnsUseNoTexture(); int d=se->ViewStartCol*MonoWidth; real w2=LA_RH/12;
  1075. tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT_NORMAL));
  1076. tnsVertex2d(_L+Dist-w2-d, LineU); tnsVertex2d(_L+Dist+w2-d, LineU);
  1077. tnsVertex2d(_L+Dist-w2-d, LineU+LA_RH); tnsVertex2d(_L+Dist+w2-d, LineU+LA_RH);
  1078. tnsPackAs(GL_QUADS);
  1079. }
  1080. Line++;
  1081. tnsFlush();
  1082. }
  1083. if(ui->Extra->HeightCoeff>=0)
  1084. tnsDrawStringAuto("◿",laThemeColor(bt,LA_BT_BORDER),ui->R-LA_RH, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
  1085. if(!NoDecal){
  1086. char buf[100]={0}; sprintf(buf, "%d,%d | %d Lines", se->CursorLine+1, se->CursorBefore+1, se->TotalLines);
  1087. 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);
  1088. }
  1089. //if (ui->Extra && ui->Extra->Edit) la_SingleLineStringDrawSelection(ui, ui->L, ui->U, bt, temp, ui->Extra->Edit);
  1090. tnsFlush();
  1091. }
  1092. void la_UiSeperatorDraw(laUiItem *ui, int h){
  1093. laBoxedTheme *bt = (*ui->Type->Theme);
  1094. if (!bt) return;
  1095. if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){
  1096. char str[]="🞄";
  1097. int strw=tnsStringGetWidth(str,0, 0);
  1098. tnsDrawStringM(str, 0, laThemeColor(bt,LA_BT_BORDER), ui->L+(ui->R-ui->L-strw)/2, ui->R, ui->U, 0);
  1099. }else{
  1100. tnsUseNoTexture();
  1101. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1102. real u=(ui->U+ui->B)/2; tnsVertex2d(ui->L, u); tnsVertex2d(ui->R, (ui->U+ui->B)/2);
  1103. tnsPackAs(GL_LINES);
  1104. }
  1105. }
  1106. void la_ColorCircleDrawHCY(laUiItem *ui, int h){
  1107. laBoxedTheme *bt = (*ui->Type->Theme);
  1108. real c = (real)((ui->R + ui->L) / 2) - h / 2; /*- bt->RM*/
  1109. real r = (ui->B - ui->U - bt->TP - bt->BP) / 2;
  1110. int i = 0;
  1111. real colors[584]={0}; //4*72*2+4*2
  1112. real verts[292]={0}; //72*2*2+2*2
  1113. real hcy[3] = {0, 1, 1};
  1114. real step = 1.0 / 72.0f;
  1115. real RealColor[4] = {0,0,0,1};
  1116. real PickerPos[2];
  1117. real pi_4;
  1118. GLuint index[26];
  1119. real v, cv, sv;
  1120. real lw = (float)(ui->B-ui->U)/LA_RH/5; if(lw<1.0f) lw=1.0f;
  1121. laGetFloatArray(&ui->PP, RealColor);
  1122. if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LogsRGB(RealColor); }
  1123. tnsRGB2HCY(RealColor, hcy);
  1124. PickerPos[0] = c + cos(hcy[0] * TNS_PI * 2) * pow(hcy[1],1.0f/MAIN.ColorPickerGamma) * r;
  1125. PickerPos[1] = ui->U + r + sin(hcy[0] * TNS_PI * 2) * pow(hcy[1],1.0f/MAIN.ColorPickerGamma) * r;
  1126. hcy[0] = 0;
  1127. hcy[1] = 1;
  1128. for (i; i < 72; i += 1){
  1129. int beg = i * 8;
  1130. hcy[0]+=step; tnsVectorSet3v(&colors[beg],hcy); colors[beg+3]=1;
  1131. tnsVectorSet4v(&colors[beg+4],&colors[beg]); colors[beg+5]=0;
  1132. }
  1133. tnsFlush();
  1134. int IsClay=ui->Flags&LA_UI_FLAGS_COLOR_SPACE_CLAY;
  1135. int ShowInfo=0;
  1136. if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_SRGB && (!IsClay)){
  1137. tnsUniformShowColorOverflowStripes(T->immShader,1);
  1138. }
  1139. if(IsClay){
  1140. tnsUniformInputColorSpace(T->immShader,TNS_COLOR_SPACE_CLAY);
  1141. if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_CLAY) ShowInfo=1;
  1142. }else{
  1143. tnsUniformInputColorSpace(T->immShader,TNS_COLOR_SPACE_SRGB);
  1144. }
  1145. tnsUseNoTexture();
  1146. tnsVectorSet4(&colors[576],1,1,hcy[2],1);
  1147. tnsVectorSet4(&colors[580],1,0,hcy[2],1);
  1148. tnsColorArray4d(colors, 146);
  1149. tnsMakeCircle2d(verts, 72, c, ui->U + r, r, 1);
  1150. for(int i=0;i<73;i++){ tnsVectorSet2(&verts[2+i*4],c,ui->U + r); }
  1151. tnsVectorSet2v(&verts[288],&verts[0]);
  1152. tnsVectorSet2v(&verts[290],&verts[2]);
  1153. tnsVertexArray2d(verts, 146);
  1154. tnsPackAs(GL_TRIANGLE_STRIP);
  1155. tnsUniformColorMode(T->immShader,1); tnsUniformHCYGamma(T->immShader,MAIN.ColorPickerGamma);
  1156. tnsFlush();
  1157. tnsUniformColorMode(T->immShader,0);
  1158. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1159. tnsMakeCircle2d(verts, 72, c, ui->U + r, r, 0);
  1160. tnsVertexArray2d(verts, 72);
  1161. tnsPackAs(GL_LINE_LOOP);
  1162. pi_4 = TNS_PI / 4;
  1163. tnsMakeArc2d(&verts[26], 12, c, ui->U + r, r + bt->LM + h, pi_4, -pi_4);
  1164. tnsMakeArc2d(verts, 12, c, ui->U + r, r + bt->LM, pi_4, -pi_4);
  1165. tnsMakeLinerGradient4d(&colors[52], 13, 0, 0, 0, 1, 1, 1, 1, 1);
  1166. tnsMakeLinerGradient4d(colors, 13, 0, 0, 0, 1, 1, 1, 1, 1);
  1167. tnsMakeBridgedIndex(index, 13, 0, 0);
  1168. tnsColorArray4d(colors, 26);
  1169. tnsVertexArray2d(verts, 26);
  1170. tnsIndexArray(index, 26);
  1171. tnsPackAs(GL_QUAD_STRIP);
  1172. tnsMakeArc2d(&verts[26], 12, c, ui->U + r, r + bt->LM + h, -pi_4, pi_4);
  1173. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1174. tnsVertexArray2d(verts, 26);
  1175. tnsPackAs(GL_LINE_LOOP);
  1176. v = -hcy[2] + 0.5;
  1177. cv = cos(v / 2 * TNS_PI);
  1178. sv = sin(v / 2 * TNS_PI);
  1179. tnsLineWidth(lw);
  1180. verts[0] = cv * r + c; verts[1] = sv * r + ui->U + r;
  1181. verts[2] = cv * (r + h) + c; verts[3] = sv * (r + h) + ui->U + r;
  1182. tnsColor4d(1, 1, 1, 1);
  1183. tnsVertexArray2d(verts, 2);
  1184. tnsPackAs(GL_LINES);
  1185. verts[1]+=lw; verts[3]+=lw;
  1186. tnsColor4d(0, 0, 0, 1);
  1187. tnsVertexArray2d(verts, 2);
  1188. tnsPackAs(GL_LINES);
  1189. real circleR=lw*8;
  1190. tnsColor4dv(RealColor);
  1191. tnsMakeCircle2d(verts, 16, PickerPos[0], PickerPos[1], circleR,0);
  1192. tnsVertexArray2d(verts, 16);
  1193. tnsPackAs(GL_TRIANGLE_FAN);
  1194. tnsColor4d(1, 1, 1, 1);
  1195. tnsVertexArray2d(verts, 16);
  1196. tnsPackAs(GL_LINE_LOOP);
  1197. tnsMakeCircle2d(verts, 16, PickerPos[0], PickerPos[1], circleR-lw,0);
  1198. tnsColor4d(0.1, 0.1, 0.1, 1);
  1199. tnsVertexArray2d(verts, 16);
  1200. tnsPackAs(GL_LINE_LOOP);
  1201. tnsLineWidth(1);
  1202. 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);
  1203. 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);
  1204. if(ShowInfo) tnsDrawStringAuto("🛈",laThemeColor(bt,LA_BT_TEXT),c-r, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_LEFT);
  1205. tnsFlush();
  1206. tnsUniformShowColorOverflowStripes(T->immShader,0);
  1207. tnsUniformInputColorSpace(T->immShader,0);
  1208. }
  1209. void la_MenuItemDraw(laUiItem *ui, int h){
  1210. laBoxedTheme *bt = (*ui->Type->Theme);
  1211. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  1212. if(!NoDecal){
  1213. tnsUseNoTexture();
  1214. tnsColor4dv(laThemeColor(bt, ui->State));
  1215. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1216. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1217. tnsPackAs(GL_TRIANGLE_FAN);
  1218. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  1219. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1220. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1221. tnsPackAs(GL_LINE_LOOP);
  1222. }
  1223. tnsDrawStringAuto(transLate(ui->Display->Ptr), laThemeColor(bt, LA_BT_TEXT|ui->State), ui->L+bt->LM, ui->R, ui->U, ui->Flags);
  1224. }
  1225. void la_ConditionToggleDraw(laUiItem *ui, int h){
  1226. laBoxedTheme *bt = (*ui->Type->Theme);
  1227. char temp[128] = {0};
  1228. char *buf[LA_RAW_CSTR_MAX_LEN];
  1229. uint32_t IconID;
  1230. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  1231. if (!ui->State) ui->State = LA_UI_NORMAL;
  1232. int UseState=ui->State;
  1233. if (!(ui->Flags&LA_TEXT_ALIGN)) ui->Flags|=LA_TEXT_ALIGN_CENTER;
  1234. if(!NoDecal){
  1235. tnsUseNoTexture();
  1236. tnsColor4dv(laThemeColor(bt, ui->State));
  1237. tnsVertex2d(ui->L, ui->U);
  1238. tnsVertex2d(ui->R, ui->U);
  1239. tnsVertex2d(ui->R, ui->B);
  1240. tnsVertex2d(ui->L, ui->B);
  1241. tnsPackAs(GL_TRIANGLE_FAN);
  1242. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  1243. tnsVertex2d(ui->L, ui->U);
  1244. tnsVertex2d(ui->R, ui->U);
  1245. tnsVertex2d(ui->R, ui->B);
  1246. tnsVertex2d(ui->L, ui->B);
  1247. tnsPackAs(GL_LINE_LOOP);
  1248. }else{
  1249. UseState=LA_UI_NORMAL;
  1250. }
  1251. buf[0] = 0;
  1252. if (ui->ExtraInstructions){
  1253. if (ui->Type->OperatorType->ParseArgs){
  1254. ui->Type->OperatorType->ParseArgs(ui->Instructions, &IconID, buf);
  1255. }
  1256. }
  1257. if (buf[0]) tnsDrawStringAuto(transLate(buf), laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
  1258. else
  1259. tnsDrawStringAuto(ui->State == LA_UI_ACTIVE ? "⯆" : "⯈", laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
  1260. }
  1261. void la_DrawColumnAdjusterRecursive(int U, int B, laColumn *c, int W, tnsVector3d color, int LeftMost){
  1262. if (c->LS){
  1263. la_DrawColumnAdjusterRecursive(U, B, c->LS, W, color, LeftMost);
  1264. la_DrawColumnAdjusterRecursive(U, B, c->RS, W, color, LeftMost);
  1265. }else{
  1266. if(c->IL==LeftMost) return;
  1267. tnsDrawStringAuto("⌉⌈", color, c->IL-LA_RH, c->IL+LA_RH, U, LA_TEXT_ALIGN_CENTER);
  1268. }
  1269. }
  1270. void la_ColumnAdjusterDraw(laUiItem *ui, int h){
  1271. laBoxedTheme *bt = (*ui->Type->Theme);
  1272. tnsUseNoTexture();
  1273. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
  1274. la_DrawColumnAdjusterRecursive(ui->U, ui->U + LA_RH, ui->C, (bt->LM+bt->RM)/2, laThemeColor(bt, LA_BT_TEXT), ui->C->IL);
  1275. }
  1276. void la_ColumnViewerDraw(laUiItem *ui, int h){
  1277. laBoxedTheme *bt = (*ui->Type->Theme);
  1278. laColumn *c = ui->PP.EndInstance;
  1279. int W = ui->R - ui->L - bt->LM - bt->RM;
  1280. //if (c->IR == c->IL)
  1281. // return;
  1282. int T = c->Top->IR - c->Top->IL;
  1283. int L = (int)((real)(c->IL - c->Top->IL) * W / T) + ui->L + bt->LM,
  1284. R = (int)((real)(c->IR - c->Top->IL) * W / T) + ui->L + bt->LM;
  1285. tnsUseNoTexture();
  1286. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1287. tnsVertex2d(L, ui->U + bt->TM);
  1288. tnsVertex2d(R, ui->U + bt->TM);
  1289. tnsVertex2d(R, ui->B - bt->BM);
  1290. tnsVertex2d(L, ui->B - bt->BM);
  1291. tnsPackAs(GL_TRIANGLE_FAN);
  1292. }
  1293. void la_NodeSocketDraw(laUiItem *ui, int h){
  1294. laBoxedTheme *bt = (*ui->Type->Theme);
  1295. char* label=0; char* icon;
  1296. laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
  1297. real* ColorBkg=0,*ColorSocket;
  1298. 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:""; }
  1299. 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:""; }
  1300. int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
  1301. tnsUseNoTexture();
  1302. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1303. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1304. tnsColor4dv(ColorBkg);
  1305. tnsPackAs(GL_TRIANGLE_FAN);
  1306. int tl,tr,tu,sl,sr,su;
  1307. 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; }
  1308. 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; }
  1309. 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; }
  1310. 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; }
  1311. else{ sl=ui->L; su=ui->U; sr=ui->R; label=0; }
  1312. tnsDrawStringAuto("⭗", IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):ColorSocket, sl, sr, su, LA_TEXT_ALIGN_CENTER);
  1313. if(label) tnsDrawStringAuto(label, IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):ColorSocket, tl, tr, tu, LA_TEXT_ALIGN_CENTER|LA_TEXT_MONO);
  1314. }
  1315. void la_HeightAdjusterDraw(laUiItem *ui, int h){
  1316. laBoxedTheme *bt = (*ui->Type->Theme);
  1317. char* str="☰";
  1318. if(ui->State==LA_BT_ACTIVE){ str="🡙"; }
  1319. tnsDrawStringAuto(str, laThemeColor(bt,LA_BT_TEXT), ui->L-1000, ui->R+1000, ui->U, LA_TEXT_ALIGN_CENTER);
  1320. }
  1321. void la_RawPropDraw(laUiItem *ui, int h){
  1322. laBoxedTheme *bt = (*ui->Type->Theme);
  1323. int s=0;
  1324. //void* data=laGetRaw(&ui->PP, &s);
  1325. //char* buf[128]; sprintf(buf,"%d bytes of raw data at 0x%0x", s, data);
  1326. tnsDrawStringAuto("RAW DATA", laThemeColor(bt,LA_BT_TEXT), ui->L, ui->R, ui->U, ui->Flags|LA_TEXT_MONO);
  1327. }
  1328. void la_MapperDraw(laUiItem *ui, int h){
  1329. laBoxedTheme *bt = (*ui->Type->Theme);
  1330. int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
  1331. if(!NoDecal){
  1332. tnsUseNoTexture();
  1333. tnsColor4dv(laThemeColor(bt, LA_BT_NORMAL));
  1334. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1335. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1336. tnsPackAs(GL_TRIANGLE_FAN);
  1337. tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
  1338. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1339. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1340. tnsPackAs(GL_LINE_LOOP);
  1341. }
  1342. laPropContainer* pc=la_EnsureSubTarget(ui->PP.LastPs->p,ui->PP.EndInstance);
  1343. if(!pc || pc!=LA_PC_MAPPER || !ui->PP.EndInstance){
  1344. tnsDrawStringAuto("Property is not a la_value_mapper.",0,ui->L+bt->LM,ui->R-bt->RM,bt->TM,LA_TEXT_LINE_WRAP); return;
  1345. }
  1346. laValueMapper* vm=ui->PP.EndInstance; int any=0;
  1347. tnsColor4dv(laAccentColor(LA_BT_TEXT));
  1348. for(laValueMapperPoint* vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
  1349. tnsVertex2d(tnsInterpolate(ui->L,ui->R,vmp->x),tnsInterpolate(ui->B,ui->U,vmp->y)); any++;
  1350. } tnsPackAs(GL_LINE_STRIP);
  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));
  1353. } tnsPackAs(GL_POINTS);
  1354. if(any){ glLineWidth(2); glPointSize(5); tnsFlush(); glPointSize(1); glLineWidth(1); }
  1355. }
  1356. void la_ImageDraw(laUiItem *ui, int h){
  1357. laBoxedTheme *bt = (*ui->Type->Theme);
  1358. tnsImage* im=ui->Extra;
  1359. if(!im->Texture) { tns_ImageToTexture(im); }
  1360. if(!im->Texture) {
  1361. tnsUseNoTexture();
  1362. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1363. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  1364. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  1365. tnsPackAs(GL_LINE_LOOP);
  1366. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->B);
  1367. tnsVertex2d(ui->R, ui->U); tnsVertex2d(ui->L, ui->B);
  1368. tnsPackAs(GL_LINES);
  1369. return;
  1370. }
  1371. int W=im->Texture->Width, H=im->Texture->Height;
  1372. int Full=ui->Flags&LA_UI_IMAGE_FULL_W;
  1373. real r=(real)(ui->R-ui->L)/W; if(r<1){W*=r;H*=r;}
  1374. real UseW=Full?(W):((real)LA_RH*ui->SymbolID/H*W);
  1375. real L=(ui->R-ui->L-UseW)/2,U=0,UseH=Full?H:(ui->B-ui->U);
  1376. if(Full){ U=(ui->B-ui->U-H)/2; }
  1377. if(ui->Flags&LA_TEXT_ALIGN_CENTER){ L=0; }
  1378. elif(ui->Flags&LA_TEXT_ALIGN_RIGHT){ L=ui->R-ui->L-UseW; }
  1379. tnsDraw2DTextureDirectly(im->Texture,ui->L+L,ui->U+U,UseW,UseH);
  1380. tnsFlush();
  1381. }
  1382. void la_ValueMeterType1Draw(laUiItem *ui, int h){
  1383. laBoxedTheme *bt = (*ui->Type->Theme);
  1384. int DataI[8]; real Data[8];
  1385. int Len, i, W; real Seg;
  1386. char buf[48] = {0};
  1387. char buf2[48] = {0};
  1388. char prefix[8][64] = {0};
  1389. int Original;
  1390. int Imin=-100, Imax=100;
  1391. real min=-100, max=100;
  1392. int s, State; int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  1393. int NoLabel=ui->Flags&LA_UI_FLAGS_NO_LABEL;
  1394. int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
  1395. Len = laGetArrayLength(&ui->PP);
  1396. laGetPrefixP(&ui->PP, prefix);
  1397. if(IsInt){
  1398. laGetIntArray(&ui->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
  1399. laGetIntRange(&ui->PP, &Imin, &Imax); min=Imin; max=Imax;
  1400. }else{
  1401. laGetFloatArray(&ui->PP, Data);
  1402. laGetFloatRange(&ui->PP,&min,&max);
  1403. }
  1404. for (i = 0; i < Len; i++){
  1405. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  1406. if(IsVertical){
  1407. Seg = (real)(ui->R-ui->L)/Len;
  1408. _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
  1409. }else{
  1410. Seg = (real)(ui->B-ui->U)/Len;
  1411. _U = ui->U + i * Seg; _B=_U+Seg;
  1412. }
  1413. tnsUseNoTexture();
  1414. tnsColor4dv(laThemeColor(bt,ui->State));
  1415. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1416. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1417. tnsPackAs(GL_TRIANGLE_FAN);
  1418. int oflow=0,ofhigh=0;
  1419. if(Data[i]<min){ oflow=1; Data[i]=min; }
  1420. if(Data[i]>max){ ofhigh=1; Data[i]=max; }
  1421. int R1=_R,U1=_U;
  1422. if(IsVertical){ U1 = (real)(max - Data[i]) / (real)(max - min) * (real)(_B-_U) + _U; }
  1423. else{ R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(_R-_L) + _L; }
  1424. tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
  1425. tnsColor4d(LA_COLOR3(color),0.4);
  1426. tnsVertex2d(_L, U1); tnsVertex2d(R1, U1);
  1427. tnsVertex2d(R1, _B); tnsVertex2d(_L, _B);
  1428. tnsPackAs(GL_TRIANGLE_FAN);
  1429. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1430. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1431. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1432. tnsPackAs(GL_LINE_LOOP);
  1433. if(!NoLabel){
  1434. if(Len==1){ sprintf(buf,ui->PP.LastPs->p->Name); } else{ if(i<8)sprintf(buf,prefix[i]); }
  1435. if(buf[0]) tnsDrawStringAuto(buf, laThemeColor(bt, LA_BT_TEXT), _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
  1436. }
  1437. if(IsVertical){
  1438. if(oflow){ tnsDrawStringAuto("⯆",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_CENTER); }
  1439. elif(ofhigh){ tnsDrawStringAuto("⯅",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _B-LA_RH, LA_TEXT_ALIGN_CENTER); }
  1440. }else{
  1441. if(oflow){ tnsDrawStringAuto("⯇",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_LEFT); }
  1442. elif(ofhigh){ tnsDrawStringAuto("⯈",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_RIGHT); }
  1443. }
  1444. }
  1445. int trisize=LA_RH/3.0f;
  1446. for(laCompoundPP* CPP=ui->CompoundPPs.pFirst;CPP;CPP=CPP->Item.pNext){
  1447. IsInt=(CPP->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
  1448. Len = laGetArrayLength(&CPP->PP);
  1449. laGetPrefixP(&CPP->PP, prefix);
  1450. if(IsInt){
  1451. laGetIntArray(&CPP->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
  1452. laGetIntRange(&CPP->PP, &Imin, &Imax); min=Imin; max=Imax;
  1453. }else{
  1454. laGetFloatArray(&CPP->PP, Data);
  1455. laGetFloatRange(&CPP->PP,&min,&max);
  1456. }
  1457. if(CPP->Slot <= LA_SLOT_MARKER_4){
  1458. for (i = 0; i < Len; i++){
  1459. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  1460. if(IsVertical){
  1461. Seg = (real)(ui->R-ui->L)/Len;
  1462. _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
  1463. }else{
  1464. Seg = (real)(ui->B-ui->U)/Len;
  1465. _U = ui->U + i * Seg; _B=_U+Seg;
  1466. }
  1467. int R1=_R,U1=_U;
  1468. if(IsVertical){ U1 = (real)(max - Data[i]) / (real)(max - min) * (real)(_B-_U) + _U; }
  1469. else{ R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(_R-_L) + _L; }
  1470. tnsUseNoTexture();
  1471. tnsColor4dv(laAccentColor(LA_BT_TEXT));
  1472. if(IsVertical){ tnsVertex2d(_L, U1); tnsVertex2d(R1, U1); }
  1473. else{ tnsVertex2d(R1, U1); tnsVertex2d(R1, _B); }
  1474. tnsPackAs(GL_LINES);
  1475. if(IsVertical){
  1476. if(! CPP->Slot % 2){ tnsVertex2d(_L, U1+trisize); tnsVertex2d(_L+trisize, U1); tnsVertex2d(_L, U1-trisize); }
  1477. else{ tnsVertex2d(_R, U1+trisize); tnsVertex2d(_R-trisize, U1); tnsVertex2d(_R, U1-trisize); }
  1478. }
  1479. else{
  1480. if(! CPP->Slot % 2){ tnsVertex2d(R1-trisize, _B); tnsVertex2d(R1, _B-trisize); tnsVertex2d(R1+trisize, _B); }
  1481. else{ tnsVertex2d(R1-trisize, U1); tnsVertex2d(R1, U1+trisize); tnsVertex2d(R1+trisize, U1); }
  1482. }
  1483. tnsPackAs(GL_TRIANGLES);
  1484. }
  1485. }
  1486. }
  1487. tnsFlush();
  1488. }
  1489. void la_ValueMeterType2Draw(laUiItem *ui, int h){
  1490. laBoxedTheme *bt = (*ui->Type->Theme);
  1491. int DataI[8]; real Data[8]; int SDataI[8]; real SData[8]; int Len, i, W; real Seg;
  1492. char buf[48] = {0}; char buf2[48] = {0};char prefix[16][64] = {0};char limits[2][64]={0};
  1493. int Original;
  1494. int Imin=-100, Imax=100; real min=-100, max=100;
  1495. int s, State; int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  1496. int NoLabel=ui->Flags&LA_UI_FLAGS_NO_LABEL;
  1497. int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
  1498. Len = laGetArrayLength(&ui->PP);
  1499. laGetPrefixP(&ui->PP, prefix);
  1500. if(IsInt){
  1501. laGetIntArray(&ui->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
  1502. laGetIntRange(&ui->PP, &Imin, &Imax); min=Imin; max=Imax;
  1503. sprintf(limits[0],"%d",Imin); sprintf(limits[1],"%d",Imax);
  1504. }else{
  1505. laGetFloatArray(&ui->PP, Data);
  1506. laGetFloatRange(&ui->PP,&min,&max);
  1507. sprintf(limits[0],"%lf",min); sprintf(limits[1],"%lf",max);
  1508. }
  1509. int sl = TNS_MAX2(abs(ui->SymbolID),5);
  1510. int ScaleLen = sl * LA_RH;
  1511. real seg = abs(ui->TemplateContext)/100;
  1512. int times=1,times10=0;
  1513. while((max-min)/seg > ScaleLen/10){
  1514. seg*=10;
  1515. }
  1516. if(seg>100){ int sseg=seg; while(sseg>=100){ sseg/=10; times*=10; times10++; } }
  1517. for (i = 0; i < Len; i++){
  1518. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  1519. if(IsVertical){
  1520. Seg = (real)(ui->R-ui->L)/Len;
  1521. _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
  1522. }else{
  1523. Seg = (real)(ui->B-ui->U)/Len;
  1524. _U = ui->U + i * Seg; _B=_U+Seg;
  1525. }
  1526. real cx=(_L+_R)/2,cy=(_U+_B)/2,cw=(_R-_L),ch=(_B-_U);
  1527. tnsPushStringClip(_L,_R,_U,_B);
  1528. tnsUseNoTexture();
  1529. tnsColor4dv(laThemeColor(bt,ui->State));
  1530. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1531. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1532. tnsPackAs(GL_TRIANGLE_FAN);
  1533. int oflow=0,ofhigh=0;
  1534. if(Data[i]<min){ oflow=1; Data[i]=min; }
  1535. if(Data[i]>max){ ofhigh=1; Data[i]=max; }
  1536. real fac = (real)(Data[i]-min) / (real)(max - min);
  1537. int SL,SR,SU,SB,_SL,_SR,_SU,_SB,Move = fac*ScaleLen;
  1538. if(IsVertical){ SL=_L; SR=_R; SB=_SB=cy+Move; SU=_SU=SB-ScaleLen; TNS_CLAMP(SB,_U,_B); TNS_CLAMP(SU,_U,_B); }
  1539. else{ SL=_SL=cx-Move; SR=_SR=SL+ScaleLen; SB=_B; SU=_U; TNS_CLAMP(SL,_L,_R); TNS_CLAMP(SR,_L,_R); }
  1540. tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
  1541. tnsColor4d(LA_COLOR3(color),0.3);
  1542. tnsVertex2d(SL, SU); tnsVertex2d(SR, SU);
  1543. tnsVertex2d(SR, SB); tnsVertex2d(SL, SB);
  1544. tnsPackAs(GL_TRIANGLE_FAN);
  1545. tnsColor4d(LA_COLOR3(color),0.7);
  1546. int scalelow=min/seg-1, scalehigh=max/seg+1;
  1547. for(int si=scalelow;si<=scalehigh;si++){
  1548. for(int ssi=0;ssi<10;ssi++){
  1549. real val=si*seg + ssi*0.1*seg; if(val<min) continue; if(val>max) break;
  1550. real sfac = (real)(val-min) / (max - min); int smove=Move-sfac*ScaleLen;
  1551. real lfac = ssi==0?(si==ssi?0.5:0.3):(ssi==5?0.2:0.1);
  1552. if(IsVertical){ int scaleb=cy+smove; if(scaleb>_B || scaleb<_U) continue;
  1553. tnsVertex2d(cx-cw*lfac,scaleb); tnsVertex2d(cx+cw*lfac,scaleb);
  1554. }else{ int scalel=cx-smove; if(scalel<_L || scalel>_R) continue;
  1555. tnsVertex2d(scalel,cy+ch*lfac); tnsVertex2d(scalel,cy-ch*lfac);
  1556. }
  1557. }
  1558. }
  1559. tnsPackAs(GL_LINES);
  1560. if(!NoLabel){
  1561. for(int si=scalelow;si<=scalehigh;si++){
  1562. real val=si*seg; if(val<min) continue; if(val>max) break;
  1563. real sfac = (real)(val-min) / (max - min); int smove=Move-sfac*ScaleLen;
  1564. if(IsInt) sprintf(buf,"%.0lf",val/times); else sprintf(buf,"%.2lf",val/times);
  1565. if(IsVertical){ int scaleb=cy+smove; if(scaleb>_B+LA_RH2 || scaleb<_U-LA_RH2) continue;
  1566. tnsDrawStringAuto(buf,laThemeColor(bt,LA_BT_TEXT),_L+bt->LM,_R-bt->RM,scaleb-LA_RH2,ui->Flags);
  1567. }else{ int scalel=cx-smove; if(scalel<_L-100 || scalel>_R+100) continue;
  1568. tnsDrawStringAuto(buf,laThemeColor(bt,LA_BT_TEXT),scalel-100,scalel+100,_U,ui->Flags);
  1569. }
  1570. }
  1571. if(IsVertical){
  1572. tnsDrawStringAuto(limits[0],laThemeColor(bt,LA_BT_TEXT|ui->State),_L+bt->LM,_R-bt->RM,_SB,ui->Flags);
  1573. tnsDrawStringAuto(limits[1],laThemeColor(bt,LA_BT_TEXT|ui->State),_L+bt->LM,_R-bt->RM,_SU-LA_RH,ui->Flags);
  1574. }else{
  1575. tnsDrawStringAuto(limits[0],laThemeColor(bt,LA_BT_TEXT|ui->State),_SL-100,_SL-bt->LM,_B-LA_RH,LA_TEXT_ALIGN_RIGHT);
  1576. tnsDrawStringAuto(limits[1],laThemeColor(bt,LA_BT_TEXT|ui->State),_SR+bt->RM,_SR+100,_B-LA_RH,LA_TEXT_ALIGN_LEFT);
  1577. }
  1578. }
  1579. tnsUseNoTexture();
  1580. tnsColor4dv(laAccentColor(LA_BT_BORDER));
  1581. if(IsVertical){tnsVertex2d(_L,cy); tnsVertex2d(_R,cy);}
  1582. else{tnsVertex2d(cx,_U); tnsVertex2d(cx,_B);}
  1583. tnsPackAs(GL_LINES);
  1584. if(times!=1){ sprintf(buf,"%d",times10);
  1585. 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);
  1586. elif(ch>LA_RH) tnsDrawStringAuto(buf,laAccentColor(LA_BT_BORDER),cx+bt->LM,cx+100,_U,LA_TEXT_MONO|LA_TEXT_ALIGN_LEFT);
  1587. }
  1588. tnsUseNoTexture();
  1589. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1590. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1591. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1592. tnsPackAs(GL_LINE_LOOP);
  1593. //if(IsVertical){
  1594. // if(oflow){ tnsDrawStringAuto("⯆",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_CENTER); }
  1595. // elif(ofhigh){ tnsDrawStringAuto("⯅",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _B-LA_RH, LA_TEXT_ALIGN_CENTER); }
  1596. //}else{
  1597. // if(oflow){ tnsDrawStringAuto("⯇",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_LEFT); }
  1598. // elif(ofhigh){ tnsDrawStringAuto("⯈",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_RIGHT); }
  1599. //}
  1600. tnsPopStringClip();
  1601. }
  1602. int trisize=LA_RH/3.0f;
  1603. for(laCompoundPP* CPP=ui->CompoundPPs.pFirst;CPP;CPP=CPP->Item.pNext){
  1604. IsInt=(CPP->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
  1605. Len = laGetArrayLength(&CPP->PP);
  1606. laGetPrefixP(&CPP->PP, prefix);
  1607. if(IsInt){
  1608. laGetIntArray(&CPP->PP, SDataI); for(int i=0;i<Len;i++){ SData[i]=SDataI[i]; }
  1609. //laGetIntRange(&CPP->PP, &Imin, &Imax); min=Imin; max=Imax;
  1610. }else{
  1611. laGetFloatArray(&CPP->PP, SData);
  1612. //laGetFloatRange(&CPP->PP,&min,&max);
  1613. }
  1614. if(CPP->Slot <= LA_SLOT_MARKER_4){
  1615. for (i = 0; i < Len; i++){
  1616. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  1617. if(IsVertical){
  1618. Seg = (real)(ui->R-ui->L)/Len;
  1619. _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
  1620. }else{
  1621. Seg = (real)(ui->B-ui->U)/Len;
  1622. _U = ui->U + i * Seg; _B=_U+Seg;
  1623. }
  1624. real cx=(_L+_R)/2,cy=(_U+_B)/2,cw=(_R-_L),ch=(_B-_U);
  1625. real sfac = (real)(SData[i]-min) / (real)(max - min);
  1626. real fac = (real)(Data[i]-min) / (real)(max - min);
  1627. int SL,SR,SU,SB,_SL,_SR,_SU,_SB, Move = fac*ScaleLen,SMove=sfac*ScaleLen;
  1628. if(IsVertical){ _SB=SB=cy+Move-SMove; TNS_CLAMP(SB,_U,_B); }
  1629. else{ SL=_SL=cx-Move+SMove; TNS_CLAMP(SL,_L,_R); }
  1630. tnsUseNoTexture();
  1631. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT|LA_BT_ACTIVE));
  1632. if(IsVertical){ tnsVertex2d(_L, SB); tnsVertex2d(_R, SB); }
  1633. else{ tnsVertex2d(SL, _U); tnsVertex2d(SL, _B); }
  1634. tnsPackAs(GL_LINES);
  1635. if(IsVertical){
  1636. if(! CPP->Slot % 2){ tnsVertex2d(_L, SB); tnsVertex2d(_L+trisize, SB); tnsVertex2d(_L, SB-trisize); }
  1637. else{ tnsVertex2d(_R, SB+trisize); tnsVertex2d(_R-trisize, SB); tnsVertex2d(_R, SB); }
  1638. if(SB==_SB){ tnsPackAs(GL_TRIANGLES); }else{ tnsPackAs(GL_LINE_LOOP); }
  1639. }
  1640. else{
  1641. if(! CPP->Slot % 2){ tnsVertex2d(SL, _B); tnsVertex2d(SL, _B-trisize); tnsVertex2d(SL+trisize, _B); }
  1642. else{ tnsVertex2d(SL-trisize, _U); tnsVertex2d(SL, _U+trisize); tnsVertex2d(SL, _U); }
  1643. if(SL==_SL){ tnsPackAs(GL_TRIANGLES); }else{ tnsPackAs(GL_LINE_LOOP); }
  1644. }
  1645. }
  1646. }
  1647. }
  1648. tnsFlush();
  1649. }
  1650. void la_ValueMeter2DDraw(laUiItem *ui, int h){
  1651. laBoxedTheme *bt = (*ui->Type->Theme);
  1652. int DataI[8]; real Data[8];
  1653. int Len, i, W; real Seg;
  1654. char buf[48] = {0};
  1655. char buf2[48] = {0};
  1656. char prefix[8][64] = {0};
  1657. int Original;
  1658. int Imin=-100, Imax=100;
  1659. real min=-100, max=100;
  1660. int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
  1661. Len = laGetArrayLength(&ui->PP);
  1662. laGetPrefixP(&ui->PP, prefix);
  1663. if(IsInt){
  1664. laGetIntArray(&ui->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
  1665. laGetIntRange(&ui->PP, &Imin, &Imax); min=Imin; max=Imax;
  1666. }else{
  1667. laGetFloatArray(&ui->PP, Data);
  1668. laGetFloatRange(&ui->PP,&min,&max);
  1669. }
  1670. int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
  1671. tnsUseNoTexture();
  1672. tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
  1673. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1674. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1675. tnsPackAs(GL_TRIANGLE_FAN);
  1676. real CL=(real)(Data[0] - min) / (real)(max - min) * (real)(_R-_L) + _L;
  1677. real CU=(real)(max - Data[1]) / (real)(max - min) * (real)(_B-_U) + _U;
  1678. real HW=((real)_R-(real)_L)/4; real HH=((real)_B-(real)_U)/4;
  1679. real ML=((real)_R+(real)_L)/2; real MU=((real)_B+(real)_U)/2;
  1680. tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
  1681. tnsColor4d(LA_COLOR3(color),0.4);
  1682. tnsVertex2d(ML+HW, MU+HH); tnsVertex2d(ML-HW, MU+HH);
  1683. tnsVertex2d(ML-HW, MU-HH); tnsVertex2d(ML+HW, MU-HH);
  1684. tnsPackAs(GL_LINE_LOOP);
  1685. tnsVertex2d(_L,_U); tnsVertex2d(_R,_B);
  1686. tnsVertex2d(_R,_U); tnsVertex2d(_L,_B);
  1687. tnsVertex2d(ML,_U); tnsVertex2d(ML,_B);
  1688. tnsVertex2d(_R,MU); tnsVertex2d(_L,MU);
  1689. tnsPackAs(GL_LINES);
  1690. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1691. tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
  1692. tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
  1693. tnsPackAs(GL_LINE_LOOP);
  1694. tnsFlush();
  1695. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
  1696. tnsVertex2d(_L, CU); tnsVertex2d(_R, CU);
  1697. tnsVertex2d(CL, _U); tnsVertex2d(CL, _B);
  1698. tnsPackAs(GL_LINES);
  1699. real circle[48];
  1700. tnsMakeCircle2d(circle,24,CL,CU,LA_RH2,0);
  1701. tnsVertexArray2d(circle,24);
  1702. tnsPackAs(GL_LINE_LOOP);
  1703. glLineWidth(2);
  1704. tnsFlush();
  1705. glLineWidth(1);
  1706. }
  1707. void la_ScopeDraw(laUiItem *ui, int h){
  1708. laBoxedTheme *bt = (*ui->Type->Theme); laSynthNodeScope* s=ui->PP.EndInstance;
  1709. if(!s) return;
  1710. real* lcolor=laAccentColor(LA_BT_TEXT); int plen=LA_SYNTH_PLEN;
  1711. int cl=ui->L+2, cr=ui->R-2, cu=ui->U+2, cb=ui->B-2; real cc=(real)(cu+cb)/2;
  1712. real yfac1=(real)(1<<(s->Gain1+1))/4.0f, yfac2=(real)(1<<(s->Gain2+1))/4.0f; yfac1/=10; yfac2/=10;
  1713. real off1=s->Offset1/20*(cb-cu), off2=s->Offset2/20*(cb-cu);
  1714. real arrx[LA_SYNTH_PLEN];
  1715. real arru1[LA_SYNTH_PLEN],arrb1[LA_SYNTH_PLEN];
  1716. real arru2[LA_SYNTH_PLEN],arrb2[LA_SYNTH_PLEN];
  1717. tnsFlush(); tnsUseNoTexture();
  1718. tnsColor4d(0,0,0,0.8);
  1719. tnsVertex2d(ui->L,ui->U); tnsVertex2d(ui->R,ui->U);
  1720. tnsVertex2d(ui->R,ui->B); tnsVertex2d(ui->L,ui->B);
  1721. tnsPackAs(GL_TRIANGLE_FAN);
  1722. tnsFlush(); tnsLineWidth(3.0);
  1723. laSpinLock(&s->Lock);
  1724. real b1=s->Brightness1, b2=s->Brightness2; real hcy[3]; tnsRGB2HCY(lcolor,hcy); hcy[2]=0.75;
  1725. real c1[3]; tnsHCY2RGB(hcy,c1);
  1726. for(int i=0;i<plen;i++){
  1727. arrx[i]=tnsInterpolate(cl,cr,((real)i)/plen);
  1728. arru1[i]=tnsInterpolate(cc,cu,yfac1*s->Display1[i])-off1;
  1729. arrb1[i]=tnsInterpolate(cc,cu,yfac1*s->Display1[i+plen])-off1;
  1730. TNS_CLAMP(arru1[i],cu,cb); TNS_CLAMP(arrb1[i],cu,cb);
  1731. tnsVertex2d(arrx[i],arru1[i]); tnsVertex2d(arrx[i],arrb1[i]);
  1732. }
  1733. tnsColor4d(LA_COLOR3(c1),b1*0.4);
  1734. tnsPackAs(GL_TRIANGLE_STRIP); tnsFlush();
  1735. for(int i=0;i<plen;i++){
  1736. arru2[i]=tnsInterpolate(cc,cu,yfac2*s->Display2[i])-off2;
  1737. arrb2[i]=tnsInterpolate(cc,cu,yfac2*s->Display2[i+plen])-off2;
  1738. TNS_CLAMP(arru2[i],cu,cb); TNS_CLAMP(arrb2[i],cu,cb);
  1739. tnsVertex2d(arrx[i],arru2[i]); tnsVertex2d(arrx[i],arrb2[i]);
  1740. }
  1741. tnsColor4d(LA_COLOR3(c1),b2*0.6);
  1742. tnsPackAs(GL_TRIANGLE_STRIP); tnsFlush();
  1743. for(int i=0;i<plen;i++){ tnsVertex2d(arrx[i],arru1[i]); }
  1744. tnsColor4d(LA_COLOR3(c1),b1);
  1745. tnsPackAs(GL_LINE_STRIP);
  1746. for(int i=0;i<plen;i++){ tnsVertex2d(arrx[i],arrb1[i]); }
  1747. tnsColor4d(LA_COLOR3(c1),b1);
  1748. tnsPackAs(GL_LINE_STRIP);
  1749. for(int i=0;i<plen;i++){ tnsVertex2d(arrx[i],arru2[i]); }
  1750. tnsColor4d(LA_COLOR3(c1),b2);
  1751. tnsPackAs(GL_LINE_STRIP);
  1752. for(int i=0;i<plen;i++){ tnsVertex2d(arrx[i],arrb2[i]); }
  1753. tnsColor4d(LA_COLOR3(c1),b2);
  1754. tnsPackAs(GL_LINE_STRIP);
  1755. laSpinUnlock(&s->Lock);
  1756. tnsFlush(); tnsLineWidth(1.0);
  1757. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  1758. tnsVertex2d(ui->L,ui->U); tnsVertex2d(ui->R,ui->U);
  1759. tnsVertex2d(ui->R,ui->B); tnsVertex2d(ui->L,ui->B);
  1760. tnsPackAs(GL_LINE_LOOP);
  1761. if(s->FromSynth && laget_SynthPlaying(s->FromSynth)){ laDeferredRedraw(MAIN.CurrentPanel); }
  1762. }
  1763. void la_ConditionNodeFreeRecursive(laUiConditionNode *ucn);
  1764. void la_GeneralUiInit(laUiItem *ui){
  1765. ui->Extra = memAcquireSimple(sizeof(laGeneralUiExtraData));
  1766. ui->Extra->ui=ui;
  1767. }
  1768. void la_GeneralUiDestroy(laUiItem *ui){
  1769. if(ui->Extra && ui->Extra->Edit){ strEndEdit(&ui->Extra->Edit, 1); }
  1770. memFree(ui->Extra);
  1771. }
  1772. void la_ConditionUiDestroy(laUiItem *ui){
  1773. laConditionUiExtraData *cued = ui->Extra;
  1774. la_ConditionNodeFreeRecursive(cued->Expression);
  1775. FreeMem(ui->Extra);
  1776. }
  1777. void la_MultiStringInit(laUiItem *ui){
  1778. laGeneralUiExtraData *e = ui->Extra;
  1779. if (!e) e = memAcquireSimple(sizeof(laGeneralUiExtraData));
  1780. ui->Extra = e;
  1781. e->HeightCoeff = 10;
  1782. }
  1783. void la_ImageUiInit(laUiItem *ui){
  1784. tnsImage* im=ui->Extra;
  1785. #ifdef LA_WITH_PNG
  1786. tnsUseImage(im);
  1787. #endif
  1788. }
  1789. void la_ImageUiDestroy(laUiItem *ui){
  1790. tnsImage* im=ui->Extra;
  1791. #ifdef LA_WITH_PNG
  1792. tnsStopUsingImage(im);
  1793. #endif
  1794. //memAssignRef(ui, &ui->Extra, 0);
  1795. }
  1796. void la_MeterUiInit(laUiItem *ui){
  1797. la_GeneralUiInit(ui); ui->SymbolID = 20; ui->TemplateContext = 1000;
  1798. }
  1799. void la_RegisterUiTypesBasic(){
  1800. laKeyMapper* km;
  1801. laPropContainer* pc;
  1802. LA_WIDGET_INT->Type=LA_WIDGET_INT_PLAIN->Type=
  1803. _LA_UI_INT = la_RegisterUiType("LA_int_array_horizon", LA_PROP_INT | LA_PROP_ARRAY, "LA_int_array_h_operator",
  1804. &_LA_THEME_VALUATOR, la_IntDraw, la_ValueGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1805. _LA_UI_INT->GetMinWidth=la_ValueGetMinWidth;
  1806. LA_WIDGET_METER_TYPE1->Type=
  1807. _LA_UI_METER_TYPE1 = la_RegisterUiType("LA_meter_type1", 0, 0, &_LA_THEME_VALUATOR, la_ValueMeterType1Draw, la_ValueMeterGetHeight, la_MeterUiInit, la_GeneralUiDestroy);
  1808. _LA_UI_METER_TYPE1->GetMinWidth=la_ValueGetMinWidth;
  1809. LA_WIDGET_METER_TYPE2->Type=
  1810. _LA_UI_METER_TYPE2 = la_RegisterUiType("LA_meter_type2", 0, 0, &_LA_THEME_VALUATOR, la_ValueMeterType2Draw, la_ValueMeterGetHeight, la_MeterUiInit, la_GeneralUiDestroy);
  1811. _LA_UI_METER_TYPE2->GetMinWidth=la_ValueGetMinWidth;
  1812. LA_WIDGET_VALUE_METER_2D->Type=
  1813. _LA_UI_VALUE_METER_2D = la_RegisterUiType("LA_value_meter_2d", 0, 0, &_LA_THEME_VALUATOR, la_ValueMeter2DDraw, la_ValueMeter2DGetHeight, la_MeterUiInit, la_GeneralUiDestroy);
  1814. LA_WIDGET_FLOAT->Type=LA_WIDGET_FLOAT_PLAIN->Type=
  1815. _LA_UI_FLOAT = la_RegisterUiType("LA_real_array_horizon", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_array_h_operator",
  1816. &_LA_THEME_VALUATOR, la_FloatDraw, la_ValueGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1817. _LA_UI_FLOAT->GetMinWidth=la_ValueGetMinWidth;
  1818. LA_WIDGET_FLOAT_COLOR->Type=
  1819. _LA_UI_FLOAT_COLOR = la_RegisterUiType("LA_real_color", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_color_operator",
  1820. &_LA_THEME_VALUATOR, la_FloatArrayColorDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1821. _LA_UI_FLOAT_COLOR->GetMinWidth=la_ColorSelectorGetMinWidth;
  1822. LA_WIDGET_FLOAT_COLOR_HCY->Type=
  1823. _LA_UI_FLOAT_COLOR_HCY = la_RegisterUiType("LA_real_hcy", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_hcy_operator",
  1824. &_LA_THEME_VALUATOR, la_ColorCircleDrawHCY, la_ColorPickerGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1825. _LA_UI_FLOAT_COLOR_HCY->GetMinWidth = la_ColorPickerGetMinWidth;
  1826. LA_WIDGET_ENUM_SELECTOR->Type=LA_WIDGET_ENUM_SELECTOR_ICON->Type=LA_WIDGET_ENUM_CYCLE->Type=LA_WIDGET_ENUM_HIGHLIGHT->Type=
  1827. _LA_UI_ENUM_SELECTOR = la_RegisterUiType("LA_enum_selector", LA_PROP_ENUM, "LA_enum_selector_operator",
  1828. &_LA_THEME_SELECTOR, la_EnumSelectorDraw, la_EnumGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1829. _LA_UI_ENUM_SELECTOR->GetMinWidth = la_EnumGetMinWidth;
  1830. LA_WIDGET_FIXED_GROUP->Type=
  1831. _LA_UI_FIXED_GROUP = la_RegisterUiType("LA_group_default", 0, 0,
  1832. &_LA_THEME_COLLECTION_GROUP, la_GroupDraw, la_GroupGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1833. _LA_UI_FIXED_GROUP->Tag|=LA_UI_TAG_SCISSOR;
  1834. LA_WIDGET_COLLECTION->Type=
  1835. _LA_UI_COLLECTION = la_RegisterUiType("LA_collection_default", LA_PROP_SUB, "LA_collection_operator",
  1836. &_LA_THEME_COLLECTION_GROUP, la_EmptyDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1837. LA_WIDGET_COLLECTION_SELECTOR->Type=
  1838. _LA_UI_COLLECTION_SELECTOR = la_RegisterUiType("LA_collection_selector_default", LA_PROP_SUB, "LA_collection_selector_operator",
  1839. &_LA_THEME_COLLECTION_SELECTOR, la_CollectionSelectorDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1840. _LA_UI_COLLECTION_SELECTOR->GetMinWidth = la_CollectionSimpleGetMinWidth;
  1841. LA_WIDGET_COLLECTION_SINGLE->Type=
  1842. _LA_UI_COLLECTION_SINGLE = la_RegisterUiType("LA_collection_single", LA_PROP_SUB, "LA_collection_operator",
  1843. &_LA_THEME_COLLECTION_GROUP, la_EmptyDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1844. LA_WIDGET_TAB->Type=
  1845. _LA_UI_TAB = la_RegisterUiType("LA_tab_default", 0, "LA_tab_operator",
  1846. &_LA_THEME_TAB, la_TabDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1847. LA_WIDGET_BUTTON->Type=LA_WIDGET_BUTTON_NO_CONFIRM->Type=
  1848. _LA_UI_BUTTON = la_RegisterUiType("LA_button_default", LA_PROP_OPERATOR, "LA_button_operator",
  1849. &_LA_THEME_BUTTON, la_ButtonDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1850. _LA_UI_BUTTON->GetMinWidth = la_ButtonGetMinWidth;
  1851. LA_WIDGET_BUTTON_NO_CONFIRM->Flags|=LA_UI_FLAGS_NO_CONFIRM;
  1852. pc=laUiHasExtraProps(_LA_UI_BUTTON, sizeof(laGeneralUiExtraData),0);
  1853. LA_WIDGET_LABEL->Type=
  1854. _LA_UI_LABEL = la_RegisterUiType("LA_label_default", LA_PROP_OPERATOR, 0,
  1855. &_LA_THEME_LABEL, la_LabelDraw, la_LabelHeight, 0, 0);
  1856. _LA_UI_LABEL->GetMinWidth = la_LabelGetMinWidth;
  1857. LA_WIDGET_MENU_ROOT->Type=
  1858. _LA_UI_MENU_ROOT = la_RegisterUiType("LA_menu_default", LA_PROP_OPERATOR, "LA_menu_root_operator",
  1859. &_LA_THEME_BUTTON, la_MenuItemDraw, 0, 0, 0);
  1860. _LA_UI_MENU_ROOT->GetMinWidth=la_LabelGetMinWidth;
  1861. LA_WIDGET_CONDITION_TOGGLE->Type=
  1862. _LA_UI_CONDITION_TOGGLE = la_RegisterUiType("LA_condition_toggle_default", LA_PROP_SELF_CONDITION, "LA_condition_toggle_operator",
  1863. &_LA_THEME_BUTTON, la_ConditionToggleDraw, 0, 0, la_ConditionUiDestroy);
  1864. LA_WIDGET_STRING->Type=LA_WIDGET_STRING_PLAIN->Type=LA_WIDGET_STRING_MONO_PLAIN->Type=
  1865. _LA_UI_STRING = la_RegisterUiType("LA_string_default", LA_PROP_STRING, "LA_string_operator",
  1866. &_LA_THEME_STRING, la_SingleLineStringDraw, la_StringPropGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1867. _LA_UI_STRING->GetMinWidth = la_StringPropGetMinWidth;
  1868. km=&_LA_UI_STRING->KeyMapper;
  1869. laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'c', 0);
  1870. laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'x', "mode=CUT");
  1871. laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
  1872. pc=laUiHasExtraProps(_LA_UI_STRING, sizeof(laGeneralUiExtraData), 0);{
  1873. laAddOperatorProperty(pc, "copy_selection", "Copy Selection", "Copy selected string into clipboard", "LA_edit_string_copy",0,0);
  1874. }
  1875. LA_WIDGET_STRING_MULTI->Type=
  1876. _LA_UI_STRING_MULTI = la_RegisterUiType("LA_string_multiline", LA_PROP_STRING, "LA_string_multi",
  1877. &_LA_THEME_STRING, la_MultiStringDraw, la_MultiStringHeight, la_MultiStringInit, la_GeneralUiDestroy);
  1878. _LA_UI_STRING_MULTI->GetMinWidth = la_StringPropGetMinWidth;
  1879. km=&_LA_UI_STRING_MULTI->KeyMapper;
  1880. laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'c', 0);
  1881. laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'x', "mode=CUT");
  1882. laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
  1883. pc=laUiHasExtraProps(_LA_UI_STRING_MULTI, sizeof(laGeneralUiExtraData), 0);{
  1884. laAddOperatorProperty(pc, "copy_selection", "Copy Selection", "Copy selected string into clipboard", "LA_edit_string_copy",0,0);
  1885. }
  1886. LA_WIDGET_ALIGN->Type=
  1887. _LA_UI_ALIGN = la_RegisterUiType("LA_colum_align_default", 0, 0,
  1888. &_LA_THEME_BUTTON, la_UiSeperatorDraw, 0, 0, 0);
  1889. LA_WIDGET_COLUMN_ADJUSTER->Type=
  1890. _LA_UI_COLUMN_ADJUSTER = la_RegisterUiType("LA_column_adjuster_default", 0, "LA_column_adjuster",
  1891. &_LA_THEME_BUTTON, la_ColumnAdjusterDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1892. _LA_UI_COLUMN_ADJUSTER->TargetSub = "ui_column";
  1893. LA_WIDGET_COLUMN_VIEWER->Type=
  1894. _LA_UI_COLUMN_VIEWER = la_RegisterUiType("LA_column_viewer_default", 0, 0,
  1895. &_LA_THEME_BUTTON, la_ColumnViewerDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
  1896. _LA_UI_COLUMN_VIEWER->TargetSub = "ui_column";
  1897. _LA_UI_COLUMN_VIEWER->GetMinWidth = la_ColumnViewerGetMinWidth;
  1898. _LA_UI_CONDITION_ELSE.Theme = &_LA_THEME_BUTTON;
  1899. la_UDFAppendSharedTypePointer("LA_condition_else", &_LA_UI_CONDITION_ELSE);
  1900. _LA_UI_CONDITION.Destroy = _LA_UI_CONDITION_ELSE.Destroy = _LA_UI_CONDITION_END.Destroy =la_ConditionUiDestroy;
  1901. _LA_UI_CONDITION.Theme = &_LA_THEME_BUTTON;
  1902. la_UDFAppendSharedTypePointer("LA_condition", &_LA_UI_CONDITION);
  1903. _LA_UI_CONDITION_END.Theme = &_LA_THEME_BUTTON;
  1904. la_UDFAppendSharedTypePointer("LA_condition_end", &_LA_UI_CONDITION_END);
  1905. LA_WIDGET_SYMBOL->Type=
  1906. _LA_UI_SYMBOL = la_RegisterUiType("LA_symbol_default", 0, 0, &_LA_THEME_BUTTON, la_SymbolDraw, la_SymbolGetHeight, 0, 0);
  1907. LA_WIDGET_NODE_SOCKET->Type=
  1908. _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);
  1909. _LA_UI_NODE_SOCKET->GetMinWidth=la_SocketGetMinWidth;
  1910. LA_WIDGET_HEIGHT_ADJUSTER->Type=
  1911. _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);
  1912. _LA_UI_HEIGHT_ADJUSTER->ForType = LA_PROP_INT;
  1913. LA_WIDGET_RAW->Type=
  1914. _LA_UI_RAW = la_RegisterUiType("LA_raw_prop_default", 0, 0, &_LA_THEME_COLLECTION_GROUP, la_RawPropDraw, 0, 0, 0);
  1915. _LA_UI_RAW->ForType = LA_PROP_RAW;
  1916. LA_WIDGET_MAPPER->Type=
  1917. _LA_UI_MAPPER = la_RegisterUiType("LA_mapper_default", 0, "LA_value_mapper", &_LA_THEME_COLLECTION_GROUP, la_MapperDraw, la_ColorPickerGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1918. LA_WIDGET_IMAGE->Type=
  1919. _LA_UI_IMAGE = la_RegisterUiType("LA_image_default", 0, 0, &_LA_THEME_COLLECTION_GROUP, la_ImageDraw, la_ImageGetHeight, la_ImageUiInit, la_ImageUiDestroy);
  1920. _LA_UI_IMAGE->GetMinWidth=la_ImageGetMinWidth;
  1921. LA_WIDGET_SCOPE->Type=
  1922. _LA_UI_SCOPE = la_RegisterUiType("LA_scope_default", 0, "LA_synth_scope", &_LA_THEME_BUTTON, la_ScopeDraw, la_ColorPickerGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
  1923. _LA_UI_INVISIBLE.Theme=&_LA_THEME_BUTTON;
  1924. _LA_UI_ROW_BEGIN.Theme=&_LA_THEME_BUTTON;
  1925. _LA_UI_ROW_END.Theme=&_LA_THEME_BUTTON;
  1926. }
  1927. // ============================================================ [Operators]
  1928. void la_DefaultEnumPanel(laUiList *uil, laPropPack *This, laPropPack *OperatorProps, laColumn *UNUSED){
  1929. laColumn *c = laFirstColumn(uil);
  1930. laShowItem(uil, c, This, 0)->Flags=(LA_UI_FLAGS_TRANSPOSE|LA_UI_FLAGS_EXPAND);
  1931. }
  1932. int la_DetectRow(laUiItem *ui, int LocalY){
  1933. return (LocalY - ui->U) / LA_RH;
  1934. }
  1935. int la_DetectColumn(laUiItem *ui, int LocalX, int Total){
  1936. return (int)((real)(LocalX - ui->L) / (real)(ui->R - ui->L) * (real)Total);
  1937. }
  1938. laColumn *la_DetectSplit(laColumn *Root, int LocalX){
  1939. laColumn *result = 0;
  1940. if (!Root->LS) return 0;
  1941. if (LocalX - Root->LS->IR < LA_SCROLL_W && Root->LS->IR - LocalX < LA_SCROLL_W &&
  1942. !Root->LS->MaxW && !Root->RS->MaxW){
  1943. return Root;
  1944. }
  1945. result = la_DetectSplit(Root->LS, LocalX);
  1946. if (result) return result;
  1947. else
  1948. return la_DetectSplit(Root->RS, LocalX);
  1949. }
  1950. void la_AdjustColumnSplit(laColumn *c, int PxLeftPositive){
  1951. if (!c->LS || c->LS->MaxW || c->RS->MaxW) return;
  1952. if (PxLeftPositive < 0 && c->LS->IR - c->LS->IL <= LA_SCROLL_W*2) return;
  1953. if (PxLeftPositive > 0 && c->RS->IR - c->RS->IL <= LA_SCROLL_W*2) return;
  1954. c->LS->IR += PxLeftPositive;
  1955. c->RS->IL += PxLeftPositive;
  1956. c->LS->SP = (real)(c->LS->IR - c->LS->IL) / (real)(c->IR - c->IL);
  1957. c->RS->SP = c->LS->SP;
  1958. }
  1959. int OPCHK_EditStringCopySelection(laPropPack *This, laStringSplitor *Instructions){
  1960. laGeneralUiExtraData *uit = This->EndInstance; if(!uit) return 0;
  1961. if(!uit->Edit || !strHasSelection(uit->Edit)) return 0;
  1962. return 1;
  1963. }
  1964. int OPINV_EditStringCopySelection(laOperator *a, laEvent *e){
  1965. laGeneralUiExtraData *uit = a->This->EndInstance; if(!uit) return LA_FINISHED;
  1966. if(!uit->Edit || !strHasSelection(uit->Edit)) return LA_FINISHED;
  1967. char* mode=strGetArgumentString(a->ExtraInstructionsP,"mode");
  1968. char* str=strGetEditString(uit->Edit, 1);
  1969. laCopyToClipboard(str); free(str);
  1970. if(strSame(mode,"CUT")){ strClearSelection(&uit->Edit); }
  1971. return LA_FINISHED;
  1972. }
  1973. int la_ProcessTextEdit(laEvent *e, laStringEdit *se, laUiItem* ui){
  1974. int Select=e->SpecialKeyBit&LA_KEY_SHIFT;
  1975. real _L, MonoWidth;
  1976. switch (e->type){
  1977. case LA_INPUT:
  1978. switch (e->Input){
  1979. case 0x08: if(strHasSelection(se)) strClearSelection(se); else strBackspace(se); return 1;
  1980. case 0x7f: if(strHasSelection(se)) strClearSelection(se); else { strMoveCursor(se,0,0); strBackspace(se); } return 1;
  1981. case 0x09: strInsertChar(se, ' ');strInsertChar(se, ' ');strInsertChar(se, ' ');strInsertChar(se, ' '); return 1;
  1982. case 0x1B: case 0x0D: return 0;
  1983. default: strInsertChar(se, e->Input); return 1;
  1984. }
  1985. break;
  1986. case LA_KEY_DOWN:
  1987. switch (e->key){
  1988. case LA_KEY_ENTER: strInsertChar(se, '\n'); return 1;
  1989. case LA_KEY_ARRLEFT: strMoveCursor(se, 1, Select); return 1;
  1990. case LA_KEY_ARRRIGHT: strMoveCursor(se, 0, Select); return 1;
  1991. case LA_KEY_ARRUP: strMoveCursorLine(se, 1, Select); return 1;
  1992. case LA_KEY_ARRDOWN: strMoveCursorLine(se, 0, Select); return 1;
  1993. }
  1994. break;
  1995. case LA_L_MOUSE_DOWN:
  1996. case LA_MOUSEMOVE:
  1997. if(!ui) return 0;
  1998. MonoWidth=tnsGetMonoFontAdvance(); _L=(*ui->Type->Theme)->LM*2+ui->L;
  1999. int Count=se->TotalLines; while(Count){ Count/=10; _L+=MonoWidth; }
  2000. if(e->type==LA_L_MOUSE_DOWN){
  2001. strSetCursor(se, (e->y-ui->U)/LA_RH+se->ViewStartLine, (real)se->ViewStartCol+((real)e->x-_L)/MonoWidth+0.5); strCancelSelect(se); strLazySelect(se);
  2002. se->MouseSelecting=1; se->CursorPreferBefore=se->CursorBefore; return 1;
  2003. }else{
  2004. if(!se->MouseSelecting) return 0;
  2005. strSetCursor(se, (e->y-ui->U)/LA_RH+se->ViewStartLine, (real)se->ViewStartCol+((real)e->x-_L)/MonoWidth+0.5); strEndSelect(se);
  2006. se->CursorPreferBefore=se->CursorBefore; return 1;
  2007. }return 0;
  2008. case LA_L_MOUSE_UP:
  2009. se->MouseSelecting=0;
  2010. }
  2011. return 0;
  2012. }
  2013. int OPINV_UiItem(laOperator *a, laEvent *e){
  2014. laUiItem *ui = a->Instance;
  2015. a->CustomData = ui->Extra;
  2016. return LA_RUNNING;
  2017. }
  2018. int OPINV_Tab(laOperator *a, laEvent *e){
  2019. laUiList *uil;
  2020. laUiItem *ui = a->Instance;
  2021. laGeneralUiExtraData *uit;
  2022. int count = 0;
  2023. //if (e->Type == LA_L_MOUSE_DOWN) {
  2024. //}
  2025. a->CustomData = ui->Extra;
  2026. uit = a->CustomData;
  2027. uit->TargetIndexVali = count;
  2028. return LA_RUNNING;
  2029. }
  2030. int OPEXT_UiItem(laOperator *a, int ExitCode){
  2031. laUiItem *ui = a->Instance;
  2032. return 0;
  2033. }
  2034. int OPMOD_IntArrayHorizon(laOperator *a, laEvent *e){
  2035. laUiItem *ui = a->Instance;
  2036. laBoxedTheme *bt = (*ui->Type->Theme);
  2037. laGeneralUiExtraData *uit = a->CustomData;
  2038. laIntProp *ip = ui->PP.LastPs->p;
  2039. int Away = 0;
  2040. int TmpArr[32];
  2041. int Len = laGetArrayLength(&ui->PP);
  2042. int IsVertical=(ui->Flags&LA_UI_FLAGS_TRANSPOSE)!=0;
  2043. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2044. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2045. int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
  2046. if (!laIsInUiItem(ui, e->x, e->y) && !ui->Extra->On){
  2047. ui->State = LA_UI_NORMAL;
  2048. if (ui->Extra) ui->Extra->On = 0;
  2049. laRedrawCurrentPanel();
  2050. return LA_FINISHED_PASS;
  2051. }
  2052. if (e->type == LA_TIME_IDLE && !uit->On && !uit->Edit && !NoTooltip){
  2053. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2054. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2055. return LA_RUNNING;
  2056. }
  2057. if(NoEvent){ return LA_RUNNING_PASS; }
  2058. if (e->type == LA_L_MOUSE_DOWN){
  2059. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  2060. if (uit->Edit){
  2061. if (!laIsInUiItem(ui, e->x, e->y)){
  2062. strEndEdit(&uit->Edit, 1);
  2063. uit->On = 0;
  2064. laRedrawCurrentPanel();
  2065. return LA_FINISHED;
  2066. }
  2067. if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
  2068. else strSelectLineAll(uit->Edit);
  2069. return LA_RUNNING;
  2070. }
  2071. uit->LastX = e->x;
  2072. uit->LastY = e->y;
  2073. ui->Extra->On = (IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
  2074. if (ui->Extra->On > Len) return LA_RUNNING;
  2075. laGetIntArray(&ui->PP, &TmpArr);
  2076. uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
  2077. laRedrawCurrentPanel();
  2078. return LA_RUNNING;
  2079. }
  2080. if (e->type == LA_MOUSEMOVE && ui->Extra->On){
  2081. if(ui->Extra->Edit){ return LA_RUNNING; }
  2082. int dist=abs(e->x - uit->LastX + uit->LastY - e->y);
  2083. if (dist > MAIN.ValuatorThreshold || uit->Dragging){
  2084. int min,max,Ranged = laGetIntRange(&ui->PP, &min, &max); real step=ip->Step; if(Ranged&&!IsKnob){ step=(real)(max-min)/(ui->R-ui->L); }
  2085. if(Ranged){ TNS_CLAMP(step,(max-min)/500,INT_MAX); }
  2086. //laGetIntArray(&ui->PP, &TmpArr);
  2087. //uit->TargetIndexVali = TmpArr[ui->Extra->On - 1];
  2088. 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;
  2089. uit->TargetIndexValf += delta*step;
  2090. laSetIntArraySingle(&ui->PP, ui->Extra->On - 1, uit->TargetIndexValf);
  2091. uit->LastX = e->x;
  2092. uit->LastY = e->y;
  2093. uit->Dragging = 1;
  2094. laRedrawCurrentPanel();
  2095. }
  2096. return LA_RUNNING;
  2097. }
  2098. if (e->type == LA_L_MOUSE_UP){
  2099. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  2100. if (uit->Dragging){
  2101. if (ui->Extra->On){
  2102. ui->Extra->On = 0;
  2103. laConfirmInt(a, uit->TargetIndexVali, LA_CONFIRM_DATA);
  2104. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2105. }
  2106. }else if(ui->Extra->On){
  2107. int SelectOn=(IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
  2108. if ((!uit->Edit) || (uit->Edit && (SelectOn != ui->Extra->On))){
  2109. char buf[32] = {0};
  2110. uit->On=SelectOn;
  2111. laGetIntArray(&ui->PP, &TmpArr);
  2112. uit->TargetIndexVali = TmpArr[ui->Extra->On - 1];
  2113. strPrintIntAfter(buf, 32, uit->TargetIndexVali);
  2114. strBeginEdit(&uit->Edit,buf);
  2115. strSelectLineAll(uit->Edit);
  2116. }
  2117. }
  2118. uit->Dragging = 0;
  2119. laRedrawCurrentPanel();
  2120. return LA_RUNNING;
  2121. }
  2122. if(e->type ==LA_KEY_DOWN){
  2123. if (e->key == LA_KEY_ENTER && uit->Edit){
  2124. char* buf=strEndEdit(&uit->Edit, 0);
  2125. int Result; sscanf(buf, "%d", &Result); free(buf);
  2126. laSetIntArraySingle(&ui->PP, ui->Extra->On - 1, Result);
  2127. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2128. ui->State = LA_UI_NORMAL;
  2129. uit->Dragging = 0;
  2130. uit->On = 0;
  2131. laRedrawCurrentPanel();
  2132. return LA_FINISHED_PASS;
  2133. }
  2134. }
  2135. if (e->type == LA_R_MOUSE_DOWN){
  2136. int GX = e->x, GY = e->y;
  2137. ui->PP.LastIndex = la_DetectColumn(ui, e->x, Len);
  2138. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2139. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2140. return LA_RUNNING;
  2141. }
  2142. if (uit->Edit){
  2143. if (la_ProcessTextEdit(e, uit->Edit, ui)) laRedrawCurrentPanel();
  2144. return LA_RUNNING;
  2145. }
  2146. return LA_RUNNING_PASS;
  2147. }
  2148. int OPMOD_FloatArrayHorizon(laOperator *a, laEvent *e){
  2149. laUiItem *ui = a->Instance;
  2150. laBoxedTheme *bt = (*ui->Type->Theme);
  2151. laGeneralUiExtraData *uit = a->CustomData;
  2152. laFloatProp *fp = ui->PP.LastPs->p;
  2153. int Away = 0;
  2154. real TmpArr[32];
  2155. int Len = laGetArrayLength(&ui->PP);
  2156. int IsVertical=(ui->Flags&LA_UI_FLAGS_TRANSPOSE)!=0;
  2157. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2158. int IsRad=ui->PP.LastPs->p->IsRadAngle;
  2159. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2160. int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
  2161. if (!laIsInUiItem(ui, e->x, e->y) && !ui->Extra->On && !NoTooltip){
  2162. ui->State = LA_UI_NORMAL;
  2163. ui->Extra->On = 0;
  2164. laRedrawCurrentPanel();
  2165. return LA_FINISHED_PASS;
  2166. }
  2167. if (e->type == LA_TIME_IDLE && !uit->On && !uit->Edit){
  2168. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2169. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2170. return LA_RUNNING;
  2171. }
  2172. if(NoEvent){ return LA_RUNNING_PASS; }
  2173. if (e->type == LA_L_MOUSE_DOWN){
  2174. if (uit->Edit){
  2175. if (!laIsInUiItem(ui, e->x, e->y)){
  2176. strEndEdit(&uit->Edit, 1);
  2177. uit->On = 0;
  2178. laRedrawCurrentPanel();
  2179. return LA_FINISHED;
  2180. }
  2181. if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
  2182. else strSelectLineAll(uit->Edit);
  2183. return LA_RUNNING;
  2184. }
  2185. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  2186. uit->LastX = e->x;
  2187. uit->LastY = e->y;
  2188. ui->Extra->On = (IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
  2189. if (ui->Extra->On > Len) return LA_RUNNING;
  2190. laGetFloatArray(&ui->PP, &TmpArr);
  2191. uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
  2192. laRedrawCurrentPanel();
  2193. return LA_RUNNING;
  2194. }
  2195. if (e->type == LA_MOUSEMOVE && ui->Extra->On){
  2196. if(uit->Edit){ return LA_RUNNING; }
  2197. int dist=abs(e->x - uit->LastX - e->y + uit->LastY);
  2198. if (dist > MAIN.ValuatorThreshold || uit->Dragging){
  2199. real min,max; int Ranged = laGetFloatRange(&ui->PP, &min, &max); real step=fp->Step; if(Ranged&&!IsKnob){ step=(max-min)/(ui->R-ui->L); }
  2200. if(Ranged){ TNS_CLAMP(step,(max-min)/500,INT_MAX); }
  2201. laGetFloatArray(&ui->PP, &TmpArr);
  2202. uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
  2203. 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;
  2204. uit->TargetIndexValf += delta*step;
  2205. laSetFloatArraySingle(&ui->PP, ui->Extra->On - 1, uit->TargetIndexValf);
  2206. uit->LastX = e->x;
  2207. uit->LastY = e->y;
  2208. uit->Dragging = 1;
  2209. laRedrawCurrentPanel();
  2210. }
  2211. return LA_RUNNING;
  2212. }
  2213. if (e->type == LA_L_MOUSE_UP){
  2214. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  2215. if (uit->Dragging){
  2216. if (ui->Extra->On){
  2217. ui->Extra->On = 0;
  2218. laConfirmFloat(a, uit->TargetIndexValf, LA_CONFIRM_DATA);
  2219. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2220. }
  2221. }else if(ui->Extra->On){
  2222. int SelectOn=(IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
  2223. if ((!uit->Edit) || (uit->Edit && (SelectOn != ui->Extra->On))){
  2224. char buf[32] = {0};
  2225. uit->On=SelectOn;
  2226. laGetFloatArray(&ui->PP, &TmpArr);
  2227. uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
  2228. strPrintFloatAfter(buf, 32, 5, IsRad?deg(uit->TargetIndexValf):uit->TargetIndexValf);
  2229. strBeginEdit(&uit->Edit,buf);
  2230. strSelectLineAll(uit->Edit);
  2231. }
  2232. }
  2233. uit->Dragging = 0;
  2234. laRedrawCurrentPanel();
  2235. return LA_RUNNING;
  2236. }
  2237. if(e->type ==LA_KEY_DOWN){
  2238. if (e->key == LA_KEY_ENTER && uit->Edit){
  2239. char* buf=strEndEdit(&uit->Edit, 0);
  2240. real Result; sscanf(buf, "%lf", &Result); free(buf);
  2241. if(IsRad) Result=rad(Result);
  2242. laSetFloatArraySingle(&ui->PP, ui->Extra->On - 1, Result);
  2243. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2244. uit->Dragging = 0;
  2245. uit->On = 0;
  2246. laRedrawCurrentPanel();
  2247. return LA_FINISHED_PASS;
  2248. }
  2249. }
  2250. if (e->type == LA_R_MOUSE_DOWN){
  2251. int GX = e->x, GY = e->y;
  2252. ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
  2253. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2254. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2255. return LA_RUNNING;
  2256. }
  2257. if (uit->Edit){
  2258. if (la_ProcessTextEdit(e, uit->Edit, ui)) laRedrawCurrentPanel();
  2259. return LA_RUNNING;
  2260. }
  2261. return LA_RUNNING_PASS;
  2262. }
  2263. int OPMOD_FloatColor(laOperator *a, laEvent *e){
  2264. laUiItem *ui = a->Instance;
  2265. laBoxedTheme *bt = (*ui->Type->Theme);
  2266. laGeneralUiExtraData *uit = a->CustomData;
  2267. int Away = 0;
  2268. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2269. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2270. if (!laIsInUiItem(ui, e->x, e->y)){
  2271. return LA_FINISHED_PASS;
  2272. }
  2273. if (e->type == LA_TIME_IDLE && !NoTooltip){
  2274. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2275. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2276. return LA_RUNNING;
  2277. }
  2278. if(NoEvent){ return LA_RUNNING_PASS; }
  2279. if (e->type == LA_L_MOUSE_DOWN){
  2280. laUiList *uil;
  2281. laColumn *col;
  2282. laPanel *p;
  2283. int GX = ui->L, GY = ui->B;
  2284. ui->State = LA_UI_ACTIVE;
  2285. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2286. p = laEnableEmptyPropertyPanel(a->ToPanel, a, GX, GX + 150, GY, 500, e);{
  2287. uil = &p->UI;
  2288. col = laFirstColumn(uil);
  2289. laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_FLOAT_COLOR_HCY, 0, 0, 0);
  2290. laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_FLOAT, 0, 0, 0)->Flags=LA_UI_FLAGS_TRANSPOSE;
  2291. laEnclosePanelContent(p, uil);
  2292. }
  2293. return LA_RUNNING;
  2294. }
  2295. if (e->type == LA_R_MOUSE_DOWN){
  2296. int GX = e->x, GY = e->y;
  2297. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2298. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2299. return LA_RUNNING;
  2300. }
  2301. return LA_RUNNING_PASS;
  2302. }
  2303. int OPMOD_ColorHCY(laOperator *a, laEvent *e){
  2304. laUiItem *ui = a->Instance;
  2305. laBoxedTheme *bt = (*ui->Type->Theme);
  2306. laGeneralUiExtraData *es = a->CustomData;
  2307. int Away = 0;
  2308. int i = 0;
  2309. real hcy[3] = {0};
  2310. real Color[4] = {0};
  2311. real PickerPos[2];
  2312. real abso;
  2313. if (!laIsInUiItem(ui, e->x, e->y) && !es->Dragging){
  2314. return LA_FINISHED_PASS;
  2315. }
  2316. 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){
  2317. es->Dragging=3; es->LastX=e->x; es->LastY=e->y; es->TargetIndexVali=es->HeightCoeff; return LA_RUNNING;
  2318. }
  2319. if(es->Dragging==3){
  2320. if(e->type==LA_MOUSEMOVE){ es->HeightCoeff=es->TargetIndexVali+((real)e->y-es->LastY+0.5)/LA_RH;
  2321. if(es->HeightCoeff<1)es->HeightCoeff=1; laRecalcCurrentPanel();}
  2322. elif(e->type==LA_L_MOUSE_UP){ es->Dragging=0; }
  2323. elif(e->type==LA_R_MOUSE_DOWN){
  2324. es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel(); }
  2325. return LA_RUNNING;
  2326. }
  2327. real c = (real)((ui->R + ui->L) / 2) - LA_RH / 2; /*- bt->RM;*/
  2328. real r = (ui->B - ui->U - bt->TP - bt->BP) / 2;
  2329. real dx = e->x - c, dy = e->y - (ui->U + r + bt->TP);
  2330. real dist = sqrt(dx * dx + dy * dy);
  2331. if (e->type == LA_L_MOUSE_DOWN){ ui->State = LA_UI_ACTIVE; laRedrawCurrentPanel(); es->Dragging=(dist<=r)?1:2; }
  2332. if (e->type == LA_L_MOUSE_UP){
  2333. ui->State = LA_UI_NORMAL; es->Dragging=0; laRedrawCurrentPanel();
  2334. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2335. return LA_RUNNING_PASS;
  2336. }
  2337. if (e->type & LA_MOUSE_EVENT && es->Dragging){
  2338. laGetFloatArray(&ui->PP, Color);
  2339. if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LogsRGB(Color); }
  2340. tnsRGB2HCY(Color, hcy);
  2341. if (es->Dragging==1){
  2342. abso = fabs(atan((real)dy / (real)dx));
  2343. hcy[0] = abso / TNS_PI / 2;
  2344. if (dx > 0){
  2345. if (dy < 0) hcy[0] = 1 - hcy[0];
  2346. }else{
  2347. if (dy > 0){
  2348. hcy[0] = 0.5 - hcy[0];
  2349. }else{
  2350. hcy[0] += 0.5;
  2351. }
  2352. }
  2353. hcy[1] = dist / r; TNS_CLAMP(hcy[1],0,1);
  2354. hcy[1]=pow(hcy[1],MAIN.ColorPickerGamma);
  2355. }else if (dist < r + LA_RH * 2 && dx > 0){
  2356. abso = -atan((real)dy / (real)dx) / TNS_PI * 2 + 0.5;
  2357. hcy[2] = abso; TNS_CLAMP(hcy[2],0,1);
  2358. }
  2359. tnsHCY2RGB(hcy, Color);
  2360. if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LinearsRGB(Color); }
  2361. laSetFloatArrayAllArray(&ui->PP, Color);
  2362. laRedrawCurrentPanel();
  2363. return LA_RUNNING;
  2364. }
  2365. return LA_RUNNING_PASS;
  2366. }
  2367. int OPMOD_EnumSelector(laOperator *a, laEvent *e){
  2368. laUiItem *ui = a->Instance;
  2369. laBoxedTheme *bt = (*ui->Type->Theme);
  2370. laGeneralUiExtraData *uit = a->CustomData;
  2371. laEnumItem *ei;
  2372. laEnumProp *ep = ui->PP.LastPs->p;
  2373. int at = 0;
  2374. laEnumItem *Data[32];
  2375. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2376. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2377. int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
  2378. int IsMomentary = IsCycle && ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
  2379. int NoConfirm = ui->Flags&LA_UI_FLAGS_NO_CONFIRM;
  2380. // norm e1
  2381. // expand e1 e2 e3
  2382. // expand vertical (vertical)
  2383. // arr expand e1 e1 e3
  2384. // e2 e2 e3
  2385. // arr exp+vert e1 e1
  2386. // e2 e2
  2387. // e3 e3
  2388. if (a->ConfirmData /* && a->ConfirmData->Mode == LA_CONFIRM_DATA*/){
  2389. ui->State = LA_UI_NORMAL;
  2390. laRedrawCurrentPanel();
  2391. return LA_RUNNING;
  2392. }
  2393. if (!laIsInUiItem(ui, e->x, e->y) && !uit->On){ return LA_FINISHED_PASS; }
  2394. if (e->type == LA_TIME_IDLE && !NoTooltip && !uit->On){
  2395. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2396. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2397. return LA_RUNNING;
  2398. }
  2399. if(NoEvent){ return LA_RUNNING_PASS; }
  2400. if (e->type == LA_L_MOUSE_DOWN || (IsMomentary && e->type == LA_L_MOUSE_UP)){
  2401. if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
  2402. int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
  2403. int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
  2404. int ArrLen = laGetArrayLength(&ui->PP);
  2405. if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
  2406. int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
  2407. int _L,_R,_U,_B, _W=ui->R - ui->L, _Col=1;
  2408. if(IsVertical){
  2409. if(IsExpand){ _Col=ArrLen; }
  2410. }else{
  2411. if(IsExpand){ _Col=EnumLen; } else { _Col=ArrLen; }
  2412. }
  2413. int row = la_DetectRow(ui, e->y);
  2414. int col = la_DetectColumn(ui, e->x, _Col);
  2415. int ArrTarget=0, EnumTarget=0, ShowMenu=0;
  2416. if(IsVertical){
  2417. if(IsExpand){ EnumTarget=row; ArrTarget=col; } else { EnumTarget=col; }
  2418. }else{
  2419. if(IsExpand){ EnumTarget=col; ArrTarget=row; } else { if(!IsCycle) ShowMenu=1; }
  2420. }
  2421. if(ShowMenu){
  2422. int GX = ui->L, GY = ui->B, GR = ui->R, t = 0;
  2423. ui->State = LA_UI_ACTIVE;
  2424. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2425. laLocalToWindow(a, a->ToPanel, &GR, &t);
  2426. laEnablePropertyPanel(a->ToPanel, a, 0, la_DefaultEnumPanel, 0, &ui->PP, GX, GR, GY, MAIN.CurrentWindow->CH-LA_2RH, 0, e);
  2427. laRedrawCurrentPanel();
  2428. }elif(IsCycle){
  2429. laEnumItem* ei=laGetEnumArrayIndexed(&ui->PP, ArrTarget);
  2430. if(!ei){ ei=((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst; }
  2431. ei = ei->Item.pNext?ei->Item.pNext:((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst;
  2432. if(IsMomentary){ uit->On = 1; if(e->type==LA_L_MOUSE_UP){ ei = ei=((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst; uit->On = 0;} }
  2433. laSetEnumArrayIndexed(&ui->PP, ArrTarget, ei->Index);
  2434. if(!NoConfirm){ laConfirmInt(a,EnumTarget,LA_CONFIRM_DATA); }
  2435. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2436. if(ui->Flags&LA_UI_FLAGS_EXIT_WHEN_TRIGGERED) return LA_FINISHED;
  2437. }else{
  2438. if(ArrTarget>=ArrLen){ArrTarget=ArrLen-1;}
  2439. if(EnumTarget>=EnumLen){EnumTarget=EnumLen-1;}
  2440. laSetEnumArrayIndexedExternal(&ui->PP, ArrTarget, EnumTarget);
  2441. if(!NoConfirm){ laConfirmInt(a,EnumTarget,LA_CONFIRM_DATA); }
  2442. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2443. return LA_RUNNING_PASS;
  2444. }
  2445. return LA_RUNNING;
  2446. }
  2447. if(e->type==LA_R_MOUSE_DOWN){
  2448. int GX = e->x, GY = e->y;
  2449. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2450. laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2451. return LA_RUNNING;
  2452. }
  2453. return LA_RUNNING_PASS;
  2454. }
  2455. int OPMOD_Button(laOperator *a, laEvent *e){
  2456. laUiItem *ui = a->Instance;
  2457. laBoxedTheme *bt = (*ui->Type->Theme);
  2458. int lx, ly;
  2459. int Away = 0;
  2460. if (e->type == LA_TIME_IDLE && !ui->State){
  2461. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2462. laPanel *p = laEnableIdlePanel(a->ToPanel, a, &ui->ExtraPP, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2463. return LA_RUNNING;
  2464. }
  2465. if (laConfirmSameDataIfAny(a)) return LA_RUNNING_PASS;
  2466. if (e->type == LA_ESCAPE_DOWN || e->type == LA_INPUT) return LA_FINISHED; //debug
  2467. if (!laIsInUiItem(ui, e->x, e->y) /*&& ui->State!= LA_UI_ACTIVE*/){
  2468. ui->State = LA_UI_NORMAL;
  2469. laRedrawCurrentPanel();
  2470. return LA_FINISHED_PASS;
  2471. }
  2472. if (e->type == LA_L_MOUSE_DOWN){
  2473. ui->State = LA_UI_ACTIVE;
  2474. laRedrawCurrentPanel();
  2475. return LA_RUNNING;
  2476. }
  2477. char *str;
  2478. int call_ret=0;
  2479. if (e->type == LA_L_MOUSE_UP && ui->State!=LA_UI_NORMAL){
  2480. ui->State = LA_UI_NORMAL;
  2481. if (ui->AT){
  2482. if (!ui->Instructions){
  2483. if (ui->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
  2484. if (ui->AT->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->AT->ExtraInstructions);
  2485. }
  2486. if (!laOperatorAvailableP(ui->AT, 0, ui->Instructions)) return LA_RUNNING;
  2487. lx = e->x;
  2488. ly = e->y;
  2489. laLocalToWindow(a, a->ToPanel, &e->x, &e->y);
  2490. e->Localized = 0;
  2491. call_ret=laInvokeP(0, ui->AT, e, 0, ui->ExtraInstructions ? ui->ExtraInstructions->Ptr : 0, 0);
  2492. e->x = lx;
  2493. e->y = ly;
  2494. e->Localized = 1;
  2495. }else{
  2496. laOperatorProp *ap = ui->PP.LastPs->p;
  2497. if (ap->OperatorID){
  2498. if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
  2499. if (!ui->Instructions){
  2500. if (ui->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
  2501. if (ap->OperatorType) strMakeInstructions(&ui->Instructions, ap->OperatorType->ExtraInstructions);
  2502. }
  2503. if (!laOperatorAvailablePSafe(ap->OperatorType, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->Instructions)) return LA_RUNNING;
  2504. lx = e->x;
  2505. ly = e->y;
  2506. laLocalToWindow(a, a->ToPanel, &e->x, &e->y);
  2507. e->Localized = 0;
  2508. call_ret=laInvokePCreateThis(0, ap->OperatorType, e, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->ExtraInstructions ? ui->ExtraInstructions->Ptr : 0, ap->Base.ExtraInstructions);
  2509. if(a->StopNow) return LA_FINISHED;
  2510. laRetriggerOperators();
  2511. e->x = lx;
  2512. e->y = ly;
  2513. e->Localized = 1;
  2514. }
  2515. }
  2516. if(MAIN.InvokeConfirmData){
  2517. a->ConfirmData=MAIN.InvokeConfirmData; laConfirmSameDataIfAny(a); a->ConfirmData=0;
  2518. }else{
  2519. if (str = strGetArgumentString(ui->Instructions, "feedback")){
  2520. if (strSame(str, "CONFIRM")) laConfirmInt(a, 0, LA_CONFIRM_OK);
  2521. elif (strSame(str, "CANCEL")) laConfirmInt(a, 0, LA_CONFIRM_CANCEL);
  2522. else { laConfirmString(a, str, LA_CONFIRM_CUSTOM_STRING); }
  2523. }elif(!(ui->Flags&LA_UI_FLAGS_NO_CONFIRM)){
  2524. laConfirmInt(a, 0, LA_CONFIRM_OK);
  2525. }
  2526. }
  2527. if(call_ret==LA_OPERATOR_CALLS_SHUTOFF) return LA_OPERATOR_CALLS_SHUTOFF;
  2528. laRedrawCurrentPanel();
  2529. if(ui->Flags&LA_UI_FLAGS_EXIT_WHEN_TRIGGERED) return LA_FINISHED_PASS;
  2530. return LA_RUNNING_PASS;
  2531. }
  2532. return LA_RUNNING_PASS;
  2533. }
  2534. int OPMOD_MenuItem(laOperator *a, laEvent *e){
  2535. laUiItem *ui = a->Instance;
  2536. laPanel *p;
  2537. laBoxedTheme *bt = (*ui->Type->Theme);
  2538. laGeneralUiExtraData *uit = a->CustomData;
  2539. int Away = 0;
  2540. if (a->ConfirmData){
  2541. ui->State = LA_UI_NORMAL;
  2542. laConfirmInt(a, a->ConfirmData->IData, a->ConfirmData->Mode);
  2543. laRedrawCurrentPanel();
  2544. return LA_RUNNING_PASS;
  2545. }
  2546. if (!laIsInUiItem(ui, e->x, e->y) && ui->State != LA_UI_ACTIVE){
  2547. ui->State = LA_UI_NORMAL;
  2548. laRedrawCurrentPanel();
  2549. return LA_FINISHED_PASS;
  2550. }
  2551. if (e->type == LA_L_MOUSE_DOWN){
  2552. int GX = ui->L, GY = ui->B;
  2553. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2554. ui->State = LA_UI_ACTIVE;
  2555. p = laEnableMenuPanel(a->ToPanel, a, ui->Subs.pFirst, &ui->PP, GX, GX + 300, GY, MAIN.CurrentWindow->CH-LA_2RH, 0, e);
  2556. laShowPanelWithDropDownEffect(p);
  2557. laRedrawCurrentPanel();
  2558. return LA_RUNNING;
  2559. }
  2560. return LA_RUNNING_PASS;
  2561. }
  2562. int OPMOD_ConditionToggle(laOperator *a, laEvent *e){
  2563. laUiItem *ui = a->Instance;
  2564. laBoxedTheme *bt = (*ui->Type->Theme);
  2565. laGeneralUiExtraData *uit = a->CustomData;
  2566. int Away = 0;
  2567. if (!laIsInUiItem(ui, e->x, e->y) /*&& ui->State!= LA_UI_ACTIVE*/){
  2568. return LA_FINISHED_PASS;
  2569. }
  2570. if (e->type == LA_L_MOUSE_DOWN){
  2571. ui->State = ui->State == LA_UI_ACTIVE ? LA_UI_NORMAL : LA_UI_ACTIVE;
  2572. laRecalcCurrentPanel();
  2573. return LA_RUNNING;
  2574. }
  2575. return LA_RUNNING_PASS;
  2576. }
  2577. int OPMOD_SingleLineString(laOperator *a, laEvent *e){
  2578. laUiItem *ui = a->Instance;
  2579. laBoxedTheme *bt = (*ui->Type->Theme);
  2580. laGeneralUiExtraData *uit = a->CustomData;
  2581. laStringEdit *se = uit->Edit;
  2582. int Away = 0;
  2583. char _buf[LA_RAW_CSTR_MAX_LEN] = {0}; char* buf=_buf;
  2584. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2585. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2586. int IsTerminal=ui->Flags&LA_UI_FLAGS_TERMINAL_INPUT;
  2587. int ImmediateInput=ui->Flags&LA_UI_FLAGS_IMMEDIATE_INPUT;
  2588. if (!laIsInUiItem(ui, e->x, e->y)){
  2589. if (ui->State != LA_UI_EDITING){
  2590. ui->State = LA_UI_NORMAL;
  2591. laRedrawCurrentPanel();
  2592. return LA_FINISHED_PASS;
  2593. }else{
  2594. if(IsTerminal && (e->type&LA_KEY_MOUSE_SCROLL)){ return LA_RUNNING_PASS; }
  2595. if ((e->type & LA_MOUSEDOWN) == LA_MOUSEDOWN){
  2596. buf=strEndEdit(&uit->Edit, 0);
  2597. laSetString(&ui->PP, buf); free(buf);
  2598. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2599. ui->State = LA_UI_NORMAL;
  2600. laRedrawCurrentPanel();
  2601. return LA_FINISHED_PASS;
  2602. }
  2603. }
  2604. }
  2605. if (e->type == LA_TIME_IDLE && !ui->State && !NoTooltip){
  2606. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2607. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2608. return LA_RUNNING;
  2609. }
  2610. if(NoEvent){ return LA_RUNNING_PASS; }
  2611. if(e->type ==LA_KEY_DOWN){
  2612. if (e->key == LA_KEY_ENTER){
  2613. buf=IsTerminal?strGetEditString(uit->Edit,0):strEndEdit(&uit->Edit, 0);
  2614. if(IsTerminal){ MAIN.IsTerminalEnter=1; }
  2615. laSetString(&ui->PP, buf); free(buf);
  2616. laRedrawCurrentPanel();
  2617. if(!IsTerminal){
  2618. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2619. ui->State = LA_UI_NORMAL;
  2620. return LA_FINISHED_PASS;
  2621. }else{
  2622. laGetString(&ui->PP, _buf, &buf);
  2623. strBeginEdit(&uit->Edit,buf);
  2624. MAIN.IsTerminalEnter=0;
  2625. return LA_RUNNING;
  2626. }
  2627. }else if (e->key == LA_KEY_ESCAPE && ui->State != LA_UI_NORMAL){
  2628. ui->State = LA_UI_NORMAL;
  2629. laRedrawCurrentPanel();
  2630. return LA_FINISHED;
  2631. }
  2632. }
  2633. if(laKeyMapExecuteEventEx(a, &ui->ExtraPP, &ui->Type->KeyMapper, e)) return LA_RUNNING;
  2634. if (e->type == LA_L_MOUSE_DOWN){
  2635. if (ui->State == LA_UI_NORMAL){
  2636. if(laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING;
  2637. ui->State = LA_UI_EDITING;
  2638. laGetString(&ui->PP, _buf, &buf);
  2639. strBeginEdit(&uit->Edit,buf);
  2640. strSelectLineAll(uit->Edit);
  2641. }elif (ui->State == LA_UI_EDITING){
  2642. if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
  2643. else strSelectLineAll(uit->Edit);
  2644. }
  2645. laRedrawCurrentPanel();
  2646. return LA_RUNNING;
  2647. }
  2648. if (e->type == LA_R_MOUSE_DOWN){
  2649. int GX = e->x, GY = e->y;
  2650. ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
  2651. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2652. 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);
  2653. return LA_RUNNING;
  2654. }
  2655. if (ui->State == LA_UI_EDITING){
  2656. if (la_ProcessTextEdit(e, se, ui)){
  2657. laRedrawCurrentPanel();
  2658. if(ImmediateInput){
  2659. buf=strGetEditString(uit->Edit,0); laSetString(&ui->PP, buf); free(buf);
  2660. }
  2661. }
  2662. return LA_RUNNING;
  2663. }
  2664. if (ui->State != LA_UI_EDITING) return LA_RUNNING_PASS;
  2665. else return LA_RUNNING;
  2666. }
  2667. void la_SetMultistringViewRange(laUiItem* ui, laStringEdit* se, laBoxedTheme* bt){
  2668. int NumberWidth=0; int MonoWidth=tnsGetMonoFontAdvance(); int Count=se->TotalLines;
  2669. while(Count){ Count/=10; NumberWidth+=MonoWidth; }
  2670. strSetEditViewRange(ui->Extra->Edit,
  2671. ui->Extra->HeightCoeff>0?ui->Extra->HeightCoeff:((ui->B-ui->U)/LA_RH),(ui->R-ui->L-NumberWidth-bt->LM*2-bt->RM)/MonoWidth);
  2672. }
  2673. int OPMOD_MultiString(laOperator *a, laEvent *e){
  2674. laUiItem *ui = a->Instance;
  2675. laBoxedTheme *bt = (*ui->Type->Theme);
  2676. laGeneralUiExtraData *es = a->CustomData;
  2677. laStringEdit *se = es->Edit;
  2678. int Away = 0;
  2679. char _buf[LA_RAW_CSTR_MAX_LEN] = {0}; char* buf=&_buf;
  2680. int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
  2681. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2682. if (!laIsInUiItem(ui, e->x, e->y) && !es->Dragging){
  2683. if ((e->type & LA_MOUSEDOWN) == LA_MOUSEDOWN){
  2684. buf=strGetEditString(es->Edit, 0); laSetString(&ui->PP, buf); free(buf);
  2685. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2686. ui->State = LA_UI_NORMAL;
  2687. laRedrawCurrentPanel();
  2688. return LA_FINISHED_PASS;
  2689. }
  2690. if(ui->State!=LA_UI_ACTIVE) return LA_FINISHED_PASS;
  2691. }
  2692. if (e->type == LA_TIME_IDLE && ui->State!=LA_UI_ACTIVE && !NoTooltip){
  2693. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2694. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2695. return LA_RUNNING;
  2696. }
  2697. if(NoEvent){ return LA_RUNNING_PASS; }
  2698. if(e->type ==LA_KEY_DOWN){
  2699. if (e->key == LA_KEY_ESCAPE){
  2700. if(ui->State != LA_UI_NORMAL){
  2701. buf=strGetEditString(es->Edit, 0); laSetString(&ui->PP, buf); free(buf);
  2702. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2703. ui->State = LA_UI_NORMAL; laRedrawCurrentPanel();la_SetMultistringViewRange(ui,es->Edit,bt);
  2704. }
  2705. if(es->Dragging){ es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel();la_SetMultistringViewRange(ui,es->Edit,bt); }
  2706. return LA_FINISHED;
  2707. }
  2708. }
  2709. if(laKeyMapExecuteEventEx(a, &ui->ExtraPP, &ui->Type->KeyMapper, e)) return LA_RUNNING;
  2710. 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){
  2711. es->Dragging=1; es->LastX=e->x; es->LastY=e->y; es->TargetIndexVali=es->HeightCoeff;
  2712. return LA_RUNNING;
  2713. }
  2714. if(es->Dragging){
  2715. if(e->type==LA_MOUSEMOVE){ es->HeightCoeff=es->TargetIndexVali+((real)e->y-es->LastY+0.5)/LA_RH;
  2716. if(es->HeightCoeff<1)es->HeightCoeff=1; laRecalcCurrentPanel(); la_SetMultistringViewRange(ui,es->Edit,bt);}
  2717. elif(e->type==LA_L_MOUSE_UP){ es->Dragging=0; }
  2718. elif(e->type==LA_R_MOUSE_DOWN){
  2719. es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel();la_SetMultistringViewRange(ui,se,bt); }
  2720. return LA_RUNNING;
  2721. }
  2722. int NoInactiveScroll=ui->Flags&LA_UI_FLAGS_NO_SCROLL_INACTIVE;
  2723. if((!NoInactiveScroll) || (ui->State==LA_UI_ACTIVE)){
  2724. if(e->type==LA_MOUSE_WHEEL_DOWN){ strMoveView(se, MAIN.ScrollingSpeed, 0); laRedrawCurrentPanel(); return LA_RUNNING; }
  2725. elif(e->type==LA_MOUSE_WHEEL_UP){ strMoveView(se, -MAIN.ScrollingSpeed, 0); laRedrawCurrentPanel(); return LA_RUNNING; }
  2726. }
  2727. if (e->type == LA_L_MOUSE_DOWN){
  2728. if (ui->State == LA_UI_NORMAL){
  2729. ui->State = LA_UI_ACTIVE;
  2730. laGetString(&ui->PP, _buf, &buf);
  2731. strBeginEdit(&es->Edit,buf);la_SetMultistringViewRange(ui,es->Edit,bt);
  2732. laRedrawCurrentPanel();
  2733. return LA_RUNNING;
  2734. }
  2735. }
  2736. if (e->type == LA_R_MOUSE_DOWN){
  2737. int GX = e->x, GY = e->y;
  2738. ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
  2739. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2740. 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);
  2741. return LA_RUNNING;
  2742. }
  2743. if (ui->State == LA_UI_ACTIVE){
  2744. if (la_ProcessTextEdit(e, se, ui))laRedrawCurrentPanel();
  2745. return LA_RUNNING;
  2746. }
  2747. if (ui->State != LA_UI_ACTIVE) return LA_RUNNING_PASS;
  2748. else return LA_RUNNING;
  2749. }
  2750. int OPMOD_TabSelector(laOperator *a, laEvent *e){
  2751. laUiItem *ui = a->Instance;
  2752. laBoxedTheme *bt = (*ui->Type->Theme);
  2753. laGeneralUiExtraData *uit = a->CustomData;
  2754. laUiList *uil;
  2755. int Away = 0;
  2756. int count = 0;
  2757. int it = 0;
  2758. int page;
  2759. if (!laIsInBound(e->x, e->y, ui->L, ui->R, ui->U, ui->U+LA_RH)){ return LA_FINISHED; }
  2760. if (e->type == LA_L_MOUSE_DOWN){
  2761. if (ui->Page->HeightCoeff && ui->R - e->x < LA_RH + bt->RM) return LA_RUNNING_PASS;
  2762. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){ count++; }
  2763. page = la_DetectColumn(ui, e->x, count);
  2764. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
  2765. if (it == page){
  2766. laRecalcCurrentPanel();
  2767. ui->Page = uil;
  2768. return LA_RUNNING;
  2769. }else
  2770. it++;
  2771. }
  2772. }
  2773. return LA_RUNNING_PASS;
  2774. }
  2775. int OPMOD_Collection(laOperator *a, laEvent *e) {
  2776. laUiItem *ui = a->Instance;
  2777. laGeneralUiExtraData *uit = a->CustomData;
  2778. laListHandle Locals = {0};
  2779. laUiList *uil;
  2780. int lx = e->x, ly = e->y;
  2781. int at = 0;
  2782. laUiList *ToUil =
  2783. a->ToPanel->MenuRefer ? a->ToPanel->MenuRefer : &a->ToPanel->UI;
  2784. if (!laIsInUiItem(ui, e->x, e->y) /* || e->y>(ui->Subs.pFirst?((laUiList*)ui->Subs.pFirst)->HeightCoeff:10000)*/){
  2785. return LA_FINISHED_PASS;
  2786. }
  2787. laLocalToPanel(a, &lx, &ly);
  2788. if (a->ToPanel && ui->U>=a->ToPanel->TitleBar.B && ly < a->ToPanel->TitleBar.B) {
  2789. return LA_FINISHED_PASS;
  2790. }
  2791. uil = la_DetectUiListRecursive(ToUil, lx, ly, 10000, 0, 0, 0, 0, 0);
  2792. if (uil != ((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target) {
  2793. //printf("%d %d EXITC\n",((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target, uil);
  2794. return LA_FINISHED;
  2795. }
  2796. if (e->type & LA_MOUSE_EVENT) {
  2797. laUiList *sub;
  2798. laUiItem *tui;
  2799. int LimHeight = 10000;
  2800. int UIB = ui->B, UIU = ui->U;
  2801. int t = 0;
  2802. void *Active = ui->PP.EndInstance;
  2803. if (ui->Subs.pFirst)
  2804. LimHeight = (int)((laUiList *)ui->Subs.pFirst)->HeightCoeff;
  2805. if (LimHeight > 0)
  2806. UIB = LimHeight;
  2807. laPanelToLocal(a, &t, &UIB);
  2808. for (sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext) {
  2809. ui->PP.EndInstance = sub->Instance;
  2810. if ((tui = la_DetectUiItemRecursive(sub, e->x, e->y, UIB, &Locals, 0))) {
  2811. if (tui && !a->Child && tui->Type->OperatorType) {
  2812. // printf("invui %d\n", tui);
  2813. laSetOperatorLocalizer(a->ToPanel);
  2814. laInvokeUiP(a, tui->Type->OperatorType, e, tui, &Locals, 0);
  2815. }
  2816. }
  2817. lstClearPointer(&Locals);
  2818. }
  2819. ui->PP.EndInstance = Active;
  2820. }
  2821. if (e->type == LA_L_MOUSE_DOWN && (!laIsPropertyReadOnly(&ui->PP)) &&
  2822. ui->Type != _LA_UI_COLLECTION_SINGLE) {
  2823. laUiList *uil;
  2824. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext) {
  2825. if (a->ConfirmData)
  2826. return LA_RUNNING_PASS;
  2827. if (laIsInBound(e->x, e->y, uil->L, uil->R, uil->U, uil->B)) {
  2828. laRecalcCurrentPanel();
  2829. laPropPack PP = {0};
  2830. la_CopyPropPack(
  2831. &ui->PP,
  2832. &PP); // needed because layout can be switched after set active.
  2833. char *cmd;
  2834. if ((!(cmd = strGetArgumentString(ui->Instructions, "feedback"))) ||
  2835. (!strSame(cmd, "NONE"))) {
  2836. laConfirmPointer(a, uil->Instance, la_EnsureSubTarget(ui->PP.LastPs->p, uil->Instance), LA_CONFIRM_DATA);
  2837. }
  2838. laSetActiveInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance,
  2839. uil->Instance);
  2840. laRecordAndPushProp(&PP, 0);
  2841. laMarkPropChanged(&PP);
  2842. return LA_RUNNING_PASS;
  2843. }
  2844. }
  2845. return LA_RUNNING;
  2846. }
  2847. elif (e->type == LA_R_MOUSE_DOWN) {
  2848. laUiList *uil;
  2849. for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext) {
  2850. if (laIsInBound(e->x, e->y, uil->L, uil->R, uil->U, uil->B)) {
  2851. ui->PP.EndInstance = uil->Instance;
  2852. lx = e->x, ly = e->y;
  2853. laLocalToWindow(a, a->ToPanel, &lx, &ly);
  2854. laEnablePropertyPanel(a->ToPanel, a, 0, 0, laui_PropOperatorUiDefine, &ui->PP,
  2855. lx, lx, ly, 0, 0, e);
  2856. }
  2857. }
  2858. return LA_RUNNING;
  2859. }
  2860. return LA_RUNNING_PASS;
  2861. }
  2862. int OPMOD_CollectionSelector(laOperator *a, laEvent *e){
  2863. laUiItem *ui = a->Instance;
  2864. laBoxedTheme *bt = (*ui->Type->Theme);
  2865. laGeneralUiExtraData *uit = a->CustomData;
  2866. int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
  2867. int at = 0;
  2868. int ReadOnly=laIsPropertyReadOnly(&ui->PP);
  2869. int Simple=ui->Flags&LA_UI_COLLECTION_SIMPLE_SELECTOR;
  2870. if (a->ConfirmData /* && a->ConfirmData->Mode == LA_CONFIRM_DATA*/){
  2871. ui->State = LA_UI_NORMAL;
  2872. laRecalcCurrentPanel();
  2873. return LA_RUNNING;
  2874. }
  2875. if (!laIsInUiItem(ui, e->x, e->y)){
  2876. return LA_FINISHED;
  2877. }
  2878. int lx = e->x, ly = e->y;
  2879. laUiList *ToUil =
  2880. a->ToPanel->MenuRefer ? a->ToPanel->MenuRefer : &a->ToPanel->UI;
  2881. laUiList* uil = la_DetectUiListRecursive(ToUil, lx, ly, 10000, 0, 0, 0, 0, 0);
  2882. if (uil != ((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target) {
  2883. //printf("%d %d EXIT\n",((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target, uil);
  2884. return LA_FINISHED;
  2885. }
  2886. if (e->type == LA_TIME_IDLE && !ui->State && !NoTooltip){
  2887. int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2888. laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
  2889. return LA_RUNNING;
  2890. }
  2891. if (e->type == LA_L_MOUSE_DOWN){
  2892. laUiList *uil;
  2893. laColumn *col;
  2894. laPanel *p;
  2895. int GX = ui->L, GY = ui->B, GR = ui->R, t = 0;
  2896. if(ReadOnly){ return LA_FINISHED; }
  2897. if(!Simple){
  2898. if (e->x >= TNS_MAX2(ui->R - LA_RH,(ui->R+ui->L)/2) && e->x < ui->R){
  2899. laSetActiveInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, 0);
  2900. laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  2901. return LA_FINISHED;
  2902. }
  2903. }
  2904. laLocalToWindow(a, a->ToPanel, &GX, &GY);
  2905. laLocalToWindow(a, a->ToPanel, &GR, &t);
  2906. laRedrawCurrentPanel();
  2907. ui->State = LA_UI_ACTIVE;
  2908. p = laEnableEmptyPropertyPanel(a->ToPanel, a, GX, GR, GY, 500, e);{
  2909. int MinWidth;
  2910. uil = &p->UI;
  2911. col = laFirstColumn(uil);
  2912. laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_COLLECTION, 0, ui->Template, 0)->SymbolID = ui->SymbolID;
  2913. laEnclosePanelContent(p, &p->UI);
  2914. }
  2915. return LA_RUNNING;
  2916. }
  2917. return LA_RUNNING_PASS;
  2918. }
  2919. int OPMOD_ColumnAdjuster(laOperator *a, laEvent *e){
  2920. laUiItem *ui = a->Instance;
  2921. laBoxedTheme *bt = (*ui->Type->Theme);
  2922. laGeneralUiExtraData *uit = a->CustomData;
  2923. laColumn *c = uit->Ptr1;
  2924. c = uit->Ptr1 ? uit->Ptr1 : la_DetectSplit(ui->C, e->x);
  2925. if(c){ laSetWindowCursor(LA_LEFT_AND_RIGHT); }else{ laSetWindowCursor(LA_ARROW); }
  2926. if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y)||!c)){
  2927. //printf("done\n");
  2928. laSetWindowCursor(LA_ARROW);
  2929. return LA_FINISHED_PASS;
  2930. }
  2931. if (e->type == LA_L_MOUSE_DOWN){
  2932. uit->Ptr1 = c;
  2933. uit->LastX = e->x;
  2934. uit->Dragging=1;
  2935. return LA_RUNNING;
  2936. }
  2937. if (uit->Dragging && uit->Ptr1 && e->type == LA_MOUSEMOVE){
  2938. la_AdjustColumnSplit(c, e->x - uit->LastX);
  2939. uit->LastX = e->x;
  2940. laRecalcCurrentPanel();
  2941. return LA_RUNNING;
  2942. }
  2943. if (uit->Dragging && (e->type == LA_L_MOUSE_UP || e->type == LA_R_MOUSE_DOWN || e->key == LA_KEY_ESCAPE)){
  2944. uit->Ptr1 = 0; uit->Dragging=0;
  2945. return LA_RUNNING;
  2946. }
  2947. return LA_RUNNING;
  2948. }
  2949. void la_NodeSocketGetPositionDelta(laUiItem* ui, int ex,int ey,int* dx,int* dy){
  2950. int cx,cy;
  2951. if(ui->Flags&LA_UI_SOCKET_LABEL_E){ cy=(ui->U+ui->B)/2; cx=ui->L+(ui->B-ui->U)/2; }
  2952. elif(ui->Flags&LA_UI_SOCKET_LABEL_W){ cy=(ui->U+ui->B)/2; cx=ui->R-(ui->B-ui->U)/2; }
  2953. elif(ui->Flags&LA_UI_SOCKET_LABEL_N){ cx=(ui->L+ui->R)/2; cy=ui->U+(ui->R-ui->L)*0.75; }
  2954. elif(ui->Flags&LA_UI_SOCKET_LABEL_S){ cx=(ui->L+ui->R)/2; cy=ui->B-(ui->R-ui->L)*0.75; }
  2955. else{ cx=(ui->L+ui->R)/2; cy=(ui->U+ui->B)/2; }
  2956. *dx=cx-ex; *dy=cy-ey;
  2957. }
  2958. int OPMOD_NodeSocket(laOperator *a, laEvent *e){
  2959. laUiItem *ui = a->Instance;
  2960. laBoxedTheme *bt = (*ui->Type->Theme);
  2961. laGeneralUiExtraData *uit = a->CustomData;
  2962. int lx=e->x,ly=e->y;
  2963. laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
  2964. laPropContainer* PCFind;
  2965. if(pc==LA_PC_SOCKET_IN) { PCFind=LA_PC_SOCKET_OUT; }
  2966. elif(pc==LA_PC_SOCKET_OUT){ PCFind=LA_PC_SOCKET_IN; }
  2967. if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
  2968. if (e->type==LA_TIME_IDLE){ return LA_RUNNING_PASS; }
  2969. if (e->type == LA_L_MOUSE_DOWN){
  2970. uit->Dragging=1; MAIN.NextWireColor+=3;
  2971. if(pc==LA_PC_SOCKET_IN) {
  2972. laNodeInSocket* s=ui->PP.EndInstance;
  2973. uit->Ptr2 = s->Source;
  2974. if(!s->Source){
  2975. s->ColorId=MAIN.NextWireColor; s->Source=MAIN.tNodeOut; latouched_NodeInSocket(0,0);
  2976. MAIN.tNodeOut->RuntimeX=MAIN.tNodeOut->RuntimeY=MAIN.tNodeOut->RuntimePX=MAIN.tNodeOut->RuntimePY=0;
  2977. }else{
  2978. MAIN.tNodeIn->Source = s->Source;
  2979. MAIN.tNodeIn->RuntimeX=MAIN.tNodeIn->RuntimeY=MAIN.tNodeIn->RuntimePX=MAIN.tNodeIn->RuntimePY=0;
  2980. MAIN.tNodeIn->RuntimePX=-(s->Source->RuntimeX+s->Source->RuntimePX)+(s->RuntimeX+s->RuntimePX);
  2981. MAIN.tNodeIn->RuntimePY=-(s->Source->RuntimeY+s->Source->RuntimePY)+(s->RuntimeY+s->RuntimePY);
  2982. s->Source=0; MAIN.tNodeIn->ColorId=s->ColorId; latouched_NodeInSocket(0,0);
  2983. }
  2984. }
  2985. elif(pc==LA_PC_SOCKET_OUT){ MAIN.tNodeIn->Source=ui->PP.EndInstance; latouched_NodeInSocket(0,0);
  2986. MAIN.tNodeIn->RuntimeX=MAIN.tNodeIn->RuntimeY=MAIN.tNodeIn->RuntimePX=MAIN.tNodeIn->RuntimePY=0;
  2987. MAIN.tNodeIn->ColorId=MAIN.NextWireColor; }
  2988. int dx,dy; la_NodeSocketGetPositionDelta(ui,e->x,e->y,&dx,&dy); uit->LastX = e->x+dx; uit->LastY = e->y+dy;
  2989. laRedrawCurrentPanel();
  2990. return LA_RUNNING;
  2991. }
  2992. if (uit->Dragging && e->type == LA_MOUSEMOVE){
  2993. laPanel* p=MAIN.CurrentPanel;
  2994. laLocalToPanel(a, &lx, &ly);
  2995. laUiItem* tui=la_DetectSocketRecursive(&p->UI,lx,ly,100000,uit->Ptr2?LA_PC_SOCKET_IN:PCFind); uit->Ptr1=tui;
  2996. if(pc==LA_PC_SOCKET_IN){
  2997. if(!uit->Ptr2){MAIN.tNodeOut->RuntimeX=e->x-uit->LastX;MAIN.tNodeOut->RuntimeY=e->y-uit->LastY;}
  2998. else { MAIN.tNodeIn->RuntimeX=e->x-uit->LastX;MAIN.tNodeIn->RuntimeY=e->y-uit->LastY; } }
  2999. elif(pc==LA_PC_SOCKET_OUT){ MAIN.tNodeIn->RuntimeX=e->x-uit->LastX; MAIN.tNodeIn->RuntimeY=e->y-uit->LastY; }
  3000. laRedrawCurrentPanel();
  3001. return LA_RUNNING;
  3002. }
  3003. if (uit->Dragging && (e->type == LA_L_MOUSE_UP || e->type == LA_R_MOUSE_DOWN || e->key == LA_KEY_ESCAPE)){
  3004. uit->Dragging=0; MAIN.tNodeIn->Source=0;
  3005. laRecalcCurrentPanel();
  3006. laUiItem* tui=uit->Ptr1; void* soc=tui?tui->PP.EndInstance:0;
  3007. if(pc == LA_PC_SOCKET_IN){
  3008. if(!uit->Ptr2){ if(!tui){ laNodeInSocket* s=ui->PP.EndInstance; s->Source=0; return LA_RUNNING; }
  3009. laNodeInSocket* s=ui->PP.EndInstance; s->Source=0; memAssignRef(s,&s->Source,soc); latouched_NodeInSocket(0,0);
  3010. s->ColorId=MAIN.NextWireColor; laRecordAndPushProp(&ui->PP, 0); laMarkPropChanged(&ui->PP);
  3011. }else{
  3012. if(!tui){
  3013. laNodeInSocket* s=ui->PP.EndInstance; s->Source=uit->Ptr2; memAssignRef(s,&s->Source,0); latouched_NodeInSocket(0,0);
  3014. laRecordAndPushProp(&ui->PP, 0); laMarkPropChanged(&ui->PP);
  3015. }else{
  3016. laNodeInSocket* s=soc; if(s->Source){ uit->Ptr2=0; return LA_RUNNING; } latouched_NodeInSocket(0,0);
  3017. memAssignRef(s,&s->Source,uit->Ptr2); s->ColorId=((laNodeInSocket*)ui->PP.EndInstance)->ColorId;
  3018. laRecordDifferences(&ui->PP,0); laRecordDifferences(&tui->PP,0); laPushDifferences("Socket status changed", 0);
  3019. laMarkPropChanged(&tui->PP); laMarkPropChanged(&ui->PP);
  3020. }
  3021. }
  3022. }
  3023. else{
  3024. if(!tui){ return LA_RUNNING; }
  3025. laNodeInSocket* s=soc; s->Source=0; memAssignRef(s,&s->Source,ui->PP.EndInstance); latouched_NodeInSocket(0,0);
  3026. s->ColorId=MAIN.NextWireColor; laRecordAndPushProp(&tui->PP, 0); laMarkPropChanged(&tui->PP);
  3027. }
  3028. uit->Ptr2=0;
  3029. return LA_RUNNING;
  3030. }
  3031. return LA_RUNNING_PASS;
  3032. }
  3033. int OPMOD_HeightAdjuster(laOperator *a, laEvent *e){
  3034. laUiItem *ui = a->Instance;
  3035. laBoxedTheme *bt = (*ui->Type->Theme);
  3036. laGeneralUiExtraData *uit = a->CustomData;
  3037. int lx=e->x,ly=e->y;
  3038. int ClickedVal=0;
  3039. if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
  3040. if (e->type == LA_L_MOUSE_DOWN || e->type==LA_R_MOUSE_DOWN){
  3041. 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;
  3042. return LA_RUNNING;
  3043. }
  3044. if(e->type==LA_L_MOUSE_UP && uit->HeightCoeff){ ui->State=(ui->State==LA_BT_ACTIVE)?LA_BT_NORMAL:LA_BT_ACTIVE; laRedrawCurrentPanel(); }
  3045. if (uit->Dragging && e->type == LA_MOUSEMOVE){
  3046. int diff=e->y-uit->LastY; diff=((real)diff+0.5)/(ui->B-ui->U); int delta=uit->TargetIndexVali;
  3047. 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(); }
  3048. return LA_RUNNING;
  3049. }
  3050. if (uit->Dragging && (e->type == LA_L_MOUSE_UP || e->type == LA_R_MOUSE_UP || e->key == LA_KEY_ESCAPE)){
  3051. uit->Dragging=0; return LA_RUNNING_PASS;
  3052. }
  3053. return LA_RUNNING_PASS;
  3054. }
  3055. void la_ValueMapperSortPoint(laValueMapper* vm){
  3056. laValueMapperPoint* vmp,*ivmp; laListHandle temp={0}; int Inserted=0;
  3057. while(vmp=lstPopItem(&vm->Points)){
  3058. Inserted=0;
  3059. for(ivmp=temp.pLast;ivmp;ivmp=ivmp->Item.pPrev){
  3060. if(ivmp->x<vmp->x){ lstInsertItemAfter(&temp,vmp,ivmp); Inserted=1; break; }
  3061. }
  3062. if(!Inserted){ lstPushItem(&temp,vmp); }
  3063. }
  3064. vm->Points.pFirst=temp.pFirst; vm->Points.pLast=temp.pLast;
  3065. }
  3066. laValueMapperPoint* la_ValueMapperCreatePoint(laValueMapper* vm, real x, real y){
  3067. laValueMapperPoint* vmp=memAcquire(sizeof(laValueMapperPoint));
  3068. vmp->x=x;vmp->y=y; lstAppendItem(&vm->Points,vmp);
  3069. la_ValueMapperSortPoint(vm);
  3070. return vmp;
  3071. }
  3072. laValueMapperPoint* la_ValueMapperGetPoint(laValueMapper* vm, real x, real y){
  3073. laValueMapperPoint* vmp=0,*ClosestVMP=0; real MinD=FLT_MAX;
  3074. if(x<0||x>1||y>1||y<0) return 0;
  3075. const real thres=0.1;
  3076. for(vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
  3077. if(vmp->x>x+thres || vmp->x<x-thres || vmp->y>y+thres || vmp->y<y-thres) continue;
  3078. real d=tnsDistIdv2(x,y,vmp->x,vmp->y);
  3079. if(d<MinD){ ClosestVMP=vmp; MinD=d; }
  3080. }
  3081. vmp=ClosestVMP;
  3082. if(!vmp){ vmp=la_ValueMapperCreatePoint(vm,x,y); }
  3083. return vmp;
  3084. }
  3085. void la_ValueMapperEnsureValidPoints(laValueMapper* vm){
  3086. if(!vm->Points.pFirst){ la_ValueMapperCreatePoint(vm,0,0); }
  3087. if(vm->Points.pFirst==vm->Points.pLast){ la_ValueMapperCreatePoint(vm,1,1); }
  3088. }
  3089. laValueMapper* laValueMapperInit(){
  3090. laValueMapper* vm=memAcquire(sizeof(laValueMapper));
  3091. vm->InRange[0]=0; vm->InRange[1]=1; vm->OutRange[0]=0; vm->OutRange[1]=1;
  3092. la_ValueMapperEnsureValidPoints(vm);
  3093. return vm;
  3094. }
  3095. laValueMapper* laValueMapperDestroy(laValueMapper* vm){
  3096. laValueMapperPoint* vmp;
  3097. while(vmp=lstPopItem(&vm->Points)){ memLeave(vmp); }
  3098. memLeave(vm);
  3099. }
  3100. laValueMapper* laValueMapperCopy(laValueMapper* new_optional, laValueMapper* vm){
  3101. laValueMapper* into=new_optional?new_optional:memAcquire(sizeof(laValueMapper)); laValueMapperPoint* vmp;
  3102. while(vmp=lstPopItem(&into->Points)){ memLeave(vmp); }
  3103. for(vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){ la_ValueMapperCreatePoint(into, vmp->x, vmp->y); }
  3104. tnsVectorSet2v(into->InRange,vm->InRange); tnsVectorSet2v(into->OutRange,vm->OutRange);
  3105. return into;
  3106. }
  3107. real laValueMapperEvaluate(laValueMapper* vm, real x, real* force_InMin, real* force_InMax, real* force_OutMin, real* force_OutMax, int ClampIn, int ClampOut){
  3108. real InMin=vm->InRange[0], InMax=vm->InRange[1], OutMin=vm->OutRange[0], OutMax=vm->OutRange[1];
  3109. if(force_InMin) InMin=*force_InMin; if(force_InMax) InMax=*force_InMax; if(force_OutMin) OutMin=*force_OutMin; if(force_OutMax) OutMax=*force_OutMax;
  3110. if(fabs(InMax-InMin)<1e-7) return 0;
  3111. x=tnsGetRatiod(InMin,InMax,x); if(ClampIn) TNS_CLAMP(x,0,1);
  3112. laValueMapperPoint* vmp,*NextVMP;
  3113. real ey=0;
  3114. for(vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
  3115. NextVMP=vmp->Item.pNext;
  3116. if(NextVMP && (!(vmp->x<=x && NextVMP->x>x))) continue;
  3117. if(!NextVMP){ NextVMP=vmp; vmp=vmp->Item.pPrev; if(!vmp) return 0; }
  3118. if(fabs(vmp->x-NextVMP->x)<1e-7){ ey=vmp->y; break; }
  3119. real ratio=tnsGetRatiod(vmp->x,NextVMP->x,x);
  3120. ey=tnsInterpolate(vmp->y,NextVMP->y,ratio); break;
  3121. }
  3122. real Out=tnsInterpolate(OutMin,OutMax,ey);
  3123. if(ClampOut) TNS_CLAMP(Out,OutMin,OutMax);
  3124. return Out;
  3125. }
  3126. int OPMOD_ValueMapper(laOperator *a, laEvent *e){
  3127. laUiItem *ui = a->Instance;
  3128. laBoxedTheme *bt = (*ui->Type->Theme);
  3129. laGeneralUiExtraData *uit = a->CustomData;
  3130. int w=ui->R-ui->L, h=ui->B-ui->U;
  3131. real x=(real)(e->x-ui->L)/w,y=(real)(ui->B-e->y)/h;
  3132. int ClickedVal=0;
  3133. if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
  3134. laValueMapper* vm=ui->PP.EndInstance;
  3135. if (e->type == LA_L_MOUSE_DOWN){
  3136. uit->Dragging=1; uit->LastX=e->x; uit->LastY=e->y;
  3137. return LA_RUNNING;
  3138. }
  3139. if (uit->Dragging && e->type == LA_MOUSEMOVE){
  3140. laValueMapperPoint* vmp=uit->Ptr1;
  3141. if(uit->Dragging==1 && tnsDistIdv2(e->x,e->y,uit->LastX,uit->LastY)>LA_RH/2){
  3142. uit->Ptr1=la_ValueMapperGetPoint(vm,x,y); if(!uit->Ptr1){ uit->Dragging=0; return LA_RUNNING; }
  3143. uit->Dragging=2;
  3144. }
  3145. elif(uit->Dragging==2){
  3146. if(x<0&&x>-0.05){ x=0; } if(x>1&&x<1.05){ x=1; } TNS_CLAMP(y,0,1);
  3147. vmp->x=x; vmp->y=y; la_ValueMapperSortPoint(vm);
  3148. laNotifyUsersPP(&ui->PP); laRedrawCurrentPanel(); laMarkPropChanged(&ui->PP);
  3149. }
  3150. return LA_RUNNING;
  3151. }
  3152. if (uit->Dragging && (e->type == LA_L_MOUSE_UP || e->type == LA_R_MOUSE_UP || e->key == LA_KEY_ESCAPE)){
  3153. uit->Dragging=0; laValueMapperPoint* vmp=uit->Ptr1; if(!vmp) return LA_RUNNING_PASS;
  3154. if(vmp->x>1||vmp->x<0) {
  3155. lstRemoveItem(&vm->Points,vmp); la_ValueMapperEnsureValidPoints(vm);
  3156. laNotifyUsersPP(&ui->PP); laRedrawCurrentPanel(); laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
  3157. }
  3158. return LA_RUNNING_PASS;
  3159. }
  3160. return LA_RUNNING_PASS;
  3161. }
  3162. void la_RegisterUiOperatorsBasic(){
  3163. laPropContainer *pc, *p;
  3164. laOperatorType *at;
  3165. laEnumProp *ep;
  3166. laCreateOperatorType("LA_edit_string_copy", "Copy Selection", "Copy selected string to clip board",
  3167. OPCHK_EditStringCopySelection, 0, 0, OPINV_EditStringCopySelection, 0, U'🗍', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3168. laCreateOperatorType("LA_int_array_h_operator", "Int(Horizon) UiItem Operator", "Do Array Valuator Stuff",
  3169. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_IntArrayHorizon, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3170. laCreateOperatorType("LA_real_array_h_operator", "Float(Horizon) UiItem Operator", "Do Array Valuator Stuff",
  3171. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_FloatArrayHorizon, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3172. laCreateOperatorType("LA_real_color_operator", "Color(Float) Display UiItem Operator", "Color Display,Click To Set Color",
  3173. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_FloatColor, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3174. laCreateOperatorType("LA_real_hcy_operator", "HCY Color Picker UiItem Operator", "HCY Color Picker,Click To Set Color",
  3175. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ColorHCY, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3176. laCreateOperatorType("LA_enum_selector_operator", "Enum Selector UiItem Operator", "Do Selector Stuff",
  3177. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_EnumSelector, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3178. laCreateOperatorType("LA_button_operator", "Button UiItem Operator", "Execute an Operator",
  3179. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_Button, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3180. laCreateOperatorType("LA_menu_root_operator", "Menu Root UiItem Operator", "Drop A Menu",
  3181. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_MenuItem, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3182. laCreateOperatorType("LA_condition_toggle_operator", "Condition +/- Button Operator", "Do Self Condition Function",
  3183. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ConditionToggle, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3184. laCreateOperatorType("LA_string_operator", "Single Line String Operator", "Do String Modifying Function",
  3185. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_SingleLineString, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3186. laCreateOperatorType("LA_string_multi", "Multi Line String Operator", "Do String Modifying Function",
  3187. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_MultiString, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3188. laCreateOperatorType("LA_tab_operator", "Tab Switcher Operator", "Change The Page In The Tab Group",
  3189. 0, 0, OPEXT_UiItem, OPINV_Tab, OPMOD_TabSelector, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3190. laCreateOperatorType("LA_collection_operator", "Collection UiItem Operator", "Activate/Deactivate Collection Item(s)",
  3191. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_Collection, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3192. laCreateOperatorType("LA_collection_selector_operator", "Collection Dropdown Selector Operator", "Do Selector Stuff",
  3193. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_CollectionSelector, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3194. laCreateOperatorType("LA_column_adjuster", "Column Width Adjuster", "Drag To Set Width of Columns",
  3195. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ColumnAdjuster, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3196. laCreateOperatorType("LA_node_socket", "Node Socket Operator", "Drag to connect node sockets",
  3197. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_NodeSocket, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3198. laCreateOperatorType("LA_height_adjuster", "Height Adjuster Operator", "Drag to adjust heights of an instance",
  3199. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_HeightAdjuster, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3200. laCreateOperatorType("LA_value_mapper", "Value mapper Operator", "Drag to set value mapping from input to output",
  3201. 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ValueMapper, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  3202. }