*/}}

la_widgets.c 123 KB

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