*/}}

la_widgets.c 112 KB

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