*/}}

la_widgets.c 120 KB

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