*/}}

la_widgets.c 153 KB

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