*/}}

la_widgets.c 152 KB

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