*/}}

la_widgets.c 124 KB

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