*/}}

la_widgets.c 125 KB

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