*/}}

la_widgets.c 152 KB

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