1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598 |
- /*
- * LaGUI: A graphical application framework.
- * Copyright (C) 2022-2023 Wu Yiming
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include "../la_5.h"
- extern LA MAIN;
- extern tnsMain* T;
- laWidget _LA_WIDGET_FIXED_GROUP={0};
- laWidget _LA_WIDGET_TAB={0};
- laWidget _LA_WIDGET_COLLECTION={0};
- laWidget _LA_WIDGET_COLLECTION_ITEM={0};
- laWidget _LA_WIDGET_COLLECTION_SELECTOR={0};
- laWidget _LA_WIDGET_COLLECTION_SINGLE={0};
- laWidget _LA_WIDGET_CONDITION_TOGGLE={0};
- laWidget _LA_WIDGET_COLUMN_ADJUSTER={0,LA_UI_FLAGS_NO_HEIGHT};
- laWidget _LA_WIDGET_COLUMN_VIEWER={0};
- laWidget _LA_WIDGET_BUTTON={0};
- laWidget _LA_WIDGET_BUTTON_NO_CONFIRM={0};
- laWidget _LA_WIDGET_LABEL={0};
- laWidget _LA_WIDGET_INT={0};
- laWidget _LA_WIDGET_INT_PLAIN={0, LA_UI_FLAGS_PLAIN};
- laWidget _LA_WIDGET_INT_PLAIN_ICON={0, LA_UI_FLAGS_INT_ICON};
- laWidget _LA_WIDGET_METER_TYPE1={0,LA_TEXT_ALIGN_CENTER};
- laWidget _LA_WIDGET_METER_TYPE2={0,LA_TEXT_ALIGN_CENTER};
- laWidget _LA_WIDGET_VALUE_METER_2D={0,LA_TEXT_ALIGN_CENTER};
- laWidget _LA_WIDGET_FLOAT={0};
- laWidget _LA_WIDGET_FLOAT_PLAIN={0, LA_UI_FLAGS_PLAIN};
- laWidget _LA_WIDGET_FLOAT_COLOR={0};
- laWidget _LA_WIDGET_FLOAT_COLOR_HCY={0};
- laWidget _LA_WIDGET_ENUM_SELECTOR={0};
- laWidget _LA_WIDGET_ENUM_SELECTOR_ICON={0, LA_UI_FLAGS_ICON};
- laWidget _LA_WIDGET_ENUM_CYCLE={0, LA_UI_FLAGS_CYCLE};
- laWidget _LA_WIDGET_ENUM_CYCLE_ICON={0, LA_UI_FLAGS_CYCLE|LA_UI_FLAGS_ICON};
- laWidget _LA_WIDGET_ENUM_ICON_PLAIN={0, LA_UI_FLAGS_PLAIN|LA_UI_FLAGS_ICON};
- laWidget _LA_WIDGET_ENUM_HIGHLIGHT={0, LA_UI_FLAGS_HIGHLIGHT|LA_UI_FLAGS_CYCLE|LA_TEXT_ALIGN_CENTER};
- laWidget _LA_WIDGET_STRING={0};
- laWidget _LA_WIDGET_STRING_PLAIN={0, LA_UI_FLAGS_PLAIN};
- laWidget _LA_WIDGET_STRING_MONO_PLAIN={0, LA_TEXT_MONO|LA_UI_FLAGS_PLAIN};
- laWidget _LA_WIDGET_STRING_MULTI={0, LA_TEXT_MONO};
- laWidget _LA_WIDGET_MENU_ROOT={0};
- laWidget _LA_WIDGET_ALIGN={0};
- laWidget _LA_WIDGET_3D_VIEW={0};
- laWidget _LA_WIDGET_2D_VIEW={0};
- laWidget _LA_WIDGET_SYMBOL={0};
- laWidget _LA_WIDGET_NODE_SOCKET={0};
- laWidget _LA_WIDGET_HEIGHT_ADJUSTER={0};
- laWidget _LA_WIDGET_RAW={0};
- laWidget _LA_WIDGET_MAPPER={0};
- laWidget _LA_WIDGET_IMAGE={0};
- laWidget _LA_WIDGET_SCOPE={0};
- laWidget _LA_WIDGET_KNOB={0,LA_UI_FLAGS_KNOB};
- laWidget *LA_WIDGET_FIXED_GROUP=&_LA_WIDGET_FIXED_GROUP;
- laWidget *LA_WIDGET_TAB=&_LA_WIDGET_TAB;
- laWidget *LA_WIDGET_COLLECTION=&_LA_WIDGET_COLLECTION;
- laWidget *LA_WIDGET_COLLECTION_ITEM=&_LA_WIDGET_COLLECTION_ITEM;
- laWidget *LA_WIDGET_COLLECTION_SELECTOR=&_LA_WIDGET_COLLECTION_SELECTOR;
- laWidget *LA_WIDGET_COLLECTION_SINGLE=&_LA_WIDGET_COLLECTION_SINGLE;
- laWidget *LA_WIDGET_CONDITION_TOGGLE=&_LA_WIDGET_CONDITION_TOGGLE;
- laWidget *LA_WIDGET_COLUMN_ADJUSTER=&_LA_WIDGET_COLUMN_ADJUSTER;
- laWidget *LA_WIDGET_COLUMN_VIEWER=&_LA_WIDGET_COLUMN_VIEWER;
- laWidget *LA_WIDGET_BUTTON=&_LA_WIDGET_BUTTON;
- laWidget *LA_WIDGET_BUTTON_NO_CONFIRM=&_LA_WIDGET_BUTTON_NO_CONFIRM;
- laWidget *LA_WIDGET_LABEL=&_LA_WIDGET_LABEL;
- laWidget *LA_WIDGET_INT=&_LA_WIDGET_INT;
- laWidget *LA_WIDGET_INT_PLAIN=&_LA_WIDGET_INT_PLAIN;
- laWidget *LA_WIDGET_INT_PLAIN_ICON=&_LA_WIDGET_INT_PLAIN_ICON;
- laWidget *LA_WIDGET_METER_TYPE1=&_LA_WIDGET_METER_TYPE1;
- laWidget *LA_WIDGET_METER_TYPE2=&_LA_WIDGET_METER_TYPE2;
- laWidget *LA_WIDGET_VALUE_METER_2D=&_LA_WIDGET_VALUE_METER_2D;
- laWidget *LA_WIDGET_FLOAT=&_LA_WIDGET_FLOAT;
- laWidget *LA_WIDGET_FLOAT_PLAIN=&_LA_WIDGET_FLOAT_PLAIN;
- laWidget *LA_WIDGET_FLOAT_COLOR=&_LA_WIDGET_FLOAT_COLOR;
- laWidget *LA_WIDGET_FLOAT_COLOR_HCY=&_LA_WIDGET_FLOAT_COLOR_HCY;
- laWidget *LA_WIDGET_ENUM_SELECTOR=&_LA_WIDGET_ENUM_SELECTOR;
- laWidget *LA_WIDGET_ENUM_SELECTOR_ICON=&_LA_WIDGET_ENUM_SELECTOR_ICON;
- laWidget *LA_WIDGET_ENUM_CYCLE=&_LA_WIDGET_ENUM_CYCLE;
- laWidget *LA_WIDGET_ENUM_CYCLE_ICON=&_LA_WIDGET_ENUM_CYCLE_ICON;
- laWidget *LA_WIDGET_ENUM_ICON_PLAIN=&_LA_WIDGET_ENUM_ICON_PLAIN;
- laWidget *LA_WIDGET_ENUM_HIGHLIGHT=&_LA_WIDGET_ENUM_HIGHLIGHT;
- laWidget *LA_WIDGET_STRING=&_LA_WIDGET_STRING;
- laWidget *LA_WIDGET_STRING_PLAIN=&_LA_WIDGET_STRING_PLAIN;
- laWidget *LA_WIDGET_STRING_MULTI=&_LA_WIDGET_STRING_MULTI;
- laWidget *LA_WIDGET_STRING_MONO_PLAIN=&_LA_WIDGET_STRING_MONO_PLAIN;
- laWidget *LA_WIDGET_MENU_ROOT=&_LA_WIDGET_MENU_ROOT;
- laWidget *LA_WIDGET_ALIGN=&_LA_WIDGET_ALIGN;
- laWidget *LA_WIDGET_3D_VIEW=&_LA_WIDGET_3D_VIEW;
- laWidget *LA_WIDGET_2D_VIEW=&_LA_WIDGET_2D_VIEW;
- laWidget *LA_WIDGET_SYMBOL=&_LA_WIDGET_SYMBOL;
- laWidget *LA_WIDGET_NODE_SOCKET=&_LA_WIDGET_NODE_SOCKET;
- laWidget *LA_WIDGET_HEIGHT_ADJUSTER=&_LA_WIDGET_HEIGHT_ADJUSTER;
- laWidget *LA_WIDGET_RAW=&_LA_WIDGET_RAW;
- laWidget *LA_WIDGET_MAPPER=&_LA_WIDGET_MAPPER;
- laWidget *LA_WIDGET_IMAGE=&_LA_WIDGET_IMAGE;
- laWidget *LA_WIDGET_SCOPE=&_LA_WIDGET_SCOPE;
- laWidget *LA_WIDGET_KNOB=&_LA_WIDGET_KNOB;
- //============================================== [Draw]
- int la_ArrayGetHeight(laUiItem *ui){
- return laGetArrayLength(&ui->PP);
- }
- int la_ValueGetHeight(laUiItem*ui){
- int rows = ui->Extra->HeightCoeff; TNS_CLAMP(rows,1,4);
- if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){ return la_ArrayGetHeight(ui)*rows; }
- return rows;
- }
- int la_ValueMeterGetHeight(laUiItem*ui){
- if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){ return ui->Extra->HeightCoeff?ui->Extra->HeightCoeff:6; }
- return laGetArrayLength(&ui->PP);
- }
- int la_ValueMeter2DGetHeight(laUiItem*ui){
- return ui->Extra->HeightCoeff?ui->Extra->HeightCoeff:(ui->Extra->HeightCoeff=(ui->TR-ui->TL)/LA_RH);
- }
- int la_CanvasGetHeight(laUiItem *ui){
- return ui->Expand;
- }
- int la_EnumGetHeight(laUiItem *ui){
- // norm e1
- // expand e1 e2 e3
- // expand vertical (vertical)
- // arr expand e1 e2 e3
- // e1 e2 e3
- // arr exp+vert e1 e1
- // e2 e2
- // e3 e3
- int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
- int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
- int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
- int ArrLen = laGetArrayLength(&ui->PP);
- if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
- int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
- if(ArrLen==1){
- if(IsVertical&&IsExpand) return laGetEnumEntryLen(&ui->PP);
- return 1;
- }else{
- if(IsVertical) return EnumLen;
- else return ArrLen;
- }
- }
- int la_ColorPickerGetHeight(laUiItem *ui){
- if(!ui->Extra->HeightCoeff) ui->Extra->HeightCoeff=7;
- return ui->Extra->HeightCoeff;
- }
- int la_SymbolGetHeight(laUiItem *ui){
- //if (!ui->State)
- //{
- // ui->State = (int)_ICON_SYMBOL_SIZE[ui->SymbolID - ICON_SYMBOL_START] * 1.4 + 1;
- //}
- return ui->State;
- }
- int la_GroupGetHeight(laUiItem *ui){
- if (ui->State == LA_UI_ACTIVE) return 0;
- return LA_RH;
- }
- int la_StringPropGetHeight(laUiItem *ui){
- laBoxedTheme *bt = *ui->Type->Theme;
- if(!(ui->Flags&LA_TEXT_LINE_WRAP)) return 1;
- char _buf[LA_RAW_CSTR_MAX_LEN]={0}; char* buf=_buf;
- laGetString(&ui->PP, _buf, &buf); int rows=0;
- int strw=tnsStringGetDimension(buf, 0, 0, ui->TR-ui->TL, &rows, ui->Flags&LA_TEXT_MONO);
- return rows;
- }
- int la_MultiStringHeight(laUiItem *ui){
- laGeneralUiExtraData *e = ui->Extra;
- return e->HeightCoeff;
- }
- int la_LabelHeight(laUiItem *ui){
- int Wrap=ui->Flags&(LA_TEXT_USE_NEWLINE|LA_TEXT_LINE_WRAP);
- if(!Wrap) return 1;
- int rows;
- tnsStringGetDimension(transLate(ui->Display->Ptr), 0, 0, ui->TR-ui->TL, &rows, ui->Flags&LA_TEXT_MONO);
- return rows;
- }
- int la_SocketGetHeight(laUiItem *ui){
- if(ui->Flags&(LA_UI_SOCKET_LABEL_N|LA_UI_SOCKET_LABEL_S))return 2; return 1;
- }
- int la_ImageGetHeight(laUiItem *ui){
- tnsImage* im=ui->Extra;
- if(ui->Flags&LA_UI_IMAGE_FULL_W){
- if(!im->Texture){ return 1; }
- int W=im->Texture->Width, H=im->Texture->Height;
- real CW=MAIN.CurrentWindow->CW-LA_RH*4, CH=MAIN.CurrentWindow->CH-LA_RH*4;
- real ra=1;
- if(W>CW){ real r=W/CW; ra=TNS_MAX2(r,ra); }
- if(H>CH){ real r=H/CH; ra=TNS_MAX2(r,ra); }
- W/=ra; H/=ra;
- return H/LA_RH+1;
- }
- if(ui->SymbolID) return ui->SymbolID;
- return 1;
- }
- int la_ColorSelectorGetMinWidth(laUiItem *ui){
- if(ui->Flags&LA_UI_FLAGS_ICON) return LA_RH;
- return 5*LA_RH;
- }
- int la_ValueGetMinWidth(laUiItem *ui){
- int ExtraW=0;
- if(ui->Flags&LA_UI_FLAGS_NO_LABEL){ return LA_RH; }
- if(ui->Flags&LA_UI_FLAGS_KNOB){ return LA_RH*TNS_MAX2(1,ui->Extra->HeightCoeff); }
- if((ui->Flags&LA_UI_FLAGS_EXPAND)&&(!(ui->Flags&LA_UI_FLAGS_NO_LABEL))){
- ExtraW+=tnsStringGetWidth(transLate(ui->PP.LastPs->p->Name),0,0);
- }
- return LA_RH*4+ExtraW;
- }
- int la_LabelGetMinWidth(laUiItem *ui){
- laBoxedTheme *bt = *ui->Type->Theme;
- if(ui->Flags&LA_UI_MIN_WIDTH){ return LA_RH; }
- int strw=tnsStringGetWidth(transLate(SSTR(ui->Display)), 0, ui->Flags&LA_TEXT_MONO);
- if(ui->Type==_LA_UI_MENU_ROOT && strw<LA_RH)strw=LA_RH;
- return (strw + bt->LM + bt->RM);
- }
- int la_StringPropGetMinWidth(laUiItem *ui){
- laBoxedTheme *bt = *ui->Type->Theme;
- if(ui->Flags&LA_UI_MIN_WIDTH){ return LA_RH; }
- char _buf[LA_RAW_CSTR_MAX_LEN]={0}; int ExtraW=0; char* buf=_buf;
- if(ui->Type == _LA_UI_STRING_MULTI){ExtraW=2*LA_RH+bt->LM;}
- laGetString(&ui->PP, _buf, &buf); int rows=0;
- int strw=tnsStringGetDimension(buf, 0, 0, 0, &rows, ui->Flags&LA_TEXT_MONO);
- int Plain = ui->Flags&LA_UI_FLAGS_PLAIN;
- if((!Plain)&&strw<LA_RH*4){strw=LA_RH*4;}
- return (strw + bt->LM + bt->RM+ExtraW);
- }
- int la_EnumGetMinWidth(laUiItem *ui){
- laBoxedTheme *bt = *ui->Type->Theme;
- laEnumProp *ep = ui->PP.LastPs->p;
- laEnumItem *i;
- int W = 0; int tW;
- int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
- int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
- int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
- int IsIcon = ui->Flags&LA_UI_FLAGS_ICON;
- int Highlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- int SharedWidth;
- if(!IsIcon){
- SharedWidth = bt->LM + bt->RM + ((IsCycle||IsExpand||NoDecal)?0:LA_RH); int HasIcon=0;
- if(Highlight){ int ico=0;
- if (ui->ExtraInstructions){
- if (ui->Type->OperatorType->ParseArgs){
- char buf[256]; buf[0]=0;
- ui->Type->OperatorType->ParseArgs(ui->Instructions, &ico, buf);
- tW = tnsStringGetWidth(transLate(buf), 0, ui->Flags&LA_TEXT_MONO) + SharedWidth;
- }
- }else{
- for (i = ep->Items.pFirst; i; i = i->Item.pNext){ if (i->IconID){ HasIcon=1; } }
- tW = tnsStringGetWidth(transLate(ep->Base.Name), 0, ui->Flags&LA_TEXT_MONO) + SharedWidth;
- }
- if (tW > W) W = tW;
- if(HasIcon||ico) W+=bt->LM+LA_RH;
- }else{
- for (i = ep->Items.pFirst; i; i = i->Item.pNext){
- tW = tnsStringGetWidth(transLate(i->Name), 0, ui->Flags&LA_TEXT_MONO) + SharedWidth;
- if (i->IconID){ HasIcon=1; }
- if (tW > W) W = tW;
- }
- if(HasIcon) W+=bt->LM+LA_RH;
- }
- }else{
- W = LA_RH;
- }
- int ArrLen = laGetArrayLength(&ui->PP);
- if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
- int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
- if(ArrLen==1){
- if(!IsVertical) return W*EnumLen;
- return W;
- }else{
- if(IsVertical) return ArrLen*W;
- return EnumLen*W;
- }
- return W;
- }
- int la_ButtonGetMinWidth(laUiItem *ui){
- laBoxedTheme *bt = *ui->Type->Theme;
- uint32_t IconID;
- char buf[LA_RAW_CSTR_MAX_LEN]={0};
- char *label;
- laOperatorProp *ap;
- int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
- if(IconOnly) return LA_RH;
- if (ui->PP.LastPs && ui->PP.LastPs->p){
- ap = ui->PP.LastPs->p;
- label = transLate(ap->Base.Name);
- if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
- IconID = ap->Base.IconID ? ap->Base.IconID : ap->OperatorType->IconID;
- }else{
- label = transLate(ui->AT->Name);
- IconID = ui->AT->IconID;
- }
- if (ui->ExtraInstructions){
- if (ui->AT && ui->AT->ParseArgs){
- ui->AT->ParseArgs(ui->Instructions, &IconID, buf);
- if (buf[0]) label = transLate(buf);
- }else if (ui->PP.LastPs->p->PropertyType == LA_PROP_OPERATOR){
- laOperatorProp *ap = ui->PP.LastPs->p;
- if (ap->OperatorType && ap->OperatorType->ParseArgs){
- ap->OperatorType->ParseArgs(ui->Instructions, &IconID, buf);
- if (buf[0]) label = transLate(buf);
- }
- }
- }
- int strw=tnsStringGetWidth(label, 0, ui->Flags&LA_TEXT_MONO);
- if(strw){ strw+=bt->RM+bt->LM; }
- return ((IconID ? (LA_RH) : 0) + strw);
- }
- int la_CollectionSimpleGetMinWidth(laUiItem *ui){
- laBoxedTheme *bt = *ui->Type->Theme;
- int Simple=ui->Flags&LA_UI_COLLECTION_SIMPLE_SELECTOR;
- int Expand=ui->Expand||(ui->Flags&LA_UI_FLAGS_EXPAND);
- int w=LA_RH+((Simple&&Expand)?(tnsStringGetWidth("Select",0,0)+bt->RM+bt->LM):0);
- return w;
- }
- int la_ColumnViewerGetMinWidth(laUiItem *ui){
- return 350;
- }
- int la_ColorPickerGetMinWidth(laUiItem *ui){
- return LA_RH * 9;
- }
- int la_SocketGetMinWidth(laUiItem *ui){
- if(ui->Flags&(LA_UI_SOCKET_LABEL_W|LA_UI_SOCKET_LABEL_E))return LA_RH*3;
- if(ui->Flags&(LA_UI_SOCKET_LABEL_S|LA_UI_SOCKET_LABEL_N))return LA_RH*2;
- return LA_RH;
- }
- int la_ImageGetMinWidth(laUiItem *ui){
- tnsImage* im=ui->Extra;
- if(!im->Texture) return LA_RH;
- int W=im->Texture->Width, H=im->Texture->Height;
- int UseW=LA_RH;
- if(ui->Flags&LA_UI_IMAGE_FULL_W) UseW=W;
- else UseW=(int)((real)LA_RH*ui->SymbolID/H*W);
- real CW=MAIN.CurrentWindow->CW-LA_RH*4, CH=MAIN.CurrentWindow->CH-LA_RH*4;
- real ra=1;
- if(UseW>CW){ real r=UseW/CW; ra=TNS_MAX2(r,ra); }
- if(H>CH){ real r=H/CH; ra=TNS_MAX2(r,ra); }
- UseW/=ra; H/=ra;
- return UseW;
- }
- void la_SingleLineStringDrawSelection(laUiItem *ui, int Begin, int U, laBoxedTheme *bt, uint32_t *str, laStringEdit *se);
- void la_CollectionSelectorDraw(laUiItem *ui, int h){
- char temp[128] = {0};
- laBoxedTheme *bt = (*ui->Type->Theme);
- real Color[16] = {0};
- tnsVector4d Transp = {0};
- int CrossDraw = 0;
- int Simple=ui->Flags&LA_UI_COLLECTION_SIMPLE_SELECTOR;
- if(Simple){ CrossDraw=0; }
- if (!ui->State) ui->State = LA_UI_NORMAL;
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,ui->State));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- if(!Simple){
- CrossDraw = laGetActiveInstanceStrict(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance) ? 1 : 0;
- }
- if (CrossDraw){
- tnsVectorCopy4d(laThemeColor(bt,LA_BT_BORDER), Transp);
- Transp[3] = 0;
- tnsMakeLinerGradient4dv(Color, 2, Transp, laThemeColor(bt,LA_BT_BORDER));
- tnsMakeLinerGradient4dv(&Color[8], 2, Transp, laThemeColor(bt,LA_BT_BORDER));
- //tnsMakeLinerGradient4dv(&Color[8], 2, laThemeColor(bt, LA_BT_BORDER), Transp);
- tnsVertex2d(ui->R - LA_RH, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R - LA_RH, ui->B); tnsVertex2d(ui->R, ui->B);
- tnsColorArray4d(Color, 4);
- tnsPackAs(GL_TRIANGLE_STRIP);
- }
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(ui->L, ui->U);
- tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B);
- tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_LINE_LOOP);
- if (CrossDraw){
- tnsDrawStringAuto("🧹", laThemeColor(bt,ui->State|LA_BT_TEXT), ui->R - LA_RH, ui->R, ui->U, 0);
- }
- if(Simple){
- int R=ui->R; if(ui->Expand || (ui->Flags&LA_UI_FLAGS_EXPAND)){
- R=ui->L+LA_RH; tnsDrawStringAuto(transLate("Select"), laThemeColor(bt,ui->State|LA_BT_TEXT), R+bt->LM, ui->R, ui->U, 0);
- }
- tnsDrawStringAuto("⯆", laThemeColor(bt,ui->State|LA_BT_TEXT), ui->L, R, ui->U, LA_TEXT_ALIGN_CENTER);
- }
- }
- void la_EmptyDraw(laUiItem *ui, int h){
- char temp[128] = {0};
- laBoxedTheme *bt = (*ui->Type->Theme);
- if (!ui->State) ui->State = LA_UI_NORMAL;
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- if(!NoDecal){
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
- tnsVertex2d(ui->L, ui->U);
- tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B);
- tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(ui->L, ui->U);
- tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B);
- tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_LINE_LOOP);
- }
- }
- void la_GroupDraw(laUiItem *ui, int h){
- char temp[128] = {0};
- laBoxedTheme *bt = (*ui->Type->Theme);
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- if(!NoDecal){
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
- tnsVertex2d(ui->L, ui->U);
- tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B);
- tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(ui->L, ui->U);
- tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B);
- tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_LINE_LOOP);
- }
- if (ui->State != LA_UI_ACTIVE){
- tnsDrawStringAuto(ui->Page ? transLate(ui->Page->TabName->Ptr) : transLate("No Page"),
- laThemeColor(bt,ui->State|LA_BT_TEXT), ui->L+bt->LM, ui->R+bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
- }
- }
- void la_TabDraw(laUiItem *ui, int h){
- char temp[128] = {0};
- laBoxedTheme *bt = (*ui->Type->Theme);
- laUiList *uil; int count = 0, page = 0;real w, l = ui->L;
- for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){ count++; }
- w = (real)(ui->R - ui->L) / (count == 0 ? 1 : count);
- real* bkg=laThemeColor(bt,LA_BT_NORMAL);
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- if(!NoDecal){
- tnsUseNoTexture();
- tnsColor4d(LA_COLOR3(bkg),bkg[3]*0.7);
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- real* bc=laThemeColor(bt,LA_BT_BORDER); real bcolor[24];
- tnsVectorCopy4d(bc,bcolor); tnsVectorSet4(&bcolor[4],bc[0],bc[1],bc[2],bc[3]*0.6);
- tnsVectorCopy4d(&bcolor[4],&bcolor[8]);
- tnsVectorCopy4d(&bcolor[4],&bcolor[12]);
- tnsVectorCopy4d(&bcolor[4],&bcolor[16]);
- tnsVectorCopy4d(bcolor,&bcolor[20]);
- tnsVertex2d(ui->L, ui->U + h); tnsVertex2d(ui->L, TNS_MIN2(ui->U+h*3,ui->B)); tnsVertex2d(ui->L, ui->B);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->R, TNS_MIN2(ui->U+h*3,ui->B)); tnsVertex2d(ui->R, ui->U + h);
- tnsColorArray4d(bcolor,6);
- tnsPackAs(GL_LINE_STRIP);
- }
- for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
- l = page*w; int IsThisPage=(uil==ui->Page);
- tnsUseNoTexture();
- if(!IsThisPage){
- tnsColor4dv(laThemeColor(bt,LA_BT_ACTIVE));
- tnsVertex2d(ui->L + l, ui->U); tnsVertex2d(ui->L + l + w, ui->U);
- tnsVertex2d(ui->L + l + w, ui->U + h); tnsVertex2d(ui->L + l, ui->U + h);
- tnsPackAs(GL_TRIANGLE_FAN);
- }
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(ui->L + l, ui->U + h); tnsVertex2d(ui->L + l, ui->U);
- tnsVertex2d(ui->L + l + w, ui->U); tnsVertex2d(ui->L + l + w, ui->U + h);
- tnsPackAs(IsThisPage?GL_LINE_STRIP:GL_LINE_LOOP);
- tnsDrawStringAuto(transLate(uil->TabName->Ptr), laThemeColor(bt,IsThisPage?LA_BT_BORDER:LA_BT_TEXT), ui->L+l+bt->LM, ui->L+l+w-bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
- page++;
- }
- tnsFlush();
- }
- void la_SymbolDraw(laUiItem *ui, int h){
- return;
- //char temp[128] = {0};
- //laBoxedTheme *bt = (*ui->Type->Theme);
- //tnsFontSingleCharacter *fsc = tfntFetchVectorGraphTextureIDW(ui->SymbolID);
- //int VOffset = (ui->B - ui->U - (fsc->height)) / 2;
- //int HOffset = (ui->R - ui->L - (fsc->width)) / 2;
- //
- //if (strArgumentMatch(ui->Instructions, "mode", "invert"))
- //{
- // tnsUseNoTexture();
- // //tnsColor4dv(laThemeColor(bt, ui->State));
- // //tnsVertex2d(ui->L, ui->U);
- // //tnsVertex2d(ui->R, ui->U);
- // //tnsVertex2d(ui->R, ui->B);
- // //tnsVertex2d(ui->L, ui->B);
- // //tnsPackAs(GL_TRIANGLE_FAN);
- //
- // tnsUseNoTexture();
- // tnsColor4dv(LA_THEME_GET(bt, LA_UI_NORMAL)->BorderColor->RGBA);
- // tnsVertex2d(ui->L, ui->U);
- // tnsVertex2d(ui->R, ui->U);
- // tnsVertex2d(ui->R, ui->B);
- // tnsVertex2d(ui->L, ui->B);
- // tnsPackAs(GL_TRIANGLE_FAN);
- //
- // // tnsDrawVectorGraphPackage(ui->SymbolID, LA_THEME_GET(bt, LA_THEME_INTERPOLATING), ui->L + HOffset, ui->R, ui->U + VOffset, ui->B, 0, 0);
- //}
- //else
- //{
- // //if (!ui->State) ui->State = LA_UI_NORMAL;
- //
- // /*tnsUseNoTexture();
- // tnsColor4dv(laThemeColor(bt, ui->State));
- // tnsVertex2d(ui->L, ui->U);
- // tnsVertex2d(ui->R, ui->U);
- // tnsVertex2d(ui->R, ui->B);
- // tnsVertex2d(ui->L, ui->B);
- // tnsPackAs(GL_TRIANGLE_FAN);*/
- //
- // //tnsUseNoTexture();
- //tnsColor4dv(LA_THEME_GET(bt, LA_UI_NORMAL)->BorderColor->RGBA);
- //tnsVertex2d(ui->L, ui->U);
- //tnsVertex2d(ui->R, ui->U);
- //tnsVertex2d(ui->R, ui->B);
- //tnsVertex2d(ui->L, ui->B);
- //tnsPackAs(GL_LINE_LOOP);
- //
- // // tnsDrawVectorGraphPackage(ui->SymbolID, LA_THEME_GET(bt, LA_UI_NORMAL), ui->L + HOffset, ui->R, ui->U + VOffset, ui->B, 0, 0);
- //}
- }
- void la_IntDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- int Data[32];
- int Len, i, Seg, W;
- char buf[48] = {0};
- char buf2[48] = {0};
- char prefix[8][64] = {0};
- int Original;
- int Ranged;
- int min, max;
- int s, State;
- int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
- int IsIcon=ui->Flags&LA_UI_FLAGS_ICON;
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- int NoLabel=ui->Flags&LA_UI_FLAGS_NO_LABEL;
- int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
- int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
- int SliderVertical = ui->Flags&LA_UI_FLAGS_VALUE_METER;
- if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
- laGetIntArray(&ui->PP, Data);
- Len = laGetArrayLength(&ui->PP);
- laGetPrefixP(&ui->PP, prefix);
- Ranged = laGetIntRange(&ui->PP, &min, &max);
- for (i = 0; i < Len; i++){
- int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
- if(IsVertical){
- Seg = ui->R - ui->L;
- _U = ui->U + i * LA_RH; _B = _U+LA_RH;
- }else{
- Seg = (ui->R - ui->L) / Len;
- _L = ui->L + i * Seg; _R=_L+Seg;
- }
- if(IsIcon){
- sprintf(buf, "%lc", laGetInt(&ui->PP));
- }else{
- buf[0] = '\0'; buf2[0] = '\0';
- if(Len==1){ strcat(buf2, transLate(ui->PP.LastPs->p->Name)); }
- if(i<8)strcat(Len==1?buf:buf2,&prefix[i]);
- strPrintIntAfter(buf, 48, Data[i]);
- strAppend(buf, ui->PP.LastPs->p->Unit ? transLate(ui->PP.LastPs->p->Unit) : "");
- }
- if (ui->Extra && ui->Extra->On == i + 1){
- Original = ui->State;
- ui->State = LA_UI_ACTIVE;
- }
- if(IsKnob && !ui->Extra->Edit){
- real ctrx = (real)(_L+_R)/2.0f, ctry=(real)(_U+_B)/2.0f, radius=TNS_MIN2((_B-_U)/2.0f,(_R-_L)/2.0f);
- tnsUseNoTexture();
- real dgx=0,dgy=0;
- if(radius*2>(_B-_U)-LA_RH/5){ dgx = radius/1.5; }
- if(radius*2>(_R-_L)-LA_RH/5){ dgy = radius/1.5; }
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(_L, ctry-dgy); tnsVertex2d(_L, _U); tnsVertex2d(ctrx-dgx, _U); tnsPackAs(GL_LINE_STRIP);
- tnsVertex2d(_R, ctry-dgy); tnsVertex2d(_R, _U); tnsVertex2d(ctrx+dgx, _U); tnsPackAs(GL_LINE_STRIP);
- tnsVertex2d(_R, ctry+dgy); tnsVertex2d(_R, _B); tnsVertex2d(ctrx+dgx, _B); tnsPackAs(GL_LINE_STRIP);
- tnsVertex2d(_L, ctry+dgy); tnsVertex2d(_L, _B); tnsVertex2d(ctrx-dgx, _B); tnsPackAs(GL_LINE_STRIP);
-
- real verts[52];//24*2+ctr+overlap
- tnsMakeCircle2d(&verts[2],24,ctrx,ctry,radius,0);
- tnsVectorCopy2d(&verts[2],&verts[50]);
- verts[0]=ctrx; verts[1]=ctry;
- tnsColor4dv(laThemeColor(bt,ui->State));
- tnsVertexArray2d(verts,26); tnsPackAs(GL_TRIANGLE_FAN);
- tnsMakeCircle2d(verts,24,ctrx,ctry,radius,0);
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertexArray2d(verts,24); tnsPackAs(GL_LINE_LOOP);
- if(Ranged){
- real arc[52]; int arcindex[26]; // 12 slices 13 ends
- real range = (real)(Data[i] - min) / (real)(max - min) * TNS_PI * 1.5;
- tnsMakeArc2d(arc,12,ctrx,ctry,radius,TNS_PI*2.75, TNS_PI*2.75 + range);
- tnsMakeArc2d(&arc[26],12,ctrx,ctry,radius*0.6,TNS_PI*2.75, TNS_PI*2.75 + range);
- tnsMakeBridgedIndex(arcindex, 13, 0, 0);
- real *color = laThemeColor(bt,LA_BT_TEXT|ui->State); //tnsColor4d(LA_COLOR3(color),0.3);
- tnsColor4dv(color);
- tnsVertexArray2d(arc,26); tnsIndexArray(arcindex,26); tnsPackAs(GL_TRIANGLE_STRIP);
- tnsMakeArc2d(&arc[2],12,ctrx,ctry,radius*0.6,TNS_PI*2.75, TNS_PI*4.25);
- tnsVertexArray2d(&arc[2],13);
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsPackAs(GL_LINE_STRIP);
- }
- }else{
- if(!NoDecal){
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,ui->State));
- tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
- tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_TRIANGLE_FAN);
- if (Ranged){
- int L1 = _L;
- int R1 = SliderVertical?_R:((real)(Data[i] - min) / (real)(max - min) * (real)(Seg) + L1);
- int U1 = SliderVertical?(_B - (real)(Data[i] - min) / (real)(max - min) * (real)(_B-_U)):_U;
- tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
- tnsColor4d(LA_COLOR3(color),0.3);
- tnsVertex2d(L1, U1); tnsVertex2d(R1, U1);
- tnsVertex2d(R1, _B); tnsVertex2d(L1, _B);
- tnsPackAs(GL_TRIANGLE_FAN);
- }
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
- tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_LINE_LOOP);
- }
- if (ui->Extra->On == i + 1 && ui->Extra->Edit){
- uint32_t *buf = strGetCursorLine(ui->Extra->Edit, 0)->Buf;
- int LL = _L + (Seg - tnsStringGetWidthU(buf, 0, ui->Flags&LA_TEXT_MONO)) / 2;
- tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
- la_SingleLineStringDrawSelection(ui, _L, _U, bt, buf, ui->Extra->Edit);
- tnsDrawStringM(0, buf, laThemeColor(bt, LA_BT_TEXT_ACTIVE), _L + bt->LM, _R - bt->RM, _U, ui->Flags);
- }else{
- tnsDrawStringWithPriority(NoLabel?0:buf2, buf,
- IsDisabled?laThemeColor(bt, LA_BT_DISABLED):laThemeColor(bt, LA_BT_TEXT|ui->State), bt->TextAlign, _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
- }
- }
- if (ui->Extra && ui->Extra->On == i + 1) ui->State = Original;
- }
- tnsFlush();
- }
- void la_FloatDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- real Data[32];
- int Len, i, W, Seg;
- char buf[48] = {0};
- char buf2[48] = {0};
- char prefix[8][64] = {0};
- int Original;
- int Ranged;
- real min, max;
- int s, State;
- int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- int IsRad=ui->PP.LastPs->p->IsRadAngle;
- int NoLabel=ui->Flags&LA_UI_FLAGS_NO_LABEL;
- int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
- int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
- int SliderVertical = ui->Flags&LA_UI_FLAGS_VALUE_METER;
- if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
- laGetFloatArray(&ui->PP, Data);
- Len = laGetArrayLength(&ui->PP);
- laGetPrefixP(&ui->PP, prefix);
- Ranged = laGetFloatRange(&ui->PP, &min, &max);
- for (i = 0; i < Len; i++){
- int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
- if(IsVertical){
- Seg = ui->R - ui->L;
- _U = ui->U + i * LA_RH; _B = _U+LA_RH;
- }else{
- Seg = (ui->R - ui->L) / Len;
- _L = ui->L + i * Seg; _R=_L+Seg;
- }
- buf[0] = '\0'; buf2[0] = '\0';
- if(Len==1){ strcat(buf2, transLate(ui->PP.LastPs->p->Name)); }
- if(i<8)strcat(Len==1?buf:buf2, &prefix[i]);
- strPrintFloatAfter(buf, 48, 3, IsRad?deg(Data[i]):Data[i]);
- strAppend(buf, ui->PP.LastPs->p->Unit ? transLate(ui->PP.LastPs->p->Unit) : "");
- if (ui->Extra && ui->Extra->On == i + 1){
- Original = ui->State;
- ui->State = LA_UI_ACTIVE;
- }
- if(IsKnob && !ui->Extra->Edit){
- real ctrx = (real)(_L+_R)/2.0f, ctry=(real)(_U+_B)/2.0f, radius=TNS_MIN2((_B-_U)/2.0f,(_R-_L)/2.0f);
- tnsUseNoTexture();
- real dgx=0,dgy=0;
- if(radius*2>(_B-_U)-LA_RH/5){ dgx = radius/1.5; }
- if(radius*2>(_R-_L)-LA_RH/5){ dgy = radius/1.5; }
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(_L, ctry-dgy); tnsVertex2d(_L, _U); tnsVertex2d(ctrx-dgx, _U); tnsPackAs(GL_LINE_STRIP);
- tnsVertex2d(_R, ctry-dgy); tnsVertex2d(_R, _U); tnsVertex2d(ctrx+dgx, _U); tnsPackAs(GL_LINE_STRIP);
- tnsVertex2d(_R, ctry+dgy); tnsVertex2d(_R, _B); tnsVertex2d(ctrx+dgx, _B); tnsPackAs(GL_LINE_STRIP);
- tnsVertex2d(_L, ctry+dgy); tnsVertex2d(_L, _B); tnsVertex2d(ctrx-dgx, _B); tnsPackAs(GL_LINE_STRIP);
-
- real verts[52];//24*2+ctr+overlap
- tnsMakeCircle2d(&verts[2],24,ctrx,ctry,radius,0);
- tnsVectorCopy2d(&verts[2],&verts[50]);
- verts[0]=ctrx; verts[1]=ctry;
- tnsColor4dv(laThemeColor(bt,ui->State));
- tnsVertexArray2d(verts,26); tnsPackAs(GL_TRIANGLE_FAN);
- tnsMakeCircle2d(verts,24,ctrx,ctry,radius,0);
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertexArray2d(verts,24); tnsPackAs(GL_LINE_LOOP);
- if(Ranged){
- real arc[52]; int arcindex[26]; // 12 slices 13 ends
- real range,rstart;
- if(min<0&&max>0){ rstart=TNS_PI*3.5; range = (real)(Data[i]) / (real)(max) * TNS_PI * 1.5 * max/(max-min);}
- else{ rstart=TNS_PI*2.75; range = (real)(Data[i] - min) / (real)(max - min) * TNS_PI * 1.5; }
- tnsMakeArc2d(arc,12,ctrx,ctry,radius,rstart, rstart + range);
- tnsMakeArc2d(&arc[26],12,ctrx,ctry,radius*0.6,rstart, rstart + range);
- tnsMakeBridgedIndex(arcindex, 13, 0, 0);
- real *color = laThemeColor(bt,LA_BT_TEXT|ui->State); //tnsColor4d(LA_COLOR3(color),0.3);
- tnsColor4dv(color);
- tnsVertexArray2d(arc,26); tnsIndexArray(arcindex,26); tnsPackAs(GL_TRIANGLE_STRIP);
- tnsMakeArc2d(&arc[2],12,ctrx,ctry,radius*0.6,TNS_PI*2.75, TNS_PI*4.25);
- arc[0] = ctrx + cos(TNS_PI*2.75) * radius; arc[1] = ctry + sin(TNS_PI*2.75) * radius;
- arc[28] =ctrx + cos(TNS_PI*4.25) * radius; arc[29] =ctry + sin(TNS_PI*4.25) * radius;
- tnsVertexArray2d(arc,15);
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsPackAs(GL_LINE_STRIP);
- }
- }else{
- if(!NoDecal){
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,ui->State));
- tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
- tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_TRIANGLE_FAN);
- if (Ranged){
- int L1 = _L;
- int R1 = SliderVertical?_R:((real)(Data[i] - min) / (real)(max - min) * (real)(Seg) + L1);
- int U1 = SliderVertical?(_B - (real)(Data[i] - min) / (real)(max - min) * (real)(_B-_U)):_U;
- tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
- tnsColor4d(LA_COLOR3(color),0.3);
- tnsVertex2d(L1, U1); tnsVertex2d(R1, U1);
- tnsVertex2d(R1, _B); tnsVertex2d(L1, _B);
- tnsPackAs(GL_TRIANGLE_FAN);
- }
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
- tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_LINE_LOOP);
- }
- if (ui->Extra->On == i + 1 && ui->Extra->Edit){
- uint32_t *buf = strGetCursorLine(ui->Extra->Edit,0)->Buf;
- int LL = _L + (Seg - tnsStringGetWidthU(buf, 0, ui->Flags&LA_TEXT_MONO)) / 2;
- tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
- la_SingleLineStringDrawSelection(ui, _L, _U, bt, buf, ui->Extra->Edit);
- tnsDrawStringM(0, buf, laThemeColor(bt, LA_BT_TEXT_ACTIVE), _L + bt->LM, _R - bt->RM, _U, ui->Flags);
- }else{
- tnsDrawStringWithPriority(NoLabel?0:buf2, buf,
- IsDisabled?laThemeColor(bt, LA_BT_DISABLED):laThemeColor(bt, LA_BT_TEXT|ui->State), bt->TextAlign, _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
- }
- }
- if (ui->Extra && ui->Extra->On == i + 1) ui->State = Original;
- }
- tnsFlush();
- }
- void la_FloatArrayColorDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- real Data[32];
- int Len, i;
- int IsColorful=ui->Flags&LA_UI_FLAGS_COLORFUL;
- laGetFloatArray(&ui->PP, Data);
- Len = laGetArrayLength(&ui->PP);
- if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LogsRGB(Data); }
- tnsUseNoTexture();
- if(IsColorful){
- int sw=(ui->R-ui->L)/2;
- tnsColor4d(Data[0], Data[1], Data[2], 1);
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->L+sw, ui->U);
- tnsVertex2d(ui->L+sw, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4d(Data[0], Data[1], Data[2], Len>3?Data[3]:1);
- tnsVertex2d(ui->L+sw, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L+sw, ui->B);
- tnsUseHalftone(1.0); tnsPackAs(GL_TRIANGLE_FAN); tnsUseHalftone(0.0);
- }else{
- tnsColor4d(Data[0], Data[1], Data[2], 1);
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- }
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- if(!NoDecal){
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_LINE_LOOP);
- }
- tnsFlush();
- }
- void la_EnumSelectorDraw(laUiItem *ui, int h){
- laEnumItem *Data[32], Len;
- laBoxedTheme *bt = (*ui->Type->Theme);
- char buf[48] = {0};
- char buf2[48] = {0};
- char prefix[8][64]= {0};
- laEnumProp *ep = ui->PP.LastPs->p;
- int HasIcon = laEnumHasIcon(&ui->PP);
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
- int NoEvent=ui->Flags&LA_UI_FLAGS_NO_EVENT;
- int Highlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
- int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
- // norm e1
- // expand e1 e2 e3
- // expand vertical (vertical)
- // arr expand e1 e1 e3
- // e2 e2 e3
- // arr exp+vert e1 e1
- // e2 e2
- // e3 e3
- tnsUseNoTexture();
- laGetEnumArray(&ui->PP,Data);
- laEnumItem* ei, *use_ei;
- int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
- int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
- int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
- int ArrLen = laGetArrayLength(&ui->PP);
- if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
- int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
- if(Highlight&&ArrLen!=1){laGetPrefixP(&ui->PP, prefix);}
- if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
- int _L,_R,_U,_B, _W=ui->R - ui->L;
- if(IsVertical){
- if(IsExpand){ _W/=ArrLen; }
- }else{
- if(IsExpand){ _W/=EnumLen; }
- else{ _W/=ArrLen; }
- }
-
- int UseIco=0,ico=0; char buft[48]={0}; int HasText=0;
- if (ui->ExtraInstructions){
- if (ui->Type->OperatorType->ParseArgs){
- ui->Type->OperatorType->ParseArgs(ui->Instructions, &UseIco, buft);
- }
- sprintf(buf,"%s",transLate(buft)); HasText=1;
- }
- for(int i=0;i<ArrLen;i++){
- if(!Data[i]){ Data[i]=((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst; }
- _L=ui->L; _R=ui->R; _U=ui->U; _B=ui->B; ei = ep->Items.pFirst;
- for(int j=0;j<EnumLen;j++){ if(!HasText)buf[0]=0;
- ico=UseIco;
- if(IsVertical){
- if(IsExpand){ _U=ui->U+j*LA_RH; _L=ui->L+i*_W; }
- else{ _U=ui->U+i*LA_RH; _L=ui->L; }
- }else{
- if(IsExpand){ _U=ui->U+i*LA_RH; _L=ui->L+j*_W; }
- else{ _U=ui->U; _L=ui->L+i*_W; }
- }
- _B=_U+LA_RH; _R=_L+_W;
- int ExtraState=IsDisabled?LA_BT_DISABLED:ui->State;
- if(IsExpand&&!IsCycle){ use_ei = ei; ei=ei->Item.pNext; ExtraState=(use_ei==Data[i])?LA_BT_ACTIVE:ExtraState; }
- else{ use_ei = Data[i]; if(Highlight && Data[i]->Index!=0){ ExtraState=LA_BT_ACTIVE; } }
- if(!NoDecal){
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt, ExtraState));
- tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
- tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
- tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
- tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_LINE_LOOP);
- }
- if(Highlight){ if(!HasText && ArrLen==1) strcpy(buf, transLate(ui->PP.LastPs->p->Name)); else{ if(i<8)strcat(buf, &prefix[i]); } }
- if((!HasText) && (!buf[0])) strcpy(buf, transLate(use_ei->Name));
- int iconR; if(IconOnly)iconR=TNS_MAX2(_L+LA_RH,_R);else{ iconR=TNS_MIN2(_L+LA_RH,_R); }
- if (use_ei->IconID && !ico){ ico=use_ei->IconID; }
- if (ico) tnsDrawIcon(ico, laThemeColor(bt, LA_BT_TEXT|ExtraState), _L,iconR, _U, LA_TEXT_ALIGN_CENTER|ui->Flags);
- if(!IconOnly){
- int UseFlags=ui->Flags; if(!HasIcon && IsExpand){ if(!(UseFlags&LA_TEXT_ALIGN)); UseFlags|=LA_TEXT_ALIGN_CENTER; }
- tnsDrawStringAuto(buf, laThemeColor(bt, LA_BT_TEXT|ExtraState), _L+bt->LM+(HasIcon?LA_RH:0), _R-bt->RM, _U, UseFlags);
- }
- if (!IsExpand && !IsVertical && !IconOnly && !IsCycle && !NoEvent){
- tnsDrawIcon(U'🔻', laThemeColor(bt, LA_BT_TEXT|ExtraState), _R-LA_RH, _R, _U, ui->Flags);
- }
- }
- }
- tnsFlush();
- }
- void la_ButtonDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- char buf[LA_RAW_CSTR_MAX_LEN] = {0};
- char *label = 0;
- uint32_t IconID=0;
- int L;
- char *Identifier;
- laOperatorProp *ap = 0;
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
- int IsHighlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
- int IsWarning=ui->Flags&LA_UI_FLAGS_WARNING;
- if (ui->PP.LastPs && ui->PP.LastPs->p){
- ap = ui->PP.LastPs->p;
- label = transLate(ap->Base.Name);
- if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
- IconID = ap->Base.IconID ? ap->Base.IconID : ap->OperatorType->IconID;
- }else{
- label = transLate(ui->AT->Name);
- IconID = ui->AT->IconID;
- }
- if (ui->AT && (!laOperatorAvailableP(ui->AT, 0, ui->Instructions)))
- ui->State = LA_UI_DISABLED;
- elif (ap && ap->OperatorType && (!laOperatorAvailablePSafe(ap->OperatorType, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->Instructions))) ui->State = LA_UI_DISABLED;
- else if (ui->State == LA_UI_DISABLED) ui->State = LA_UI_NORMAL;
- if(!NoDecal){
- tnsUseNoTexture();
- tnsColor4dv(ui->State==LA_UI_NORMAL?(
- IsHighlight?laAccentColor(LA_BT_NORMAL):(IsWarning?laAccentColor(LA_BT_WARNING):laThemeColor(bt, ui->State)))
- :laThemeColor(bt, ui->State));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_LINE_LOOP);
- }
- if (ui->ExtraInstructions){
- uint32_t tIconID=0;
- if (ui->AT && ui->AT->ParseArgs){
- ui->AT->ParseArgs(ui->Instructions, &tIconID, buf);
- if (buf[0]) label = transLate(buf);
- if (tIconID) IconID=tIconID;
- }else if (ui->PP.LastPs->p->PropertyType == LA_PROP_OPERATOR){
- laOperatorProp *ap = ui->PP.LastPs->p;
- if (ap->OperatorType && ap->OperatorType->ParseArgs){
- ap->OperatorType->ParseArgs(ui->Instructions, &tIconID, buf);
- if (buf[0]) label = transLate(buf);
- if (tIconID) IconID=tIconID;
- }
- }
- }
- if (IconID) L = ui->L + bt->LM + h;
- else L = ui->L + bt->LM;
- 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);
- if (!IconOnly) tnsDrawStringAuto(label, laThemeColor(bt, ui->State|LA_BT_TEXT), L, ui->R-bt->RM, ui->U, ui->Flags);
- }
- void la_LabelDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
- int IsHighlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
- int IsWarning=ui->Flags&LA_UI_FLAGS_WARNING;
- if (!ui->State) ui->State = LA_UI_NORMAL;
- if (ui->ExtraInstructions && !ui->Instructions){
- strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
- }
- //int State = ui->Instructions ? (strArgumentMatch(ui->Instructions, "disabled", "true") ? LA_THEME_DISABLED : LA_UI_NORMAL) : LA_UI_NORMAL;
- tnsDrawStringAuto(transLate(SSTR(ui->Display)),
- IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):
- (IsHighlight?laAccentColor(LA_BT_TEXT):
- (IsWarning?laAccentColor(LA_BT_WARNING):laThemeColor(bt,LA_BT_TEXT))),
- ui->L, ui->R, ui->U, ui->Flags);
- }
- void la_SingleLineStringDrawSelection(laUiItem *ui, int Begin, int U, laBoxedTheme *bt, uint32_t *str, laStringEdit *se){
- tnsUseNoTexture();
- if (!strHasSelection(se)){
- tnsColor4dv(laAccentColor(LA_BT_TEXT));
- int L = (se->CursorBefore ? tnsStringGetWidthU(str, se->CursorBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
- tnsVertex2d(L-1, U + LA_RH - bt->BM);
- tnsVertex2d(L-1, U + bt->TM);
- tnsVertex2d(L+2, U + bt->TM);
- tnsVertex2d(L+2, U + LA_RH - bt->BM);
- tnsPackAs(GL_TRIANGLE_FAN);
- }else{
- int L = (se->BeginBefore ? tnsStringGetWidthU(str, se->BeginBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
- int R = (se->EndBefore ? tnsStringGetWidthU(str, se->EndBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
- tnsColor4dv(laAccentColor(LA_BT_NORMAL));
- tnsVertex2d(L, U + bt->TM);
- tnsVertex2d(L, U + LA_RH - bt->BM);
- tnsVertex2d(R, U + LA_RH - bt->TM);
- tnsVertex2d(R, U + bt->BM);
- tnsPackAs(GL_TRIANGLE_FAN);
- }
- }
- void la_SingleLineStringDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- char* _temp[LA_RAW_CSTR_MAX_LEN] = {0}; char* temp=_temp;
- uint32_t* line=0;
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
- if (!ui->State) ui->State = LA_UI_NORMAL;
- if(!NoDecal){
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt, ui->State));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_LINE_LOOP);
- }
- if (ui->Extra && ui->Extra->Edit){
- line=strGetCursorLine(ui->Extra->Edit,0)->Buf;
- }else{
- laGetString(&ui->PP, _temp, &temp);
- }
- if (line) la_SingleLineStringDrawSelection(ui, ui->L+(NoDecal?0:bt->LM), ui->U, bt, line, ui->Extra->Edit);
- if(ui->PP.LastPs->p->CanTranslate){ temp=transLate(temp); }
- 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);
- }
- void la_MultiStringDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- char _temp[LA_RAW_CSTR_MAX_LEN] = {0}; char* temp=_temp;
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- if (!ui->State) ui->State = LA_UI_NORMAL;
- int NumberWidth=bt->LM;
- if((!ui->Extra->Edit) || (ui->Extra->Ptr1!=ui->PP.EndInstance)){
- laGetString(&ui->PP, _temp, &temp);
- strBeginEdit(&ui->Extra->Edit, temp);
- ui->Extra->Ptr1=ui->PP.EndInstance;
- }
- laStringEdit* se=ui->Extra->Edit;
- real MonoWidth=tnsGetMonoFontAdvance(); int Count=se->TotalLines;
- while(Count){ Count/=10; NumberWidth+=MonoWidth; }
- if (ui->State!=LA_UI_ACTIVE){
- strSetEditViewRange(ui->Extra->Edit,
- ui->Extra->HeightCoeff>0?ui->Extra->HeightCoeff:((ui->B-ui->U)/LA_RH),(ui->R-ui->L-NumberWidth-bt->LM*2-bt->RM)/MonoWidth);
- }
- if(!NoDecal){
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt, ui->State));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_LINE_LOOP);
- tnsColor4d(LA_COLOR3(laThemeColor(bt,LA_BT_BORDER)),0.8);
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->L+NumberWidth, ui->U);
- tnsVertex2d(ui->L, ui->B); tnsVertex2d(ui->L+NumberWidth, ui->B);
- tnsPackAs(GL_TRIANGLE_STRIP);
- if(!(se->CursorLine<se->ViewStartLine||se->CursorLine>se->ViewStartLine+se->ViewHeight)){
- int LineU=(se->CursorLine-se->ViewStartLine)*LA_RH+ui->U;
- tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_NORMAL):laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(ui->L, LineU); tnsVertex2d(ui->R, LineU);
- tnsVertex2d(ui->L, LineU+LA_RH); tnsVertex2d(ui->R, LineU+LA_RH);
- tnsPackAs(GL_LINES);
- tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT_NORMAL));
- tnsVertex2d(ui->L, LineU); tnsVertex2d(ui->L+NumberWidth, LineU);
- tnsVertex2d(ui->L, LineU+LA_RH); tnsVertex2d(ui->L+NumberWidth, LineU+LA_RH);
- tnsPackAs(GL_TRIANGLE_STRIP);
- }
- }else{
- NumberWidth=bt->LM;
- }
- tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
- int Line=0, Skip=0, _L=ui->L+NumberWidth+bt->LM; char num[10]={0};
- for(laStringLine* sl=se->Lines.pFirst;sl;sl=sl->Item.pNext){
- int UseLine=Line+Skip;
- if(UseLine<se->ViewStartLine){ Skip++; continue; }
- if(UseLine>=se->ViewHeight+se->ViewStartLine){ break; }
- int slen=strlenU(sl->Buf);
- sprintf(num,"%d", UseLine+1); int LineU=ui->U+Line*LA_RH;
- tnsDrawStringM(num, 0, laThemeColor(bt, ((UseLine==se->CursorLine)?LA_BT_NORMAL:LA_BT_TEXT)),
- _L-bt->LM -(tnsStringGetWidth(num, 0, ui->Flags&LA_TEXT_MONO)), ui->R, LineU, ui->Flags);
- if(slen>=se->ViewStartCol){
- tnsDrawStringM(0, &sl->Buf[se->ViewStartCol], laThemeColor(bt, ui->State|LA_BT_TEXT), _L, ui->R, LineU, ui->Flags|LA_TEXT_OVERFLOW_ARROW);
- }
- if(UseLine>=se->BeginLine&&UseLine<=se->EndLine){
- int BeginC=UseLine==se->BeginLine?se->BeginBefore:0; int EndC=UseLine==se->EndLine?se->EndBefore:slen;
- BeginC-=se->ViewStartCol; EndC-=se->ViewStartCol; if(EndC>se->ViewWidth)EndC=se->ViewWidth;
- tnsUseNoTexture();
- tnsVertex2d(BeginC*MonoWidth+_L, LineU); tnsVertex2d(EndC*MonoWidth+_L, LineU);
- tnsVertex2d(EndC*MonoWidth+_L, LineU+LA_RH); tnsVertex2d(BeginC*MonoWidth+_L, LineU+LA_RH);
- tnsColor4dv(laAccentColor(LA_BT_NORMAL));
- tnsPackAs(GL_TRIANGLE_FAN);
- }
- int len=strlenU(sl->Buf);
- if(UseLine==se->CursorLine){
- int Dist=se->CursorBefore==0?0:tnsStringGetWidthU(sl->Buf,se->CursorBefore,ui->Flags&LA_TEXT_MONO);
- tnsUseNoTexture(); int d=se->ViewStartCol*MonoWidth; real w2=LA_RH/12;
- tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT_NORMAL));
- tnsVertex2d(_L+Dist-w2-d, LineU); tnsVertex2d(_L+Dist+w2-d, LineU);
- tnsVertex2d(_L+Dist-w2-d, LineU+LA_RH); tnsVertex2d(_L+Dist+w2-d, LineU+LA_RH);
- tnsPackAs(GL_TRIANGLE_STRIP);
- }
- Line++;
- tnsFlush();
- }
- 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);
- if(!NoDecal){
- char buf[100]={0}; sprintf(buf, "%d,%d | %d Lines", se->CursorLine+1, se->CursorBefore+1, se->TotalLines);
- 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);
- }
-
- //if (ui->Extra && ui->Extra->Edit) la_SingleLineStringDrawSelection(ui, ui->L, ui->U, bt, temp, ui->Extra->Edit);
- tnsFlush();
- }
- void la_UiSeperatorDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- if (!bt) return;
- if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){
- char str[]="🞄";
- int strw=tnsStringGetWidth(str,0, 0);
- tnsDrawStringM(str, 0, laThemeColor(bt,LA_BT_BORDER), ui->L+(ui->R-ui->L-strw)/2, ui->R, ui->U, 0);
- }else{
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- real u=(ui->U+ui->B)/2; tnsVertex2d(ui->L, u); tnsVertex2d(ui->R, (ui->U+ui->B)/2);
- tnsPackAs(GL_LINES);
- }
- }
- void la_ColorCircleDrawHCY(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- real c = (real)((ui->R + ui->L) / 2) - h / 2; /*- bt->RM*/
- real r = (ui->B - ui->U - bt->TP - bt->BP) / 2;
- int i = 0;
- real colors[584]={0}; //4*72*2+4*2
- real verts[292]={0}; //72*2*2+2*2
- real hcy[3] = {0, 1, 1};
- real step = 1.0 / 72.0f;
- real RealColor[4] = {0,0,0,1};
- real PickerPos[2];
- real pi_4;
- GLuint index[26];
- real v, cv, sv;
- real lw = (float)(ui->B-ui->U)/LA_RH/5; if(lw<1.0f) lw=1.0f;
- laGetFloatArray(&ui->PP, RealColor);
- if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LogsRGB(RealColor); }
- tnsRGB2HCY(RealColor, hcy);
- PickerPos[0] = c + cos(hcy[0] * TNS_PI * 2) * pow(hcy[1],1.0f/MAIN.ColorPickerGamma) * r;
- PickerPos[1] = ui->U + r + sin(hcy[0] * TNS_PI * 2) * pow(hcy[1],1.0f/MAIN.ColorPickerGamma) * r;
- hcy[0] = 0;
- hcy[1] = 1;
- for (i; i < 72; i += 1){
- int beg = i * 8;
- hcy[0]+=step; tnsVectorSet3v(&colors[beg],hcy); colors[beg+3]=1;
- tnsVectorSet4v(&colors[beg+4],&colors[beg]); colors[beg+5]=0;
- }
- tnsFlush();
- tnsUniformColorMode(T->immShader,1); tnsUniformHCYGamma(T->immShader,MAIN.ColorPickerGamma);
- int IsClay=ui->Flags&LA_UI_FLAGS_COLOR_SPACE_CLAY;
- int IsP3=ui->Flags&LA_UI_FLAGS_COLOR_SPACE_D65_P3;
- int ShowInfo=0;
- if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_SRGB && (!IsClay) && (!IsP3)){
- tnsUniformShowColorOverflowStripes(T->immShader,1);
- }
- if(IsClay){
- tnsUniformInputColorSpace(T->immShader,TNS_COLOR_SPACE_CLAY);
- if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_CLAY) ShowInfo=1;
- }elif(IsP3){
- tnsUniformInputColorSpace(T->immShader,TNS_COLOR_SPACE_D65_P3);
- if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_D65_P3) ShowInfo=1;
- }else{
- tnsUniformInputColorSpace(T->immShader,TNS_COLOR_SPACE_SRGB);
- }
- tnsUseNoTexture();
- tnsVectorSet4(&colors[576],1,1,hcy[2],1);
- tnsVectorSet4(&colors[580],1,0,hcy[2],1);
- tnsColorArray4d(colors, 146);
- tnsMakeCircle2d(verts, 72, c, ui->U + r, r, 1);
- for(int i=0;i<73;i++){ tnsVectorSet2(&verts[2+i*4],c,ui->U + r); }
- tnsVectorSet2v(&verts[288],&verts[0]);
- tnsVectorSet2v(&verts[290],&verts[2]);
- tnsVertexArray2d(verts, 146);
- tnsPackAs(GL_TRIANGLE_STRIP);
- tnsFlush();
-
- tnsUniformColorMode(T->immShader,0);
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsMakeCircle2d(verts, 72, c, ui->U + r, r, 0);
- tnsVertexArray2d(verts, 72);
- tnsPackAs(GL_LINE_LOOP);
- pi_4 = TNS_PI / 4;
- tnsMakeArc2d(&verts[26], 12, c, ui->U + r, r + bt->LM + h, pi_4, -pi_4);
- tnsMakeArc2d(verts, 12, c, ui->U + r, r + bt->LM, pi_4, -pi_4);
- tnsMakeLinerGradient4d(&colors[52], 13, 0, 0, 0, 1, 1, 1, 1, 1);
- tnsMakeLinerGradient4d(colors, 13, 0, 0, 0, 1, 1, 1, 1, 1);
- tnsMakeBridgedIndex(index, 13, 0, 0);
- tnsColorArray4d(colors, 26);
- tnsVertexArray2d(verts, 26);
- tnsIndexArray(index, 26);
- tnsPackAs(GL_TRIANGLE_STRIP);
- tnsMakeArc2d(&verts[26], 12, c, ui->U + r, r + bt->LM + h, -pi_4, pi_4);
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertexArray2d(verts, 26);
- tnsPackAs(GL_LINE_LOOP);
- v = -hcy[2] + 0.5;
- cv = cos(v / 2 * TNS_PI);
- sv = sin(v / 2 * TNS_PI);
- tnsLineWidth(lw);
- verts[0] = cv * r + c; verts[1] = sv * r + ui->U + r;
- verts[2] = cv * (r + h) + c; verts[3] = sv * (r + h) + ui->U + r;
- tnsColor4d(1, 1, 1, 1);
- tnsVertexArray2d(verts, 2);
- tnsPackAs(GL_LINES);
- verts[1]+=lw; verts[3]+=lw;
- tnsColor4d(0, 0, 0, 1);
- tnsVertexArray2d(verts, 2);
- tnsPackAs(GL_LINES);
- real circleR=lw*8;
- tnsColor4dv(RealColor);
- tnsMakeCircle2d(verts, 16, PickerPos[0], PickerPos[1], circleR,0);
- tnsVertexArray2d(verts, 16);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4d(1, 1, 1, 1);
- tnsVertexArray2d(verts, 16);
- tnsPackAs(GL_LINE_LOOP);
- tnsMakeCircle2d(verts, 16, PickerPos[0], PickerPos[1], circleR-lw,0);
- tnsColor4d(0.1, 0.1, 0.1, 1);
- tnsVertexArray2d(verts, 16);
- tnsPackAs(GL_LINE_LOOP);
- tnsLineWidth(1);
- 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);
- 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);
- if(IsP3) tnsDrawStringAuto("D65 P3",laThemeColor(bt,LA_BT_BORDER),ui->L, c-r+LA_RH, ui->U+bt->TM, LA_TEXT_ALIGN_RIGHT|LA_TEXT_MONO);
- if(ShowInfo) tnsDrawStringAuto("🛈",laThemeColor(bt,LA_BT_TEXT),c-r, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_LEFT);
- tnsFlush();
- tnsUniformShowColorOverflowStripes(T->immShader,0);
- tnsUniformInputColorSpace(T->immShader,0);
- }
- void la_MenuItemDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- if(!NoDecal){
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt, ui->State));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_LINE_LOOP);
- }
- tnsDrawStringAuto(transLate(ui->Display->Ptr), laThemeColor(bt, LA_BT_TEXT|ui->State), ui->L+bt->LM, ui->R, ui->U, ui->Flags);
- }
- void la_ConditionToggleDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- char temp[128] = {0};
- char *buf[LA_RAW_CSTR_MAX_LEN];
- uint32_t IconID;
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- if (!ui->State) ui->State = LA_UI_NORMAL;
- int UseState=ui->State;
- if (!(ui->Flags&LA_TEXT_ALIGN)) ui->Flags|=LA_TEXT_ALIGN_CENTER;
- if(!NoDecal){
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt, ui->State));
- tnsVertex2d(ui->L, ui->U);
- tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B);
- tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
- tnsVertex2d(ui->L, ui->U);
- tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B);
- tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_LINE_LOOP);
- }else{
- UseState=LA_UI_NORMAL;
- }
- buf[0] = 0;
- if (ui->ExtraInstructions){
- if (ui->Type->OperatorType->ParseArgs){
- ui->Type->OperatorType->ParseArgs(ui->Instructions, &IconID, buf);
- }
- }
- if (buf[0]) tnsDrawStringAuto(transLate(buf), laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
- else
- tnsDrawStringAuto(ui->State == LA_UI_ACTIVE ? "⯆" : "⯈", laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
- }
- void la_DrawColumnAdjusterRecursive(int U, int B, laColumn *c, int W, tnsVector3d color, int LeftMost){
- if (c->LS){
- la_DrawColumnAdjusterRecursive(U, B, c->LS, W, color, LeftMost);
- la_DrawColumnAdjusterRecursive(U, B, c->RS, W, color, LeftMost);
- }else{
- if(c->IL==LeftMost) return;
- tnsDrawStringAuto("⌉⌈", color, c->IL-LA_RH, c->IL+LA_RH, U, LA_TEXT_ALIGN_CENTER);
- }
- }
- void la_ColumnAdjusterDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
- la_DrawColumnAdjusterRecursive(ui->U, ui->U + LA_RH, ui->C, (bt->LM+bt->RM)/2, laThemeColor(bt, LA_BT_TEXT), ui->C->IL);
- }
- void la_ColumnViewerDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- laColumn *c = ui->PP.EndInstance;
- int W = ui->R - ui->L - bt->LM - bt->RM;
- //if (c->IR == c->IL)
- // return;
- int T = c->Top->IR - c->Top->IL;
- int L = (int)((real)(c->IL - c->Top->IL) * W / T) + ui->L + bt->LM,
- R = (int)((real)(c->IR - c->Top->IL) * W / T) + ui->L + bt->LM;
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(L, ui->U + bt->TM);
- tnsVertex2d(R, ui->U + bt->TM);
- tnsVertex2d(R, ui->B - bt->BM);
- tnsVertex2d(L, ui->B - bt->BM);
- tnsPackAs(GL_TRIANGLE_FAN);
- }
- void la_NodeSocketDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- char* label=0; char* icon;
- laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
- real* ColorBkg=0,*ColorSocket;
- 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:""; }
- 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:""; }
- int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
- tnsUseNoTexture();
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsColor4dv(ColorBkg);
- tnsPackAs(GL_TRIANGLE_FAN);
- int tl,tr,tu,sl,sr,su;
- 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; }
- 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; }
- 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; }
- 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; }
- else{ sl=ui->L; su=ui->U; sr=ui->R; label=0; }
- tnsDrawStringAuto("⭗", IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):ColorSocket, sl, sr, su, LA_TEXT_ALIGN_CENTER);
- if(label) tnsDrawStringAuto(label, IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):ColorSocket, tl, tr, tu, LA_TEXT_ALIGN_CENTER|LA_TEXT_MONO);
- }
- void la_HeightAdjusterDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- char* str="☰";
- if(ui->State==LA_BT_ACTIVE){ str="🡙"; }
- tnsDrawStringAuto(str, laThemeColor(bt,LA_BT_TEXT), ui->L-1000, ui->R+1000, ui->U, LA_TEXT_ALIGN_CENTER);
- }
- void la_RawPropDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- int s=0;
- //void* data=laGetRaw(&ui->PP, &s);
- //char* buf[128]; sprintf(buf,"%d bytes of raw data at 0x%0x", s, data);
- tnsDrawStringAuto("RAW DATA", laThemeColor(bt,LA_BT_TEXT), ui->L, ui->R, ui->U, ui->Flags|LA_TEXT_MONO);
- }
- void la_MapperDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
- if(!NoDecal){
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt, LA_BT_NORMAL));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_LINE_LOOP);
- }
- laPropContainer* pc=la_EnsureSubTarget(ui->PP.LastPs->p,ui->PP.EndInstance);
- if(!pc || pc!=LA_PC_MAPPER || !ui->PP.EndInstance){
- tnsDrawStringAuto("Property is not a la_value_mapper.",0,ui->L+bt->LM,ui->R-bt->RM,bt->TM,LA_TEXT_LINE_WRAP); return;
- }
- laValueMapper* vm=ui->PP.EndInstance; int any=0;
- tnsColor4dv(laAccentColor(LA_BT_TEXT));
- for(laValueMapperPoint* vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
- tnsVertex2d(tnsInterpolate(ui->L,ui->R,vmp->x),tnsInterpolate(ui->B,ui->U,vmp->y)); any++;
- } tnsPackAs(GL_LINE_STRIP);
- for(laValueMapperPoint* vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
- tnsVertex2d(tnsInterpolate(ui->L,ui->R,vmp->x),tnsInterpolate(ui->B,ui->U,vmp->y));
- } tnsPackAs(GL_POINTS);
- if(any){ glLineWidth(2); glPointSize(5); tnsFlush(); glPointSize(1); glLineWidth(1); }
- }
- void la_ImageDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- tnsImage* im=ui->Extra;
- if(!im->Texture) { tns_ImageToTexture(im); }
- if(!im->Texture) {
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
- tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_LINE_LOOP);
- tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->B);
- tnsVertex2d(ui->R, ui->U); tnsVertex2d(ui->L, ui->B);
- tnsPackAs(GL_LINES);
- return;
- }
- int W=im->Texture->Width, H=im->Texture->Height;
- int Full=ui->Flags&LA_UI_IMAGE_FULL_W;
- real r=(real)(ui->R-ui->L)/W; if(r<1){W*=r;H*=r;}
- real UseW=Full?(W):((real)LA_RH*ui->SymbolID/H*W);
- real L=(ui->R-ui->L-UseW)/2,U=0,UseH=Full?H:(ui->B-ui->U);
- if(Full){ U=(ui->B-ui->U-H)/2; }
- if(ui->Flags&LA_TEXT_ALIGN_CENTER){ L=0; }
- elif(ui->Flags&LA_TEXT_ALIGN_RIGHT){ L=ui->R-ui->L-UseW; }
- tnsDraw2DTextureDirectly(im->Texture,ui->L+L,ui->U+U,UseW,UseH);
- tnsFlush();
- }
- void la_ValueMeterType1Draw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- int DataI[8]; real Data[8];
- int Len, i, W; real Seg;
- char buf[48] = {0};
- char buf2[48] = {0};
- char prefix[8][64] = {0};
- int Original;
- int Imin=-100, Imax=100;
- real min=-100, max=100;
- int s, State; int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
- int NoLabel=ui->Flags&LA_UI_FLAGS_NO_LABEL;
- int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
- Len = laGetArrayLength(&ui->PP);
- laGetPrefixP(&ui->PP, prefix);
- if(IsInt){
- laGetIntArray(&ui->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
- laGetIntRange(&ui->PP, &Imin, &Imax); min=Imin; max=Imax;
- }else{
- laGetFloatArray(&ui->PP, Data);
- laGetFloatRange(&ui->PP,&min,&max);
- }
- for (i = 0; i < Len; i++){
- int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
- if(IsVertical){
- Seg = (real)(ui->R-ui->L)/Len;
- _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
- }else{
- Seg = (real)(ui->B-ui->U)/Len;
- _U = ui->U + i * Seg; _B=_U+Seg;
- }
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,ui->State));
- tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
- tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_TRIANGLE_FAN);
- int oflow=0,ofhigh=0;
- if(Data[i]<min){ oflow=1; Data[i]=min; }
- if(Data[i]>max){ ofhigh=1; Data[i]=max; }
-
- int R1=_R,U1=_U;
- if(IsVertical){ U1 = (real)(max - Data[i]) / (real)(max - min) * (real)(_B-_U) + _U; }
- else{ R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(_R-_L) + _L; }
- tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
- tnsColor4d(LA_COLOR3(color),0.4);
- tnsVertex2d(_L, U1); tnsVertex2d(R1, U1);
- tnsVertex2d(R1, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
- tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_LINE_LOOP);
- if(!NoLabel){
- if(Len==1){ sprintf(buf,"%s",ui->PP.LastPs->p->Name); } else{ if(i<8)sprintf(buf,"%s",prefix[i]); }
- if(buf[0]) tnsDrawStringAuto(buf, laThemeColor(bt, LA_BT_TEXT), _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
- }
- if(IsVertical){
- if(oflow){ tnsDrawStringAuto("⯆",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_CENTER); }
- elif(ofhigh){ tnsDrawStringAuto("⯅",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _B-LA_RH, LA_TEXT_ALIGN_CENTER); }
- }else{
- if(oflow){ tnsDrawStringAuto("⯇",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_LEFT); }
- elif(ofhigh){ tnsDrawStringAuto("⯈",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_RIGHT); }
- }
- }
- int trisize=LA_RH/3.0f;
- for(laCompoundPP* CPP=ui->CompoundPPs.pFirst;CPP;CPP=CPP->Item.pNext){
- IsInt=(CPP->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
- Len = laGetArrayLength(&CPP->PP);
- laGetPrefixP(&CPP->PP, prefix);
- if(IsInt){
- laGetIntArray(&CPP->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
- laGetIntRange(&CPP->PP, &Imin, &Imax); min=Imin; max=Imax;
- }else{
- laGetFloatArray(&CPP->PP, Data);
- laGetFloatRange(&CPP->PP,&min,&max);
- }
- if(CPP->Slot <= LA_SLOT_MARKER_4){
- for (i = 0; i < Len; i++){
- int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
- if(IsVertical){
- Seg = (real)(ui->R-ui->L)/Len;
- _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
- }else{
- Seg = (real)(ui->B-ui->U)/Len;
- _U = ui->U + i * Seg; _B=_U+Seg;
- }
- int R1=_R,U1=_U;
- if(IsVertical){ U1 = (real)(max - Data[i]) / (real)(max - min) * (real)(_B-_U) + _U; }
- else{ R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(_R-_L) + _L; }
-
- tnsUseNoTexture();
- tnsColor4dv(laAccentColor(LA_BT_TEXT));
- if(IsVertical){ tnsVertex2d(_L, U1); tnsVertex2d(R1, U1); }
- else{ tnsVertex2d(R1, U1); tnsVertex2d(R1, _B); }
- tnsPackAs(GL_LINES);
- if(IsVertical){
- if(! CPP->Slot % 2){ tnsVertex2d(_L, U1+trisize); tnsVertex2d(_L+trisize, U1); tnsVertex2d(_L, U1-trisize); }
- else{ tnsVertex2d(_R, U1+trisize); tnsVertex2d(_R-trisize, U1); tnsVertex2d(_R, U1-trisize); }
- }
- else{
- if(! CPP->Slot % 2){ tnsVertex2d(R1-trisize, _B); tnsVertex2d(R1, _B-trisize); tnsVertex2d(R1+trisize, _B); }
- else{ tnsVertex2d(R1-trisize, U1); tnsVertex2d(R1, U1+trisize); tnsVertex2d(R1+trisize, U1); }
- }
- tnsPackAs(GL_TRIANGLES);
- }
- }
- }
- tnsFlush();
- }
- void la_ValueMeterType2Draw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- int DataI[8]; real Data[8]; int SDataI[8]; real SData[8]; int Len, i, W; real Seg;
- char buf[48] = {0}; char buf2[48] = {0};char prefix[16][64] = {0};char limits[2][64]={0};
- int Original;
- int Imin=-100, Imax=100; real min=-100, max=100;
- int s, State; int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
- int NoLabel=ui->Flags&LA_UI_FLAGS_NO_LABEL;
- int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
- Len = laGetArrayLength(&ui->PP);
- laGetPrefixP(&ui->PP, prefix);
- if(IsInt){
- laGetIntArray(&ui->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
- laGetIntRange(&ui->PP, &Imin, &Imax); min=Imin; max=Imax;
- sprintf(limits[0],"%d",Imin); sprintf(limits[1],"%d",Imax);
- }else{
- laGetFloatArray(&ui->PP, Data);
- laGetFloatRange(&ui->PP,&min,&max);
- sprintf(limits[0],"%lf",min); sprintf(limits[1],"%lf",max);
- }
- int sl = TNS_MAX2(abs(ui->SymbolID),5);
- int ScaleLen = sl * LA_RH;
- real seg = abs(ui->TemplateContext)/100;
- int times=1,times10=0;
- while((max-min)/seg > ScaleLen/10){
- seg*=10;
- }
- if(seg>100){ int sseg=seg; while(sseg>=100){ sseg/=10; times*=10; times10++; } }
- for (i = 0; i < Len; i++){
- int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
- if(IsVertical){
- Seg = (real)(ui->R-ui->L)/Len;
- _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
- }else{
- Seg = (real)(ui->B-ui->U)/Len;
- _U = ui->U + i * Seg; _B=_U+Seg;
- }
- real cx=(_L+_R)/2,cy=(_U+_B)/2,cw=(_R-_L),ch=(_B-_U);
-
- tnsPushStringClip(_L,_R,_U,_B);
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,ui->State));
- tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
- tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_TRIANGLE_FAN);
- int oflow=0,ofhigh=0;
- if(Data[i]<min){ oflow=1; Data[i]=min; }
- if(Data[i]>max){ ofhigh=1; Data[i]=max; }
-
- real fac = (real)(Data[i]-min) / (real)(max - min);
- int SL,SR,SU,SB,_SL,_SR,_SU,_SB,Move = fac*ScaleLen;
- if(IsVertical){ SL=_L; SR=_R; SB=_SB=cy+Move; SU=_SU=SB-ScaleLen; TNS_CLAMP(SB,_U,_B); TNS_CLAMP(SU,_U,_B); }
- else{ SL=_SL=cx-Move; SR=_SR=SL+ScaleLen; SB=_B; SU=_U; TNS_CLAMP(SL,_L,_R); TNS_CLAMP(SR,_L,_R); }
- tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
- tnsColor4d(LA_COLOR3(color),0.3);
- tnsVertex2d(SL, SU); tnsVertex2d(SR, SU);
- tnsVertex2d(SR, SB); tnsVertex2d(SL, SB);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsColor4d(LA_COLOR3(color),0.7);
- int scalelow=min/seg-1, scalehigh=max/seg+1;
- for(int si=scalelow;si<=scalehigh;si++){
- for(int ssi=0;ssi<10;ssi++){
- real val=si*seg + ssi*0.1*seg; if(val<min) continue; if(val>max) break;
- real sfac = (real)(val-min) / (max - min); int smove=Move-sfac*ScaleLen;
- real lfac = ssi==0?(si==ssi?0.5:0.3):(ssi==5?0.2:0.1);
- if(IsVertical){ int scaleb=cy+smove; if(scaleb>_B || scaleb<_U) continue;
- tnsVertex2d(cx-cw*lfac,scaleb); tnsVertex2d(cx+cw*lfac,scaleb);
- }else{ int scalel=cx-smove; if(scalel<_L || scalel>_R) continue;
- tnsVertex2d(scalel,cy+ch*lfac); tnsVertex2d(scalel,cy-ch*lfac);
- }
- }
- }
- tnsPackAs(GL_LINES);
- if(!NoLabel){
- for(int si=scalelow;si<=scalehigh;si++){
- real val=si*seg; if(val<min) continue; if(val>max) break;
- real sfac = (real)(val-min) / (max - min); int smove=Move-sfac*ScaleLen;
- if(IsInt) sprintf(buf,"%.0lf",val/times); else sprintf(buf,"%.2lf",val/times);
- if(IsVertical){ int scaleb=cy+smove; if(scaleb>_B+LA_RH2 || scaleb<_U-LA_RH2) continue;
- tnsDrawStringAuto(buf,laThemeColor(bt,LA_BT_TEXT),_L+bt->LM,_R-bt->RM,scaleb-LA_RH2,ui->Flags);
- }else{ int scalel=cx-smove; if(scalel<_L-100 || scalel>_R+100) continue;
- tnsDrawStringAuto(buf,laThemeColor(bt,LA_BT_TEXT),scalel-100,scalel+100,_U,ui->Flags);
- }
- }
- if(IsVertical){
- tnsDrawStringAuto(limits[0],laThemeColor(bt,LA_BT_TEXT|ui->State),_L+bt->LM,_R-bt->RM,_SB,ui->Flags);
- tnsDrawStringAuto(limits[1],laThemeColor(bt,LA_BT_TEXT|ui->State),_L+bt->LM,_R-bt->RM,_SU-LA_RH,ui->Flags);
- }else{
- tnsDrawStringAuto(limits[0],laThemeColor(bt,LA_BT_TEXT|ui->State),_SL-100,_SL-bt->LM,_B-LA_RH,LA_TEXT_ALIGN_RIGHT);
- tnsDrawStringAuto(limits[1],laThemeColor(bt,LA_BT_TEXT|ui->State),_SR+bt->RM,_SR+100,_B-LA_RH,LA_TEXT_ALIGN_LEFT);
- }
- }
- tnsUseNoTexture();
- tnsColor4dv(laAccentColor(LA_BT_BORDER));
- if(IsVertical){tnsVertex2d(_L,cy); tnsVertex2d(_R,cy);}
- else{tnsVertex2d(cx,_U); tnsVertex2d(cx,_B);}
- tnsPackAs(GL_LINES);
- if(times!=1){ sprintf(buf,"%d",times10);
- if(IsVertical && cw>LA_RH) tnsDrawStringAuto(buf,laAccentColor(LA_BT_BORDER),_L+bt->LM,_R-bt->RM,cy,LA_TEXT_MONO|LA_TEXT_ALIGN_RIGHT);
- elif(ch>LA_RH) tnsDrawStringAuto(buf,laAccentColor(LA_BT_BORDER),cx+bt->LM,cx+100,_U,LA_TEXT_MONO|LA_TEXT_ALIGN_LEFT);
- }
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
- tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_LINE_LOOP);
- //if(IsVertical){
- // if(oflow){ tnsDrawStringAuto("⯆",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_CENTER); }
- // elif(ofhigh){ tnsDrawStringAuto("⯅",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _B-LA_RH, LA_TEXT_ALIGN_CENTER); }
- //}else{
- // if(oflow){ tnsDrawStringAuto("⯇",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_LEFT); }
- // elif(ofhigh){ tnsDrawStringAuto("⯈",laThemeColor(bt, LA_BT_TEXT), _L+bt->LM,_R-bt->RM, _U, LA_TEXT_ALIGN_RIGHT); }
- //}
- tnsPopStringClip();
- }
- int trisize=LA_RH/3.0f;
- for(laCompoundPP* CPP=ui->CompoundPPs.pFirst;CPP;CPP=CPP->Item.pNext){
- IsInt=(CPP->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
- Len = laGetArrayLength(&CPP->PP);
- laGetPrefixP(&CPP->PP, prefix);
- if(IsInt){
- laGetIntArray(&CPP->PP, SDataI); for(int i=0;i<Len;i++){ SData[i]=SDataI[i]; }
- //laGetIntRange(&CPP->PP, &Imin, &Imax); min=Imin; max=Imax;
- }else{
- laGetFloatArray(&CPP->PP, SData);
- //laGetFloatRange(&CPP->PP,&min,&max);
- }
- if(CPP->Slot <= LA_SLOT_MARKER_4){
- for (i = 0; i < Len; i++){
- int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
- if(IsVertical){
- Seg = (real)(ui->R-ui->L)/Len;
- _L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
- }else{
- Seg = (real)(ui->B-ui->U)/Len;
- _U = ui->U + i * Seg; _B=_U+Seg;
- }
- real cx=(_L+_R)/2,cy=(_U+_B)/2,cw=(_R-_L),ch=(_B-_U);
- real sfac = (real)(SData[i]-min) / (real)(max - min);
- real fac = (real)(Data[i]-min) / (real)(max - min);
- int SL,SR,SU,SB,_SL,_SR,_SU,_SB, Move = fac*ScaleLen,SMove=sfac*ScaleLen;
- if(IsVertical){ _SB=SB=cy+Move-SMove; TNS_CLAMP(SB,_U,_B); }
- else{ SL=_SL=cx-Move+SMove; TNS_CLAMP(SL,_L,_R); }
-
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,LA_BT_TEXT|LA_BT_ACTIVE));
- if(IsVertical){ tnsVertex2d(_L, SB); tnsVertex2d(_R, SB); }
- else{ tnsVertex2d(SL, _U); tnsVertex2d(SL, _B); }
- tnsPackAs(GL_LINES);
- if(IsVertical){
- if(! CPP->Slot % 2){ tnsVertex2d(_L, SB); tnsVertex2d(_L+trisize, SB); tnsVertex2d(_L, SB-trisize); }
- else{ tnsVertex2d(_R, SB+trisize); tnsVertex2d(_R-trisize, SB); tnsVertex2d(_R, SB); }
- if(SB==_SB){ tnsPackAs(GL_TRIANGLES); }else{ tnsPackAs(GL_LINE_LOOP); }
- }
- else{
- if(! CPP->Slot % 2){ tnsVertex2d(SL, _B); tnsVertex2d(SL, _B-trisize); tnsVertex2d(SL+trisize, _B); }
- else{ tnsVertex2d(SL-trisize, _U); tnsVertex2d(SL, _U+trisize); tnsVertex2d(SL, _U); }
- if(SL==_SL){ tnsPackAs(GL_TRIANGLES); }else{ tnsPackAs(GL_LINE_LOOP); }
- }
- }
- }
- }
- tnsFlush();
- }
- void la_ValueMeter2DDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme);
- int DataI[8]; real Data[8];
- int Len, i, W; real Seg;
- char buf[48] = {0};
- char buf2[48] = {0};
- char prefix[8][64] = {0};
- int Original;
- int Imin=-100, Imax=100;
- real min=-100, max=100;
- int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
- Len = laGetArrayLength(&ui->PP);
- laGetPrefixP(&ui->PP, prefix);
- if(IsInt){
- laGetIntArray(&ui->PP, DataI); for(int i=0;i<Len;i++){ Data[i]=DataI[i]; }
- laGetIntRange(&ui->PP, &Imin, &Imax); min=Imin; max=Imax;
- }else{
- laGetFloatArray(&ui->PP, Data);
- laGetFloatRange(&ui->PP,&min,&max);
- }
- int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
- tnsUseNoTexture();
- tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
- tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
- tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_TRIANGLE_FAN);
- real CL=(real)(Data[0] - min) / (real)(max - min) * (real)(_R-_L) + _L;
- real CU=(real)(max - Data[1]) / (real)(max - min) * (real)(_B-_U) + _U;
- real HW=((real)_R-(real)_L)/4; real HH=((real)_B-(real)_U)/4;
- real ML=((real)_R+(real)_L)/2; real MU=((real)_B+(real)_U)/2;
- tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
- tnsColor4d(LA_COLOR3(color),0.4);
- tnsVertex2d(ML+HW, MU+HH); tnsVertex2d(ML-HW, MU+HH);
- tnsVertex2d(ML-HW, MU-HH); tnsVertex2d(ML+HW, MU-HH);
- tnsPackAs(GL_LINE_LOOP);
- tnsVertex2d(_L,_U); tnsVertex2d(_R,_B);
- tnsVertex2d(_R,_U); tnsVertex2d(_L,_B);
- tnsVertex2d(ML,_U); tnsVertex2d(ML,_B);
- tnsVertex2d(_R,MU); tnsVertex2d(_L,MU);
- tnsPackAs(GL_LINES);
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
- tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
- tnsPackAs(GL_LINE_LOOP);
- tnsFlush();
- tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
- tnsVertex2d(_L, CU); tnsVertex2d(_R, CU);
- tnsVertex2d(CL, _U); tnsVertex2d(CL, _B);
- tnsPackAs(GL_LINES);
- real circle[48];
- tnsMakeCircle2d(circle,24,CL,CU,LA_RH2,0);
- tnsVertexArray2d(circle,24);
- tnsPackAs(GL_LINE_LOOP);
- glLineWidth(2);
- tnsFlush();
- glLineWidth(1);
- }
- void la_ScopeDraw(laUiItem *ui, int h){
- laBoxedTheme *bt = (*ui->Type->Theme); laSynthNodeScope* s=ui->PP.EndInstance;
- if(!s) return;
- real* lcolor=laAccentColor(LA_BT_TEXT); int plen=LA_SYNTH_PLEN;
- int cl=ui->L+2, cr=ui->R-2, cu=ui->U+2, cb=ui->B-2; real cc=(real)(cu+cb)/2;
- real yfac1=(real)(1<<(s->Gain1+1))/4.0f, yfac2=(real)(1<<(s->Gain2+1))/4.0f; yfac1/=10; yfac2/=10;
- real off1=s->Offset1/20*(cb-cu), off2=s->Offset2/20*(cb-cu);
- real arrx[LA_SYNTH_PLEN];
- real arru1[LA_SYNTH_PLEN],arrb1[LA_SYNTH_PLEN];
- real arru2[LA_SYNTH_PLEN],arrb2[LA_SYNTH_PLEN];
- tnsFlush(); tnsUseNoTexture();
-
- tnsColor4d(0,0,0,0.8);
- tnsVertex2d(ui->L,ui->U); tnsVertex2d(ui->R,ui->U);
- tnsVertex2d(ui->R,ui->B); tnsVertex2d(ui->L,ui->B);
- tnsPackAs(GL_TRIANGLE_FAN);
- tnsFlush(); tnsLineWidth(3.0);
- laSpinLock(&s->Lock);
- real b1=s->Brightness1, b2=s->Brightness2; real hcy[3]; tnsRGB2HCY(lcolor,hcy); hcy[2]=0.75;
- real c1[3]; tnsHCY2RGB(hcy,c1);
- for(int i=0;i<plen;i++){
- arrx[i]=tnsInterpolate(cl,cr,((real)i)/plen);
- arru1[i]=tnsInterpolate(cc,cu,yfac1*s->Display1[i])-off1;
- arrb1[i]=tnsInterpolate(cc,cu,yfac1*s->Display1[i+plen])-off1;
- TNS_CLAMP(arru1[i],cu,cb); TNS_CLAMP(arrb1[i],cu,cb);
- tnsVertex2d(arrx[i],arru1[i]); tnsVertex2d(arrx[i],arrb1[i]);
- }
- tnsColor4d(LA_COLOR3(c1),b1*0.4);
- tnsPackAs(GL_TRIANGLE_STRIP); tnsFlush();
- for(int i=0;i<plen;i++){
- arru2[i]=tnsInterpolate(cc,cu,yfac2*s->Display2[i])-off2;
- arrb2[i]=tnsInterpolate(cc,cu,yfac2*s->Display2[i+plen])-off2;
- TNS_CLAMP(arru2[i],cu,cb); TNS_CLAMP(arrb2[i],cu,cb);
- tnsVertex2d(arrx[i],arru2[i]); tnsVertex2d(arrx[i],arrb2[i]);
- }
- tnsColor4d(LA_COLOR3(c1),b2*0.6);
- tnsPackAs(GL_TRIANGLE_STRIP); tnsFlush();
- for(int i=0;i<plen;i++){ tnsVertex2d(arrx[i],arru1[i]); }
- tnsColor4d(LA_COLOR3(c1),b1);
- tnsPackAs(GL_LINE_STRIP);
- for(int i=0;i<plen;i++){ tnsVertex2d(arrx[i],arrb1[i]); }
- tnsColor4d(LA_COLOR3(c1),b1);
- tnsPackAs(GL_LINE_STRIP);
- for(int i=0;i<plen;i++){ tnsVertex2d(arrx[i],arru2[i]); }
- tnsColor4d(LA_COLOR3(c1),b2);
- tnsPackAs(GL_LINE_STRIP);
- for(int i=0;i<plen;i++){ tnsVertex2d(arrx[i],arrb2[i]); }
- tnsColor4d(LA_COLOR3(c1),b2);
- tnsPackAs(GL_LINE_STRIP);
- laSpinUnlock(&s->Lock);
- tnsFlush(); tnsLineWidth(1.0);
- tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
- tnsVertex2d(ui->L,ui->U); tnsVertex2d(ui->R,ui->U);
- tnsVertex2d(ui->R,ui->B); tnsVertex2d(ui->L,ui->B);
- tnsPackAs(GL_LINE_LOOP);
- if(s->FromSynth && laget_SynthPlaying(s->FromSynth)){ laDeferredRedraw(MAIN.CurrentPanel); }
- }
- void la_ConditionNodeFreeRecursive(laUiConditionNode *ucn);
- void la_GeneralUiInit(laUiItem *ui){
- ui->Extra = memAcquireSimple(sizeof(laGeneralUiExtraData));
- ui->Extra->ui=ui;
- }
- void la_GeneralUiDestroy(laUiItem *ui){
- if(ui->Extra && ui->Extra->Edit){ strEndEdit(&ui->Extra->Edit, 1); }
- memFree(ui->Extra);
- }
- void la_ConditionUiDestroy(laUiItem *ui){
- laConditionUiExtraData *cued = ui->Extra;
- la_ConditionNodeFreeRecursive(cued->Expression);
- FreeMem(ui->Extra);
- }
- void la_MultiStringInit(laUiItem *ui){
- laGeneralUiExtraData *e = ui->Extra;
- if (!e) e = memAcquireSimple(sizeof(laGeneralUiExtraData));
- ui->Extra = e;
- e->HeightCoeff = 10;
- }
- void la_ImageUiInit(laUiItem *ui){
- tnsImage* im=ui->Extra;
- #ifdef LA_WITH_PNG
- tnsUseImage(im);
- #endif
- }
- void la_ImageUiDestroy(laUiItem *ui){
- tnsImage* im=ui->Extra;
- #ifdef LA_WITH_PNG
- tnsStopUsingImage(im);
- #endif
- //memAssignRef(ui, &ui->Extra, 0);
- }
- void la_MeterUiInit(laUiItem *ui){
- la_GeneralUiInit(ui); ui->SymbolID = 20; ui->TemplateContext = 1000;
- }
- void la_RegisterUiTypesBasic(){
- laKeyMapper* km;
- laPropContainer* pc;
- LA_WIDGET_INT->Type=LA_WIDGET_INT_PLAIN->Type=
- _LA_UI_INT = la_RegisterUiType("LA_int_array_horizon", LA_PROP_INT | LA_PROP_ARRAY, "LA_int_array_h_operator",
- &_LA_THEME_VALUATOR, la_IntDraw, la_ValueGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
- _LA_UI_INT->GetMinWidth=la_ValueGetMinWidth;
- LA_WIDGET_METER_TYPE1->Type=
- _LA_UI_METER_TYPE1 = la_RegisterUiType("LA_meter_type1", 0, 0, &_LA_THEME_VALUATOR, la_ValueMeterType1Draw, la_ValueMeterGetHeight, la_MeterUiInit, la_GeneralUiDestroy);
- _LA_UI_METER_TYPE1->GetMinWidth=la_ValueGetMinWidth;
- LA_WIDGET_METER_TYPE2->Type=
- _LA_UI_METER_TYPE2 = la_RegisterUiType("LA_meter_type2", 0, 0, &_LA_THEME_VALUATOR, la_ValueMeterType2Draw, la_ValueMeterGetHeight, la_MeterUiInit, la_GeneralUiDestroy);
- _LA_UI_METER_TYPE2->GetMinWidth=la_ValueGetMinWidth;
-
- LA_WIDGET_VALUE_METER_2D->Type=
- _LA_UI_VALUE_METER_2D = la_RegisterUiType("LA_value_meter_2d", 0, 0, &_LA_THEME_VALUATOR, la_ValueMeter2DDraw, la_ValueMeter2DGetHeight, la_MeterUiInit, la_GeneralUiDestroy);
- LA_WIDGET_FLOAT->Type=LA_WIDGET_FLOAT_PLAIN->Type=
- _LA_UI_FLOAT = la_RegisterUiType("LA_real_array_horizon", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_array_h_operator",
- &_LA_THEME_VALUATOR, la_FloatDraw, la_ValueGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
- _LA_UI_FLOAT->GetMinWidth=la_ValueGetMinWidth;
- LA_WIDGET_FLOAT_COLOR->Type=
- _LA_UI_FLOAT_COLOR = la_RegisterUiType("LA_real_color", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_color_operator",
- &_LA_THEME_VALUATOR, la_FloatArrayColorDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
- _LA_UI_FLOAT_COLOR->GetMinWidth=la_ColorSelectorGetMinWidth;
- LA_WIDGET_FLOAT_COLOR_HCY->Type=
- _LA_UI_FLOAT_COLOR_HCY = la_RegisterUiType("LA_real_hcy", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_hcy_operator",
- &_LA_THEME_VALUATOR, la_ColorCircleDrawHCY, la_ColorPickerGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
- _LA_UI_FLOAT_COLOR_HCY->GetMinWidth = la_ColorPickerGetMinWidth;
- LA_WIDGET_ENUM_SELECTOR->Type=LA_WIDGET_ENUM_SELECTOR_ICON->Type=LA_WIDGET_ENUM_CYCLE->Type=LA_WIDGET_ENUM_HIGHLIGHT->Type=
- _LA_UI_ENUM_SELECTOR = la_RegisterUiType("LA_enum_selector", LA_PROP_ENUM, "LA_enum_selector_operator",
- &_LA_THEME_SELECTOR, la_EnumSelectorDraw, la_EnumGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
- _LA_UI_ENUM_SELECTOR->GetMinWidth = la_EnumGetMinWidth;
- LA_WIDGET_FIXED_GROUP->Type=
- _LA_UI_FIXED_GROUP = la_RegisterUiType("LA_group_default", 0, 0,
- &_LA_THEME_COLLECTION_GROUP, la_GroupDraw, la_GroupGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
- _LA_UI_FIXED_GROUP->Tag|=LA_UI_TAG_SCISSOR;
- LA_WIDGET_COLLECTION->Type=
- _LA_UI_COLLECTION = la_RegisterUiType("LA_collection_default", LA_PROP_SUB, "LA_collection_operator",
- &_LA_THEME_COLLECTION_GROUP, la_EmptyDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
- LA_WIDGET_COLLECTION_SELECTOR->Type=
- _LA_UI_COLLECTION_SELECTOR = la_RegisterUiType("LA_collection_selector_default", LA_PROP_SUB, "LA_collection_selector_operator",
- &_LA_THEME_COLLECTION_SELECTOR, la_CollectionSelectorDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
- _LA_UI_COLLECTION_SELECTOR->GetMinWidth = la_CollectionSimpleGetMinWidth;
- LA_WIDGET_COLLECTION_SINGLE->Type=
- _LA_UI_COLLECTION_SINGLE = la_RegisterUiType("LA_collection_single", LA_PROP_SUB, "LA_collection_operator",
- &_LA_THEME_COLLECTION_GROUP, la_EmptyDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
- LA_WIDGET_TAB->Type=
- _LA_UI_TAB = la_RegisterUiType("LA_tab_default", 0, "LA_tab_operator",
- &_LA_THEME_TAB, la_TabDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
- LA_WIDGET_BUTTON->Type=LA_WIDGET_BUTTON_NO_CONFIRM->Type=
- _LA_UI_BUTTON = la_RegisterUiType("LA_button_default", LA_PROP_OPERATOR, "LA_button_operator",
- &_LA_THEME_BUTTON, la_ButtonDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
- _LA_UI_BUTTON->GetMinWidth = la_ButtonGetMinWidth;
- LA_WIDGET_BUTTON_NO_CONFIRM->Flags|=LA_UI_FLAGS_NO_CONFIRM;
- pc=laUiHasExtraProps(_LA_UI_BUTTON, sizeof(laGeneralUiExtraData),0);
- LA_WIDGET_LABEL->Type=
- _LA_UI_LABEL = la_RegisterUiType("LA_label_default", LA_PROP_OPERATOR, 0,
- &_LA_THEME_LABEL, la_LabelDraw, la_LabelHeight, 0, 0);
- _LA_UI_LABEL->GetMinWidth = la_LabelGetMinWidth;
- LA_WIDGET_MENU_ROOT->Type=
- _LA_UI_MENU_ROOT = la_RegisterUiType("LA_menu_default", LA_PROP_OPERATOR, "LA_menu_root_operator",
- &_LA_THEME_BUTTON, la_MenuItemDraw, 0, 0, 0);
- _LA_UI_MENU_ROOT->GetMinWidth=la_LabelGetMinWidth;
- LA_WIDGET_CONDITION_TOGGLE->Type=
- _LA_UI_CONDITION_TOGGLE = la_RegisterUiType("LA_condition_toggle_default", LA_PROP_SELF_CONDITION, "LA_condition_toggle_operator",
- &_LA_THEME_BUTTON, la_ConditionToggleDraw, 0, 0, la_ConditionUiDestroy);
- LA_WIDGET_STRING->Type=LA_WIDGET_STRING_PLAIN->Type=LA_WIDGET_STRING_MONO_PLAIN->Type=
- _LA_UI_STRING = la_RegisterUiType("LA_string_default", LA_PROP_STRING, "LA_string_operator",
- &_LA_THEME_STRING, la_SingleLineStringDraw, la_StringPropGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
- _LA_UI_STRING->GetMinWidth = la_StringPropGetMinWidth;
- km=&_LA_UI_STRING->KeyMapper;
- laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'c', 0);
- laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'x', "mode=CUT");
- laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
- pc=laUiHasExtraProps(_LA_UI_STRING, sizeof(laGeneralUiExtraData), 0);{
- laAddOperatorProperty(pc, "copy_selection", "Copy Selection", "Copy selected string into clipboard", "LA_edit_string_copy",0,0);
- }
- LA_WIDGET_STRING_MULTI->Type=
- _LA_UI_STRING_MULTI = la_RegisterUiType("LA_string_multiline", LA_PROP_STRING, "LA_string_multi",
- &_LA_THEME_STRING, la_MultiStringDraw, la_MultiStringHeight, la_MultiStringInit, la_GeneralUiDestroy);
- _LA_UI_STRING_MULTI->GetMinWidth = la_StringPropGetMinWidth;
- km=&_LA_UI_STRING_MULTI->KeyMapper;
- laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'c', 0);
- laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'x', "mode=CUT");
- laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
- pc=laUiHasExtraProps(_LA_UI_STRING_MULTI, sizeof(laGeneralUiExtraData), 0);{
- laAddOperatorProperty(pc, "copy_selection", "Copy Selection", "Copy selected string into clipboard", "LA_edit_string_copy",0,0);
- }
- LA_WIDGET_ALIGN->Type=
- _LA_UI_ALIGN = la_RegisterUiType("LA_colum_align_default", 0, 0,
- &_LA_THEME_BUTTON, la_UiSeperatorDraw, 0, 0, 0);
- LA_WIDGET_COLUMN_ADJUSTER->Type=
- _LA_UI_COLUMN_ADJUSTER = la_RegisterUiType("LA_column_adjuster_default", 0, "LA_column_adjuster",
- &_LA_THEME_BUTTON, la_ColumnAdjusterDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
- _LA_UI_COLUMN_ADJUSTER->TargetSub = "ui_column";
- LA_WIDGET_COLUMN_VIEWER->Type=
- _LA_UI_COLUMN_VIEWER = la_RegisterUiType("LA_column_viewer_default", 0, 0,
- &_LA_THEME_BUTTON, la_ColumnViewerDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
- _LA_UI_COLUMN_VIEWER->TargetSub = "ui_column";
- _LA_UI_COLUMN_VIEWER->GetMinWidth = la_ColumnViewerGetMinWidth;
- _LA_UI_CONDITION_ELSE.Theme = &_LA_THEME_BUTTON;
- la_UDFAppendSharedTypePointer("LA_condition_else", &_LA_UI_CONDITION_ELSE);
- _LA_UI_CONDITION.Destroy = _LA_UI_CONDITION_ELSE.Destroy = _LA_UI_CONDITION_END.Destroy =la_ConditionUiDestroy;
- _LA_UI_CONDITION.Theme = &_LA_THEME_BUTTON;
- la_UDFAppendSharedTypePointer("LA_condition", &_LA_UI_CONDITION);
- _LA_UI_CONDITION_END.Theme = &_LA_THEME_BUTTON;
- la_UDFAppendSharedTypePointer("LA_condition_end", &_LA_UI_CONDITION_END);
- LA_WIDGET_SYMBOL->Type=
- _LA_UI_SYMBOL = la_RegisterUiType("LA_symbol_default", 0, 0, &_LA_THEME_BUTTON, la_SymbolDraw, la_SymbolGetHeight, 0, 0);
- LA_WIDGET_NODE_SOCKET->Type=
- _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);
- _LA_UI_NODE_SOCKET->GetMinWidth=la_SocketGetMinWidth;
-
- LA_WIDGET_HEIGHT_ADJUSTER->Type=
- _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);
- _LA_UI_HEIGHT_ADJUSTER->ForType = LA_PROP_INT;
- LA_WIDGET_RAW->Type=
- _LA_UI_RAW = la_RegisterUiType("LA_raw_prop_default", 0, 0, &_LA_THEME_COLLECTION_GROUP, la_RawPropDraw, 0, 0, 0);
- _LA_UI_RAW->ForType = LA_PROP_RAW;
- LA_WIDGET_MAPPER->Type=
- _LA_UI_MAPPER = la_RegisterUiType("LA_mapper_default", 0, "LA_value_mapper", &_LA_THEME_COLLECTION_GROUP, la_MapperDraw, la_ColorPickerGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
- LA_WIDGET_IMAGE->Type=
- _LA_UI_IMAGE = la_RegisterUiType("LA_image_default", 0, 0, &_LA_THEME_COLLECTION_GROUP, la_ImageDraw, la_ImageGetHeight, la_ImageUiInit, la_ImageUiDestroy);
- _LA_UI_IMAGE->GetMinWidth=la_ImageGetMinWidth;
- LA_WIDGET_SCOPE->Type=
- _LA_UI_SCOPE = la_RegisterUiType("LA_scope_default", 0, "LA_synth_scope", &_LA_THEME_BUTTON, la_ScopeDraw, la_ColorPickerGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
- _LA_UI_INVISIBLE.Theme=&_LA_THEME_BUTTON;
- _LA_UI_ROW_BEGIN.Theme=&_LA_THEME_BUTTON;
- _LA_UI_ROW_END.Theme=&_LA_THEME_BUTTON;
- }
- // ============================================================ [Operators]
- void la_DefaultEnumPanel(laUiList *uil, laPropPack *This, laPropPack *OperatorProps, laColumn *UNUSED){
- laColumn *c = laFirstColumn(uil);
- laShowItem(uil, c, This, 0)->Flags=(LA_UI_FLAGS_TRANSPOSE|LA_UI_FLAGS_EXPAND);
- }
- int la_DetectRow(laUiItem *ui, int LocalY){
- return (LocalY - ui->U) / LA_RH;
- }
- int la_DetectColumn(laUiItem *ui, int LocalX, int Total){
- return (int)((real)(LocalX - ui->L) / (real)(ui->R - ui->L) * (real)Total);
- }
- laColumn *la_DetectSplit(laColumn *Root, int LocalX){
- laColumn *result = 0;
- if (!Root->LS) return 0;
- if (LocalX - Root->LS->IR < LA_SCROLL_W && Root->LS->IR - LocalX < LA_SCROLL_W &&
- !Root->LS->MaxW && !Root->RS->MaxW){
- return Root;
- }
- result = la_DetectSplit(Root->LS, LocalX);
- if (result) return result;
- else
- return la_DetectSplit(Root->RS, LocalX);
- }
- void la_AdjustColumnSplit(laColumn *c, int PxLeftPositive){
- if (!c->LS || c->LS->MaxW || c->RS->MaxW) return;
- if (PxLeftPositive < 0 && c->LS->IR - c->LS->IL <= LA_SCROLL_W*2) return;
- if (PxLeftPositive > 0 && c->RS->IR - c->RS->IL <= LA_SCROLL_W*2) return;
- c->LS->IR += PxLeftPositive;
- c->RS->IL += PxLeftPositive;
- c->LS->SP = (real)(c->LS->IR - c->LS->IL) / (real)(c->IR - c->IL);
- c->RS->SP = c->LS->SP;
- }
- int OPCHK_EditStringCopySelection(laPropPack *This, laStringSplitor *Instructions){
- laGeneralUiExtraData *uit = This->EndInstance; if(!uit) return 0;
- if(!uit->Edit || !strHasSelection(uit->Edit)) return 0;
- return 1;
- }
- int OPINV_EditStringCopySelection(laOperator *a, laEvent *e){
- laGeneralUiExtraData *uit = a->This->EndInstance; if(!uit) return LA_FINISHED;
- if(!uit->Edit || !strHasSelection(uit->Edit)) return LA_FINISHED;
- char* mode=strGetArgumentString(a->ExtraInstructionsP,"mode");
- char* str=strGetEditString(uit->Edit, 1);
- laCopyToClipboard(str); free(str);
- if(strSame(mode,"CUT")){ strClearSelection(&uit->Edit); }
- return LA_FINISHED;
- }
- int la_ProcessTextEdit(laEvent *e, laStringEdit *se, laUiItem* ui){
- int Select=e->SpecialKeyBit&LA_KEY_SHIFT;
- real _L, MonoWidth;
- switch (e->type){
- case LA_INPUT:
- switch (e->Input){
- case 0x08: if(strHasSelection(se)) strClearSelection(se); else strBackspace(se); return 1;
- case 0x7f: if(strHasSelection(se)) strClearSelection(se); else { strMoveCursor(se,0,0); strBackspace(se); } return 1;
- case 0x09: strInsertChar(se, ' ');strInsertChar(se, ' ');strInsertChar(se, ' ');strInsertChar(se, ' '); return 1;
- case 0x1B: case 0x0D: return 0;
- default: strInsertChar(se, e->Input); return 1;
- }
- break;
- case LA_KEY_DOWN:
- switch (e->key){
- case LA_KEY_ENTER: strInsertChar(se, '\n'); return 1;
- case LA_KEY_ARRLEFT: strMoveCursor(se, 1, Select); return 1;
- case LA_KEY_ARRRIGHT: strMoveCursor(se, 0, Select); return 1;
- case LA_KEY_ARRUP: strMoveCursorLine(se, 1, Select); return 1;
- case LA_KEY_ARRDOWN: strMoveCursorLine(se, 0, Select); return 1;
- #ifdef LAGUI_ANDROID
- case LA_KEY_BACKSPACE: if(strHasSelection(se)) strClearSelection(se); else strBackspace(se); return 1;
- #endif
- }
- break;
- case LA_L_MOUSE_DOWN:
- case LA_MOUSEMOVE:
- if(!ui) return 0;
- MonoWidth=tnsGetMonoFontAdvance(); _L=(*ui->Type->Theme)->LM*2+ui->L;
- int Count=se->TotalLines; while(Count){ Count/=10; _L+=MonoWidth; }
- if(e->type==LA_L_MOUSE_DOWN){
- strSetCursor(se, (e->y-ui->U)/LA_RH+se->ViewStartLine, (real)se->ViewStartCol+((real)e->x-_L)/MonoWidth+0.5); strCancelSelect(se); strLazySelect(se);
- se->MouseSelecting=1; se->CursorPreferBefore=se->CursorBefore; return 1;
- }else{
- if(!se->MouseSelecting) return 0;
- strSetCursor(se, (e->y-ui->U)/LA_RH+se->ViewStartLine, (real)se->ViewStartCol+((real)e->x-_L)/MonoWidth+0.5); strEndSelect(se);
- se->CursorPreferBefore=se->CursorBefore; return 1;
- }return 0;
- case LA_L_MOUSE_UP:
- se->MouseSelecting=0;
- }
- return 0;
- }
- int OPINV_UiItem(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- a->CustomData = ui->Extra;
- return LA_RUNNING;
- }
- int OPINV_Tab(laOperator *a, laEvent *e){
- laUiList *uil;
- laUiItem *ui = a->Instance;
- laGeneralUiExtraData *uit;
- int count = 0;
- //if (e->Type == LA_L_MOUSE_DOWN) {
- //}
- a->CustomData = ui->Extra;
- uit = a->CustomData;
- uit->TargetIndexVali = count;
- return LA_RUNNING;
- }
- int OPEXT_UiItem(laOperator *a, int ExitCode){
- laUiItem *ui = a->Instance;
- return 0;
- }
- int OPMOD_IntArrayHorizon(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- laIntProp *ip = ui->PP.LastPs->p;
- int Away = 0;
- int TmpArr[32];
- int Len = laGetArrayLength(&ui->PP);
- int IsVertical=(ui->Flags&LA_UI_FLAGS_TRANSPOSE)!=0;
- int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
- int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
- int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER || ui->Flags&LA_UI_FLAGS_VALUE_METER;
- if (!laIsInUiItem(ui, e->x, e->y) && !ui->Extra->On){
- ui->State = LA_UI_NORMAL;
- if (ui->Extra) ui->Extra->On = 0;
- laRedrawCurrentPanel();
- return LA_FINISHED_PASS;
- }
- if (e->type == LA_TIME_IDLE && !uit->On && !uit->Edit && !NoTooltip){
- int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
- return LA_RUNNING;
- }
- if(NoEvent){ return LA_RUNNING_PASS; }
- if (e->type == LA_L_MOUSE_DOWN){
- if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
- if (uit->Edit){
- if (!laIsInUiItem(ui, e->x, e->y)){
- strEndEdit(&uit->Edit, 1);
- uit->On = 0;
- laRedrawCurrentPanel(); la_DisplayKeyboard(0);
- return LA_FINISHED;
- }
- if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
- else strSelectLineAll(uit->Edit); la_DisplayKeyboard(1);
- return LA_RUNNING;
- }
- uit->LastX = e->x;
- uit->LastY = e->y;
- ui->Extra->On = (IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
- if (ui->Extra->On > Len) return LA_RUNNING;
- laGetIntArray(&ui->PP, &TmpArr);
- uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
- laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- if (e->type == LA_MOUSEMOVE && ui->Extra->On){
- if(ui->Extra->Edit){ return LA_RUNNING; }
- int dist=abs(e->x - uit->LastX + uit->LastY - e->y);
- if (dist > MAIN.ValuatorThreshold || uit->Dragging){
- int min,max,Ranged = laGetIntRange(&ui->PP, &min, &max); real step=ip->Step; if(Ranged&&!IsKnob){ step=(real)(max-min)/(ui->R-ui->L); }
- if(Ranged){ TNS_CLAMP(step,(max-min)/500,INT_MAX); }
- //laGetIntArray(&ui->PP, &TmpArr);
- //uit->TargetIndexVali = TmpArr[ui->Extra->On - 1];
- int delta=e->x-uit->LastX; if(IsKnob){ int dy=uit->LastY-e->y; delta=delta+dy; } if(!uit->Dragging) delta=delta>0?1:-1;
- uit->TargetIndexValf += delta*step;
- laSetIntArraySingle(&ui->PP, ui->Extra->On - 1, uit->TargetIndexValf);
- uit->LastX = e->x;
- uit->LastY = e->y;
- uit->Dragging = 1;
- laRedrawCurrentPanel();
- }
- return LA_RUNNING;
- }
- if (e->type == LA_L_MOUSE_UP){
- if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
- if (uit->Dragging){
- if (ui->Extra->On){
- ui->Extra->On = 0;
- laConfirmInt(a, uit->TargetIndexVali, LA_CONFIRM_DATA);
- laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- }
- }else if(ui->Extra->On){
- int SelectOn=(IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
- if ((!uit->Edit) || (uit->Edit && (SelectOn != ui->Extra->On))){
- char buf[32] = {0};
- uit->On=SelectOn;
- laGetIntArray(&ui->PP, &TmpArr);
- uit->TargetIndexVali = TmpArr[ui->Extra->On - 1];
- strPrintIntAfter(buf, 32, uit->TargetIndexVali);
- strBeginEdit(&uit->Edit,buf);
- strSelectLineAll(uit->Edit); la_DisplayKeyboard(1);
- }
- }
- uit->Dragging = 0;
- laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- if(e->type ==LA_KEY_DOWN){
- if (e->key == LA_KEY_ENTER && uit->Edit){
- char* buf=strEndEdit(&uit->Edit, 0);
- int Result; sscanf(buf, "%d", &Result); free(buf);
- laSetIntArraySingle(&ui->PP, ui->Extra->On - 1, Result);
- laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- ui->State = LA_UI_NORMAL;
- uit->Dragging = 0;
- uit->On = 0;
- laRedrawCurrentPanel();
- return LA_FINISHED_PASS;
- }
- }
-
- if (e->type == LA_R_MOUSE_DOWN){
- int GX = e->x, GY = e->y;
- ui->PP.LastIndex = la_DetectColumn(ui, e->x, Len);
- laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
- return LA_RUNNING;
- }
- if (uit->Edit){
- if (la_ProcessTextEdit(e, uit->Edit, ui)) laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- return LA_RUNNING_PASS;
- }
- int OPMOD_FloatArrayHorizon(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- laFloatProp *fp = ui->PP.LastPs->p;
- int Away = 0;
- real TmpArr[32];
- int Len = laGetArrayLength(&ui->PP);
- int IsVertical=(ui->Flags&LA_UI_FLAGS_TRANSPOSE)!=0;
- int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
- int IsRad=ui->PP.LastPs->p->IsRadAngle;
- int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
- int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER || ui->Flags&LA_UI_FLAGS_VALUE_METER;
- if (!laIsInUiItem(ui, e->x, e->y) && !ui->Extra->On && !NoTooltip){
- ui->State = LA_UI_NORMAL;
- ui->Extra->On = 0;
- laRedrawCurrentPanel();
- return LA_FINISHED_PASS;
- }
- if (e->type == LA_TIME_IDLE && !uit->On && !uit->Edit){
- int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
- return LA_RUNNING;
- }
- if(NoEvent){ return LA_RUNNING_PASS; }
- if (e->type == LA_L_MOUSE_DOWN){
- if (uit->Edit){
- if (!laIsInUiItem(ui, e->x, e->y)){
- strEndEdit(&uit->Edit, 1);
- uit->On = 0;
- laRedrawCurrentPanel(); la_DisplayKeyboard(0);
- return LA_FINISHED;
- }
- if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
- else strSelectLineAll(uit->Edit); la_DisplayKeyboard(1);
- return LA_RUNNING;
- }
- if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
- uit->LastX = e->x;
- uit->LastY = e->y;
- ui->Extra->On = (IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
- if (ui->Extra->On > Len) return LA_RUNNING;
- laGetFloatArray(&ui->PP, &TmpArr);
- uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
- laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- if (e->type == LA_MOUSEMOVE && ui->Extra->On){
- if(uit->Edit){ return LA_RUNNING; }
- int dist=abs(e->x - uit->LastX - e->y + uit->LastY);
- if (dist > MAIN.ValuatorThreshold || uit->Dragging){
- real min,max; int Ranged = laGetFloatRange(&ui->PP, &min, &max); real step=fp->Step; if(Ranged&&!IsKnob){ step=(max-min)/(ui->R-ui->L); }
- if(Ranged){ TNS_CLAMP(step,(max-min)/500,INT_MAX); }
- laGetFloatArray(&ui->PP, &TmpArr);
- uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
- int delta=e->x-uit->LastX; if(IsKnob){ int dy=uit->LastY-e->y; delta=delta+dy; } if(!uit->Dragging) delta=delta>0?1:-1;
- uit->TargetIndexValf += delta*step;
- laSetFloatArraySingle(&ui->PP, ui->Extra->On - 1, uit->TargetIndexValf);
- uit->LastX = e->x;
- uit->LastY = e->y;
- uit->Dragging = 1;
- laRedrawCurrentPanel();
- }
- return LA_RUNNING;
- }
- if (e->type == LA_L_MOUSE_UP){
- if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
- if (uit->Dragging){
- if (ui->Extra->On){
- ui->Extra->On = 0;
- laConfirmFloat(a, uit->TargetIndexValf, LA_CONFIRM_DATA);
- laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- }
- }else if(ui->Extra->On){
- int SelectOn=(IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
- if ((!uit->Edit) || (uit->Edit && (SelectOn != ui->Extra->On))){
- char buf[32] = {0};
- uit->On=SelectOn;
- laGetFloatArray(&ui->PP, &TmpArr);
- uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
- strPrintFloatAfter(buf, 32, 5, IsRad?deg(uit->TargetIndexValf):uit->TargetIndexValf);
- strBeginEdit(&uit->Edit,buf);
- strSelectLineAll(uit->Edit); la_DisplayKeyboard(1);
- }
- }
- uit->Dragging = 0;
- laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- if(e->type ==LA_KEY_DOWN){
- if (e->key == LA_KEY_ENTER && uit->Edit){
- char* buf=strEndEdit(&uit->Edit, 0);
- real Result; sscanf(buf, "%lf", &Result); free(buf);
- if(IsRad) Result=rad(Result);
- laSetFloatArraySingle(&ui->PP, ui->Extra->On - 1, Result);
- laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- uit->Dragging = 0;
- uit->On = 0;
- laRedrawCurrentPanel();
- return LA_FINISHED_PASS;
- }
- }
- if (e->type == LA_R_MOUSE_DOWN){
- int GX = e->x, GY = e->y;
- ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
- laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
- return LA_RUNNING;
- }
- if (uit->Edit){
- if (la_ProcessTextEdit(e, uit->Edit, ui)) laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- return LA_RUNNING_PASS;
- }
- int OPMOD_FloatColor(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- int Away = 0;
- int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
- int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
- if (!laIsInUiItem(ui, e->x, e->y)){
- return LA_FINISHED_PASS;
- }
- if (e->type == LA_TIME_IDLE && !NoTooltip){
- int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
- return LA_RUNNING;
- }
-
- if(NoEvent){ return LA_RUNNING_PASS; }
- if (e->type == LA_L_MOUSE_DOWN){
- laUiList *uil;
- laColumn *col;
- laPanel *p;
- int GX = ui->L, GY = ui->B;
- ui->State = LA_UI_ACTIVE;
- laLocalToWindow(a, a->ToPanel, &GX, &GY);
- p = laEnableEmptyPropertyPanel(a->ToPanel, a, GX, GX + 150, GY, 500, e);{
- uil = &p->UI;
- col = laFirstColumn(uil);
- laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_FLOAT_COLOR_HCY, 0, 0, 0);
- laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_FLOAT, 0, 0, 0)->Flags=LA_UI_FLAGS_TRANSPOSE;
- laEnclosePanelContent(p, uil);
- }
- return LA_RUNNING;
- }
- if (e->type == LA_R_MOUSE_DOWN){
- int GX = e->x, GY = e->y;
- laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
- return LA_RUNNING;
- }
- return LA_RUNNING_PASS;
- }
- int OPMOD_ColorHCY(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *es = a->CustomData;
- int Away = 0;
- int i = 0;
- real hcy[3] = {0};
- real Color[4] = {0};
- real PickerPos[2];
- real abso;
- if (!laIsInUiItem(ui, e->x, e->y) && !es->Dragging){
- return LA_FINISHED_PASS;
- }
- 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){
- es->Dragging=3; es->LastX=e->x; es->LastY=e->y; es->TargetIndexVali=es->HeightCoeff; return LA_RUNNING;
- }
- if(es->Dragging==3){
- if(e->type==LA_MOUSEMOVE){ es->HeightCoeff=es->TargetIndexVali+((real)e->y-es->LastY+0.5)/LA_RH;
- if(es->HeightCoeff<1)es->HeightCoeff=1; laRecalcCurrentPanel();}
- elif(e->type==LA_L_MOUSE_UP){ es->Dragging=0; }
- elif(e->type==LA_R_MOUSE_DOWN){
- es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel(); }
- return LA_RUNNING;
- }
- real c = (real)((ui->R + ui->L) / 2) - LA_RH / 2; /*- bt->RM;*/
- real r = (ui->B - ui->U - bt->TP - bt->BP) / 2;
- real dx = e->x - c, dy = e->y - (ui->U + r + bt->TP);
- real dist = sqrt(dx * dx + dy * dy);
- if (e->type == LA_L_MOUSE_DOWN){ ui->State = LA_UI_ACTIVE; laRedrawCurrentPanel(); es->Dragging=(dist<=r)?1:2; }
- if (e->type == LA_L_MOUSE_UP){
- ui->State = LA_UI_NORMAL; es->Dragging=0; laRedrawCurrentPanel();
- laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- return LA_RUNNING_PASS;
- }
- if (e->type & LA_MOUSE_EVENT && es->Dragging){
- laGetFloatArray(&ui->PP, Color);
- if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LogsRGB(Color); }
- tnsRGB2HCY(Color, hcy);
- if (es->Dragging==1){
- abso = fabs(atan((real)dy / (real)dx));
- hcy[0] = abso / TNS_PI / 2;
- if (dx > 0){
- if (dy < 0) hcy[0] = 1 - hcy[0];
- }else{
- if (dy > 0){
- hcy[0] = 0.5 - hcy[0];
- }else{
- hcy[0] += 0.5;
- }
- }
- hcy[1] = dist / r; TNS_CLAMP(hcy[1],0,1);
- hcy[1]=pow(hcy[1],MAIN.ColorPickerGamma);
- }else if (dist < r + LA_RH * 2 && dx > 0){
- abso = -atan((real)dy / (real)dx) / TNS_PI * 2 + 0.5;
- hcy[2] = abso; TNS_CLAMP(hcy[2],0,1);
- }
- tnsHCY2RGB(hcy, Color);
- if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LinearsRGB(Color); }
- laSetFloatArrayAllArray(&ui->PP, Color);
- laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- return LA_RUNNING_PASS;
- }
- int OPMOD_EnumSelector(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- laEnumItem *ei;
- laEnumProp *ep = ui->PP.LastPs->p;
- int at = 0;
- laEnumItem *Data[32];
- int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
- int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
- int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
- int IsMomentary = IsCycle && ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
- int NoConfirm = ui->Flags&LA_UI_FLAGS_NO_CONFIRM;
- // norm e1
- // expand e1 e2 e3
- // expand vertical (vertical)
- // arr expand e1 e1 e3
- // e2 e2 e3
- // arr exp+vert e1 e1
- // e2 e2
- // e3 e3
- if (a->ConfirmData /* && a->ConfirmData->Mode == LA_CONFIRM_DATA*/){
- ui->State = LA_UI_NORMAL;
- laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- if (!laIsInUiItem(ui, e->x, e->y) && !uit->On){ return LA_FINISHED_PASS; }
-
- if (e->type == LA_TIME_IDLE && !NoTooltip && !uit->On){
- int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
- return LA_RUNNING;
- }
- if(NoEvent){ return LA_RUNNING_PASS; }
- if (e->type == LA_L_MOUSE_DOWN || (IsMomentary && e->type == LA_L_MOUSE_UP)){
- if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
- int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
- int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
- int ArrLen = laGetArrayLength(&ui->PP);
- if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
- int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
- int _L,_R,_U,_B, _W=ui->R - ui->L, _Col=1;
- if(IsVertical){
- if(IsExpand){ _Col=ArrLen; }
- }else{
- if(IsExpand){ _Col=EnumLen; } else { _Col=ArrLen; }
- }
- int row = la_DetectRow(ui, e->y);
- int col = la_DetectColumn(ui, e->x, _Col);
- int ArrTarget=0, EnumTarget=0, ShowMenu=0;
- if(IsVertical){
- if(IsExpand){ EnumTarget=row; ArrTarget=col; } else { EnumTarget=col; }
- }else{
- if(IsExpand){ EnumTarget=col; ArrTarget=row; } else { if(!IsCycle) ShowMenu=1; }
- }
- if(ShowMenu){
- int GX = ui->L, GY = ui->B, GR = ui->R, t = 0;
- ui->State = LA_UI_ACTIVE;
- laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laLocalToWindow(a, a->ToPanel, &GR, &t);
- laEnablePropertyPanel(a->ToPanel, a, 0, la_DefaultEnumPanel, 0, &ui->PP, GX, GR, GY, MAIN.CurrentWindow->CH-LA_2RH, 0, e);
- laRedrawCurrentPanel();
- }elif(IsCycle){
- laEnumItem* ei=laGetEnumArrayIndexed(&ui->PP, ArrTarget);
- if(!ei){ ei=((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst; }
- ei = ei->Item.pNext?ei->Item.pNext:((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst;
- if(IsMomentary){ uit->On = 1; if(e->type==LA_L_MOUSE_UP){ ei = ei=((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst; uit->On = 0;} }
- laSetEnumArrayIndexed(&ui->PP, ArrTarget, ei->Index);
- if(!NoConfirm){ laConfirmInt(a,EnumTarget,LA_CONFIRM_DATA); }
- laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- if(ui->Flags&LA_UI_FLAGS_EXIT_WHEN_TRIGGERED) return LA_FINISHED;
- }else{
- if(ArrTarget>=ArrLen){ArrTarget=ArrLen-1;}
- if(EnumTarget>=EnumLen){EnumTarget=EnumLen-1;}
- laSetEnumArrayIndexedExternal(&ui->PP, ArrTarget, EnumTarget);
- if(!NoConfirm){ laConfirmInt(a,EnumTarget,LA_CONFIRM_DATA); }
- laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- return LA_RUNNING_PASS;
- }
- return LA_RUNNING;
- }
- if(e->type==LA_R_MOUSE_DOWN){
- int GX = e->x, GY = e->y;
- laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
- return LA_RUNNING;
- }
- return LA_RUNNING_PASS;
- }
- int OPMOD_Button(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- int lx, ly;
- int Away = 0;
- if (e->type == LA_TIME_IDLE && !ui->State){
- int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laPanel *p = laEnableIdlePanel(a->ToPanel, a, &ui->ExtraPP, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
- return LA_RUNNING;
- }
-
- if (laConfirmSameDataIfAny(a)) return LA_RUNNING_PASS;
- if (e->type == LA_ESCAPE_DOWN || e->type == LA_INPUT) return LA_FINISHED; //debug
- if (!laIsInUiItem(ui, e->x, e->y) /*&& ui->State!= LA_UI_ACTIVE*/){
- ui->State = LA_UI_NORMAL;
- laRedrawCurrentPanel();
- return LA_FINISHED_PASS;
- }
- if (e->type == LA_L_MOUSE_DOWN){
- ui->State = LA_UI_ACTIVE;
- laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- char *str;
- int call_ret=0;
- if (e->type == LA_L_MOUSE_UP && ui->State!=LA_UI_NORMAL){
- ui->State = LA_UI_NORMAL;
- if (ui->AT){
- if (!ui->Instructions){
- if (ui->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
- if (ui->AT->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->AT->ExtraInstructions);
- }
- if (!laOperatorAvailableP(ui->AT, 0, ui->Instructions)) return LA_RUNNING;
- lx = e->x;
- ly = e->y;
- laLocalToWindow(a, a->ToPanel, &e->x, &e->y);
- e->Localized = 0;
- call_ret=laInvokeP(0, ui->AT, e, 0, ui->ExtraInstructions ? ui->ExtraInstructions->Ptr : 0, 0);
- e->x = lx;
- e->y = ly;
- e->Localized = 1;
- }else{
- laOperatorProp *ap = ui->PP.LastPs->p;
- if (ap->OperatorID){
- if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
- if (!ui->Instructions){
- if (ui->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
- if (ap->OperatorType) strMakeInstructions(&ui->Instructions, ap->OperatorType->ExtraInstructions);
- }
- if (!laOperatorAvailablePSafe(ap->OperatorType, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->Instructions)) return LA_RUNNING;
- lx = e->x;
- ly = e->y;
- laLocalToWindow(a, a->ToPanel, &e->x, &e->y);
- e->Localized = 0;
- call_ret=laInvokePCreateThis(0, ap->OperatorType, e, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->ExtraInstructions ? ui->ExtraInstructions->Ptr : 0, ap->Base.ExtraInstructions);
- if(a->StopNow) return LA_FINISHED;
- laRetriggerOperators();
- e->x = lx;
- e->y = ly;
- e->Localized = 1;
- }
- }
- if(MAIN.InvokeConfirmData){
- a->ConfirmData=MAIN.InvokeConfirmData; laConfirmSameDataIfAny(a); a->ConfirmData=0;
- }else{
- if (str = strGetArgumentString(ui->Instructions, "feedback")){
- if (strSame(str, "CONFIRM")) laConfirmInt(a, 0, LA_CONFIRM_OK);
- elif (strSame(str, "CANCEL")) laConfirmInt(a, 0, LA_CONFIRM_CANCEL);
- else { laConfirmString(a, str, LA_CONFIRM_CUSTOM_STRING); }
- }elif(!(ui->Flags&LA_UI_FLAGS_NO_CONFIRM)){
- laConfirmInt(a, 0, LA_CONFIRM_OK);
- }
- }
- if(call_ret==LA_OPERATOR_CALLS_SHUTOFF) return LA_OPERATOR_CALLS_SHUTOFF;
- laRedrawCurrentPanel();
- if(ui->Flags&LA_UI_FLAGS_EXIT_WHEN_TRIGGERED) return LA_FINISHED_PASS;
- return LA_RUNNING_PASS;
- }
- return LA_RUNNING_PASS;
- }
- int OPMOD_MenuItem(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laPanel *p;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- int Away = 0;
- if (a->ConfirmData){
- ui->State = LA_UI_NORMAL;
- laConfirmInt(a, a->ConfirmData->IData, a->ConfirmData->Mode);
- laRedrawCurrentPanel();
- return LA_RUNNING_PASS;
- }
- if (!laIsInUiItem(ui, e->x, e->y) && ui->State != LA_UI_ACTIVE){
- ui->State = LA_UI_NORMAL;
- laRedrawCurrentPanel();
- return LA_FINISHED_PASS;
- }
- if (e->type == LA_L_MOUSE_DOWN){
- int GX = ui->L, GY = ui->B;
- laLocalToWindow(a, a->ToPanel, &GX, &GY);
- ui->State = LA_UI_ACTIVE;
- p = laEnableMenuPanel(a->ToPanel, a, ui->Subs.pFirst, &ui->PP, GX, GX + 300, GY, MAIN.CurrentWindow->CH-LA_2RH, 0, e);
- p->NoConfirm = (ui->Flags&LA_UI_FLAGS_NO_CONFIRM)!=0;
- laShowPanelWithDropDownEffect(p);
- laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- return LA_RUNNING_PASS;
- }
- int OPMOD_ConditionToggle(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- int Away = 0;
- if (!laIsInUiItem(ui, e->x, e->y) /*&& ui->State!= LA_UI_ACTIVE*/){
- return LA_FINISHED_PASS;
- }
- if (e->type == LA_L_MOUSE_DOWN){
- ui->State = ui->State == LA_UI_ACTIVE ? LA_UI_NORMAL : LA_UI_ACTIVE;
- laRecalcCurrentPanel();
- return LA_RUNNING;
- }
- return LA_RUNNING_PASS;
- }
- int OPMOD_SingleLineString(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- laStringEdit *se = uit->Edit;
- int Away = 0;
- char _buf[LA_RAW_CSTR_MAX_LEN] = {0}; char* buf=_buf;
- int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
- int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
- int IsTerminal=ui->Flags&LA_UI_FLAGS_TERMINAL_INPUT;
- int ImmediateInput=ui->Flags&LA_UI_FLAGS_IMMEDIATE_INPUT;
- if (!laIsInUiItem(ui, e->x, e->y)){
- if (ui->State != LA_UI_EDITING){
- ui->State = LA_UI_NORMAL;
- laRedrawCurrentPanel();
- return LA_FINISHED_PASS;
- }else{
- if(IsTerminal && (e->type&LA_KEY_MOUSE_SCROLL)){ return LA_RUNNING_PASS; }
- if ((e->type & LA_MOUSEDOWN) == LA_MOUSEDOWN){
- buf=strEndEdit(&uit->Edit, 0);
- laSetString(&ui->PP, buf); free(buf);
- laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- ui->State = LA_UI_NORMAL; la_DisplayKeyboard(0);
- laRedrawCurrentPanel();
- return LA_FINISHED_PASS;
- }
- }
- }
- if (e->type == LA_TIME_IDLE && !ui->State && !NoTooltip){
- int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
- return LA_RUNNING;
- }
-
- if(NoEvent){ return LA_RUNNING_PASS; }
- if(e->type ==LA_KEY_DOWN){
- if (e->key == LA_KEY_ENTER){
- buf=IsTerminal?strGetEditString(uit->Edit,0):strEndEdit(&uit->Edit, 0);
- if(IsTerminal){ MAIN.IsTerminalEnter=1; }
- laSetString(&ui->PP, buf); free(buf);
- laRedrawCurrentPanel();
- if(!IsTerminal){
- laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- ui->State = LA_UI_NORMAL; la_DisplayKeyboard(0);
- return LA_FINISHED_PASS;
- }else{
- laGetString(&ui->PP, _buf, &buf);
- strBeginEdit(&uit->Edit,buf); la_DisplayKeyboard(1);
- MAIN.IsTerminalEnter=0;
- return LA_RUNNING;
- }
- }else if (e->key == LA_KEY_ESCAPE && ui->State != LA_UI_NORMAL){
- ui->State = LA_UI_NORMAL; la_DisplayKeyboard(0);
- laRedrawCurrentPanel();
- return LA_FINISHED;
- }
- }
- if(laKeyMapExecuteEventEx(a, &ui->ExtraPP, &ui->Type->KeyMapper, e)) return LA_RUNNING;
- if (e->type == LA_L_MOUSE_DOWN){
- if (ui->State == LA_UI_NORMAL){
- if(laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING;
- ui->State = LA_UI_EDITING;
- laGetString(&ui->PP, _buf, &buf);
- strBeginEdit(&uit->Edit,buf); la_DisplayKeyboard(1);
- strSelectLineAll(uit->Edit);
- }elif (ui->State == LA_UI_EDITING){
- if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
- else strSelectLineAll(uit->Edit);
- }
- laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- if (e->type == LA_R_MOUSE_DOWN){
- int GX = e->x, GY = e->y;
- ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
- laLocalToWindow(a, a->ToPanel, &GX, &GY);
- 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);
- return LA_RUNNING;
- }
- if (ui->State == LA_UI_EDITING){
- if (la_ProcessTextEdit(e, se, ui)){
- laRedrawCurrentPanel();
- if(ImmediateInput){
- buf=strGetEditString(uit->Edit,0); laSetString(&ui->PP, buf); free(buf);
- }
- }
- return LA_RUNNING;
- }
- if (ui->State != LA_UI_EDITING) return LA_RUNNING_PASS;
- else return LA_RUNNING;
- }
- void la_SetMultistringViewRange(laUiItem* ui, laStringEdit* se, laBoxedTheme* bt){
- int NumberWidth=0; int MonoWidth=tnsGetMonoFontAdvance(); int Count=se->TotalLines;
- while(Count){ Count/=10; NumberWidth+=MonoWidth; }
- strSetEditViewRange(ui->Extra->Edit,
- ui->Extra->HeightCoeff>0?ui->Extra->HeightCoeff:((ui->B-ui->U)/LA_RH),(ui->R-ui->L-NumberWidth-bt->LM*2-bt->RM)/MonoWidth);
- }
- int OPMOD_MultiString(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *es = a->CustomData;
- laStringEdit *se = es->Edit;
- int Away = 0;
- char _buf[LA_RAW_CSTR_MAX_LEN] = {0}; char* buf=&_buf;
- int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
- int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
- if (!laIsInUiItem(ui, e->x, e->y) && !es->Dragging){
- if ((e->type & LA_MOUSEDOWN) == LA_MOUSEDOWN){
- buf=strGetEditString(es->Edit, 0); laSetString(&ui->PP, buf); free(buf);
- laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- ui->State = LA_UI_NORMAL;
- laRedrawCurrentPanel();
- return LA_FINISHED_PASS;
- }
- if(ui->State!=LA_UI_ACTIVE) return LA_FINISHED_PASS;
- }
- if (e->type == LA_TIME_IDLE && ui->State!=LA_UI_ACTIVE && !NoTooltip){
- int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
- return LA_RUNNING;
- }
- if(NoEvent){ return LA_RUNNING_PASS; }
- if(e->type ==LA_KEY_DOWN){
- if (e->key == LA_KEY_ESCAPE){
- if(ui->State != LA_UI_NORMAL){
- buf=strGetEditString(es->Edit, 0); laSetString(&ui->PP, buf); free(buf);
- laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- ui->State = LA_UI_NORMAL; laRedrawCurrentPanel();la_SetMultistringViewRange(ui,es->Edit,bt);
- }
- if(es->Dragging){ es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel();la_SetMultistringViewRange(ui,es->Edit,bt); }
- return LA_FINISHED;
- }
- }
- if(laKeyMapExecuteEventEx(a, &ui->ExtraPP, &ui->Type->KeyMapper, e)) return LA_RUNNING;
-
- 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){
- es->Dragging=1; es->LastX=e->x; es->LastY=e->y; es->TargetIndexVali=es->HeightCoeff;
- return LA_RUNNING;
- }
- if(es->Dragging){
- if(e->type==LA_MOUSEMOVE){ es->HeightCoeff=es->TargetIndexVali+((real)e->y-es->LastY+0.5)/LA_RH;
- if(es->HeightCoeff<1)es->HeightCoeff=1; laRecalcCurrentPanel(); la_SetMultistringViewRange(ui,es->Edit,bt);}
- elif(e->type==LA_L_MOUSE_UP){ es->Dragging=0; }
- elif(e->type==LA_R_MOUSE_DOWN){
- es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel();la_SetMultistringViewRange(ui,se,bt); }
- return LA_RUNNING;
- }
-
- int NoInactiveScroll=ui->Flags&LA_UI_FLAGS_NO_SCROLL_INACTIVE;
- if((!NoInactiveScroll) || (ui->State==LA_UI_ACTIVE)){
- if(e->type==LA_MOUSE_WHEEL_DOWN){ strMoveView(se, MAIN.ScrollingSpeed, 0); laRedrawCurrentPanel(); return LA_RUNNING; }
- elif(e->type==LA_MOUSE_WHEEL_UP){ strMoveView(se, -MAIN.ScrollingSpeed, 0); laRedrawCurrentPanel(); return LA_RUNNING; }
- }
- if (e->type == LA_L_MOUSE_DOWN){
- if (ui->State == LA_UI_NORMAL){
- ui->State = LA_UI_ACTIVE;
- laGetString(&ui->PP, _buf, &buf);
- strBeginEdit(&es->Edit,buf);la_SetMultistringViewRange(ui,es->Edit,bt);
- laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- }
- if (e->type == LA_R_MOUSE_DOWN){
- int GX = e->x, GY = e->y;
- ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
- laLocalToWindow(a, a->ToPanel, &GX, &GY);
- 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);
- return LA_RUNNING;
- }
- if (ui->State == LA_UI_ACTIVE){
- if (la_ProcessTextEdit(e, se, ui))laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- if (ui->State != LA_UI_ACTIVE) return LA_RUNNING_PASS;
- else return LA_RUNNING;
- }
- int OPMOD_TabSelector(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- laUiList *uil;
- int Away = 0;
- int count = 0;
- int it = 0;
- int page;
- if (!laIsInBound(e->x, e->y, ui->L, ui->R, ui->U, ui->U+LA_RH)){ return LA_FINISHED; }
- if (e->type == LA_L_MOUSE_DOWN){
- if (ui->Page->HeightCoeff && ui->R - e->x < LA_RH + bt->RM) return LA_RUNNING_PASS;
- for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){ count++; }
- page = la_DetectColumn(ui, e->x, count);
- for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
- if (it == page){
- laRecalcCurrentPanel();
- ui->Page = uil;
- return LA_RUNNING;
- }else
- it++;
- }
- }
-
- return LA_RUNNING_PASS;
- }
- int OPMOD_Collection(laOperator *a, laEvent *e) {
- laUiItem *ui = a->Instance;
- laGeneralUiExtraData *uit = a->CustomData;
- laListHandle Locals = {0};
- laUiList *uil;
- int lx = e->x, ly = e->y;
- int at = 0;
- laUiList *ToUil =
- a->ToPanel->MenuRefer ? a->ToPanel->MenuRefer : &a->ToPanel->UI;
- if (!laIsInUiItem(ui, e->x, e->y) /* || e->y>(ui->Subs.pFirst?((laUiList*)ui->Subs.pFirst)->HeightCoeff:10000)*/){
- return LA_FINISHED_PASS;
- }
- laLocalToPanel(a, &lx, &ly);
- if (a->ToPanel && ui->U>=a->ToPanel->TitleBar.B && ly < a->ToPanel->TitleBar.B) {
- return LA_FINISHED_PASS;
- }
- uil = la_DetectUiListRecursive(ToUil, lx, ly, 10000, 0, 0, 0, 0, 0);
- if (uil != ((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target) {
- //printf("%d %d EXITC\n",((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target, uil);
- return LA_FINISHED;
- }
- if (e->type & LA_MOUSE_EVENT) {
- laUiList *sub;
- laUiItem *tui;
- int LimHeight = 10000;
- int UIB = ui->B, UIU = ui->U;
- int t = 0;
- void *Active = ui->PP.EndInstance;
- if (ui->Subs.pFirst)
- LimHeight = (int)((laUiList *)ui->Subs.pFirst)->HeightCoeff;
- if (LimHeight > 0)
- UIB = LimHeight;
- laPanelToLocal(a, &t, &UIB);
- for (sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext) {
- ui->PP.EndInstance = sub->Instance;
- if ((tui = la_DetectUiItemRecursive(sub, e->x, e->y, UIB, &Locals, 0))) {
- if (tui && !a->Child && tui->Type->OperatorType) {
- // printf("invui %d\n", tui);
- laSetOperatorLocalizer(a->ToPanel);
- laInvokeUiP(a, tui->Type->OperatorType, e, tui, &Locals, 0);
- }
- }
- lstClearPointer(&Locals);
- }
- ui->PP.EndInstance = Active;
- }
- if (e->type == LA_L_MOUSE_DOWN && (!laIsPropertyReadOnly(&ui->PP)) &&
- ui->Type != _LA_UI_COLLECTION_SINGLE) {
- laUiList *uil;
- for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext) {
- if (a->ConfirmData)
- return LA_RUNNING_PASS;
- if (laIsInBound(e->x, e->y, uil->L, uil->R, uil->U, uil->B)) {
- laRecalcCurrentPanel();
- laPropPack PP = {0};
- la_CopyPropPack(
- &ui->PP,
- &PP); // needed because layout can be switched after set active.
- char *cmd;
- if ((!(ui->Flags&LA_UI_FLAGS_NO_CONFIRM)) &&
- ((!(cmd = strGetArgumentString(ui->Instructions, "feedback"))) ||
- (!strSame(cmd, "NONE")))) {
- laConfirmPointer(a, uil->Instance, la_EnsureSubTarget(ui->PP.LastPs->p, uil->Instance), LA_CONFIRM_DATA);
- }
- laSetActiveInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance,
- uil->Instance);
- laRecordAndPushProp(&PP, 0);
- laMarkPropChanged(&PP);
- return LA_RUNNING_PASS;
- }
- }
- return LA_RUNNING;
- }
- elif (e->type == LA_R_MOUSE_DOWN) {
- laUiList *uil;
- for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext) {
- if (laIsInBound(e->x, e->y, uil->L, uil->R, uil->U, uil->B)) {
- ui->PP.EndInstance = uil->Instance;
- lx = e->x, ly = e->y;
- laLocalToWindow(a, a->ToPanel, &lx, &ly);
- laEnablePropertyPanel(a->ToPanel, a, 0, 0, laui_PropOperatorUiDefine, &ui->PP,
- lx, lx, ly, 0, 0, e);
- }
- }
- return LA_RUNNING;
- }
- return LA_RUNNING_PASS;
- }
- int OPMOD_CollectionSelector(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
- int at = 0;
- int ReadOnly=laIsPropertyReadOnly(&ui->PP);
- int Simple=ui->Flags&LA_UI_COLLECTION_SIMPLE_SELECTOR;
- if (a->ConfirmData /* && a->ConfirmData->Mode == LA_CONFIRM_DATA*/){
- ui->State = LA_UI_NORMAL;
- laRecalcCurrentPanel();
- return LA_RUNNING;
- }
- if (!laIsInUiItem(ui, e->x, e->y)){
- return LA_FINISHED;
- }
- //int lx = e->x, ly = e->y;
- //laUiList *ToUil =
- // a->ToPanel->MenuRefer ? a->ToPanel->MenuRefer : &a->ToPanel->UI;
- //laUiList* uil = la_DetectUiListRecursive(ToUil, lx, ly, 10000, 0, 0, 0, 0, 0);
- //if (uil != ((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target) {
- // printf("%d %d EXIT\n",((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target, uil);
- // return LA_FINISHED;
- //}
- if (e->type == LA_TIME_IDLE && !ui->State && !NoTooltip){
- int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
- return LA_RUNNING;
- }
- if (e->type == LA_L_MOUSE_DOWN){
- laUiList *uil;
- laColumn *col;
- laPanel *p;
- int GX = ui->L, GY = ui->B, GR = ui->R, t = 0;
- if(ReadOnly){ return LA_FINISHED; }
- if(!Simple){
- if (e->x >= TNS_MAX2(ui->R - LA_RH,(ui->R+ui->L)/2) && e->x < ui->R){
- laSetActiveInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, 0);
- laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- return LA_FINISHED;
- }
- }
- laLocalToWindow(a, a->ToPanel, &GX, &GY);
- laLocalToWindow(a, a->ToPanel, &GR, &t);
- laRedrawCurrentPanel();
- ui->State = LA_UI_ACTIVE;
- p = laEnableEmptyPropertyPanel(a->ToPanel, a, GX, GR, GY, 500, e);{
- int MinWidth;
- uil = &p->UI;
- col = laFirstColumn(uil);
- laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_COLLECTION, 0, ui->Template, 0)->SymbolID = ui->SymbolID;
- laEnclosePanelContent(p, &p->UI);
- }
- return LA_RUNNING;
- }
- return LA_RUNNING_PASS;
- }
- int OPMOD_ColumnAdjuster(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- laColumn *c = uit->Ptr1;
- c = uit->Ptr1 ? uit->Ptr1 : la_DetectSplit(ui->C, e->x);
- if(c){ laSetWindowCursor(LA_LEFT_AND_RIGHT); }else{ laSetWindowCursor(LA_ARROW); }
- if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y)||!c)){
- //printf("done\n");
- laSetWindowCursor(LA_ARROW);
- return LA_FINISHED_PASS;
- }
- if (e->type == LA_L_MOUSE_DOWN){
- uit->Ptr1 = c;
- uit->LastX = e->x;
- uit->Dragging=1;
- return LA_RUNNING;
- }
- if (uit->Dragging && uit->Ptr1 && e->type == LA_MOUSEMOVE){
- la_AdjustColumnSplit(c, e->x - uit->LastX);
- uit->LastX = e->x;
- laRecalcCurrentPanel();
- return LA_RUNNING;
- }
- if (uit->Dragging && (e->type == LA_L_MOUSE_UP || e->type == LA_R_MOUSE_DOWN || e->key == LA_KEY_ESCAPE)){
- uit->Ptr1 = 0; uit->Dragging=0;
- return LA_RUNNING;
- }
- return LA_RUNNING;
- }
- void la_NodeSocketGetPositionDelta(laUiItem* ui, int ex,int ey,int* dx,int* dy){
- int cx,cy;
- if(ui->Flags&LA_UI_SOCKET_LABEL_E){ cy=(ui->U+ui->B)/2; cx=ui->L+(ui->B-ui->U)/2; }
- elif(ui->Flags&LA_UI_SOCKET_LABEL_W){ cy=(ui->U+ui->B)/2; cx=ui->R-(ui->B-ui->U)/2; }
- elif(ui->Flags&LA_UI_SOCKET_LABEL_N){ cx=(ui->L+ui->R)/2; cy=ui->U+(ui->R-ui->L)*0.75; }
- elif(ui->Flags&LA_UI_SOCKET_LABEL_S){ cx=(ui->L+ui->R)/2; cy=ui->B-(ui->R-ui->L)*0.75; }
- else{ cx=(ui->L+ui->R)/2; cy=(ui->U+ui->B)/2; }
- *dx=cx-ex; *dy=cy-ey;
- }
- int OPMOD_NodeSocket(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- int lx=e->x,ly=e->y;
- laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
- laPropContainer* PCFind;
- if(pc==LA_PC_SOCKET_IN) { PCFind=LA_PC_SOCKET_OUT; }
- elif(pc==LA_PC_SOCKET_OUT){ PCFind=LA_PC_SOCKET_IN; }
- if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
- if (e->type==LA_TIME_IDLE){ return LA_RUNNING; }
- if (e->type == LA_L_MOUSE_DOWN){
- uit->Dragging=1; MAIN.NextWireColor+=3;
- if(pc==LA_PC_SOCKET_IN) {
- laNodeInSocket* s=ui->PP.EndInstance;
- uit->Ptr2 = s->Source;
- if(!s->Source){
- s->ColorId=MAIN.NextWireColor; s->Source=MAIN.tNodeOut; latouched_NodeInSocket(0,0);
- MAIN.tNodeOut->RuntimeX=MAIN.tNodeOut->RuntimeY=MAIN.tNodeOut->RuntimePX=MAIN.tNodeOut->RuntimePY=0;
- }else{
- MAIN.tNodeIn->Source = s->Source;
- MAIN.tNodeIn->RuntimeX=MAIN.tNodeIn->RuntimeY=MAIN.tNodeIn->RuntimePX=MAIN.tNodeIn->RuntimePY=0;
- MAIN.tNodeIn->RuntimePX=-(s->Source->RuntimeX+s->Source->RuntimePX)+(s->RuntimeX+s->RuntimePX);
- MAIN.tNodeIn->RuntimePY=-(s->Source->RuntimeY+s->Source->RuntimePY)+(s->RuntimeY+s->RuntimePY);
- s->Source=0; MAIN.tNodeIn->ColorId=s->ColorId; latouched_NodeInSocket(0,0);
- }
- }
- elif(pc==LA_PC_SOCKET_OUT){ MAIN.tNodeIn->Source=ui->PP.EndInstance; latouched_NodeInSocket(0,0);
- MAIN.tNodeIn->RuntimeX=MAIN.tNodeIn->RuntimeY=MAIN.tNodeIn->RuntimePX=MAIN.tNodeIn->RuntimePY=0;
- MAIN.tNodeIn->ColorId=MAIN.NextWireColor; }
- int dx,dy; la_NodeSocketGetPositionDelta(ui,e->x,e->y,&dx,&dy); uit->LastX = e->x+dx; uit->LastY = e->y+dy;
- laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- if (uit->Dragging && e->type == LA_MOUSEMOVE){
- laPanel* p=MAIN.CurrentPanel;
- laLocalToPanel(a, &lx, &ly);
- laUiItem* tui=la_DetectSocketRecursive(&p->UI,lx,ly,100000,uit->Ptr2?LA_PC_SOCKET_IN:PCFind); uit->Ptr1=tui;
- if(pc==LA_PC_SOCKET_IN){
- if(!uit->Ptr2){MAIN.tNodeOut->RuntimeX=e->x-uit->LastX;MAIN.tNodeOut->RuntimeY=e->y-uit->LastY;}
- else { MAIN.tNodeIn->RuntimeX=e->x-uit->LastX;MAIN.tNodeIn->RuntimeY=e->y-uit->LastY; } }
- elif(pc==LA_PC_SOCKET_OUT){ MAIN.tNodeIn->RuntimeX=e->x-uit->LastX; MAIN.tNodeIn->RuntimeY=e->y-uit->LastY; }
- laRedrawCurrentPanel();
- return LA_RUNNING;
- }
- if (uit->Dragging && (e->type == LA_L_MOUSE_UP || e->type == LA_R_MOUSE_DOWN || e->key == LA_KEY_ESCAPE)){
- uit->Dragging=0; MAIN.tNodeIn->Source=0;
- laRecalcCurrentPanel();
- laUiItem* tui=uit->Ptr1; void* soc=tui?tui->PP.EndInstance:0;
- if(pc == LA_PC_SOCKET_IN){
- if(!uit->Ptr2){ if(!tui){ laNodeInSocket* s=ui->PP.EndInstance; s->Source=0; return LA_RUNNING; }
- laNodeInSocket* s=ui->PP.EndInstance; s->Source=0; memAssignRef(s,&s->Source,soc); latouched_NodeInSocket(0,0);
- s->ColorId=MAIN.NextWireColor; laRecordAndPushProp(&ui->PP, 0); laMarkPropChanged(&ui->PP);
- }else{
- if(!tui){
- laNodeInSocket* s=ui->PP.EndInstance; s->Source=uit->Ptr2; memAssignRef(s,&s->Source,0); latouched_NodeInSocket(0,0);
- laRecordAndPushProp(&ui->PP, 0); laMarkPropChanged(&ui->PP);
- }else{
- laNodeInSocket* s=soc; if(s->Source){ uit->Ptr2=0; return LA_RUNNING; } latouched_NodeInSocket(0,0);
- memAssignRef(s,&s->Source,uit->Ptr2); s->ColorId=((laNodeInSocket*)ui->PP.EndInstance)->ColorId;
- laRecordDifferences(&ui->PP,0); laRecordDifferences(&tui->PP,0); laPushDifferences("Socket status changed", 0);
- laMarkPropChanged(&tui->PP); laMarkPropChanged(&ui->PP);
- }
- }
- }
- else{
- if(!tui){ return LA_RUNNING; }
- laNodeInSocket* s=soc; s->Source=0; memAssignRef(s,&s->Source,ui->PP.EndInstance); latouched_NodeInSocket(0,0);
- s->ColorId=MAIN.NextWireColor; laRecordAndPushProp(&tui->PP, 0); laMarkPropChanged(&tui->PP);
- }
-
- uit->Ptr2=0;
- return LA_RUNNING;
- }
- return LA_RUNNING_PASS;
- }
- int OPMOD_HeightAdjuster(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- int lx=e->x,ly=e->y;
- int ClickedVal=0;
- if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
- if (e->type == LA_L_MOUSE_DOWN || e->type==LA_R_MOUSE_DOWN){
- 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;
- return LA_RUNNING;
- }
- if(e->type==LA_L_MOUSE_UP && uit->HeightCoeff){ ui->State=(ui->State==LA_BT_ACTIVE)?LA_BT_NORMAL:LA_BT_ACTIVE; laRedrawCurrentPanel(); }
- if (uit->Dragging && e->type == LA_MOUSEMOVE){
- int diff=e->y-uit->LastY; diff=((real)diff+0.5)/(ui->B-ui->U); int delta=uit->TargetIndexVali;
- 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(); }
- return LA_RUNNING;
- }
- if (uit->Dragging && (e->type == LA_L_MOUSE_UP || e->type == LA_R_MOUSE_UP || e->key == LA_KEY_ESCAPE)){
- uit->Dragging=0; return LA_RUNNING_PASS;
- }
- return LA_RUNNING_PASS;
- }
- void la_ValueMapperSortPoint(laValueMapper* vm){
- laValueMapperPoint* vmp,*ivmp; laListHandle temp={0}; int Inserted=0;
- while(vmp=lstPopItem(&vm->Points)){
- Inserted=0;
- for(ivmp=temp.pLast;ivmp;ivmp=ivmp->Item.pPrev){
- if(ivmp->x<vmp->x){ lstInsertItemAfter(&temp,vmp,ivmp); Inserted=1; break; }
- }
- if(!Inserted){ lstPushItem(&temp,vmp); }
- }
- vm->Points.pFirst=temp.pFirst; vm->Points.pLast=temp.pLast;
- }
- laValueMapperPoint* la_ValueMapperCreatePoint(laValueMapper* vm, real x, real y){
- laValueMapperPoint* vmp=memAcquire(sizeof(laValueMapperPoint));
- vmp->x=x;vmp->y=y; lstAppendItem(&vm->Points,vmp);
- la_ValueMapperSortPoint(vm);
- return vmp;
- }
- laValueMapperPoint* la_ValueMapperGetPoint(laValueMapper* vm, real x, real y){
- laValueMapperPoint* vmp=0,*ClosestVMP=0; real MinD=FLT_MAX;
- if(x<0||x>1||y>1||y<0) return 0;
- const real thres=0.1;
- for(vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
- if(vmp->x>x+thres || vmp->x<x-thres || vmp->y>y+thres || vmp->y<y-thres) continue;
- real d=tnsDistIdv2(x,y,vmp->x,vmp->y);
- if(d<MinD){ ClosestVMP=vmp; MinD=d; }
- }
- vmp=ClosestVMP;
- if(!vmp){ vmp=la_ValueMapperCreatePoint(vm,x,y); }
- return vmp;
- }
- void la_ValueMapperEnsureValidPoints(laValueMapper* vm){
- if(!vm->Points.pFirst){ la_ValueMapperCreatePoint(vm,0,0); }
- if(vm->Points.pFirst==vm->Points.pLast){ la_ValueMapperCreatePoint(vm,1,1); }
- }
- laValueMapper* laValueMapperInit(){
- laValueMapper* vm=memAcquire(sizeof(laValueMapper));
- vm->InRange[0]=0; vm->InRange[1]=1; vm->OutRange[0]=0; vm->OutRange[1]=1;
- la_ValueMapperEnsureValidPoints(vm);
- return vm;
- }
- laValueMapper* laValueMapperDestroy(laValueMapper* vm){
- laValueMapperPoint* vmp;
- while(vmp=lstPopItem(&vm->Points)){ memLeave(vmp); }
- memLeave(vm);
- }
- laValueMapper* laValueMapperCopy(laValueMapper* new_optional, laValueMapper* vm){
- laValueMapper* into=new_optional?new_optional:memAcquire(sizeof(laValueMapper)); laValueMapperPoint* vmp;
- while(vmp=lstPopItem(&into->Points)){ memLeave(vmp); }
- for(vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){ la_ValueMapperCreatePoint(into, vmp->x, vmp->y); }
- tnsVectorSet2v(into->InRange,vm->InRange); tnsVectorSet2v(into->OutRange,vm->OutRange);
- return into;
- }
- real laValueMapperEvaluate(laValueMapper* vm, real x, real* force_InMin, real* force_InMax, real* force_OutMin, real* force_OutMax, int ClampIn, int ClampOut){
- real InMin=vm->InRange[0], InMax=vm->InRange[1], OutMin=vm->OutRange[0], OutMax=vm->OutRange[1];
- if(force_InMin) InMin=*force_InMin; if(force_InMax) InMax=*force_InMax; if(force_OutMin) OutMin=*force_OutMin; if(force_OutMax) OutMax=*force_OutMax;
- if(fabs(InMax-InMin)<1e-7) return 0;
- x=tnsGetRatiod(InMin,InMax,x); if(ClampIn) TNS_CLAMP(x,0,1);
- laValueMapperPoint* vmp,*NextVMP;
- real ey=0;
- for(vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
- NextVMP=vmp->Item.pNext;
- if(NextVMP && (!(vmp->x<=x && NextVMP->x>x))) continue;
- if(!NextVMP){ NextVMP=vmp; vmp=vmp->Item.pPrev; if(!vmp) return 0; }
- if(fabs(vmp->x-NextVMP->x)<1e-7){ ey=vmp->y; break; }
- real ratio=tnsGetRatiod(vmp->x,NextVMP->x,x);
- ey=tnsInterpolate(vmp->y,NextVMP->y,ratio); break;
- }
- real Out=tnsInterpolate(OutMin,OutMax,ey);
- if(ClampOut) TNS_CLAMP(Out,OutMin,OutMax);
- return Out;
- }
- int OPMOD_ValueMapper(laOperator *a, laEvent *e){
- laUiItem *ui = a->Instance;
- laBoxedTheme *bt = (*ui->Type->Theme);
- laGeneralUiExtraData *uit = a->CustomData;
- int w=ui->R-ui->L, h=ui->B-ui->U;
- real x=(real)(e->x-ui->L)/w,y=(real)(ui->B-e->y)/h;
- int ClickedVal=0;
- if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
- laValueMapper* vm=ui->PP.EndInstance;
- if (e->type == LA_L_MOUSE_DOWN){
- uit->Dragging=1; uit->LastX=e->x; uit->LastY=e->y;
- return LA_RUNNING;
- }
- if (uit->Dragging && e->type == LA_MOUSEMOVE){
- laValueMapperPoint* vmp=uit->Ptr1;
- if(uit->Dragging==1 && tnsDistIdv2(e->x,e->y,uit->LastX,uit->LastY)>LA_RH/2){
- uit->Ptr1=la_ValueMapperGetPoint(vm,x,y); if(!uit->Ptr1){ uit->Dragging=0; return LA_RUNNING; }
- uit->Dragging=2;
- }
- elif(uit->Dragging==2){
- if(x<0&&x>-0.05){ x=0; } if(x>1&&x<1.05){ x=1; } TNS_CLAMP(y,0,1);
- vmp->x=x; vmp->y=y; la_ValueMapperSortPoint(vm);
- laNotifyUsersPP(&ui->PP); laRedrawCurrentPanel(); laMarkPropChanged(&ui->PP);
- }
- return LA_RUNNING;
- }
- if (uit->Dragging && (e->type == LA_L_MOUSE_UP || e->type == LA_R_MOUSE_UP || e->key == LA_KEY_ESCAPE)){
- uit->Dragging=0; laValueMapperPoint* vmp=uit->Ptr1; if(!vmp) return LA_RUNNING_PASS;
- if(vmp->x>1||vmp->x<0) {
- lstRemoveItem(&vm->Points,vmp); la_ValueMapperEnsureValidPoints(vm);
- laNotifyUsersPP(&ui->PP); laRedrawCurrentPanel(); laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
- }
- return LA_RUNNING_PASS;
- }
- return LA_RUNNING_PASS;
- }
- void la_RegisterUiOperatorsBasic(){
- laPropContainer *pc, *p;
- laOperatorType *at;
- laEnumProp *ep;
- laCreateOperatorType("LA_edit_string_copy", "Copy Selection", "Copy selected string to clip board",
- OPCHK_EditStringCopySelection, 0, 0, OPINV_EditStringCopySelection, 0, U'🗍', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_int_array_h_operator", "Int(Horizon) UiItem Operator", "Do Array Valuator Stuff",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_IntArrayHorizon, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_real_array_h_operator", "Float(Horizon) UiItem Operator", "Do Array Valuator Stuff",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_FloatArrayHorizon, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_real_color_operator", "Color(Float) Display UiItem Operator", "Color Display,Click To Set Color",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_FloatColor, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_real_hcy_operator", "HCY Color Picker UiItem Operator", "HCY Color Picker,Click To Set Color",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ColorHCY, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_enum_selector_operator", "Enum Selector UiItem Operator", "Do Selector Stuff",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_EnumSelector, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_button_operator", "Button UiItem Operator", "Execute an Operator",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_Button, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_menu_root_operator", "Menu Root UiItem Operator", "Drop A Menu",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_MenuItem, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_condition_toggle_operator", "Condition +/- Button Operator", "Do Self Condition Function",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ConditionToggle, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_string_operator", "Single Line String Operator", "Do String Modifying Function",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_SingleLineString, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_string_multi", "Multi Line String Operator", "Do String Modifying Function",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_MultiString, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_tab_operator", "Tab Switcher Operator", "Change The Page In The Tab Group",
- 0, 0, OPEXT_UiItem, OPINV_Tab, OPMOD_TabSelector, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_collection_operator", "Collection UiItem Operator", "Activate/Deactivate Collection Item(s)",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_Collection, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_collection_selector_operator", "Collection Dropdown Selector Operator", "Do Selector Stuff",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_CollectionSelector, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_column_adjuster", "Column Width Adjuster", "Drag To Set Width of Columns",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ColumnAdjuster, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_node_socket", "Node Socket Operator", "Drag to connect node sockets",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_NodeSocket, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_height_adjuster", "Height Adjuster Operator", "Drag to adjust heights of an instance",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_HeightAdjuster, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- laCreateOperatorType("LA_value_mapper", "Value mapper Operator", "Drag to set value mapping from input to output",
- 0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ValueMapper, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
- }
|