*/}}

la_widgets.c 125 KB

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