*/}}

la_widgets.c 150 KB

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