*/}}

la_widgets.c 152 KB

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