*/}}

la_widgets.c 123 KB

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