*/}}

la_widgets.c 153 KB

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