*/}}

la_widgets.c 152 KB

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