*/}}

la_widgets.c 125 KB

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