*/}}

la_operators.c 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659
  1. /*
  2. * LaGUI: A graphical application framework.
  3. * Copyright (C) 2022-2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "../la_5.h"
  19. extern LA MAIN;
  20. extern struct _tnsMain *T;
  21. void la_PanelActiviatorParser(laStringSplitor *ss, uint32_t *IconID, char *DisplayString){
  22. char *StrArg;
  23. if (ss && ss->parts.pFirst){
  24. if (StrArg = strGetArgumentString(ss, "text")){
  25. strCopyFull(DisplayString, StrArg);
  26. }else if (StrArg = strGetArgumentString(ss, "panel_id")){
  27. laUiTemplate* uit = laFindUiTemplate(StrArg);
  28. strCopyFull(DisplayString, transLate("Show "));
  29. strAppend(DisplayString, uit->Title->Ptr);
  30. }
  31. }else{
  32. strCopyFull(DisplayString, transLate("Activate A Panel"));
  33. }
  34. }
  35. void la_DefaultOperatorParser(laStringSplitor *ss, uint32_t *IconID, char *DisplayString){
  36. char *StrArg;
  37. laStringPart *sp;
  38. if (ss && ss->parts.pFirst){
  39. if (StrArg = strGetArgumentString(ss, "text")){
  40. strCopyFull(DisplayString, StrArg);
  41. }
  42. if (StrArg = strGetArgumentString(ss, "icon")){
  43. int adv=0; *IconID = laToUnicode(StrArg, &adv);
  44. }
  45. }
  46. }
  47. laProp *la_PropLookup(laListHandle *lst, char *ID);
  48. void la_EnsurePanelSnapping(laPanel *p, int CW, int CH);
  49. void la_RecalcBlockRecursive(laBlock *b, int X, int Y, int W, int H);
  50. void la_ConditionNodeFreeRecursive(laUiConditionNode *ucn);
  51. int OPMOD_FinishOnData(laOperator* a, laEvent* e){
  52. if(a->ConfirmData){
  53. return LA_FINISHED_PASS;
  54. }
  55. return LA_RUNNING;
  56. }
  57. void OPEXT_FreeUserData(laOperator* a, int mark_unused){
  58. if(a->CustomData) memFree(a->CustomData);
  59. }
  60. int OPCHK_AlwaysTrue(laPropPack *pp, laStringSplitor *ss){
  61. return 1;
  62. }
  63. int OPINV_DoNothing(laOperator *a, laEvent *e){
  64. return LA_FINISHED;
  65. }
  66. int OPINV_PureYesNo(laOperator *a, laEvent *e){
  67. laEnableYesNoPanel(a, 0, "Please Consider:", "Are You Sure?", 80, 80, 250, e);
  68. return LA_FINISHED;
  69. }
  70. #define DEFINE_FORMAT(str, type) \
  71. if (!strcmp(format, str)) return type;
  72. int la_DetectFileItemType(char* format){
  73. for(laExtensionType* et=MAIN.ExtraExtensions.pFirst;et;et=et->Item.pNext){ DEFINE_FORMAT(et->Extension, et->FileType); }
  74. DEFINE_FORMAT("lasdexchange", LA_FILETYPE_LASDEXCHANGE);
  75. DEFINE_FORMAT("odt", LA_FILETYPE_DOCUMENT);
  76. DEFINE_FORMAT("ods", LA_FILETYPE_DOCUMENT);
  77. DEFINE_FORMAT("odp", LA_FILETYPE_DOCUMENT);
  78. DEFINE_FORMAT("txt", LA_FILETYPE_DOCUMENT);
  79. DEFINE_FORMAT("c", LA_FILETYPE_DOCUMENT);
  80. DEFINE_FORMAT("cpp", LA_FILETYPE_DOCUMENT);
  81. DEFINE_FORMAT("cxx", LA_FILETYPE_DOCUMENT);
  82. DEFINE_FORMAT("cs", LA_FILETYPE_DOCUMENT);
  83. DEFINE_FORMAT("pas", LA_FILETYPE_DOCUMENT);
  84. DEFINE_FORMAT("h", LA_FILETYPE_DOCUMENT);
  85. DEFINE_FORMAT("hpp", LA_FILETYPE_DOCUMENT);
  86. DEFINE_FORMAT("hxx", LA_FILETYPE_DOCUMENT);
  87. DEFINE_FORMAT("inl", LA_FILETYPE_DOCUMENT);
  88. DEFINE_FORMAT("doc", LA_FILETYPE_DOCUMENT);
  89. DEFINE_FORMAT("docx", LA_FILETYPE_DOCUMENT);
  90. DEFINE_FORMAT("xls", LA_FILETYPE_DOCUMENT);
  91. DEFINE_FORMAT("xlsx", LA_FILETYPE_DOCUMENT);
  92. DEFINE_FORMAT("ppt", LA_FILETYPE_DOCUMENT);
  93. DEFINE_FORMAT("pptx", LA_FILETYPE_DOCUMENT);
  94. DEFINE_FORMAT("rtf", LA_FILETYPE_DOCUMENT);
  95. DEFINE_FORMAT("md", LA_FILETYPE_DOCUMENT);
  96. DEFINE_FORMAT("jpg", LA_FILETYPE_IMAGE);
  97. DEFINE_FORMAT("jpeg", LA_FILETYPE_IMAGE);
  98. DEFINE_FORMAT("png", LA_FILETYPE_IMAGE);
  99. DEFINE_FORMAT("tga", LA_FILETYPE_IMAGE);
  100. DEFINE_FORMAT("bmp", LA_FILETYPE_IMAGE);
  101. DEFINE_FORMAT("exr", LA_FILETYPE_IMAGE);
  102. DEFINE_FORMAT("psd", LA_FILETYPE_IMAGE);
  103. DEFINE_FORMAT("kra", LA_FILETYPE_IMAGE);
  104. DEFINE_FORMAT("dng", LA_FILETYPE_IMAGE);
  105. DEFINE_FORMAT("cr2", LA_FILETYPE_IMAGE);
  106. DEFINE_FORMAT("dds", LA_FILETYPE_IMAGE);
  107. DEFINE_FORMAT("mp3", LA_FILETYPE_AUDIO);
  108. DEFINE_FORMAT("wav", LA_FILETYPE_AUDIO);
  109. DEFINE_FORMAT("ape", LA_FILETYPE_AUDIO);
  110. DEFINE_FORMAT("flac", LA_FILETYPE_AUDIO);
  111. DEFINE_FORMAT("cue", LA_FILETYPE_AUDIO);
  112. DEFINE_FORMAT("wma", LA_FILETYPE_AUDIO);
  113. DEFINE_FORMAT("aac", LA_FILETYPE_AUDIO);
  114. DEFINE_FORMAT("m4a", LA_FILETYPE_AUDIO);
  115. DEFINE_FORMAT("ogg", LA_FILETYPE_AUDIO);
  116. DEFINE_FORMAT("mp4", LA_FILETYPE_VIDEO);
  117. DEFINE_FORMAT("mov", LA_FILETYPE_VIDEO);
  118. DEFINE_FORMAT("avi", LA_FILETYPE_VIDEO);
  119. DEFINE_FORMAT("avchd", LA_FILETYPE_VIDEO);
  120. DEFINE_FORMAT("mkv", LA_FILETYPE_VIDEO);
  121. DEFINE_FORMAT("qt", LA_FILETYPE_VIDEO);
  122. DEFINE_FORMAT("flv", LA_FILETYPE_VIDEO);
  123. DEFINE_FORMAT("zip", LA_FILETYPE_COMPRESSED);
  124. DEFINE_FORMAT("rar", LA_FILETYPE_COMPRESSED);
  125. DEFINE_FORMAT("gz", LA_FILETYPE_COMPRESSED);
  126. DEFINE_FORMAT("bz", LA_FILETYPE_COMPRESSED);
  127. DEFINE_FORMAT("7z", LA_FILETYPE_COMPRESSED);
  128. DEFINE_FORMAT("iso", LA_FILETYPE_COMPRESSED);
  129. DEFINE_FORMAT("dmg", LA_FILETYPE_COMPRESSED);
  130. DEFINE_FORMAT("ttf", LA_FILETYPE_FONT);
  131. DEFINE_FORMAT("otf", LA_FILETYPE_FONT);
  132. DEFINE_FORMAT("woff", LA_FILETYPE_FONT);
  133. DEFINE_FORMAT("svg", LA_FILETYPE_VECTOR);
  134. DEFINE_FORMAT("dwg", LA_FILETYPE_VECTOR);
  135. DEFINE_FORMAT("dxf", LA_FILETYPE_VECTOR);
  136. DEFINE_FORMAT("cdr", LA_FILETYPE_VECTOR);
  137. DEFINE_FORMAT("htm", LA_FILETYPE_WEBPAGE);
  138. DEFINE_FORMAT("html", LA_FILETYPE_WEBPAGE);
  139. DEFINE_FORMAT("xhtml", LA_FILETYPE_WEBPAGE);
  140. DEFINE_FORMAT("xml", LA_FILETYPE_META);
  141. DEFINE_FORMAT("dat", LA_FILETYPE_META);
  142. DEFINE_FORMAT("json", LA_FILETYPE_META);
  143. DEFINE_FORMAT("blend", LA_FILETYPE_BLEND);
  144. DEFINE_FORMAT("pdf", LA_FILETYPE_PDF);
  145. DEFINE_FORMAT("exe", LA_FILETYPE_EXEC);
  146. DEFINE_FORMAT("dll", LA_FILETYPE_SYS);
  147. DEFINE_FORMAT("sys", LA_FILETYPE_SYS);
  148. return 0;
  149. }
  150. int la_AcceptFileFormat(laFileBrowser* fb, char* format){
  151. if(!format || !format[0]) return 1;
  152. char buf[2048];
  153. if(fb->FilterType){
  154. for(laExtensionType* et=MAIN.ExtraExtensions.pFirst;et;et=et->Item.pNext){
  155. if(et->FileType==fb->FilterType && strSame(format, et->Extension)) return 1;
  156. if(fb->ShowBackups){
  157. sprintf(buf,"%s~",et->Extension);
  158. if(strSame(format,buf)) return 1;
  159. }
  160. }
  161. return 0;
  162. }
  163. if(!fb->ss_filter_extensions) return 1;
  164. for(laStringPart* sp=fb->ss_filter_extensions->parts.pFirst;sp;sp=sp->Item.pNext){
  165. if(!strcmp(sp->Content, format)) return 1;
  166. if(fb->ShowBackups){
  167. sprintf(buf,"%s~",sp->Content);
  168. if(strSame(format,buf)) return 1;
  169. }
  170. }
  171. return 0;
  172. }
  173. typedef int (*FileSortCompF)(laFileItem* f1,laFileItem* f2);
  174. #if defined (_WIN32) || defined (LAGUI_ANDROID)
  175. #define strverscmp strcmp
  176. #endif
  177. int la_filecompname(laFileItem* f1,laFileItem* f2){ return strverscmp(f2->Name, f1->Name); }
  178. int la_filecompnamerev(laFileItem* f1,laFileItem* f2){ return strverscmp(f1->Name, f2->Name); }
  179. int la_filecomptime(laFileItem* f1,laFileItem* f2){ return f1->Timestamp - f2->Timestamp; }
  180. int la_filecomptimerev(laFileItem* f1,laFileItem* f2){ return f2->Timestamp - f1->Timestamp; }
  181. int la_filecompsize(laFileItem* f1,laFileItem* f2){ return f1->Size - f2->Size; }
  182. int la_filecompsizerev(laFileItem* f1,laFileItem* f2){ return f2->Size - f1->Size; }
  183. #ifdef _WIN32
  184. #undef strverscmp
  185. #endif
  186. void la_SortFiles(laFileBrowser* fb, laListHandle* files){
  187. laListHandle tmp={0}; laFileItem* fi;
  188. FileSortCompF comp = 0;
  189. switch(fb->SortBy){
  190. case LA_FILE_SORT_NAME: default: comp=la_filecompname; break;
  191. case LA_FILE_SORT_NAME_REV: comp=la_filecompnamerev; break;
  192. case LA_FILE_SORT_TIME: comp=la_filecomptime; break;
  193. case LA_FILE_SORT_TIME_REV: comp=la_filecomptimerev; break;
  194. case LA_FILE_SORT_SIZE: comp=la_filecompsize; break;
  195. case LA_FILE_SORT_SIZE_REV: comp=la_filecompsizerev; break;
  196. }
  197. while(fi=lstPopItem(files)){ int inserted=0;
  198. for(laFileItem* fii=tmp.pFirst;fii;fii=fii->Hyper.pNext){
  199. int a=comp(fii,fi);
  200. if(a<0){ lstInsertItemBefore(&tmp,fi,fii); inserted=1; break; }
  201. }
  202. if(!inserted){ lstAppendItem(&tmp, fi); }
  203. }
  204. files->pFirst=tmp.pFirst; files->pLast=tmp.pLast;
  205. }
  206. void la_FileBrowserRebuildList(laFileBrowser *fb){
  207. laFileItem *fi = 0;
  208. laDiskItem *dl = 0;
  209. laListHandle Files = {0};
  210. char Lookup[2048]={0};
  211. char Final[2048]={0};
  212. char DiskLabels[256] = {0};
  213. char *pd = DiskLabels;
  214. int len = strlen(fb->Path);
  215. int NumDisks = 0;
  216. u64bit FreeAvailable = 0;
  217. u64bit FreeSpace_UNUSED = 0;
  218. u64bit TotalSpace = 0;
  219. real Ratio = 0;
  220. #ifdef __linux__
  221. #ifdef LAGUI_ANDROID
  222. #define versionsort alphasort
  223. #endif
  224. if (fb->Path[len - 1] != U'/') strcat(fb->Path, "/");
  225. struct dirent **NameList=0;
  226. int NumFiles=scandir(fb->Path,&NameList,0,versionsort);
  227. while (fi = lstPopItem(&fb->FileList)) memFree(fi);
  228. for(int i=0;i<NumFiles;i++){
  229. struct dirent* d = NameList[i];
  230. if(!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")){continue;}
  231. if(fb->FilterName[0] && !strcasestr(d->d_name,fb->FilterName)){continue;}
  232. struct stat s;
  233. sprintf(Final, "%s%s",fb->Path,d->d_name);
  234. stat(Final, &s);
  235. if (S_ISDIR(s.st_mode)){
  236. fi = memAcquireSimple(sizeof(laFileItem));
  237. strcpy(fi->Name, d->d_name);
  238. fi->IsFolder = 1;
  239. fi->Type = LA_FILETYPE_FOLDER;
  240. lstAppendItem(&fb->FileList, fi);
  241. }elif (!fb->SelectFolder){
  242. char *format = strGetLastSegment(d->d_name, '.');
  243. if(!la_AcceptFileFormat(fb,format)){ continue; }
  244. fi = memAcquireSimple(sizeof(laFileItem));
  245. strcpy(fi->Name, d->d_name);
  246. fi->Size = s.st_size;
  247. fi->Type = la_DetectFileItemType(format);
  248. fi->Timestamp = s.st_ctime;
  249. struct tm *t = localtime(&s.st_ctime);
  250. fi->TimeModified.Year = t->tm_year+1900;
  251. fi->TimeModified.Month = t->tm_mon+1;;
  252. fi->TimeModified.Day = t->tm_mday;
  253. fi->TimeModified.Hour = t->tm_hour;
  254. fi->TimeModified.Minute = t->tm_min;
  255. fi->TimeModified.Second = t->tm_sec;
  256. lstAppendItem(&Files, fi);
  257. //lstAppendItem(&fb->FileList, fi);
  258. }
  259. }
  260. for (int i = 0; i < NumFiles; i++) { free(NameList[i]); } free(NameList);
  261. #endif
  262. #ifdef _WIN32
  263. WIN32_FIND_DATA FindFileData;
  264. HANDLE hFind;
  265. SYSTEMTIME stUTC, stLocal;
  266. strCopyFull(Lookup, fb->Path);
  267. if (Lookup[len - 1] != U'\\') strcat(Lookup, "\\*.*"); else strcat(Lookup, "*.*");
  268. hFind = FindFirstFile(Lookup, &FindFileData);
  269. while (fi = lstPopItem(&fb->FileList)) memFree(fi);
  270. if (hFind == INVALID_HANDLE_VALUE){ return; }
  271. char buf[1024]; if (fb->FilterName[0]) { strToLower(fb->FilterName); }
  272. while (1) {
  273. if (fb->FilterName[0]) {
  274. strcpy(buf, FindFileData.cFileName); strToLower(buf);
  275. if (!strstr(buf, fb->FilterName)) { goto findnext; }
  276. }
  277. if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  278. if (FindFileData.cFileName[0] != '.') {
  279. fi = memAcquireSimple(sizeof(laFileItem));
  280. strcpy(fi->Name, FindFileData.cFileName);
  281. fi->IsFolder = 1;
  282. fi->Type = LA_FILETYPE_FOLDER;
  283. lstAppendItem(&fb->FileList, fi);
  284. }
  285. }elif(!fb->SelectFolder) {
  286. fi = memAcquireSimple(sizeof(laFileItem));
  287. strCopyFull(fi->Name, FindFileData.cFileName);
  288. fi->Size = FindFileData.nFileSizeLow;
  289. fi->Type = la_DetectFileItemType(fi);
  290. FileTimeToSystemTime(&(FindFileData.ftLastWriteTime), &stUTC);
  291. SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
  292. fi->Timestamp = (uint64_t)FindFileData.ftLastWriteTime.dwHighDateTime|((uint64_t)(FindFileData.ftLastWriteTime.dwLowDateTime)<<32);
  293. fi->TimeModified.Year = stLocal.wYear;
  294. fi->TimeModified.Month = stLocal.wMonth;
  295. fi->TimeModified.Day = stLocal.wDay;
  296. fi->TimeModified.Hour = stLocal.wHour;
  297. fi->TimeModified.Minute = stLocal.wMinute;
  298. fi->TimeModified.Second = stLocal.wSecond;
  299. lstAppendItem(&Files, fi);
  300. //lstAppendItem(&fb->FileList, fi);
  301. }
  302. findnext:
  303. if (!FindNextFile(hFind, &FindFileData))
  304. break;
  305. }
  306. #endif
  307. la_SortFiles(fb, &Files);
  308. lstCombineLists(&fb->FileList, &Files);
  309. while (dl = lstPopItem(&fb->Disks)) memFree(dl);
  310. #ifdef _WIN32
  311. NumDisks = GetLogicalDriveStrings(256, DiskLabels) / 4;
  312. while (*pd){
  313. char Name[3] = "*:";
  314. Name[0] = *pd;
  315. if (GetDiskFreeSpaceEx(Name, &FreeAvailable, &TotalSpace, &FreeSpace_UNUSED)){
  316. dl = memAcquire(sizeof(laDiskItem));
  317. dl->ID = *pd;
  318. dl->Total_GB = (real)TotalSpace / 1073741824.0f; //B->GB
  319. dl->Free_GB = (real)FreeAvailable / 1073741824.0f; //B->GB
  320. if (Name[0] == fb->Path[0])
  321. fb->RootDisk = dl;
  322. lstAppendItem(&fb->Disks, dl);
  323. }
  324. pd += 4;
  325. }
  326. #endif
  327. fb->Active = 0;
  328. }
  329. laFileBrowser *la_FileBrowserInit(laOperator *a){
  330. laFileBrowser *fb = memAcquire(sizeof(laFileBrowser));
  331. char* arg=0;
  332. #ifdef LAGUI_ANDROID
  333. strcpy(fb->Path, MAIN.ExternalDataPath);
  334. laBookmarkedFolder* bf=memAcquireSimple(sizeof(laBookmarkedFolder));
  335. strcpy(bf->Path,fb->Path); strcpy(bf->Name,strGetLastSegment(fb->Path,"External")); lstAppendItem(&fb->Bookmarks,bf);
  336. bf=memAcquireSimple(sizeof(laBookmarkedFolder));
  337. strcpy(bf->Path,MAIN.InternalDataPath); strcpy(bf->Name,"Internal"); lstAppendItem(&fb->Bookmarks,bf);
  338. if(!MAIN.GotFilePermission){
  339. MAIN.GotFilePermission = la_check_permission("android.permission.WRITE_EXTERNAL_STORAGE");
  340. if(!MAIN.GotFilePermission){
  341. la_request_permission("android.permission.WRITE_EXTERNAL_STORAGE");
  342. }
  343. }
  344. #else
  345. strcpy(fb->Path, SSTR(MAIN.WorkingDirectory));
  346. #endif
  347. if (strArgumentMatch(a->ExtraInstructionsP, "select", "folder")){ fb->SelectFolder = LA_FILE_SELECT_FOLDER; }
  348. if (strArgumentMatch(a->ExtraInstructionsP, "warn_file_exists", "true")){ fb->WarnFileExists = 1; }
  349. if ((arg=strGetArgumentString(a->ExtraInstructionsP, "filter_extensions"))){ fb->ss_filter_extensions=strSplitPath(arg,','); }
  350. if ((arg=strGetArgumentString(a->ExtraInstructionsP, "use_extension"))){ strcpy(fb->UseExtension, arg); }
  351. if ((arg=strGetArgumentString(a->ExtraInstructionsP, "filter_type"))){ sscanf(arg,"%d",&fb->FilterType); }
  352. if ((arg=strGetArgumentString(a->ExtraInstructionsP, "use_type"))){ sscanf(arg,"%d",&fb->UseType); }
  353. #ifdef LA_LINUX
  354. char BookmarkPath[1024];
  355. strcat(strcpy(BookmarkPath, getenv("HOME")), "/.config/gtk-3.0/bookmarks");
  356. FILE* f=fopen(BookmarkPath, "r");
  357. if(f){ char entry[1024]={0};
  358. while(fgets(entry,1024,f)){ laBookmarkedFolder* bf=memAcquireSimple(sizeof(laBookmarkedFolder));
  359. entry[strlen(entry)-1]=0;
  360. strcpy(bf->Path,&entry[7]);
  361. strcpy(bf->Name,strGetLastSegment(&entry[7],'/')); lstAppendItem(&fb->Bookmarks,bf);
  362. }
  363. fclose(f);
  364. }
  365. #endif
  366. la_FileBrowserRebuildList(fb);
  367. fb->FileName[0] = 0;
  368. memAssignRef(fb, &fb->Thumbnail, tnsNewImage(0));
  369. fb->ShowThumbnail = 1;
  370. return fb;
  371. }
  372. void la_FileBrowserGetFullPath(laFileBrowser *fb,char* buf){
  373. buf[0]=0; int plen;
  374. if (!fb->SelectFolder && fb->FileName[0] == U'\0') return;
  375. plen = strlen(fb->Path);
  376. if (fb->Path[plen - 1] != LA_PATH_SEP) strcat(fb->Path, LA_PATH_SEPSTR);
  377. strCopyFull(buf, fb->Path);
  378. strcat(buf, fb->FileName);
  379. }
  380. void la_FileBrowserRefreshThumbnail(laFileBrowser* fb){
  381. if(MAIN.ThumbnailProp && fb->Active && fb->Active->Type==LA_FILETYPE_UDF){
  382. char* prop=SSTR(MAIN.ThumbnailProp); if(prop[0]){
  383. char fbuf[2048];la_FileBrowserGetFullPath(fb,fbuf);
  384. FILE* fpudf=fopen(fbuf,"rb"); if(fpudf){
  385. void* data=0; size_t size=0;
  386. if(laExtractQuickRaw(fpudf,prop,&data,&size)){
  387. tnsRefreshImage(fb->Thumbnail,data);
  388. fclose(fpudf); return;
  389. }
  390. fclose(fpudf);
  391. }
  392. }
  393. }
  394. #ifdef LA_LINUX
  395. char buf[2048]="file://"; char md5[128];
  396. la_FileBrowserGetFullPath(fb,buf+strlen(buf));
  397. md5String(buf,md5); toHexString(md5,fb->MD5);
  398. sprintf(buf,"%s/.cache/thumbnails/normal/%s.png", getenv("HOME"),fb->MD5);
  399. FILE *fp=fopen(buf,"rb"); char* data=0;
  400. if(fp){
  401. fseek(fp, 0, SEEK_END); u64bit SeekEnd = ftell(fp); fseek(fp, 0, SEEK_SET);
  402. data = calloc(1, SeekEnd); fread(data, SeekEnd, 1, fp);
  403. tnsRefreshImage(fb->Thumbnail,data);
  404. }else{
  405. tnsRefreshImage(fb->Thumbnail,0);
  406. }
  407. #endif
  408. }
  409. void laset_FileBrowserSelectFile(laFileBrowser *fb, laFileItem *fi, int State){
  410. int len;
  411. if (fb->Active == fi){
  412. if (fi->IsFolder){
  413. len = strlen(fb->Path);
  414. if (fb->Path[len - 1] != LA_PATH_SEP) strcat(fb->Path, LA_PATH_SEPSTR);
  415. strcat(fb->Path, fi->Name);
  416. la_FileBrowserRebuildList(fb);
  417. fb->FileName[0] = 0; fb->FilterName[0]=0;
  418. laRecalcCurrentPanelImmediate();
  419. }
  420. }else{
  421. if (!fi->IsFolder){
  422. strCopyFull(fb->FileName, fi->Name);
  423. }
  424. fb->Active = fi;
  425. la_FileBrowserRefreshThumbnail(fb);
  426. }
  427. }
  428. int la_FileBrowserConfirm(laOperator *a, laFileBrowser *fb){
  429. char buf[2048];
  430. la_FileBrowserGetFullPath(fb,buf);
  431. laConfirmString(a, buf, LA_CONFIRM_OK);
  432. return 1;
  433. }
  434. void *laget_FileBrowserFirstFile(laFileBrowser *fb, void* unused){
  435. return fb->FileList.pFirst;
  436. }
  437. void *laget_FileBrowserActiveFile(laFileBrowser *fb){
  438. return fb->Active;
  439. }
  440. void laget_FileBrowserDiskID(laDiskItem *di, char *result){
  441. result[0] = di->ID;
  442. result[1] = U':';
  443. result[2] = LA_PATH_SEP;
  444. result[3] = U'\0';
  445. }
  446. void *laset_FileBrowserActiveDisk(laFileBrowser *fb, laDiskItem *di, int UNUSED_State){
  447. fb->RootDisk = di;
  448. laget_FileBrowserDiskID(di, fb->Path);
  449. la_FileBrowserRebuildList(fb);
  450. fb->FileName[0] = 0;
  451. }
  452. void laset_FileBrowserPath(laFileBrowser *fb, char *content){
  453. if(!strSame(content, fb->Path)){
  454. strCopyFull(fb->Path, content); la_FileBrowserRebuildList(fb); fb->FileName[0] = 0; laRecalcCurrentPanel();
  455. }
  456. }
  457. void *laset_FileBrowserBookmark(laFileBrowser *fb, laBookmarkedFolder *bf){
  458. strcpy(fb->Path,bf->Path); la_FileBrowserRebuildList(fb); fb->FileName[0] = 0;
  459. }
  460. void laset_FileBrowserFileName(laFileBrowser *fb, char *content){
  461. strCopyFull(fb->FileName, content); int file_okay=0;
  462. char* ext=strGetLastSegment(fb->FileName,'.');
  463. if(fb->UseExtension[0] && strcmp(ext,fb->UseExtension)){ strcat(fb->FileName,"."); strcat(fb->FileName,fb->UseExtension); }
  464. else if(fb->UseType){ int file_okay=0; laExtensionType* FirstET=0;
  465. for(laExtensionType*et=MAIN.ExtraExtensions.pFirst;et;et=et->Item.pNext){
  466. if((!FirstET) && et->FileType==fb->UseType) FirstET=et;
  467. if(et->FileType==fb->UseType && strSame(ext,et->Extension)){ file_okay=1; break; }
  468. }
  469. if((!file_okay) && FirstET){ strcat(fb->FileName,"."); strcat(fb->FileName,FirstET->Extension); }
  470. }
  471. la_FileBrowserRebuildList(fb);
  472. laRecalcCurrentPanel();
  473. }
  474. void laset_FileBrowserFilterName(laFileBrowser *fb, char *content){
  475. strCopyFull(fb->FilterName, content); int file_okay=0;
  476. la_FileBrowserRebuildList(fb); laRecalcCurrentPanel();
  477. }
  478. void* laget_FileBrowserAcceptedExtensionsFrist(laFileBrowser* fb, laPropIterator* pi){
  479. if(!fb->UseType){ return 0; }
  480. for(laExtensionType*et=MAIN.ExtraExtensions.pFirst;et;et=et->Item.pNext){
  481. if(et->FileType==fb->UseType){ return et; }
  482. }
  483. return 0;
  484. }
  485. void* laget_FileBrowserAcceptedExtensionsNext(laExtensionType* et, laPropIterator* pi){
  486. for(laExtensionType*iet=et->Item.pNext;iet;iet=iet->Item.pNext){
  487. if(et->FileType==iet->FileType){ return iet; }
  488. }
  489. return 0;
  490. }
  491. void* laset_FileBrowserExtension(laFileBrowser* fb, laExtensionType* et){
  492. if(fb->UseType && fb->FileName[0] && et){ char* ext=strGetLastSegment(fb->FileName,'.');
  493. if(!ext){ sprintf(fb->FileName,".%s",ext); }
  494. elif(strcmp(et->Extension,ext)){ sprintf(ext,"%s",et->Extension); }
  495. la_FileBrowserRebuildList(fb); laRecalcCurrentPanel();
  496. }
  497. return 0;
  498. }
  499. void laset_FileBrowserShowBackups(laFileBrowser* fb, int show){
  500. fb->ShowBackups = show; la_FileBrowserRebuildList(fb); laRecalcCurrentPanel();
  501. }
  502. void laset_FileBrowserShowThumbnail(laFileBrowser* fb, int show){
  503. fb->ShowThumbnail = show; if(show){ la_FileBrowserRefreshThumbnail(fb); } laRecalcCurrentPanel();
  504. }
  505. void laset_FileBrowserSortName(laFileBrowser* fb, int s){
  506. if(fb->SortBy==LA_FILE_SORT_NAME) fb->SortBy=LA_FILE_SORT_NAME_REV;
  507. else fb->SortBy=LA_FILE_SORT_NAME; la_FileBrowserRebuildList(fb); laRecalcCurrentPanel();
  508. }
  509. int laget_FileBrowserSortName(laFileBrowser*fb){
  510. if(fb->SortBy==LA_FILE_SORT_NAME) return 1; if(fb->SortBy==LA_FILE_SORT_NAME_REV) return 2; return 0;
  511. }
  512. void laset_FileBrowserSortTime(laFileBrowser* fb, int s){
  513. if(fb->SortBy==LA_FILE_SORT_TIME) fb->SortBy=LA_FILE_SORT_TIME_REV;
  514. else fb->SortBy=LA_FILE_SORT_TIME; la_FileBrowserRebuildList(fb); laRecalcCurrentPanel();
  515. }
  516. int laget_FileBrowserSortTime(laFileBrowser*fb){
  517. if(fb->SortBy==LA_FILE_SORT_TIME) return 1; if(fb->SortBy==LA_FILE_SORT_TIME_REV) return 2; return 0;
  518. }
  519. void laset_FileBrowserSortSize(laFileBrowser* fb, int s){
  520. if(fb->SortBy==LA_FILE_SORT_SIZE) fb->SortBy=LA_FILE_SORT_SIZE_REV;
  521. else fb->SortBy=LA_FILE_SORT_SIZE; la_FileBrowserRebuildList(fb); laRecalcCurrentPanel();
  522. }
  523. int laget_FileBrowserSortSize(laFileBrowser*fb){
  524. if(fb->SortBy==LA_FILE_SORT_SIZE) return 1; if(fb->SortBy==LA_FILE_SORT_SIZE_REV) return 2; return 0;
  525. }
  526. void laget_FileBrowserFileSizeString(laFileItem* fi, char* content, char** move){
  527. if(fi->Size >= (1<<30)){
  528. sprintf(content, "%.3lf GB", (real)fi->Size/(1<<30));
  529. }elif(fi->Size >= (1<<20)){
  530. sprintf(content, "%.3lf MB", (real)fi->Size/(1<<20));
  531. }elif(fi->Size >= (1<<10)){
  532. sprintf(content, "%.3lf KB", (real)fi->Size/(1<<10));
  533. }else{
  534. sprintf(content, "%d %s", fi->Size, transLate("Bytes"));
  535. }
  536. }
  537. void la_FileBrowserUpLevel(laFileBrowser *fb){
  538. char *p = fb->Path;
  539. char *LastP = 0;
  540. int Count = 0;
  541. for (p; *p; p++){
  542. if (*p && *p == LA_PATH_SEP && p[1]!=0){
  543. LastP = p;
  544. Count++;
  545. }
  546. }
  547. if (Count > 1) *LastP = 0;
  548. else if(LastP) *(LastP + 1) = 0;
  549. la_FileBrowserRebuildList(fb); fb->FileName[0] = 0;
  550. }
  551. void la_FileBrowserNewDirectory(laFileBrowser* fb,char* path){
  552. char* p=fb->Path;
  553. int len =strlen(p);
  554. #ifdef LA_LINUX
  555. if (p[len - 1] != U'/') strcat(p, "/");
  556. char usepath[2048]; sprintf(usepath,"%s%s",p,path);
  557. if(!mkdir(usepath,S_IRWXU | S_IRWXG | S_IRWXO)){
  558. strcpy(fb->Path,usepath);
  559. }
  560. #endif
  561. #ifdef _WIN32
  562. if (p[len - 1] != U'\\' && p[len - 1] != U'/') strcat(p, "\\");
  563. char usepath[2048]; sprintf(usepath,"%s%s",p,path);
  564. if(!_mkdir(usepath)){
  565. strcpy(fb->Path,usepath);
  566. }
  567. #endif
  568. la_FileBrowserRebuildList(fb); laRecalcCurrentPanel();
  569. }
  570. int OPINV_FileBrowser(laOperator *a, laEvent *e){
  571. a->CustomData = la_FileBrowserInit(a);
  572. laEnableOperatorPanel(a, 0, LA_RH2, LA_RH2, 500, 500, 0, 0, 0, 0, LA_RH2, LA_RH2, LA_RH2, LA_RH2, e);
  573. return LA_RUNNING;
  574. }
  575. void OPEXT_FileBrowser(laOperator *a, int mark){
  576. laFileBrowser *fb = a->CustomData;
  577. void* f;
  578. while (f=lstPopItem(&fb->Disks)) memFree(f);
  579. while (f=lstPopItem(&fb->FileList)) memFree(f);
  580. while (f=lstPopItem(&fb->Bookmarks)) memFree(f);
  581. strDestroyStringSplitor(&fb->ss_filter_extensions);
  582. tnsRemoveImage(fb->Thumbnail);
  583. memFree(fb);
  584. }
  585. int OPMOD_FileBrowser(laOperator *a, laEvent *e){
  586. laFileBrowser *fb = a->CustomData;
  587. if (a->ConfirmData){
  588. if (a->ConfirmData->Mode == LA_CONFIRM_CANCEL){
  589. if(fb->StatusWaitingWarning){ fb->StatusWaitingWarning=0; return LA_RUNNING; }
  590. laConfirmSameDataIfAny(a); return LA_FINISHED_PASS;
  591. }
  592. if (a->ConfirmData->Mode == LA_CONFIRM_OK){
  593. la_FileBrowserConfirm(a, fb); return LA_FINISHED_PASS;
  594. }
  595. }
  596. if (e->type == LA_KEY_DOWN && e->key==LA_KEY_ESCAPE){
  597. laConfirmInt(a, 0, LA_CONFIRM_CANCEL);
  598. return LA_FINISHED;
  599. }
  600. return LA_RUNNING;
  601. }
  602. int OPCHK_IsFileBrowser(laPropPack *This, laStringSplitor *ss){
  603. if (This && This->LastPs->p->SubProp == _LA_PROP_FILE_BROWSER) return 1;
  604. return 0;
  605. }
  606. int OPINV_FileBrowserUpLevel(laOperator *a, laEvent *e){
  607. if (a->This){
  608. la_FileBrowserUpLevel(a->This->EndInstance);
  609. laNotifyUsersPPPath(a->This, "path");
  610. laRecalcCurrentPanel();
  611. }
  612. return LA_FINISHED_PASS;
  613. }
  614. int OPINV_FileBrowserRefresh(laOperator *a, laEvent *e){
  615. if (a->This){
  616. la_FileBrowserRebuildList(a->This->EndInstance); laRecalcCurrentPanel();
  617. laNotifyUsersPPPath(a->This, "path");
  618. }
  619. return LA_FINISHED_PASS;
  620. }
  621. int OPINV_FileBrowserNewDirectory(laOperator *a, laEvent *e){
  622. if (a->This){
  623. laEnableOperatorPanel(a,a->This,e->x,e->y,200,200,400,400,0,0,0,0,0,0,e);
  624. return LA_RUNNING;
  625. }
  626. return LA_FINISHED;
  627. }
  628. int OPMOD_FileBrowserNewDirectory(laOperator *a, laEvent *e){
  629. laFileBrowser* fb=a->This->EndInstance;
  630. if (a->ConfirmData){
  631. if (a->ConfirmData->Mode == LA_CONFIRM_OK){
  632. la_FileBrowserNewDirectory(fb,fb->TempStr);
  633. }
  634. return LA_FINISHED;
  635. }
  636. return LA_RUNNING;
  637. }
  638. int OPCHK_FileBrowserCanConfirm(laPropPack *This, laStringSplitor *ss){
  639. if(!OPCHK_IsFileBrowser(This,ss)) return 0;
  640. laFileBrowser* fb=This->EndInstance;
  641. if(fb->SelectFolder) return 1;
  642. if(fb->FileName[0]) return 1;
  643. return 0;
  644. }
  645. int OPINV_FileBrowserConfirm(laOperator *a, laEvent *e){
  646. if (a->This){
  647. laFileBrowser* fb=a->This->EndInstance;
  648. if(fb->WarnFileExists){
  649. char path[2048]; la_FileBrowserGetFullPath(fb, path);
  650. #ifdef LA_LINUX
  651. if(access(path, F_OK)==0)
  652. #endif
  653. #ifdef _WIN32
  654. if (PathFileExists(path))
  655. #endif
  656. {
  657. laEnableYesNoPanel(a,0,"File exists","Selected file already exists. Overwrite the file?",e->x-LA_RH,e->y-LA_RH,200,e);
  658. fb->StatusWaitingWarning=1; return LA_RUNNING;
  659. }
  660. }
  661. laConfirmInt(a, 0, LA_CONFIRM_OK); return LA_FINISHED_PASS;
  662. }
  663. return LA_FINISHED_PASS;
  664. }
  665. int OPMOD_FileBrowserConfirm(laOperator *a, laEvent *e){
  666. laFileBrowser* fb=a->This->EndInstance;
  667. if (a->ConfirmData){
  668. if (a->ConfirmData->Mode == LA_CONFIRM_CANCEL){
  669. if(fb->StatusWaitingWarning){ fb->StatusWaitingWarning=0; return LA_FINISHED; }
  670. }
  671. if (a->ConfirmData->Mode == LA_CONFIRM_OK){
  672. laConfirmInt(a, 0, LA_CONFIRM_OK); return LA_FINISHED_PASS;
  673. }
  674. return LA_FINISHED;
  675. }
  676. return LA_RUNNING;
  677. }
  678. void laui_FileBrowserNewDirectory(laUiList *uil, laPropPack *This, laPropPack *Operator, laColumn *UNUSED, int context){
  679. laColumn* c=laFirstColumn(uil);
  680. laShowItem(uil,c,This,"temp_str");
  681. laUiItem* row=laBeginRow(uil,c,0,0);
  682. laShowSeparator(uil,c)->Expand=1;
  683. laShowItem(uil,c,0,"LA_confirm")->Flags|=LA_UI_FLAGS_HIGHLIGHT;
  684. laEndRow(uil,row);
  685. }
  686. void OPEXT_UDFOperation(laOperator *a, laEvent *e){
  687. laUDFPreviewExtra *upe = a->CustomData;
  688. memFree(upe);
  689. }
  690. int OPINV_UDFRead(laOperator *a, laEvent *e){
  691. laInvoke(a, "LA_file_dialog", e, 0, "filter_type=1;", 0);
  692. a->CustomData = memAcquireSimple(sizeof(laUDFPreviewExtra));
  693. laUDFPreviewExtra *upe = a->CustomData;
  694. if(strArgumentMatch(a->ExtraInstructionsP,"mode","append")){ upe->Append=1; }
  695. return LA_RUNNING;
  696. }
  697. int OPMOD_UDFRead(laOperator *a, laEvent *e){
  698. laUDFPreviewExtra *upe = a->CustomData;
  699. if (a->ConfirmData){
  700. if (a->ConfirmData->StrData){
  701. laManagedUDF* m;
  702. upe->UDF = laOpenUDF(a->ConfirmData->StrData, 1, 0, &m);
  703. if (upe->UDF){
  704. laFreeNewerDifferences();
  705. laFreeOlderDifferences(1);
  706. laExtractUDF(upe->UDF, m, upe->Append?LA_UDF_MODE_APPEND:LA_UDF_MODE_OVERWRITE);
  707. laCloseUDF(upe->UDF);
  708. laRecordEverythingAndPush(); laNotifyUsers("la.differences");
  709. return LA_FINISHED;
  710. }
  711. }
  712. return LA_FINISHED;
  713. }
  714. return LA_RUNNING;
  715. }
  716. int OPINV_UDFSaveInstance(laOperator *a, laEvent *e){
  717. laInvoke(a, "LA_file_dialog", e, 0, 0, 0);
  718. a->CustomData = memAcquireSimple(sizeof(laUDFPreviewExtra));
  719. return LA_RUNNING;
  720. }
  721. int OPMOD_UDFSaveInstance(laOperator *a, laEvent *e){
  722. laUDFPreviewExtra *upe = a->CustomData;
  723. laPropPack* pp=a->This; if(!pp||!pp->EndInstance) return LA_CANCELED;
  724. if (a->ConfirmData){
  725. if (a->ConfirmData->StrData){
  726. upe->UDF = laPrepareUDF(a->ConfirmData->StrData);
  727. if (upe->UDF){
  728. laWritePropP(upe->UDF, pp);
  729. laPackUDF(upe->UDF, 0, 0);
  730. return LA_FINISHED;
  731. }
  732. }
  733. }
  734. return LA_FINISHED;
  735. }
  736. void* laget_FirstManagedUDF(void* unused, void* unused_pi){ return MAIN.ManagedUDFs.pFirst; }
  737. void laset_ManagedSavePage(laManagedSaveExtra* mse, int p){
  738. mse->ShowPage=p;
  739. laRegisterModifications(0,0,0,0);
  740. }
  741. void OPEXT_ManagedSave(laOperator *a, laEvent *e){
  742. laManagedSaveExtra *upe = a->CustomData;
  743. memFree(upe);
  744. }
  745. int OPINV_ManagedSave(laOperator *a, laEvent *e){
  746. int OnExit=0;
  747. if(a->ExtraInstructionsP){
  748. if(strSame(strGetArgumentString(a->ExtraInstructionsP, "quiet"),"true")){
  749. int empty=0; laRegisterModifications(0,1,&empty,0);
  750. if(strSame(strGetArgumentString(a->ExtraInstructionsP, "ignore_unassigned"),"true")) empty=0;
  751. int modified_only=0; if(strSame(strGetArgumentString(a->ExtraInstructionsP, "modified_only"),"true")) modified_only=1;
  752. if(!empty){ laSaveManagedUDF(modified_only); return LA_FINISHED; }
  753. }
  754. if(strSame(strGetArgumentString(a->ExtraInstructionsP, "on_exit"),"true")){ OnExit=1; }
  755. }
  756. if(laOperatorExistsT(a->Type)) return LA_CANCELED;
  757. a->CustomData = memAcquire(sizeof(laManagedSaveExtra));
  758. laManagedSaveExtra* mse=a->CustomData;
  759. mse->OnExit=OnExit;
  760. mse->ShowPage = MAIN.ManagerDefaultView;
  761. laEnableOperatorPanel(a, 0, LA_RH2,LA_RH2,400,400,0,0,0,0,LA_RH2,LA_RH2,LA_RH2,LA_RH2,e);
  762. return LA_RUNNING;
  763. }
  764. int OPMOD_ManagedSave(laOperator *a, laEvent *e){
  765. laUDFPreviewExtra *upe = a->CustomData;
  766. if (a->ConfirmData){
  767. if(a->ConfirmData->Mode==LA_CONFIRM_CUSTOM_STRING && strSame(a->ConfirmData->StrData,"DISCARD_AND_QUIT")){
  768. return LA_OPERATOR_CALLS_SHUTOFF;
  769. }
  770. if(a->ConfirmData->Mode==LA_CONFIRM_CANCEL||a->ConfirmData->Mode==LA_CONFIRM_OK) return LA_FINISHED;
  771. return LA_RUNNING;
  772. }
  773. return LA_RUNNING;
  774. }
  775. int OPINV_ManagedSaveNewFile(laOperator *a, laEvent *e){
  776. if(MAIN.SetUDFPending) return LA_FINISHED;
  777. MAIN.SetUDFPending=1;
  778. a->CustomData = memAcquireSimple(sizeof(laUDFPreviewExtra));
  779. laInvoke(a, "LA_file_dialog", e, 0, "use_type=1;filter_type=1", 0);
  780. return LA_RUNNING;
  781. }
  782. int OPMOD_ManagedSaveNewFile(laOperator *a, laEvent *e){
  783. laUDFPreviewExtra *upe = a->CustomData;
  784. if (a->ConfirmData){
  785. if(a->ConfirmData->Mode==LA_CONFIRM_CANCEL){ MAIN.SetUDFPending=0; return LA_FINISHED; }
  786. if(a->ConfirmData->Mode==LA_CONFIRM_OK){
  787. if(a->ConfirmData->StrData){
  788. char* path=a->ConfirmData->StrData;
  789. if(la_FindManagedUDF(path)){
  790. laEnableMessagePanel(a, 0, "Duplicated files", "The file you chose already exists in the managed file list.",e->x,e->y,0,e);
  791. return LA_FINISHED;
  792. }
  793. laManagedUDF* m=MAIN.DummyManageUDF;
  794. m->udf = laPrepareUDF(path); strSafeSet(&m->BaseName, strGetLastSegment(path,LA_PATH_SEP));
  795. m->udf->Managed=1;
  796. la_MakeDummyManagedUDF();
  797. laNotifyUsers("la.managed_udfs"); laNotifyUsers("la.managed_props");
  798. }
  799. MAIN.SetUDFPending=0;
  800. return LA_FINISHED;
  801. }
  802. return LA_RUNNING;
  803. }
  804. return LA_RUNNING;
  805. }
  806. int OPINV_UDFManager(laOperator *a, laEvent *e){
  807. laRegisterModifications(0,0,0,0);
  808. laActivatePanel("LAUI_data_manager", e->x, e->y);
  809. return LA_FINISHED;
  810. }
  811. int OPINV_AddResourceFolder(laOperator *a, laEvent *e){
  812. laAddResourceFolder(0);
  813. laNotifyUsers("la.user_preferences.resource_folders");
  814. return LA_FINISHED;
  815. }
  816. int OPINV_RemoveResourceFolder(laOperator *a, laEvent *e){
  817. if(!a->This || !a->This->EndInstance) return LA_CANCELED;
  818. laResourceFolder* rf=a->This->EndInstance;
  819. laRemoveResourceFolder(rf);
  820. laRefreshUDFRegistries();
  821. laNotifyUsers("la.user_preferences.resource_folders");
  822. return LA_FINISHED;
  823. }
  824. int OPCHK_Undo(laPropPack *This, laStringSplitor *ss){
  825. laDiff* diff=MAIN.HeadDifference; if(!diff) return 0;
  826. diff=diff->Item.pPrev; if(!diff) return 0;
  827. }
  828. int OPCHK_Redo(laPropPack *This, laStringSplitor *ss){
  829. laDiff* diff=MAIN.HeadDifference; if(!diff) return 0;
  830. if(diff==MAIN.Differences.pLast) return 0;
  831. }
  832. int OPINV_Undo(laOperator *a, laEvent *e){
  833. laUndo();
  834. laPrintDBInstInfo();
  835. return LA_FINISHED;
  836. }
  837. int OPINV_Redo(laOperator *a, laEvent *e){
  838. laRedo();
  839. laPrintDBInstInfo();
  840. return LA_FINISHED;
  841. }
  842. int OPINV_UDFPropagate(laOperator *a, laEvent *e){
  843. laProp* p=a->This?a->This->LastPs->p:0; if(!p||p->PropertyType!=LA_PROP_SUB) return LA_FINISHED;
  844. void* instance=a->This->EndInstance; if(!instance) return LA_FINISHED;
  845. laPropContainer* pc=la_EnsureSubTarget(p,instance);
  846. int force=0;
  847. if(strSame(strGetArgumentString(a->ExtraInstructionsP,"force"),"true")){ force=1; }
  848. laPropagateUDF(pc, instance, force);
  849. laNotifyUsers("la.managed_props");
  850. return LA_FINISHED;
  851. }
  852. int OPINV_NewInputMapping(laOperator *a, laEvent *e){
  853. laNewInputMapping("New Mapping"); laNotifyUsers("la.input_mapping"); return LA_FINISHED;
  854. }
  855. int OPINV_RemoveInputMapping(laOperator *a, laEvent *e){
  856. if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMapping* im=a->This->EndInstance;
  857. char* buf[256];sprintf(buf,"%s \"%s\".",transLate("Will remove input mapping"),SSTR(im->Name));
  858. laEnableYesNoPanel(0, 0, "Confirm?", buf, e->x, e->y, 200, e);
  859. return LA_RUNNING;
  860. }
  861. int OPINV_NewInputMappingEntry(laOperator *a, laEvent *e){
  862. if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMapping* im=a->This->EndInstance;
  863. laInputMappingEntry* ime=laNewInputMappingEntry(im,0,0,"a",0,"none");
  864. if(strArgumentMatch(a->ExtraInstructionsP,"position","top")){
  865. lstRemoveItem(&im->Entries,ime);
  866. lstPushItem(&im->Entries,ime);
  867. }
  868. laNotifyUsers("la.input_mapping"); return LA_FINISHED;
  869. }
  870. int OPINV_RemoveInputMappingEntry(laOperator *a, laEvent *e){
  871. if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMappingEntry* ie=a->This->EndInstance;
  872. laEnableYesNoPanel(0, 0, "Confirm?", "Will remove this key map entry", e->x, e->y, 200, e);
  873. return LA_RUNNING;
  874. }
  875. int OPINV_ClearInputMappingFields(laOperator *a, laEvent *e){
  876. if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMappingEntry* ime=a->This->EndInstance;
  877. strSafeDestroy(&ime->Operator);strSafeDestroy(&ime->OperatorName);strSafeDestroy(&ime->OperatorArguments);
  878. strSafeDestroy(&ime->Key); strSafeDestroy(&ime->Signal);
  879. ime->OperatorBase=ime->OperatorType=0; ime->KeyValue=ime->SpecialKeyBits=0; ime->SignalValue=0;
  880. ime->JoystickDevice=ime->Axis=ime->Button=0; ime->DeviceType=0; ime->Disabled=0;
  881. return LA_FINISHED;
  882. }
  883. int OPMOD_RemoveInputMapping(laOperator *a, laEvent *e){
  884. if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMapping* im=a->This->EndInstance;
  885. if(a->ConfirmData){
  886. if(a->ConfirmData->Mode == LA_CONFIRM_OK){
  887. laRemoveInputMapping(im); laNotifyUsers("la.input_mapping");
  888. }
  889. return LA_FINISHED;
  890. }
  891. return LA_RUNNING;
  892. }
  893. int OPMOD_RemoveInputMappingEntry(laOperator *a, laEvent *e){
  894. if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMappingEntry* ie=a->This->EndInstance;
  895. if(a->ConfirmData){
  896. if(a->ConfirmData->Mode == LA_CONFIRM_OK){
  897. laRemoveInputMappingEntry(ie->Parent,ie); laNotifyUsers("la.input_mapping");
  898. }
  899. return LA_FINISHED;
  900. }
  901. return LA_RUNNING;
  902. }
  903. int OPINV_InputMappingEntrySelectSignal(laOperator *a, laEvent *e){
  904. if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMappingEntry* ime=a->This->EndInstance;
  905. laEnableOperatorPanel(a,a->This,e->x-LA_RH*5,e->y-LA_RH,LA_RH*15,LA_RH*15,LA_RH*30,LA_RH*30,0,0,0,0,0,0,e);
  906. return LA_RUNNING;
  907. }
  908. int OPMOD_InputMappingEntrySelectSignal(laOperator *a, laEvent *e){
  909. if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMappingEntry* ime=a->This->EndInstance;
  910. if(a->ConfirmData){
  911. if(a->ConfirmData->Mode == LA_CONFIRM_DATA && a->ConfirmData->PointerData && strSame(a->ConfirmData->PointerType->Identifier,"la_custom_signal")){
  912. laCustomSignal* cs=a->ConfirmData->PointerData;
  913. ime->SignalValue = cs->Signal; strSafeSet(&ime->Signal,SSTR(cs->Name));
  914. laNotifyUsers("la.input_mapping");
  915. }
  916. return LA_FINISHED;
  917. }
  918. return LA_RUNNING;
  919. }
  920. void laui_InputMappingEntrySignalSelector(laUiList *uil, laPropPack *Base, laPropPack *OperatorInst, laColumn *ExtraColumns, int context){
  921. laColumn* c=laFirstColumn(uil);
  922. laUiItem* b=laBeginRow(uil,c,0,0);
  923. laShowLabel(uil,c,"🔍",0,0);
  924. laUiItem* ui=laShowItem(uil,c,0,"la.signal_filter");ui->Expand=1;ui->Flags|=LA_UI_FLAGS_IMMEDIATE_INPUT;
  925. laEndRow(uil,b);
  926. laUiItem* g=laMakeEmptyGroup(uil,c,0,0); laUiList* guil=g->Page; laColumn* gc=laFirstColumn(guil); guil->HeightCoeff=10;
  927. laShowItemFull(guil,gc,0,"la.filtered_signals",LA_WIDGET_COLLECTION,0,0,0)->Flags|=LA_UI_FLAGS_NO_DECAL;
  928. }
  929. int OPINV_InputMappingEntrySelectOperator(laOperator *a, laEvent *e){
  930. if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMappingEntry* ime=a->This->EndInstance;
  931. laEnableOperatorPanel(a,a->This,e->x-LA_RH*5,e->y-LA_RH,LA_RH*15,LA_RH*20,LA_RH*30,LA_RH*35,0,0,0,0,0,0,e);
  932. return LA_RUNNING;
  933. }
  934. int OPMOD_InputMappingEntrySelectOperator(laOperator *a, laEvent *e){
  935. if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMappingEntry* ime=a->This->EndInstance;
  936. if(a->ConfirmData){
  937. if(a->ConfirmData->Mode == LA_CONFIRM_DATA && a->ConfirmData->PointerData && strSame(a->ConfirmData->PointerType->Identifier,"la_operator_type")){
  938. laOperatorType* at=a->ConfirmData->PointerData;
  939. strSafeSet(&ime->Operator,at->Identifier);
  940. strSafeSet(&ime->OperatorName,at->Name);
  941. ime->OperatorType = at;
  942. laNotifyUsers("la.input_mapping");
  943. }
  944. return LA_FINISHED;
  945. }
  946. return LA_RUNNING;
  947. }
  948. void laui_InputMappingEntryOperatorSelector(laUiList *uil, laPropPack *Base, laPropPack *OperatorInst, laColumn *ExtraColumns, int context){
  949. laColumn* c=laFirstColumn(uil);
  950. laUiItem* b=laBeginRow(uil,c,0,0);
  951. laShowLabel(uil,c,"🔍",0,0);
  952. laUiItem* ui=laShowItem(uil,c,0,"la.operator_filter");ui->Expand=1;ui->Flags|=LA_UI_FLAGS_IMMEDIATE_INPUT;
  953. laEndRow(uil,b);
  954. laUiItem* g=laMakeEmptyGroup(uil,c,0,0); laUiList* guil=g->Page; laColumn* gc=laFirstColumn(guil); guil->HeightCoeff=20;
  955. laShowItemFull(guil,gc,0,"la.filtered_operators",LA_WIDGET_COLLECTION,0,laui_OperatorTypeEntry,0)->Flags|=LA_UI_FLAGS_NO_DECAL;
  956. }
  957. STRUCTURE(laKeyDetectorData){
  958. int pad;
  959. int DeviceType;
  960. int Key;
  961. int SpecialKeyBit;
  962. int Button, Axis, Device;
  963. laSafeString* Str;
  964. };
  965. int OPEXT_InputMappingEntrySelectKey(laOperator* a,int exitmode){
  966. laKeyDetectorData* kdd=a->CustomData;
  967. strSafeDestroy(&kdd->Str);
  968. memFree(kdd);
  969. }
  970. int OPINV_InputMappingEntrySelectKey(laOperator *a, laEvent *e){
  971. if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMappingEntry* ime=a->This->EndInstance;
  972. a->CustomData = memAcquire(sizeof(laKeyDetectorData));
  973. laEnableOperatorPanel(a,a->This,e->x-LA_RH*5,e->y-LA_RH,LA_RH*10,LA_RH*10,LA_RH*20,LA_RH*20,LA_RH*10,0,0,0,0,0,e);
  974. laOperatorModalOver(a);
  975. return LA_RUNNING;
  976. }
  977. int OPMOD_InputMappingEntrySelectKey(laOperator *a, laEvent *e){
  978. if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMappingEntry* ime=a->This->EndInstance;
  979. laKeyDetectorData* kdd=a->CustomData; if(!kdd){ return LA_FINISHED; }
  980. char buf[64],*_next=buf;
  981. if(e->type == LA_KEY_DOWN){
  982. kdd->Key = e->key; la_InputMappingGetKeyName(kdd->Key,e->SpecialKeyBit,buf); strSafeSet(&kdd->Str,buf); kdd->DeviceType=LA_INPUT_DEVICE_KEYBOARD;
  983. laNotifyInstanceUsers(kdd); kdd->SpecialKeyBit=e->SpecialKeyBit;
  984. return LA_RUNNING;
  985. }elif(e->type == LA_EMPTY){
  986. if(MAIN.ControllerHasNewAxis){
  987. kdd->Axis = MAIN.LastControllerAxis; kdd->Device = MAIN.LastControllerAxisDevice; kdd->Button =-1; kdd->DeviceType=LA_INPUT_DEVICE_JOYSTICK;
  988. strSafeSet(&kdd->Str,laControllerIDGetAxisName(kdd->Device,kdd->Axis)); laNotifyInstanceUsers(kdd);
  989. }elif(MAIN.ControllerHasNewKey){
  990. kdd->Button = MAIN.LastControllerKey; kdd->Device = MAIN.LastControllerKeyDevice; kdd->Axis = -1; kdd->DeviceType=LA_INPUT_DEVICE_JOYSTICK;
  991. strSafeSet(&kdd->Str,laControllerIDGetButtonName(kdd->Device,kdd->Button)); laNotifyInstanceUsers(kdd);
  992. }
  993. }
  994. if(a->ConfirmData){
  995. if(a->ConfirmData->Mode == LA_CONFIRM_CUSTOM_STRING){
  996. char* ReportedEvent=a->ConfirmData->StrData;
  997. strSafeSet(&kdd->Str,ReportedEvent);
  998. kdd->DeviceType = LA_INPUT_DEVICE_MOUSE;
  999. kdd->Key = la_InputMappingGetKeyFromName(ReportedEvent,&kdd->SpecialKeyBit);
  1000. laNotifyInstanceUsers(kdd);
  1001. return LA_RUNNING_PASS;
  1002. }
  1003. if(a->ConfirmData->Mode == LA_CONFIRM_OK){
  1004. strSafeSet(&ime->Key,SSTR(kdd->Str));
  1005. if(kdd->DeviceType==LA_INPUT_DEVICE_JOYSTICK){ ime->DeviceType = LA_INPUT_DEVICE_JOYSTICK; ime->Axis=kdd->Axis; ime->Button=kdd->Button; ime->JoystickDevice = kdd->Device; }
  1006. elif(kdd->DeviceType==LA_INPUT_DEVICE_MOUSE){ ime->DeviceType = LA_INPUT_DEVICE_MOUSE; ime->KeyValue = kdd->Key; ime->SpecialKeyBits=kdd->SpecialKeyBit; }
  1007. else{ ime->DeviceType = LA_INPUT_DEVICE_KEYBOARD; ime->KeyValue = kdd->Key; ime->SpecialKeyBits=kdd->SpecialKeyBit; }
  1008. laNotifyInstanceUsers(ime);
  1009. }
  1010. return LA_FINISHED_PASS;
  1011. }
  1012. return LA_RUNNING_PASS;
  1013. }
  1014. void laui_InputMappingEntryKeySelector(laUiList *uil, laPropPack *Base, laPropPack *OperatorInst, laColumn *ExtraColumns, int context){
  1015. laColumn* c=laFirstColumn(uil);
  1016. laUiItem* b;
  1017. laShowLabel(uil,c,"Press a key:",0,0)->Flags|=LA_UI_FLAGS_DISABLED;
  1018. laShowItem(uil,c,OperatorInst,"pressed_string")->Flags|=LA_UI_FLAGS_PLAIN;
  1019. laShowLabel(uil,c,"Or click mouse button in:",0,0)->Flags|=LA_UI_FLAGS_DISABLED;
  1020. laShowMouseActionReporter(uil,c,3,0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
  1021. b=laBeginRow(uil,c,0,0);
  1022. laShowSeparator(uil,c)->Expand=1;
  1023. laShowItem(uil,c,0,"LA_confirm");
  1024. laEndRow(uil,b);
  1025. }
  1026. void laget_KeyDetectorPressedString(laKeyDetectorData* kdd, char* out, char** pivot){
  1027. if(kdd->DeviceType==LA_INPUT_DEVICE_JOYSTICK){
  1028. if(kdd->Axis>=0){ sprintf(out, "Controller %d axis \"%s\" (0x%0x)", kdd->Device, SSTR(kdd->Str), kdd->Axis); }
  1029. else{ sprintf(out, "Controller %d button \"%s\" (0x%0x)", kdd->Device, SSTR(kdd->Str), kdd->Button); }
  1030. }elif(kdd->DeviceType==LA_INPUT_DEVICE_MOUSE){
  1031. sprintf(out, "Mouse \"%s\" (0x%0x)", SSTR(kdd->Str), kdd->Key);
  1032. }else{
  1033. sprintf(out, "Keyboard \"%s\" (0x%0x)", SSTR(kdd->Str), kdd->Key);
  1034. }
  1035. }
  1036. int OPINV_SaveUserPreferences(laOperator *a, laEvent *e){
  1037. laSaveUserPreferences(); return LA_FINISHED;
  1038. }
  1039. int OPMOD_RestoreFactorySettings(laOperator* a, laEvent* e){
  1040. if (a->ConfirmData){
  1041. if (a->ConfirmData->Mode == LA_CONFIRM_OK){
  1042. if (laRestoreFactorySettings()){
  1043. laEnableMessagePanel(0, 0, "Success", "Restart the program for changes to take effect.", e->x, e->y, 200, 0);
  1044. MAIN.SavePreferenceOnExit = 0;
  1045. }else{
  1046. laEnableMessagePanel(0, 0, "Problem", "Unable to remove preference file.", e->x, e->y, 200, 0);
  1047. }
  1048. }
  1049. return LA_FINISHED;
  1050. }
  1051. return LA_RUNNING;
  1052. }
  1053. int OPINV_RestoreFactorySettings(laOperator* a, laEvent* e){
  1054. laEnableYesNoPanel(0, 0, "Confirm?", "This will remove the preference file.\nChanges take effect on restating the program.", e->x, e->y, 200, e);
  1055. return LA_RUNNING;
  1056. }
  1057. int OPCHK_TerminateProgram(laPropPack *This, laStringSplitor *Instructions){
  1058. return 1;
  1059. }
  1060. int OPINV_TerminateProgram(laOperator *a, laEvent *e){
  1061. int empty=0; int mod=laRegisterModifications(1,1,&empty,0);
  1062. if(mod || empty){ laInvoke(0, "LA_managed_save", 0,0,"on_exit=true;",0); return LA_FINISHED; }
  1063. return LA_OPERATOR_CALLS_SHUTOFF;
  1064. }
  1065. int OPCHK_PropSetValue(laPropPack *This, laStringSplitor *Instructions){
  1066. if (This && (!This->LastPs->p->ReadOnly)) return 1;
  1067. else return 0;
  1068. }
  1069. int OPCHK_StringSetValue(laPropPack *This, laStringSplitor *Instructions){
  1070. if (This && (This->LastPs->p->PropertyType == LA_PROP_STRING) && (!This->LastPs->p->ReadOnly)) return 1;
  1071. else return 0;
  1072. }
  1073. int OPCHK_CollectionSetValue(laPropPack *This, laStringSplitor *Instructions){
  1074. laSubProp*sp=This->LastPs->p;
  1075. if (This && (This->LastPs->p->PropertyType == LA_PROP_SUB) && (!This->LastPs->p->ReadOnly) &&
  1076. (sp->Base.UDFIsRefer && (!sp->Base.UDFIsSingle) && (sp->Base.Offset>=0||sp->Set||sp->SetState))) return 1;
  1077. else return 0;
  1078. }
  1079. int OPINV_CollectionClearSelection(laOperator *a, laEvent *e){
  1080. if(!a->This) return LA_CANCELED; laSubProp* sp=a->This->LastPs->p;
  1081. laSetActiveInstance(sp, a->This->LastPs->UseInstance, 0);
  1082. return LA_FINISHED;
  1083. }
  1084. int OPINV_PropSetDefault(laOperator *a, laEvent *e){
  1085. if(!a->This) return LA_CANCELED; laProp* p=a->This->LastPs->p;
  1086. if (p->PropertyType==LA_PROP_ENUM){
  1087. laEnumProp *ep = a->This->LastPs->p; laSetEnum(a->This, ep->DefVal); }
  1088. elif (p->PropertyType==(LA_PROP_ENUM|LA_PROP_ARRAY)){
  1089. laEnumProp *ep = a->This->LastPs->p; laSetEnumArrayAll(a->This, ep->DefVal); }
  1090. elif (p->PropertyType==LA_PROP_INT){
  1091. laIntProp *ip = a->This->LastPs->p; laSetInt(a->This, ip->DefVal);}
  1092. elif (p->PropertyType==(LA_PROP_INT|LA_PROP_ARRAY)){ laIntProp *ip = a->This->LastPs->p;
  1093. if (ip->DefArr) laSetIntArrayAllArray(a->This, ip->DefArr); else laSetIntArrayAll(a->This, ip->DefVal); }
  1094. elif (p->PropertyType==LA_PROP_FLOAT){
  1095. laFloatProp *ip = a->This->LastPs->p; laSetFloat(a->This, ip->DefVal); }
  1096. elif (p->PropertyType==(LA_PROP_FLOAT|LA_PROP_ARRAY)){ laFloatProp *ip = a->This->LastPs->p;
  1097. if (ip->DefArr) laSetFloatArrayAllArray(a->This, ip->DefArr); else laSetFloatArrayAll(a->This, ip->DefVal); }
  1098. elif (p->PropertyType==LA_PROP_STRING){laStringProp *sp = a->This->LastPs->p;
  1099. if (sp->DefStr) laSetString(a->This, sp->DefStr); else laSetString(a->This, ""); }
  1100. return LA_FINISHED;
  1101. }
  1102. int OPINV_PropSetMax(laOperator *a, laEvent *e){
  1103. if(!a->This) return LA_CANCELED; laProp* p=a->This->LastPs->p;
  1104. if (p->PropertyType==LA_PROP_INT){
  1105. laIntProp *ip = a->This->LastPs->p; laSetInt(a->This, ip->Max); }
  1106. elif (p->PropertyType==(LA_PROP_INT|LA_PROP_ARRAY)){
  1107. laIntProp *ip = a->This->LastPs->p; laSetIntArrayAll(a->This, ip->Max); }
  1108. elif (p->PropertyType==LA_PROP_FLOAT){
  1109. laFloatProp *ip = a->This->LastPs->p; laSetFloat(a->This, ip->Max); }
  1110. elif (p->PropertyType==(LA_PROP_FLOAT|LA_PROP_ARRAY)){
  1111. laFloatProp *ip = a->This->LastPs->p; laSetFloatArrayAll(a->This, ip->Max); }
  1112. return LA_FINISHED;
  1113. }
  1114. int OPINV_PropSetMin(laOperator *a, laEvent *e){
  1115. if(!a->This) return LA_CANCELED; laProp* p=a->This->LastPs->p;
  1116. if (p->PropertyType==LA_PROP_INT){
  1117. laIntProp *ip = a->This->LastPs->p; laSetInt(a->This, ip->Min); }
  1118. elif (p->PropertyType==(LA_PROP_INT|LA_PROP_ARRAY)){
  1119. laIntProp *ip = a->This->LastPs->p; laSetIntArrayAll(a->This, ip->Min); }
  1120. elif (p->PropertyType==LA_PROP_FLOAT){
  1121. laFloatProp *ip = a->This->LastPs->p; laSetFloat(a->This, ip->Min); }
  1122. elif (p->PropertyType==(LA_PROP_FLOAT|LA_PROP_ARRAY)){
  1123. laFloatProp *ip = a->This->LastPs->p; laSetFloatArrayAll(a->This, ip->Min); }
  1124. return LA_FINISHED;
  1125. }
  1126. int OPINV_StringGetFolderPath(laOperator *a, laEvent *e){
  1127. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_STRING)){
  1128. laInvoke(a, "LA_file_dialog", e, 0, "select=folder;", 0);
  1129. return LA_RUNNING;
  1130. }
  1131. return LA_FINISHED;
  1132. }
  1133. int OPINV_StringGetFilePath(laOperator *a, laEvent *e){
  1134. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_STRING)){
  1135. laInvoke(a, "LA_file_dialog", e, 0, 0, 0);
  1136. return LA_RUNNING;
  1137. }
  1138. return LA_FINISHED;
  1139. }
  1140. int OPMOD_StringGetFolderOrFilePath(laOperator *a, laEvent *e){
  1141. if (a->ConfirmData){
  1142. if (a->ConfirmData->StrData){
  1143. laStringProp *sp = a->This->LastPs->p;
  1144. laSetString(a->This, a->ConfirmData->StrData);
  1145. return LA_FINISHED_PASS;
  1146. }
  1147. return LA_FINISHED_PASS;
  1148. }
  1149. return LA_RUNNING;
  1150. }
  1151. int OPINV_StringCopy(laOperator *a, laEvent *e){
  1152. laPropPack* pp=a->This; if(!a->This) return LA_FINISHED;
  1153. char _buf[256]={0}; char* buf=_buf;
  1154. laGetString(pp,_buf,&buf);
  1155. laCopyToClipboard(buf);
  1156. return LA_FINISHED;
  1157. }
  1158. int OPINV_StringPaste(laOperator *a, laEvent *e){
  1159. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_STRING)){
  1160. laStringProp *sp = a->This->LastPs->p;
  1161. if (sp->DefStr) laSetString(a->This, sp->DefStr);
  1162. else laSetString(a->This, "");
  1163. }
  1164. return LA_FINISHED;
  1165. }
  1166. int OPCHK_CombineChildBlocks(laPropPack *This, laStringSplitor *Instructions){
  1167. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  1168. laBlock *b = l->OnBlockSeperator;
  1169. if (!(b)) return 0;
  1170. }
  1171. int OPINV_CombineChildBlocks(laOperator *a, laEvent *e){
  1172. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  1173. laBlock *b = l->OnBlockSeperator;
  1174. if (!b) b = laDetectBlockRecursive(l->FirstBlock, e->x, e->y);
  1175. if (b){
  1176. laCombineChildBlocks(b);
  1177. return LA_FINISHED;
  1178. }
  1179. return LA_CANCELED;
  1180. }
  1181. int OPCHK_PropInsertKey(laPropPack *This, laStringSplitor *Instructions){
  1182. if (MAIN.Animation->CurrentAction && This && This->LastPs->p->Keyable) return 1;
  1183. else return 0;
  1184. }
  1185. int OPINV_PropInsertKey(laOperator *a, laEvent *e){
  1186. int err; laAction* aa=MAIN.Animation->CurrentAction;
  1187. laAnimationInsertKeyFrame(aa,a->This->LastPs->UseInstance,a->This->LastPs->p,&err);
  1188. if(err==1){
  1189. laEnableMessagePanel(a,0,"Error","Action holder info missing.\nThis should not happen.",e->x,e->y,100,e);
  1190. }elif(err==2){
  1191. char msg[1024]; char _id[128]="unknown container",*id=_id,_idc[128]="unknown object",*idc=_idc;
  1192. laTryGetInstanceIdentifier(aa->HolderInstance,aa->HolderContainer,_id,&id);
  1193. laTryGetInstanceIdentifier(a->This->LastPs->UseInstance,a->This->LastPs->p->Container,_idc,&idc);
  1194. sprintf(msg,"Can't insert key frame into current action.\n\"%s\" doesn't belong to \"%s\".",idc,id);
  1195. laEnableMessagePanel(a,0,"Error",msg,e->x,e->y,100,e);
  1196. }
  1197. return LA_FINISHED;
  1198. }
  1199. STRUCTURE(laNewPanelData){
  1200. laUiTemplate* SelectedTemplate;
  1201. laBlock* b;
  1202. };
  1203. void laui_TitleOnly(laUiList *uil, laPropPack *This, laPropPack *OP_UNUSED, laColumn *Extra, int context){
  1204. laColumn *col = Extra, *c, *cl, *cr, *crl, *crr, *cll, *clr, *clrl, *clrr, *clrrl, *clrrr;
  1205. laUiItem *ui;
  1206. c = laFirstColumn(uil);
  1207. laShowItemFull(uil, c, This, "title", LA_WIDGET_STRING_PLAIN, 0, 0, 0);
  1208. }
  1209. laUiTemplate* laget_FirstPanelTemplate(void* unused1, void* unused2){
  1210. return MAIN.PanelTemplates.pFirst;
  1211. }
  1212. void laset_NewPanelSetTemplate(laNewPanelData *np, laUiTemplate *uit, int State){
  1213. np->SelectedTemplate = uit;
  1214. }
  1215. laUiTemplate* laget_NewPanelGetActiveTemplate(laNewPanelData* np, laUiTemplate* uit){
  1216. return np->SelectedTemplate;
  1217. }
  1218. void laui_PanelTemplateSelect(laUiList *uil, laPropPack *This, laPropPack *OperatorProps, laColumn *UNUSED, int context){
  1219. laColumn *c = laFirstColumn(uil);
  1220. laUiItem* ui=laShowItem(uil, c, OperatorProps, "template");ui->SymbolID=2; ui->Flags|=LA_UI_FLAGS_NO_DECAL;
  1221. }
  1222. int OPINV_Fullscreen(laOperator *a, laEvent *e){
  1223. laWindow* w=MAIN.CurrentWindow;
  1224. int full=1;
  1225. if(strArgumentMatch(a->ExtraInstructionsP,"restore","true")){ full=0; }
  1226. if(strArgumentMatch(a->ExtraInstructionsP,"toggle","true")){ full=w->IsFullScreen?0:1; }
  1227. #ifdef LA_LINUX
  1228. XClientMessageEvent msg = {
  1229. .type = ClientMessage, .display = MAIN.dpy, .window = w->win,
  1230. .message_type = XInternAtom(MAIN.dpy, "_NET_WM_STATE", True), .format = 32,
  1231. .data = {.l = {full, XInternAtom(MAIN.dpy, "_NET_WM_STATE_FULLSCREEN", True), None, 0, 1 }}
  1232. };
  1233. XSendEvent(MAIN.dpy, XRootWindow(MAIN.dpy, XDefaultScreen(MAIN.dpy)), False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent*) &msg);
  1234. #endif
  1235. #ifdef _WIN32
  1236. DWORD dwStyle = GetWindowLong(w->win, GWL_STYLE);
  1237. static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
  1238. if (full){
  1239. MONITORINFO mi = { sizeof(mi) };
  1240. if (GetWindowPlacement(w->win, &g_wpPrev) &&
  1241. GetMonitorInfo(MonitorFromWindow(w->win,
  1242. MONITOR_DEFAULTTOPRIMARY), &mi)) {
  1243. SetWindowLong(w->win, GWL_STYLE,
  1244. dwStyle & ~WS_OVERLAPPEDWINDOW);
  1245. SetWindowPos(w->win, HWND_TOP,
  1246. mi.rcMonitor.left, mi.rcMonitor.top,
  1247. mi.rcMonitor.right - mi.rcMonitor.left,
  1248. mi.rcMonitor.bottom - mi.rcMonitor.top,
  1249. SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
  1250. }
  1251. }else{
  1252. SetWindowLong(w->win, GWL_STYLE,dwStyle|WS_OVERLAPPEDWINDOW);
  1253. SetWindowPlacement(w->win, &g_wpPrev);
  1254. SetWindowPos(w->win,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_FRAMECHANGED);
  1255. }
  1256. #endif
  1257. w->IsFullScreen=full;
  1258. laRedrawCurrentWindow();
  1259. return LA_FINISHED;
  1260. }
  1261. int OPINV_NewLayout(laOperator *a, laEvent *e){
  1262. laWindow* w=MAIN.CurrentWindow;
  1263. laDesignLayout(w, "New Layout");
  1264. laRedrawCurrentWindow();
  1265. return LA_FINISHED;
  1266. }
  1267. int OPCHK_RemoveLayout(laPropPack *This, laStringSplitor *Instructions){
  1268. laWindow* w=MAIN.CurrentWindow; if(w->Layouts.pFirst==w->Layouts.pLast) return 0;
  1269. return 1;
  1270. }
  1271. int OPINV_RemoveLayout(laOperator *a, laEvent *e){
  1272. laWindow* w=MAIN.CurrentWindow; if(w->Layouts.pFirst==w->Layouts.pLast) return LA_FINISHED;
  1273. laDestroyLayout(w,w->CurrentLayout); laRedrawCurrentWindow();
  1274. return LA_FINISHED;
  1275. }
  1276. int OPINV_NewPanel(laOperator *a, laEvent *e){
  1277. laNewPanelData* np= memAcquire(sizeof(laNewPanelData));
  1278. a->CustomData = np;
  1279. laEnableOperatorPanel(a, 0, e->x-50,e->y-50,500,500,10000,0,0,0,0,0,0,0,e);
  1280. return LA_RUNNING;
  1281. }
  1282. int OPMOD_NewPanel(laOperator *a, laEvent *e){
  1283. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  1284. laNewPanelData* np=a->CustomData;
  1285. if(!a->ConfirmData) return LA_RUNNING;
  1286. if(a->ConfirmData->Mode == LA_CONFIRM_CANCEL||a->ConfirmData->Mode == LA_CONFIRM_OK){ if(np) memFree(np); return LA_CANCELED; }
  1287. if(a->ConfirmData->Mode == LA_CONFIRM_DATA){
  1288. if (!np || !np->SelectedTemplate){ if(np) memFree(np); return LA_CANCELED; }
  1289. laPanel *p = la_FindFreePanelByTemplate(MAIN.CurrentWindow, np->SelectedTemplate);
  1290. if (!p){
  1291. p = laCreateTopPanel(MAIN.CurrentWindow, np->SelectedTemplate->Identifier->Ptr, e->x, e->y,0,0,0,0,0,0,0,0,0,0);
  1292. }
  1293. laShowPanelWithExpandEffect(p); laPopPanel(p); memFree(np);
  1294. return LA_FINISHED;
  1295. }
  1296. return LA_RUNNING;
  1297. }
  1298. int OPINV_BlockFoldTitle(laOperator *a, laEvent *e){
  1299. laBlock* b=a->This?a->This->EndInstance:0;
  1300. if(!b) return LA_CANCELED;
  1301. if(strSame(strGetArgumentString(a->ExtraInstructionsP, "show"), "true")) laUnfoldBlockTitle(b);
  1302. else laFoldBlockTitle(b);
  1303. return LA_FINISHED;
  1304. }
  1305. int OPINV_BlockMaximize(laOperator *a, laEvent *e){
  1306. laBlock* b=a->This?a->This->EndInstance:0;
  1307. if(!b || strSame(strGetArgumentString(a->ExtraInstructionsP, "restore"), "true")) laRestoreToLayout();
  1308. else laMaximizeBlock(b);
  1309. return LA_FINISHED;
  1310. }
  1311. int OPINV_CanvasUiMaximize(laOperator *a, laEvent *e){
  1312. laUiItem* ui=a->This?a->This->EndInstance:0;
  1313. laPanel* p=MAIN.CurrentPanel;
  1314. if(!ui || !p || (!ui->Type->Tag&LA_UI_TAG_IS_OFFSCREEN) || MAIN.CurrentWindow->MaximizedUi ||
  1315. strSame(strGetArgumentString(a->ExtraInstructionsP, "restore"), "true")) laRestoreCanvasUI();
  1316. else laMaximizeCanvasUI(ui,p);
  1317. return LA_FINISHED;
  1318. }
  1319. int OPINV_HideMenuBar(laOperator *a, laEvent *e){
  1320. if(!MAIN.CurrentWindow->MaximizedUi || strSame(strGetArgumentString(a->ExtraInstructionsP, "restore"), "true")) laShowMenuBar();
  1321. else laHideMenuBar();
  1322. return LA_FINISHED;
  1323. }
  1324. int OPINV_BlockTearOffPanel(laOperator *a, laEvent *e){
  1325. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  1326. laBlock* b = l->OperatingBlock;
  1327. if (!b) b = laDetectBlockRecursive(l->FirstBlock, e->x, e->y);
  1328. if(!b) return LA_CANCELED;
  1329. laTearOffPanel(b,0);
  1330. return LA_FINISHED;
  1331. }
  1332. int OPCHK_BlockHasMorePanels(laPropPack *This, laStringSplitor *Instructions){
  1333. laPanel*p = This?This->LastPs->UseInstance:0;
  1334. if(p && p->Mode == LA_PANEL_FLOATING_TOP) return 1;
  1335. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  1336. laBlock *b = l->OperatingBlock;
  1337. if (b && b->Panels.pFirst == b->Panels.pLast) return 0;
  1338. return 1;
  1339. }
  1340. int OPINV_BlockClosePanel(laOperator *a, laEvent *e){
  1341. laPanel*p = a->This?a->This->EndInstance:0;
  1342. if(p && p->Mode == LA_PANEL_FLOATING_TOP){
  1343. laDestroySinglePanel(p,0);
  1344. return LA_FINISHED;
  1345. }
  1346. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  1347. laBlock *b = l->OperatingBlock;
  1348. int x = e->x, y = e->y;
  1349. if (!b) b = laDetectBlockRecursive(l->FirstBlock, e->x, e->y);
  1350. if (b){
  1351. if (b->CurrentPanel){
  1352. //laLocalToWindow(a, MAIN.CurrentPanel, &x, &y);
  1353. laEnableYesNoPanel(a, 0, "Caution!", "Are you sure to destroy this panel?", e->x - 250, e->y, 250, e);
  1354. return LA_RUNNING;
  1355. }
  1356. }
  1357. return LA_CANCELED;
  1358. }
  1359. int OPMOD_BlockClosePanel(laOperator *a, laEvent *e){
  1360. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  1361. laBlock *b = l->OperatingBlock;
  1362. if (e->type == LA_KEY_DOWN && e->key==LA_KEY_ESCAPE) return LA_FINISHED;
  1363. if (a->ConfirmData){
  1364. if (!b) b = laDetectBlockRecursive(l->FirstBlock, e->x, e->y);
  1365. if (!b) return LA_CANCELED;
  1366. if (a->ConfirmData->Mode == LA_CONFIRM_OK){
  1367. laDestroySinglePanel(b->CurrentPanel,1);
  1368. la_RecalcBlockRecursive(b, b->X, b->Y, b->W, b->H);
  1369. }
  1370. return LA_FINISHED;
  1371. }else
  1372. return LA_RUNNING;
  1373. }
  1374. int laui_BlockEdgeMenu(laOperator *WindowAct, laLayout *l, laBlock *b, laEvent *e){
  1375. laPanel *p;
  1376. laColumn *c, *cl, *cr;
  1377. laUiList *uil;
  1378. p = laDefineAndEnableMenuPanel(0, WindowAct, 0, e->x, e->y, 500, 200, e);
  1379. uil = laPrepareUi(p);
  1380. c = laFirstColumn(uil);
  1381. laSplitColumn(uil, c, 0.5);
  1382. cl = laLeftColumn(c, 0);
  1383. cr = laRightColumn(c, 0);
  1384. laShowItem(uil, c, 0, "LA_combine_child_blocks");
  1385. laEnclosePanelContent(p,uil);
  1386. }
  1387. laBlock* la_MakeDropBlock(laBlock* DropToBlock, int DropLocation){
  1388. switch (DropLocation){
  1389. case 0: return DropToBlock;
  1390. case LA_BLOCK_DROP_LOCATION_U:
  1391. laSplitBlockVertical(DropToBlock, 0.5); laSwapSubBlocks(DropToBlock);
  1392. return DropToBlock->B1;
  1393. case LA_BLOCK_DROP_LOCATION_B:
  1394. laSplitBlockVertical(DropToBlock, 0.5);
  1395. return DropToBlock->B2;
  1396. case LA_BLOCK_DROP_LOCATION_L:
  1397. laSplitBlockHorizon(DropToBlock, 0.5); laSwapSubBlocks(DropToBlock);
  1398. return DropToBlock->B1;
  1399. case LA_BLOCK_DROP_LOCATION_R:
  1400. laSplitBlockHorizon(DropToBlock, 0.5);
  1401. return DropToBlock->B2;
  1402. }
  1403. }
  1404. void la_StartDocking(laWindow* from, laPanel* p){
  1405. for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){ w->DockingFrom = from; w->IsDocking=1; } MAIN.DockingPanel=p;
  1406. }
  1407. void la_StopDocking(){
  1408. for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){ w->DockingFrom = 0; w->IsDocking=0; } MAIN.DockingPanel=0;
  1409. }
  1410. void la_ClearDockingTarget(){
  1411. for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){ w->CurrentLayout->DropToBlock=0; }
  1412. }
  1413. int OPINV_DockPanel(laOperator* a, laEvent* e){
  1414. laPanel*p = a->This?a->This->EndInstance:0;
  1415. if(!p) return LA_CANCELED;
  1416. la_StartDocking(MAIN.CurrentWindow, p);
  1417. laRestoreToLayout();
  1418. laRestoreCanvasUI();
  1419. return LA_FINISHED;
  1420. }
  1421. int OPINV_NewWindow(laOperator* a, laEvent* e){
  1422. laWindow* w = a->This?a->This->EndInstance:MAIN.CurrentWindow;
  1423. laWindow* nw =laDesignWindow(w->X,w->Y,w->W,w->H);
  1424. laLayout* l=(w->Layouts.pFirst!=w->Layouts.pLast)?w->CurrentLayout:0;
  1425. if (l && !strSame(strGetArgumentString(a->ExtraInstructionsP, "clean"), "true")){
  1426. laLayout* nextl=l->Item.pPrev?l->Item.pPrev:l->Item.pNext;
  1427. memAssignRef(w, &w->CurrentLayout, nextl);
  1428. lstRemoveItem(&w->Layouts, l); lstAppendItem(&nw->Layouts, l);
  1429. memAssignRef(nw, &nw->CurrentLayout, l);
  1430. laRenameWindow(nw, l->ID->Ptr);
  1431. laRenameWindow(w, w->CurrentLayout->ID->Ptr);
  1432. }else{
  1433. laDesignLayout(nw, "Empty Layout");
  1434. }
  1435. laStartWindow(nw);
  1436. laRedrawAllWindows();
  1437. return LA_FINISHED;
  1438. }
  1439. void *la_OnBlockSeperator(laBlock *b, laEvent *e){
  1440. int at;
  1441. laBlock *bb;
  1442. if (!b->B1) return 0;
  1443. if (b->Vertical){
  1444. at = b->H * b->SplitRatio + b->Y;
  1445. if (e->x>=b->X && e->x<=b->X+b->W && e->y >= at - LA_SEAM_W && e->y <= at + LA_SEAM_W){
  1446. return b;
  1447. }
  1448. }else{
  1449. at = b->X + b->W * b->SplitRatio;
  1450. if (e->y>=b->Y && e->y<=b->Y+b->H && e->x >= at - LA_SEAM_W && e->x <= at + LA_SEAM_W){
  1451. return b;
  1452. }
  1453. }
  1454. if (bb = la_OnBlockSeperator(b->B1, e)) return bb;
  1455. else
  1456. return la_OnBlockSeperator(b->B2, e);
  1457. }
  1458. int la_DetectBlockDropLocation(laBlock *b, int X, int Y){
  1459. laPanel *p = b->Panels.pFirst;
  1460. if (!p) return 0;
  1461. real L = tnsGetRatiod(p->X, p->X + p->W, X);
  1462. real U = tnsGetRatiod(p->Y, p->Y + p->H, Y);
  1463. if (L > U){
  1464. if (U < 0.25){
  1465. if (L < 0.75) return LA_BLOCK_DROP_LOCATION_U;
  1466. else
  1467. return LA_BLOCK_DROP_LOCATION_R;
  1468. }else{
  1469. if (L < 0.75) return 0;
  1470. else
  1471. return LA_BLOCK_DROP_LOCATION_R;
  1472. }
  1473. }else{
  1474. if (U > 0.75){
  1475. if (L < 0.25) return LA_BLOCK_DROP_LOCATION_L;
  1476. else
  1477. return LA_BLOCK_DROP_LOCATION_B;
  1478. }else{
  1479. if (L < 0.25) return LA_BLOCK_DROP_LOCATION_L;
  1480. else
  1481. return 0;
  1482. }
  1483. }
  1484. }
  1485. int laui_BlockMenu(laOperator *WindowAct, laWindow* w, laLayout *l, laBlock *b, laEvent *e){
  1486. laPanel *p;
  1487. laColumn *c;
  1488. laUiList *uil;
  1489. p = laDefineAndEnableMenuPanel(0, WindowAct, 0, b->X, b->Y + LA_RH + 1, 500, 500, e);
  1490. uil = laPrepareUi(p);
  1491. c = laFirstColumn(uil);
  1492. laPanel* forp=b->CurrentPanel;
  1493. laUiItem* b1=laBeginRow(uil,c,0,0);
  1494. laShowItem(uil,c,&b->PP,"fold");
  1495. laUiItem* b2=laOnConditionThat(uil,c,laPropExpression(&w->PP, "maximized_block"));{
  1496. laShowItemFull(uil,c,&b->PP,"maximize",0,"restore=true;text=Restore;",0,0);
  1497. }laElse(uil,b2);{
  1498. laShowItem(uil,c,&b->PP,"maximize");
  1499. }laEndCondition(uil,b2);
  1500. laEndRow(uil,b1);
  1501. laShowSeparator(uil,c);
  1502. if(forp->PanelTemplate && forp->PanelTemplate->Header){
  1503. laShowLabel(uil, c, "Panel properties:", 0, 0);
  1504. forp->PanelTemplate->Header(uil, &forp->PP, &forp->PropLinkPP, c, 0);
  1505. }else{
  1506. if(forp->PropLinkPP.LastPs->p->SubProp->Props.pFirst){
  1507. for(laProp* p = forp->PropLinkPP.LastPs->p->SubProp->Props.pFirst;p;p=p->Item.pNext){
  1508. if(p->PropertyType&LA_PROP_SUB){
  1509. laShowItemFull(uil, c, &forp->PropLinkPP, p->Identifier, LA_WIDGET_COLLECTION_SELECTOR,0,laui_IdentifierOnly,0);
  1510. }else{ laShowItem(uil, c, &forp->PropLinkPP, p->Identifier); }
  1511. }
  1512. }else{
  1513. laShowLabel(uil, c, "Panel doesn't have configurable property.", 0, 0);
  1514. }
  1515. }
  1516. //laShowItem(uil, c, 0, "LA_new_panel");
  1517. //laShowItem(uil, c, 0, "LA_block_close_panel");
  1518. //laShowItem(uil, c, 0, "LA_block_tear_off_panel");
  1519. laEnclosePanelContent(p,uil);
  1520. }
  1521. int la_ProcessBlockEvent(laOperator *a, laBlock *b, laEvent *e){
  1522. int Executed = 0, Ret=1;
  1523. int L = LA_RH+LA_SEAM_W, R, tw = 0;
  1524. real ratio = 1.0f;
  1525. laPanel *p = b->Panels.pFirst;
  1526. laGeneralUiExtraData *uid = a->CustomData;
  1527. laLayout *l;
  1528. if(!b->Panels.pFirst){return 0;}
  1529. if (laIsInBlockHeader(b, e->x, e->y) || MAIN.CurrentWindow->CurrentLayout->ClickedPanel){
  1530. MAIN.CurrentWindow->CurrentLayout->OperatingBlock = b;
  1531. if (b->CurrentPanel){
  1532. if (e->type == LA_MOUSE_WHEEL_DOWN && b->CurrentPanel->Item.pNext){
  1533. b->CurrentPanel = b->CurrentPanel->Item.pNext; Executed = 1;
  1534. }elif (e->type == LA_MOUSE_WHEEL_UP && b->CurrentPanel->Item.pPrev){
  1535. b->CurrentPanel = b->CurrentPanel->Item.pPrev; Executed = 1;
  1536. }
  1537. }
  1538. if(!b->Folded){
  1539. for (p = b->Panels.pFirst; p; p = p->Item.pNext){ tw += (p->TitleWidth + LA_SEAM_W*2); }
  1540. if (tw > b->W - LA_SEAM_W*2 - LA_RH) ratio = (real)(b->W - LA_SEAM_W*2 - LA_RH) / tw;
  1541. if ((e->type == LA_L_MOUSE_DOWN)){
  1542. uid->LastX = e->x;
  1543. uid->LastY = e->y;
  1544. int LT=0,RT=0;
  1545. for (p = b->Panels.pFirst; p; p = p->Item.pNext){
  1546. RT = LT + p->TitleWidth+LA_SEAM_W*2;
  1547. if (e->x >= b->X + L+LT * ratio && e->x < b->X + L+RT * ratio){
  1548. MAIN.CurrentWindow->CurrentLayout->ClickedPanel = p; b->CurrentPanel = p; Executed = 1;
  1549. }
  1550. LT = RT;
  1551. }
  1552. }elif (e->type == LA_MOUSEMOVE){
  1553. if (abs(e->x - uid->LastX) > LA_RH*3 || abs(e->y - uid->LastY) > LA_RH*3){
  1554. if (MAIN.CurrentWindow->CurrentLayout->ClickedPanel){
  1555. l = MAIN.CurrentWindow->CurrentLayout;
  1556. l->DropToBlock = b;
  1557. l->DropLocation = la_DetectBlockDropLocation(b, e->x, e->y);
  1558. laRefreshWindow();
  1559. }
  1560. }
  1561. }elif (e->type == LA_L_MOUSE_UP){
  1562. l = MAIN.CurrentWindow->CurrentLayout;
  1563. if (l->DropToBlock){
  1564. l->DropToBlock = la_MakeDropBlock(l->DropToBlock,l->DropLocation);
  1565. p = l->ClickedPanel;
  1566. if(p->Block == l->DropToBlock){
  1567. if(laTearOffPanel(p->Block, p)) Executed=1;
  1568. }else{
  1569. p->Block->CurrentPanel = p->Item.pPrev ? p->Item.pPrev : (p->Item.pNext ? p->Item.pNext : 0);
  1570. lstRemoveItem(&p->Block->Panels, p); laBlock* orig_block=p->Block->parent;
  1571. int clear=0; if(!lstHaveItemInList(&p->Block->Panels)){clear=1;}
  1572. lstPushItem(&l->DropToBlock->Panels, p);
  1573. p->Block = l->DropToBlock;
  1574. if(clear){
  1575. laCombineChildBlocks(orig_block);
  1576. if(!lstFindItem(orig_block->CurrentPanel,nutSameAddress,&orig_block->Panels)){
  1577. orig_block->CurrentPanel = orig_block->Panels.pFirst;
  1578. }
  1579. }
  1580. p->Block->CurrentPanel = p;
  1581. Executed = 1;
  1582. la_RecalcBlockRecursive(p->Block, p->Block->X, p->Block->Y, p->Block->W, p->Block->H);
  1583. if(orig_block!=p->Block){
  1584. la_RecalcBlockRecursive(orig_block, orig_block->X, orig_block->Y, orig_block->W, orig_block->H);
  1585. }
  1586. }
  1587. }
  1588. MAIN.CurrentWindow->CurrentLayout->DropToBlock = 0;
  1589. MAIN.CurrentWindow->CurrentLayout->ClickedPanel = 0;
  1590. return 0;
  1591. }
  1592. }else{
  1593. if(!b->OnButton){ b->OnButton=1; laRefreshWindow(); } Ret=0;
  1594. if(laIsInBlockBotton1(b, e->x, e->y)){ if(b->OnButton!=2){b->OnButton=2;laRefreshWindow();} if(e->type==LA_L_MOUSE_DOWN){laUnfoldBlockTitle(b);Executed=1;Ret=1;} }
  1595. elif(laIsInBlockBotton2(b, e->x, e->y)){ if(b->OnButton!=2){b->OnButton=2;laRefreshWindow();} if(e->type==LA_L_MOUSE_DOWN){laMaximizeBlock(b);Executed=1;Ret=1;} }
  1596. }
  1597. if (Executed){
  1598. laRecalcPanel(b->CurrentPanel);
  1599. la_RecalcBlockRecursive(b, b->X, b->Y, b->W, b->H);
  1600. }
  1601. if (!Executed && e->type == LA_L_MOUSE_DOWN && laIsInBlockBotton1(b, e->x, e->y)){
  1602. laui_BlockMenu(a, MAIN.CurrentWindow, MAIN.CurrentWindow->CurrentLayout, b, e);
  1603. }
  1604. return Ret;
  1605. }else{
  1606. if(b->OnButton){b->OnButton=0;laRefreshWindow();}
  1607. }
  1608. return 0;
  1609. }
  1610. int la_ProcessBlockEdgeEvent(laOperator *WindowAct, laLayout *l, laBlock *b, laEvent *e){
  1611. laBlock *ob = l->MovingBlock;
  1612. laWindow *w = WindowAct->Instance;
  1613. if (e->type == LA_MOUSEMOVE && ob && l->MovingBlock && l->IsMoving){
  1614. if (ob->Vertical) ob->SplitRatio = (real)(e->y - ob->Y) / (real)(ob->H);
  1615. else ob->SplitRatio = (real)(e->x - ob->X) / (real)(ob->W);
  1616. la_RecalcBlockRecursive(ob, ob->X, ob->Y, ob->W, ob->H);
  1617. if (ob->B1->CurrentPanel) laRecalcPanel(ob->B1->CurrentPanel);
  1618. if (ob->B2->CurrentPanel) laRecalcPanel(ob->B2->CurrentPanel);
  1619. return 1;
  1620. }
  1621. if (ob = la_OnBlockSeperator(b, e)){
  1622. ob->B1->OnButton=ob->B2->OnButton=0;
  1623. if(l->MovingBlock!=ob){ laRefreshWindow(); }
  1624. l->MovingBlock = ob; laSetWindowCursor(ob->Vertical?LA_UP_AND_DOWN:LA_LEFT_AND_RIGHT);
  1625. if (e->type == LA_L_MOUSE_DOWN){
  1626. l->IsMoving = 1;
  1627. }elif (e->type == LA_L_MOUSE_UP){
  1628. l->IsMoving = 0;
  1629. }elif (e->type == LA_R_MOUSE_DOWN){
  1630. l->OnBlockSeperator = ob;
  1631. laui_BlockEdgeMenu(WindowAct, l, ob, e);
  1632. }
  1633. return 1;
  1634. }
  1635. if(l->MovingBlock){ l->MovingBlock = 0; laRefreshWindow(); laSetWindowCursor(LA_ARROW); }
  1636. return 0;
  1637. }
  1638. real la_ScrollerVerticalPan(int MousePanY, laPanel *p, laUiList *suil, laUiItem *pui){
  1639. int DisplayH, TotalH;
  1640. if (!pui){ DisplayH = p->H-suil->U; }
  1641. else{ DisplayH = pui->Page?(pui->B-pui->Page->U):(pui->B - pui->U); }
  1642. TotalH = suil->B - suil->U;
  1643. return ((real)TotalH * (real)MousePanY / (real)DisplayH);
  1644. }
  1645. real la_ScrollerHorizontalPan(int MousePanX, laPanel *p, laUiList *suil, laUiItem *pui){
  1646. int DisplayW, TotalW;
  1647. DisplayW = pui->Page?(pui->R-pui->Page->L):(pui->R - pui->L);
  1648. TotalW = suil->R - suil->L;
  1649. return ((real)TotalW * (real)MousePanX / (real)DisplayW);
  1650. }
  1651. void laui_LayoutCycle(laUiList *uil, laPropPack *This, laPropPack *OperatorProps, laColumn *UNUSED, int context){
  1652. laColumn *c;
  1653. c = laFirstColumn(uil);
  1654. laShowItemFull(uil, c, 0, "la.windows.layouts", 0, 0, laui_IdentifierOnly, 0);
  1655. laUiItem* b=laBeginRow(uil,c,0,0);
  1656. laShowItem(uil, c, 0, "LA_new_layout")->Expand=1;
  1657. laShowItem(uil, c, 0, "LA_remove_layout")->Flags|=LA_UI_FLAGS_ICON|LA_UI_FLAGS_NO_CONFIRM;
  1658. laEndRow(uil,b);
  1659. }
  1660. int OPINV_SwitchLayout(laOperator *a, laEvent *e){
  1661. laWindow *w = MAIN.CurrentWindow; if (!w) return LA_FINISHED;
  1662. if (strSame(strGetArgumentString(a->ExtraInstructionsP, "show_list"), "true")){
  1663. laPanel* p =laEnableOperatorPanel(a, 0, e->x-LA_RH, e->y-LA_RH, 500, 500, 0,0,0,0,0,0,0,0,e);
  1664. return LA_RUNNING;
  1665. }
  1666. laLayout* newlayout;
  1667. if (strSame(strGetArgumentString(a->ExtraInstructionsP, "reverse"), "true")) newlayout = w->CurrentLayout->Item.pPrev ? w->CurrentLayout->Item.pPrev : w->Layouts.pLast;
  1668. else newlayout = w->CurrentLayout->Item.pNext ? w->CurrentLayout->Item.pNext : w->Layouts.pFirst;
  1669. memAssignRef(w, &w->CurrentLayout, newlayout);
  1670. laRenameWindow(w, w->CurrentLayout->ID->Ptr);
  1671. la_StopAllOperators();
  1672. laRetriggerOperators();
  1673. laRedrawCurrentWindow();
  1674. laNotifyUsers("la.windows.layouts");
  1675. return LA_FINISHED;
  1676. }
  1677. int OPINV_DeleteTheme(laOperator *a, laEvent *e){
  1678. laTheme* t = a->This?a->This->EndInstance:MAIN.CurrentTheme;
  1679. if(!t || MAIN.Themes.pFirst == MAIN.Themes.pLast) return LA_CANCELED;
  1680. laBoxedTheme* NextBt;
  1681. for(laBoxedTheme* bt=t->BoxedThemes.pFirst; bt; bt=NextBt){
  1682. NextBt = bt->Item.pNext; lstRemoveItem(&t->BoxedThemes, bt); memFree(bt);
  1683. }
  1684. lstRemoveItem(&MAIN.Themes, t); memFree(t);
  1685. if(t==MAIN.CurrentTheme){MAIN.CurrentTheme = MAIN.Themes.pFirst;la_RefreshThemeColor(MAIN.CurrentTheme);}
  1686. laNotifyUsers("themes"); laRedrawCurrentWindow();
  1687. return LA_FINISHED;
  1688. }
  1689. int la_GenericTopPanelProcessing(laOperator* a, laEvent* e){
  1690. laPanel* p;
  1691. if (p = laDetectPanel(e->x, e->y)){
  1692. int x = e->x;
  1693. int y = e->y;
  1694. laWindowToLocal(0, p, &x, &y);
  1695. if (laIsInPanel(p, x, y) /*&& p->Show*/){
  1696. laSetOperatorLocalizer(p);
  1697. laInvokeUi(a, "LA_panel_operator", e, p, 0, 1);
  1698. return LA_RUNNING;
  1699. }
  1700. }
  1701. return 0;
  1702. }
  1703. int la_GeneratePasteEvent(laWindow* w){
  1704. #ifdef LA_LINUX
  1705. XConvertSelection(MAIN.dpy, MAIN.bufid, MAIN.fmtid, MAIN.propid, w->win, CurrentTime);
  1706. #endif
  1707. }
  1708. int OPINV_SystemPaste(laOperator *a, laEvent *e){ la_GeneratePasteEvent(MAIN.CurrentWindow); return LA_FINISHED; }
  1709. int OPINV_Window(laOperator *a, laEvent *e){
  1710. laRetriggerOperators();
  1711. return LA_RUNNING;
  1712. }
  1713. int OPMOD_Window(laOperator *a, laEvent *e){
  1714. laPanel *p;
  1715. laBlock *b = 0;
  1716. laWindow *w = a->Instance;
  1717. laGeneralUiExtraData *uid = a->CustomData;
  1718. if (!uid) uid = memAcquireSimple(sizeof(laGeneralUiExtraData));
  1719. a->CustomData = uid;
  1720. if(e->type == LA_OPERATOR_EVENT && (!e->OperatorBase)){
  1721. laInvokeP(a, e->Operator, e, 0, e->OperatorInstructions, 0);
  1722. return LA_RUNNING;
  1723. }
  1724. if(laKeyMapExecuteEvent(a, &MAIN.KeyMap, e)) return LA_RUNNING_PASS;
  1725. if(w->IsDocking && MAIN.DockingPanel){
  1726. laRestoreToLayout();
  1727. laRestoreCanvasUI();
  1728. laLayout* l=MAIN.CurrentWindow->CurrentLayout;
  1729. laBlock *Recieve = laDetectBlockRecursive(l->FirstBlock, e->x, e->y);
  1730. if (Recieve){
  1731. la_ClearDockingTarget(); l->DropToBlock = Recieve;
  1732. l->DropLocation = la_DetectBlockDropLocation(Recieve, e->x, e->y);
  1733. laRefreshWindow();
  1734. }else{
  1735. MAIN.CurrentWindow->CurrentLayout->DropToBlock = 0;
  1736. }
  1737. if(e->type==LA_L_MOUSE_UP && l->DropToBlock){
  1738. l->DropToBlock = la_MakeDropBlock(l->DropToBlock, l->DropLocation);
  1739. laDockPanel(w->DockingFrom, l->DropToBlock, MAIN.DockingPanel);
  1740. la_StopDocking();la_ClearDockingTarget(); return LA_RUNNING;
  1741. }
  1742. if(e->type==LA_R_MOUSE_DOWN || (e->type==LA_KEY_DOWN&&e->key==LA_KEY_ESCAPE)){
  1743. la_StopDocking();la_ClearDockingTarget(); return LA_RUNNING;
  1744. }
  1745. return LA_RUNNING;
  1746. }
  1747. if(w->MaximizedUi && w->MaximizedUiPanel){
  1748. if(((e->y<LA_RH && e->x<LA_RH)||e->y<LA_SEAM_W) && uid->Dragging){ laShowMenuBar(); uid->Dragging=0; }
  1749. if(!la_UiOperatorExists(w->MaximizedUi)){
  1750. laSetOperatorLocalizer(w->MaximizedUiPanel);
  1751. laInvokeUi(a, w->MaximizedUi->Type->OperatorID, e, w->MaximizedUi, 0, 1);
  1752. return LA_RUNNING;
  1753. }
  1754. if(e->y>LA_2RH && e->x>LA_2RH){ if(!uid->Dragging)laRequestDelayEvent(0.5); uid->Dragging=1; }
  1755. if(e->type==LA_TIME_DELAY){ laHideMenuBar(); }
  1756. }else{
  1757. if(MAIN.PendingSplash){
  1758. laSetOperatorLocalizer(MAIN.PendingSplash);
  1759. laInvokeUi(a, "LA_panel_operator", e, MAIN.PendingSplash, 0, 1);
  1760. laRetriggerOperators();
  1761. MAIN.PendingSplash=0; return LA_RUNNING;
  1762. }
  1763. laBlock* RootBlock=w->MaximizedBlock?w->MaximizedBlock:w->CurrentLayout->FirstBlock;
  1764. if (la_ProcessBlockEdgeEvent(a, w->CurrentLayout, RootBlock, e)) return LA_RUNNING;
  1765. b = w->MaximizedBlock?w->MaximizedBlock:laDetectBlockRecursive(w->CurrentLayout->FirstBlock, e->x, e->y);
  1766. laClearBlockButtonRecursive(RootBlock,b);
  1767. if (b && la_ProcessBlockEvent(a, b, e)) return LA_RUNNING;
  1768. for (p = w->Panels.pFirst; p; p = p->Item.pNext){
  1769. int x = e->x; int y = e->y;
  1770. laWindowToLocal(0, p, &x, &y);
  1771. if (laIsInPanel(p, x, y) && p->Show){
  1772. laSetOperatorLocalizer(p);
  1773. if (!p->LaterDestroy) laInvokeUi(a, "LA_panel_operator", e, p, 0, 1);
  1774. return LA_RUNNING;
  1775. }
  1776. }
  1777. }
  1778. if(la_GenericTopPanelProcessing(a,e)) return LA_RUNNING;
  1779. return LA_RUNNING;
  1780. }
  1781. int OPINV_Panel(laOperator *a, laEvent *e){
  1782. if (!((laPanel *)a->Instance)->Show) return LA_FINISHED;
  1783. a->CustomData = memAcquireSimple(sizeof(laGeneralUiExtraData));
  1784. laRetriggerOperators();
  1785. return LA_RUNNING;
  1786. }
  1787. void OPEXT_Panel(laOperator *a, int ExitCode){
  1788. memFree(a->CustomData);
  1789. }
  1790. int la_ScrollPanel(laGeneralUiExtraData*ex, laPanel*p, laEvent* e){
  1791. int ret=0;
  1792. if(ex->TargetIndexVali==4 && e->type==LA_MOUSEMOVE){
  1793. laUiList* uuil=ex->Ptr1; laUiItem* upui=ex->Ptr2;
  1794. if(upui){ laPanUiListFree(uuil, ex->LastX-e->x, ex->LastY-e->y);
  1795. //if(uuil->HeightCoeff){
  1796. if(uuil->B-upui->Page->PanY<upui->TB-(*p->BT)->BM-LA_SCROLL_W){
  1797. upui->Page->PanY = (uuil->B-upui->TB+(*p->BT)->BM+LA_SCROLL_W);
  1798. if(upui->Page->PanY<0){upui->Page->PanY=0;}
  1799. }
  1800. //}
  1801. }
  1802. ex->LastX=e->x; ex->LastY=e->y;
  1803. laRedrawCurrentPanel();
  1804. ret= 1;
  1805. }
  1806. if(ex->TargetIndexVali==5 && e->type==LA_MOUSEMOVE){
  1807. laUiList* uuil=ex->Ptr1; laUiItem* upui=ex->Ptr2;
  1808. if(upui)laScaleUiList(uuil, -(ex->LastY-e->y)*0.005+1, upui->L, upui->R, upui->U, upui->B);
  1809. ex->LastX=e->x; ex->LastY=e->y;
  1810. laRecalcCurrentPanel();
  1811. ret= 1;
  1812. }
  1813. if(e->type==LA_M_MOUSE_UP){ ex->TargetIndexVali=0; }
  1814. if (e->type & LA_KEY_MOUSE_SCROLL || (e->type==LA_M_MOUSE_DOWN) || (e->key&LA_KEY_PANNING)){
  1815. laUiItem *pui = 0; laListHandle levels={0}; int dir=0;
  1816. if(e->key&LA_KEY_PANNING){
  1817. if (e->key&LA_KEY_ARRDOWN) dir=1;
  1818. elif (e->key&LA_KEY_ARRUP) dir=-1;
  1819. }else{
  1820. if (e->type & LA_STATE_DOWN) dir=1;
  1821. elif (e->type & LA_STATE_UP) dir=-1;
  1822. }
  1823. laUiList *duil = la_DetectUiListRecursiveDeep(p->MenuRefer?p->MenuRefer:&p->UI, e->x, e->y, 10000, &pui, 0, 0, 0, 0, &levels);
  1824. laUiListRecord* lip=levels.pLast; laUiList* uuil=lip->uil; laUiItem* upui=lip->Item.pPrev?((laUiListRecord*)lip->Item.pPrev)->pui:0; int ran=0;
  1825. if(e->SpecialKeyBit == LA_KEY_CTRL){
  1826. if(e->type==LA_M_MOUSE_DOWN){
  1827. while (lip && upui && (!uuil->AllowScale)) { lip=lip->Item.pPrev; uuil=lip->uil; upui=lip->Item.pPrev?((laUiListRecord*)lip->Item.pPrev)->pui:0; }
  1828. if(uuil) { ex->TargetIndexVali=5; ex->Ptr1=uuil; ex->Ptr2=upui; ex->LastX=e->x; ex->LastY=e->y; ret= 1;}
  1829. }else{
  1830. }
  1831. }else{
  1832. if(e->type==LA_M_MOUSE_DOWN){
  1833. while (lip && upui && (!uuil->AllowScale)) { lip=lip->Item.pPrev; uuil=lip->uil; upui=lip->Item.pPrev?((laUiListRecord*)lip->Item.pPrev)->pui:0; }
  1834. if(uuil) { ex->TargetIndexVali=4; ex->Ptr1=uuil; ex->Ptr2=upui; ex->LastX=e->x; ex->LastY=e->y; ret= 1;}
  1835. }else{
  1836. while (lip && upui){
  1837. if(uuil->AllowScale){ if((ran=laScaleUiList(uuil, 1.0f-dir*0.1, upui->L, upui->R, upui->U, upui->B))){ laRecalcCurrentPanel(); break;} }
  1838. else{ if((ran=laPanUiListAuto(uuil, 0, dir*MAIN.ScrollingSpeed*LA_RH,
  1839. uuil->L, upui->R-(uuil->ScrollerShownV?(LA_SCROLL_W+(*p->BT)->RM):0),
  1840. uuil->U, upui->B-(*upui->Type->Theme)->BM-(uuil->ScrollerShownH?(LA_SCROLL_W+(*p->BT)->BM):0)))) break; }
  1841. lip=lip->Item.pPrev; uuil=lip->uil; upui=lip->Item.pPrev?((laUiListRecord*)lip->Item.pPrev)->pui:0;
  1842. }
  1843. if(!ran) laPanUiListAuto(p->MenuRefer?p->MenuRefer:&p->UI, 0, dir*MAIN.ScrollingSpeed*LA_RH, 0, p->W, p->TitleBar.B+(*p->BT)->TM, p->H-(*p->BT)->BM);
  1844. laRedrawCurrentPanel();
  1845. ret= 1;
  1846. }
  1847. }
  1848. while(duil=lstPopPointer(&levels));
  1849. }
  1850. return ret;
  1851. }
  1852. int OPMOD_Panel(laOperator *a, laEvent *e){
  1853. int x = e->x;
  1854. int y = e->y;
  1855. laPanel *p = a->Instance, *dp;
  1856. laUiItem *ui = 0;
  1857. laGeneralUiExtraData *uid = a->CustomData;
  1858. laListHandle Locals = {0};
  1859. int RET=LA_RUNNING|(p->IsMenuPanel?0:LA_PASS_ON);
  1860. if(MAIN.DockingPanel){ return LA_FINISHED; }
  1861. if (!p->Show || (!laIsInPanel(p, x, y) && !uid->TargetIndexVali)){
  1862. if(p->CloseWhenMovedOut==2){
  1863. if(e->type&LA_STATE_DOWN){
  1864. la_StopUiOperatorService(p); laDestroySinglePanel(p,0); return LA_FINISHED;
  1865. }
  1866. return LA_RUNNING;
  1867. }
  1868. if(p->ShowCorner){ p->ShowCorner=0; laSetWindowCursor(LA_ARROW); laRefreshWindow(); }
  1869. return LA_FINISHED_PASS;
  1870. }
  1871. if(((e->type==LA_KEY_DOWN && e->key==LA_KEY_ESCAPE)||(e->type==LA_R_MOUSE_DOWN)) && p->CloseWhenMovedOut==2){
  1872. la_StopUiOperatorService(p); laDestroySinglePanel(p,0); return LA_FINISHED;
  1873. }
  1874. int NoPrimaryUI=(p==MAIN.CurrentWindow->MaximizedUiPanel);
  1875. if(e->type == LA_OPERATOR_EVENT && e->OperatorBase==LA_KM_SEL_PANEL){
  1876. laInvokeP(a, e->Operator, e, &p->PP, e->OperatorInstructions, 0);
  1877. return LA_RUNNING;
  1878. }
  1879. if(p->PanelTemplate && laKeyMapExecuteEvent(a, &p->PanelTemplate->KeyMap, e)) return RET;
  1880. int IsTop=laIsTopPanel(p);
  1881. if (!IsTop && !uid->TargetIndexVali){
  1882. laLocalToWindow(0, p, &x, &y);
  1883. dp = laDetectPanel(x, y);
  1884. if (dp && dp->Mode && dp != p){
  1885. return LA_FINISHED;
  1886. }else if ((e->type & LA_MOUSEDOWN) == LA_MOUSEDOWN){
  1887. laPopPanel(p); IsTop=1;
  1888. }else if(p->Mode) return LA_RUNNING;
  1889. laWindowToLocal(0, p, &x, &y);
  1890. }
  1891. if (e->type == LA_L_MOUSE_DOWN && (!NoPrimaryUI) && e->x + e->y < p->W + p->H - LA_SCROLL_W*2){
  1892. laUiItem *pui = 0; laUiList *suil = 0;laListHandle levels={0};
  1893. laUiList *duil = la_DetectUiListRecursiveDeep(&p->UI, e->x, e->y, 10000, &pui, &suil, 0, 0, 0, &levels);
  1894. while(duil=lstPopPointer(&levels));
  1895. if (suil){
  1896. uid->Ptr1 = suil; uid->Ptr2 = pui;
  1897. uid->TargetIndexVali = 3;
  1898. uid->LastX = e->x; uid->LastY = e->y;
  1899. uid->On=(!pui || e->x>pui->R-LA_SCROLL_W-2*(*p->BT)->RM)?1:0;
  1900. return LA_RUNNING;
  1901. }
  1902. }
  1903. if(la_ScrollPanel(uid,p,e))return LA_RUNNING;
  1904. if (!p->Mode || (IsTop && !uid->TargetIndexVali)){
  1905. if(y<p->TitleBar.B){ ui = la_DetectUiItemRecursive(&p->TitleBar, x, y, 10000, &Locals, 0); }
  1906. elif (!ui && (!NoPrimaryUI)){
  1907. lstClearPointer(&Locals);
  1908. ui = la_DetectUiItemRecursive(&p->UI, x, y, 10000, &Locals, 0);
  1909. }
  1910. }
  1911. if (ui && !a->Child && ui->Type->OperatorType && !la_UiOperatorExists(ui)){
  1912. laSetOperatorLocalizer(p);
  1913. if (laInvokeUiP(a, ui->Type->OperatorType, e, ui, &Locals, 0) >= 0){ laRetriggerOperators(); }
  1914. lstClearPointer(&Locals);
  1915. //return LA_RUNNING;
  1916. }
  1917. lstClearPointer(&Locals);
  1918. if (p->Mode && e->type&LA_MOUSE_EVENT && !uid->TargetIndexVali && !p->IsMenuPanel){
  1919. if (e->x + e->y > p->W + p->H - LA_SCROLL_W*2){
  1920. if((!a->Item.pPrev) && (!p->ShowCorner)){ p->ShowCorner=1; laSetWindowCursor(LA_CORNER); laRefreshWindow(); }
  1921. if(e->type==LA_L_MOUSE_DOWN){ uid->TargetIndexVali = 2; uid->LastX=e->x;uid->LastY=e->y; }
  1922. return LA_RUNNING;
  1923. }else{
  1924. if(p->ShowCorner){ p->ShowCorner=0; laSetWindowCursor(LA_ARROW); laRefreshWindow(); }
  1925. if(e->type==LA_L_MOUSE_DOWN){ uid->TargetIndexVali = 1; uid->LastX=e->x;uid->LastY=e->y; return LA_RUNNING; }
  1926. }
  1927. }
  1928. if (e->type == LA_MOUSEMOVE){
  1929. if (uid->TargetIndexVali == 1){
  1930. if (!p->SL && !p->SR) p->TX = p->X + e->x - uid->LastX;
  1931. if (!p->ST && !p->SB) p->TY = p->Y + e->y - uid->LastY;
  1932. laNotifyUsersPPPath(&p->PP, "position");
  1933. la_EnsurePanelSnapping(p, MAIN.CurrentWindow->CW, MAIN.CurrentWindow->CH);
  1934. laRecalcCurrentPanel();
  1935. return LA_RUNNING;
  1936. }elif (uid->TargetIndexVali == 2){
  1937. p->TW += e->x - uid->LastX; p->TH += e->y - uid->LastY;
  1938. uid->LastX = e->x; uid->LastY = e->y;
  1939. p->BoundUi=0;
  1940. laNotifyUsersPPPath(&p->PP, "size");
  1941. la_EnsurePanelSnapping(p, MAIN.CurrentWindow->CW, MAIN.CurrentWindow->CH);
  1942. laRecalcCurrentPanel();
  1943. return LA_RUNNING;
  1944. }elif (uid->TargetIndexVali == 3){
  1945. laUiList *suil = uid->Ptr1; laUiItem *pui = uid->Ptr2;
  1946. int IsVertical=uid->On;
  1947. uid->TargetIndexValf+=IsVertical?la_ScrollerVerticalPan(e->y - uid->LastY, p, uid->Ptr1, uid->Ptr2):
  1948. (pui?la_ScrollerHorizontalPan(e->x - uid->LastX, p, uid->Ptr1, uid->Ptr2):0);
  1949. uid->Dragging = (int)uid->TargetIndexValf; uid->TargetIndexValf-=uid->Dragging;
  1950. int pV=uid->Dragging*IsVertical, pH=uid->Dragging*(!IsVertical);
  1951. if (!pui) laPanUiList(suil, pH, pV,0, p->W, suil->U, p->H-(*p->BT)->BM);
  1952. else laPanUiList(suil, pH, pV, suil->L, pui->R-(suil->ScrollerShownV?(LA_SCROLL_W+(*p->BT)->RM):0),
  1953. suil->U, pui->B-(*p->BT)->BM-(suil->ScrollerShownH?(LA_SCROLL_W+(*p->BT)->BM):0));
  1954. uid->LastX = e->x; uid->LastY = e->y;
  1955. laRedrawCurrentPanel();
  1956. return LA_RUNNING;
  1957. }
  1958. }
  1959. if (e->type == LA_L_MOUSE_UP){
  1960. uid->TargetIndexVali = 0; laSetWindowCursor(LA_ARROW);
  1961. return LA_RUNNING;
  1962. }
  1963. if(p->Mode&&e->type&LA_MOUSE_EVENT){ return LA_RUNNING; }
  1964. return RET;
  1965. }
  1966. int OPMOD_MenuPanel(laOperator *a, laEvent *e){
  1967. int x = e->x;
  1968. int y = e->y;
  1969. laPanel *p = a->Instance;
  1970. laUiItem *ui;
  1971. laListHandle Locals = {0};
  1972. laGeneralUiExtraData *uid = a->CustomData;
  1973. if(MAIN.DockingPanel){return LA_FINISHED; }
  1974. int IsClose=laIsCloseToPanel(p,x,y);
  1975. int IsIn=laIsInPanel(p, x, y);
  1976. if(p->CloseWhenMovedOut && ((!IsClose) || (!IsIn && e->type==LA_TIME_IDLE) || e->type==LA_L_MOUSE_DOWN||e->type==LA_R_MOUSE_DOWN)){
  1977. la_StopUiOperatorService(p);
  1978. laDestroySinglePanel(p,0);
  1979. return LA_FINISHED_PASS;
  1980. }
  1981. if ((e->type == LA_KEY_DOWN && e->key==LA_KEY_ESCAPE) || (e->type == LA_L_MOUSE_DOWN && !IsIn)){
  1982. laConfirmInt(a, 1, LA_CONFIRM_DATA);
  1983. la_StopUiOperatorService(p);
  1984. laDestroySinglePanel(p,0);
  1985. return LA_FINISHED_PASS;
  1986. }
  1987. if(p->PanelTemplate && laKeyMapExecuteEvent(a, &p->PanelTemplate->KeyMap, e)) return LA_RUNNING_PASS;
  1988. if (e->type == LA_L_MOUSE_DOWN && e->y < p->H - LA_SCROLL_W){
  1989. laUiItem *pui = 0; laUiList *suil = 0;laListHandle levels={0};
  1990. laUiList *duil = la_DetectUiListRecursiveDeep(p->MenuRefer?p->MenuRefer:&p->UI, e->x, e->y, 10000, &pui, &suil, 0, 0, 0, &levels);
  1991. while(duil=lstPopPointer(&levels));
  1992. if (suil){
  1993. uid->Ptr1 = suil; uid->Ptr2 = pui;
  1994. uid->TargetIndexVali = 3;
  1995. uid->LastX = e->x; uid->LastY = e->y;
  1996. uid->On=(!pui || e->x>pui->R-LA_SCROLL_W-2*(*p->BT)->RM)?1:0;
  1997. return LA_RUNNING;
  1998. }
  1999. }
  2000. if (e->type == LA_L_MOUSE_UP && uid->TargetIndexVali == 3){
  2001. uid->TargetIndexVali = 0;
  2002. return LA_RUNNING;
  2003. }
  2004. if(la_ScrollPanel(uid,p,e))return LA_RUNNING;
  2005. if (e->type == LA_MOUSEMOVE){
  2006. if (uid->TargetIndexVali == 3){
  2007. laUiList *suil = uid->Ptr1; laUiItem *pui = uid->Ptr2;
  2008. int IsVertical=uid->On;
  2009. uid->TargetIndexValf+=IsVertical?la_ScrollerVerticalPan(e->y - uid->LastY, p, uid->Ptr1, uid->Ptr2):
  2010. (pui?la_ScrollerHorizontalPan(e->x - uid->LastX, p, uid->Ptr1, uid->Ptr2):0);
  2011. uid->Dragging = (int)uid->TargetIndexValf; uid->TargetIndexValf-=uid->Dragging;
  2012. int pV=uid->Dragging*IsVertical, pH=uid->Dragging*(!IsVertical);
  2013. if (!pui) laPanUiList(suil, pH, pV,0, p->W, suil->U, p->H-(*p->BT)->BM);
  2014. else laPanUiList(suil, pH, pV, suil->L, pui->R-(suil->ScrollerShownV?(LA_SCROLL_W+(*p->BT)->RM):0),
  2015. suil->U, pui->B-(*p->BT)->BM-(suil->ScrollerShownH?(LA_SCROLL_W+(*p->BT)->BM):0));
  2016. uid->LastX = e->x; uid->LastY = e->y;
  2017. laRedrawCurrentPanel();
  2018. return LA_RUNNING;
  2019. }
  2020. }
  2021. ui = la_DetectUiItemRecursive(&p->UI, x, y, 10000, &Locals, 0);
  2022. if (!ui){
  2023. lstClearPointer(&Locals);
  2024. ui = la_DetectUiItemRecursive(p->MenuRefer, x, y, 10000, &Locals, 0);
  2025. }
  2026. if (ui && !la_UiOperatorExists(ui)){
  2027. laSetOperatorLocalizer(p);
  2028. laInvokeUiP(a, ui->Type->OperatorType, e, ui, &Locals, 0);
  2029. }
  2030. lstClearPointer(&Locals);
  2031. if (a->ConfirmData && (!p->NoConfirm)){
  2032. laConfirmInt(a, a->ConfirmData->IData, a->ConfirmData->Mode);
  2033. la_StopUiOperatorService(p);
  2034. laDestroySinglePanel(p,0);
  2035. return LA_FINISHED_PASS;
  2036. }
  2037. return LA_RUNNING;
  2038. }
  2039. int OPMOD_ModalPanel(laOperator *a, laEvent *e){
  2040. int x = e->x;
  2041. int y = e->y;
  2042. laPanel *p = a->Instance;
  2043. laUiItem *ui = 0;
  2044. laListHandle Locals = {0};
  2045. laGeneralUiExtraData *uid = a->CustomData;
  2046. if(MAIN.DockingPanel){return LA_FINISHED; }
  2047. if (e->type == LA_KEY_DOWN && e->key==LA_KEY_ESCAPE){
  2048. laConfirmInt(a, 0, LA_CONFIRM_CANCEL);
  2049. la_StopUiOperatorService(p);
  2050. laDestroySinglePanel(p,0);
  2051. return LA_FINISHED_PASS;
  2052. }
  2053. if (a->ConfirmData){
  2054. laConfirmSameDataIfAny(a);
  2055. if (a->ConfirmData->Mode == LA_CONFIRM_DATA||a->ConfirmData->Mode==LA_CONFIRM_CUSTOM_STRING){
  2056. return LA_RUNNING_PASS;
  2057. }
  2058. la_StopUiOperatorService(p);
  2059. laDestroySinglePanel(p,0);
  2060. return LA_FINISHED_PASS;
  2061. }
  2062. if (!laIsInPanel(p, e->x, e->y) && !uid->TargetIndexVali){
  2063. if(e->type&LA_STATE_DOWN){
  2064. p->AnimationRatio=0; p->AnimationMode=LA_PANEL_ANIMATION_FLASH; laRedrawCurrentPanel();
  2065. }
  2066. if(p->ShowCorner){ p->ShowCorner=0; laSetWindowCursor(LA_ARROW); laRefreshWindow(); } return LA_RUNNING;
  2067. }
  2068. if(p->PanelTemplate && laKeyMapExecuteEvent(a, &p->PanelTemplate->KeyMap, e)) return LA_RUNNING_PASS;
  2069. if (e->type == LA_L_MOUSE_DOWN && e->y < p->H - LA_SCROLL_W){
  2070. laUiItem *pui = 0; laUiList *suil = 0;laListHandle levels={0};
  2071. laUiList *duil = la_DetectUiListRecursiveDeep(&p->UI, e->x, e->y, 10000, &pui, &suil, 0, 0, 0, &levels);
  2072. while(duil=lstPopPointer(&levels));
  2073. if (suil){
  2074. uid->Ptr1 = suil; uid->Ptr2 = pui;
  2075. uid->TargetIndexVali = 3;
  2076. uid->LastX = e->x; uid->LastY = e->y;
  2077. uid->On=(!pui || e->x>pui->R-LA_SCROLL_W-2*(*p->BT)->RM)?1:0;
  2078. return LA_RUNNING;
  2079. }
  2080. }
  2081. if(la_ScrollPanel(uid,p,e))return LA_RUNNING;
  2082. if (!uid->TargetIndexVali){
  2083. ui = la_DetectUiItemRecursive(&p->TitleBar, x, y, 10000, &Locals, 0);
  2084. if (!ui){
  2085. lstClearPointer(&Locals);
  2086. ui = la_DetectUiItemRecursive(&p->UI, x, y, 10000, &Locals, 0);
  2087. }
  2088. }
  2089. if (ui && !a->Child && ui->Type->OperatorType && !la_UiOperatorExists(ui)){
  2090. laSetOperatorLocalizer(p);
  2091. laInvokeUiP(a, ui->Type->OperatorType, e, ui, &Locals, 0);
  2092. return LA_RUNNING;
  2093. }
  2094. lstClearPointer(&Locals);
  2095. int insize=0; if (e->x + e->y > p->W + p->H - LA_SCROLL_W*2){ insize=1;
  2096. if((!a->Item.pPrev) && (!p->ShowCorner)){ p->ShowCorner=1; laSetWindowCursor(LA_CORNER); laRefreshWindow(); }
  2097. }else{ if(p->ShowCorner){ p->ShowCorner=0; laSetWindowCursor(LA_ARROW); laRefreshWindow(); } }
  2098. if (e->type == LA_L_MOUSE_DOWN){
  2099. uid->LastX = e->x;
  2100. uid->LastY = e->y;
  2101. if(insize){ uid->TargetIndexVali = 2; laSetWindowCursor(LA_CORNER); }
  2102. else uid->TargetIndexVali = 1;
  2103. return LA_RUNNING;
  2104. }
  2105. if (e->type == LA_MOUSEMOVE){
  2106. if (uid->TargetIndexVali == 1){
  2107. if (!p->SL && !p->SR) p->TX = p->X + e->x - uid->LastX;
  2108. if (!p->ST && !p->SB) p->TY = p->Y + e->y - uid->LastY;
  2109. laNotifyUsersPPPath(&p->PP, "position");
  2110. la_EnsurePanelSnapping(p, MAIN.CurrentWindow->CW, MAIN.CurrentWindow->CH);
  2111. laRecalcCurrentPanel();
  2112. return LA_RUNNING;
  2113. }elif (uid->TargetIndexVali == 2){
  2114. p->TW += e->x - uid->LastX; p->TH += e->y - uid->LastY;
  2115. uid->LastX = e->x; uid->LastY = e->y;
  2116. p->BoundUi=0;
  2117. laNotifyUsersPPPath(&p->PP, "size");
  2118. la_EnsurePanelSnapping(p, MAIN.CurrentWindow->CW, MAIN.CurrentWindow->CH);
  2119. laRecalcCurrentPanel();
  2120. return LA_RUNNING;
  2121. }elif (uid->TargetIndexVali == 3){
  2122. laUiList *suil = uid->Ptr1; laUiItem *pui = uid->Ptr2;
  2123. int IsVertical=uid->On;
  2124. uid->TargetIndexValf+=IsVertical?la_ScrollerVerticalPan(e->y - uid->LastY, p, uid->Ptr1, uid->Ptr2):
  2125. (pui?la_ScrollerHorizontalPan(e->x - uid->LastX, p, uid->Ptr1, uid->Ptr2):0);
  2126. uid->Dragging = (int)uid->TargetIndexValf; uid->TargetIndexValf-=uid->Dragging;
  2127. int pV=uid->Dragging*IsVertical, pH=uid->Dragging*(!IsVertical);
  2128. if (!pui) laPanUiList(suil, pH, pV,0, p->W, suil->U, p->H-(*p->BT)->BM);
  2129. else laPanUiList(suil, pH, pV, suil->L, pui->R-(suil->ScrollerShownV?(LA_SCROLL_W+(*p->BT)->RM):0),
  2130. suil->U, pui->B-(*p->BT)->BM-(suil->ScrollerShownH?(LA_SCROLL_W+(*p->BT)->BM):0));
  2131. uid->LastX = e->x; uid->LastY = e->y;
  2132. laRedrawCurrentPanel();
  2133. return LA_RUNNING;
  2134. }
  2135. if(uid->TargetIndexVali==2){laSetWindowCursor(LA_CORNER);}
  2136. }
  2137. if (e->type == LA_L_MOUSE_UP){
  2138. uid->TargetIndexVali = 0; laSetWindowCursor(LA_ARROW);
  2139. return LA_RUNNING;
  2140. }
  2141. return LA_RUNNING;
  2142. }
  2143. int OPCHK_IsPanel(laPropPack *This, laStringSplitor *ss){
  2144. if (This && This->LastPs->p == _LA_PROP_PANEL) return 1;
  2145. else{
  2146. char *PanelInternalID = strGetArgumentString(ss, "panel_id");
  2147. if (!PanelInternalID) return 0;
  2148. else
  2149. return 1;
  2150. }
  2151. return 0;
  2152. }
  2153. int OPCHK_IsPanelNoInstructions(laPropPack *This, laStringSplitor *ss){
  2154. if (This && This->LastPs->p == _LA_PROP_PANEL) return 1;
  2155. return 0;
  2156. }
  2157. int OPINV_HidePanel(laOperator *a, laEvent *e){
  2158. laPanel *p = a->This?a->This->EndInstance:0;
  2159. laHidePanelWithDissoveEffect(p);
  2160. return LA_FINISHED;
  2161. }
  2162. int OPINV_ActivatePanel(laOperator *a, laEvent *e){
  2163. laStringSplitor *ss = a->ExtraInstructionsP;
  2164. char *TemplateID = strGetArgumentString(ss, "panel_id");
  2165. if (!TemplateID) return LA_CANCELED;
  2166. laActivatePanel(TemplateID, e->x, e->y);
  2167. return LA_FINISHED;
  2168. }
  2169. int OPINV_PanPanel(laOperator *a, laEvent *e){
  2170. laPanel *p = a->This?a->This->EndInstance:0;
  2171. //laHidePanel(p);
  2172. return LA_FINISHED;
  2173. }
  2174. int OPCHK_IsHyper(laPropPack *This, laStringSplitor *ss){
  2175. if (This && This->LastPs->p->Container->Hyper) return 1;
  2176. return 0;
  2177. }
  2178. int OPINV_ViewHyperData(laOperator *a, laEvent *e){
  2179. char buf[2048]={0};
  2180. memHyperInfo(a->This, buf);
  2181. printf("%s",buf);
  2182. return LA_FINISHED;
  2183. }
  2184. int OPINV_TranslationDumpMisMatch(laOperator *a, laEvent *e){
  2185. transDumpMissMatchRecord("TranslationDump.txt");
  2186. laEnableMessagePanel(a, 0, "OK", "Untranslated strings exported to TranslationDump.txt", e->x - 250, e->y - 10, 300, e);
  2187. return LA_FINISHED;
  2188. }
  2189. int OPINV_RefreshScreens(laOperator *a, laEvent *e){
  2190. #ifdef LA_LINUX
  2191. la_GetDPI(MAIN.win);
  2192. #endif
  2193. #ifdef _WIN32
  2194. la_GetDPI(MAIN.CurrentWindow);
  2195. #endif
  2196. return LA_FINISHED;
  2197. }
  2198. int OPINV_RemoveScreenConfig(laOperator *a, laEvent *e){
  2199. if(!a->This || !a->This->EndInstance) return LA_FINISHED;
  2200. laEnableYesNoPanel(0, 0, "Confirm?", "Will remove this screen entry", e->x, e->y, 200, e);
  2201. return LA_RUNNING;
  2202. }
  2203. int OPMOD_RemoveScreenConfig(laOperator *a, laEvent *e){
  2204. if(!a->This || !a->This->EndInstance) return LA_FINISHED; laScreen* s=a->This->EndInstance;
  2205. if(a->ConfirmData){
  2206. if(a->ConfirmData->Mode == LA_CONFIRM_OK){
  2207. la_RemoveScreen(s); laNotifyUsers("la.user_preferences.screens");
  2208. }
  2209. return LA_FINISHED;
  2210. }
  2211. return LA_FINISHED;
  2212. }
  2213. int OPINV_OpenInternetLink(laOperator *a, laEvent *e){
  2214. char *link = strGetArgumentString(a->ExtraInstructionsP, "link");
  2215. if (link) laOpenInternetLink(link);
  2216. return LA_FINISHED;
  2217. }
  2218. void laget_PanelTemplateCategory(void* rack_unused, laUiTemplate* uit, char* copy, char** ptr);
  2219. void la_RegisterBuiltinOperators(){
  2220. laPropContainer *pc; laProp *p;
  2221. laOperatorType *at;
  2222. laEnumProp *ep;
  2223. laCreateOperatorType("LA_terminate_program", "Quit", "Terminate Program Immediately",
  2224. OPCHK_TerminateProgram, 0, 0, OPINV_TerminateProgram, 0, U'⏻', LA_ACTUATOR_SYSTEM);
  2225. laCreateOperatorType("LA_undo", "Undo", "Undo from recorded data state", OPCHK_Undo, 0, 0, OPINV_Undo, 0, U'⮌', LA_ACTUATOR_SYSTEM);
  2226. laCreateOperatorType("LA_redo", "Redo", "Redo using recorded data state", OPCHK_Redo, 0, 0, OPINV_Redo, 0, U'⮎', LA_ACTUATOR_SYSTEM);
  2227. laCreateOperatorType("LA_refresh_screens", "Refresh Screens", "Refresh Screens", 0, 0, 0, OPINV_RefreshScreens, 0, U'⭯', LA_ACTUATOR_SYSTEM);
  2228. laCreateOperatorType("LA_remove_screen_config", "Remove Screen", "Remove this screen configuration", 0, 0, 0, OPINV_RemoveScreenConfig, OPMOD_RemoveScreenConfig, U'🞫', LA_ACTUATOR_SYSTEM);
  2229. laCreateOperatorType("LA_translation_dump", "Dump Untranslated Text", "Dump Untranslated Text To File", 0, 0, 0, OPINV_TranslationDumpMisMatch, 0, U'📥', LA_ACTUATOR_SYSTEM);
  2230. laCreateOperatorType("LA_open_internet_link", "Goto", "Open Internet Link", 0, 0, 0, OPINV_OpenInternetLink, 0, U'🌐', LA_ACTUATOR_SYSTEM);
  2231. laCreateOperatorType("LA_system_paste", "SYSWINDOW Paste", "Generate a syetem paste event", 0, 0, 0, OPINV_SystemPaste, 0, U'📋', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2232. laCreateOperatorType("LA_string_copy", "Copy", "Copy string to clip board", 0, 0, 0, OPINV_StringCopy, 0, U'🗍', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2233. laCreateOperatorType("LA_window_operator", "SYSWINDOW Operator", "Handle All Unhandled Events", 0, 0, 0, OPINV_Window, OPMOD_Window, U'🖦', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2234. at = laCreateOperatorType("LA_switch_layout", "Switch Layout", "Cycle All Layouts In Current SYSWINDOW", 0, 0, 0, OPINV_SwitchLayout, OPMOD_FinishOnData, U'↔', LA_ACTUATOR_SYSTEM);
  2235. at->UiDefine=laui_LayoutCycle;
  2236. at = laCreateOperatorType("LA_new_window", "New SYSWINDOW", "Create a new window", 0, 0, 0, OPINV_NewWindow, 0, U'🗗', LA_ACTUATOR_SYSTEM);
  2237. laCreateOperatorType("LA_combine_child_blocks", "Combine Child Block", "If Child Blocks Are Two Panel Blocks, Then Combine Them.",
  2238. OPCHK_CombineChildBlocks, 0, 0, OPINV_CombineChildBlocks, 0, U'□' , LA_ACTUATOR_SYSTEM);
  2239. at = laCreateOperatorType("LA_new_panel", "New Panel", "Create a new panel",
  2240. 0, 0, 0, OPINV_NewPanel, OPMOD_NewPanel, U'🞆', LA_ACTUATOR_SYSTEM);
  2241. pc = laDefineOperatorProps(at, 0);
  2242. p = laAddSubGroup(pc, "template", "Template", "Template selection used to create the new panel", "panel_template", 0, 0, laui_TitleOnly, -1, laget_FirstPanelTemplate, laget_NewPanelGetActiveTemplate, laget_ListNext, 0, 0, laset_NewPanelSetTemplate,0,0);
  2243. laSubGroupExtraFunctions(p,0,0,0,0,laget_PanelTemplateCategory);
  2244. at->UiDefine=laui_PanelTemplateSelect;
  2245. laCreateOperatorType("LA_block_fold_title", "Fold Title", "Fold the tile bar of the block", 0, 0, 0, OPINV_BlockFoldTitle, 0, U'⯅', LA_ACTUATOR_SYSTEM);
  2246. laCreateOperatorType("LA_block_maximize", "Maximize", "Maximize this block", 0, 0, 0, OPINV_BlockMaximize, 0, U'⮼', LA_ACTUATOR_SYSTEM);
  2247. laCreateOperatorType("LA_block_tear_off_panel", "Tear Off", "Tear off current panel in the block",
  2248. OPCHK_BlockHasMorePanels, 0, 0, OPINV_BlockTearOffPanel, 0, U'🗗', LA_ACTUATOR_SYSTEM);
  2249. laCreateOperatorType("LA_block_close_panel", "Close Panel", "Close current panel in the block",
  2250. OPCHK_BlockHasMorePanels, 0, 0, OPINV_BlockClosePanel, OPMOD_BlockClosePanel, U'🞫', LA_ACTUATOR_SYSTEM);
  2251. laCreateOperatorType("LA_canvas_ui_maximize", "Maximize", "Maximize this UI item", 0, 0, 0, OPINV_CanvasUiMaximize, 0, U'⮼', LA_ACTUATOR_SYSTEM);
  2252. laCreateOperatorType("LA_hide_menu_bar", "Hide Menu Bar", "Hide menu bar of the window", 0, 0, 0, OPINV_HideMenuBar, 0, U'⯅', LA_ACTUATOR_SYSTEM);
  2253. laCreateOperatorType("LA_fullscreen", "Fullscreen", "Switch full screen for the window",
  2254. 0, 0, 0, OPINV_Fullscreen, 0, U'🡵', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2255. laCreateOperatorType("LA_new_layout", "New Layout", "Create a new layout in the window",
  2256. 0, 0, 0, OPINV_NewLayout, 0, U'🞦', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2257. laCreateOperatorType("LA_remove_layout", "Remove Layout", "Remove current layout in the window",
  2258. OPCHK_RemoveLayout, 0, 0, OPINV_RemoveLayout, 0, U'🞫', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2259. laCreateOperatorType("LA_panel_operator", "Panel Operator", "Handle Events On The Panel Level",
  2260. 0, 0, OPEXT_Panel, OPINV_Panel, OPMOD_Panel, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2261. laCreateOperatorType("LA_modal_panel_operator", "Modal Panel Operator", "Handle Events On Modal Panels Like Yes-No Boxes",
  2262. 0, 0, OPEXT_Panel, OPINV_Panel, OPMOD_ModalPanel, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2263. laCreateOperatorType("LA_menu_panel_operator", "Menu Panel Operator", "Handle Events On Menu Panel,Recieve And Dispatch Confirm Messages,Then Self-destroy.",
  2264. 0, 0, OPEXT_Panel, OPINV_Panel, OPMOD_MenuPanel, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2265. laCreateOperatorType("LA_panel_activator", "Panel Activator", "Show A Panel When Invoked.Need An Extra Argument[panel_id]",
  2266. OPCHK_IsPanel, 0, 0, OPINV_ActivatePanel, 0, 0, LA_ACTUATOR_SYSTEM)
  2267. ->ParseArgs = la_PanelActiviatorParser;
  2268. laCreateOperatorType("LA_hide_panel", "Hide Panel", "Hide a panel",
  2269. OPCHK_IsPanel, 0, 0, OPINV_HidePanel, 0, 0, LA_ACTUATOR_SYSTEM);
  2270. laCreateOperatorType("LA_dock_panel", "Dock Panel", "Dock a panel",
  2271. OPCHK_IsPanel, 0, 0, OPINV_DockPanel, 0, 0, LA_ACTUATOR_SYSTEM);
  2272. laCreateOperatorType("LA_prop_restore_default", "Restore default value", "Restore property back to its default value", OPCHK_PropSetValue, 0, 0, OPINV_PropSetDefault, 0, U'⭯', LA_ACTUATOR_SYSTEM);
  2273. laCreateOperatorType("LA_prop_set_min", "Set Min Value", "Set property to its minimum value", OPCHK_PropSetValue, 0, 0, OPINV_PropSetMin, 0, 0, LA_ACTUATOR_SYSTEM);
  2274. laCreateOperatorType("LA_prop_set_max", "Set Max Value", "Set property to its maximum value", OPCHK_PropSetValue, 0, 0, OPINV_PropSetMax, 0, 0, LA_ACTUATOR_SYSTEM);
  2275. laCreateOperatorType("LA_string_set_default", "Set Default Value", "Set default string", OPCHK_StringSetValue, 0, 0, OPINV_PropSetDefault, 0, U'⭯', LA_ACTUATOR_SYSTEM);
  2276. laCreateOperatorType("LA_string_get_folder_path", "Get folder Path", "get folder path", OPCHK_StringSetValue, 0, 0, OPINV_StringGetFolderPath, OPMOD_StringGetFolderOrFilePath, U'📁', LA_ACTUATOR_SYSTEM);
  2277. laCreateOperatorType("LA_string_get_file_path", "Get folder Path", "get file path", OPCHK_StringSetValue, 0, 0, OPINV_StringGetFilePath, OPMOD_StringGetFolderOrFilePath, U'🖹', LA_ACTUATOR_SYSTEM);
  2278. laCreateOperatorType("LA_collection_clear_selection", "Clear Selection", "Clear collection selection", OPCHK_CollectionSetValue, 0, 0, OPINV_CollectionClearSelection, 0, U'🧹', LA_ACTUATOR_SYSTEM);
  2279. laCreateOperatorType("LA_prop_insert_key", "Insert Key Frame", "Insert key frame in the active action", OPCHK_PropInsertKey, 0, 0, OPINV_PropInsertKey, 0, U'🔑', LA_ACTUATOR_SYSTEM);
  2280. laCreateOperatorType("LA_view_hyper_data", "View Hyper Data", "Show Properties Of Specific Data Block", OPCHK_IsHyper, 0, 0, OPINV_ViewHyperData, 0, U'🛈', LA_ACTUATOR_SYSTEM);
  2281. at = laCreateOperatorType("LA_file_dialog_new_directory", "New Directory", "New Directory", OPCHK_IsFileBrowser, 0, 0, OPINV_FileBrowserNewDirectory, OPMOD_FileBrowserNewDirectory, U'📁', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2282. at->UiDefine = laui_FileBrowserNewDirectory;
  2283. laCreateOperatorType("LA_file_dialog_refresh", "Refresh", "Refresh List", OPCHK_IsFileBrowser, 0, 0, OPINV_FileBrowserRefresh, 0, U'🗘', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2284. laCreateOperatorType("LA_file_dialog_up", "Up", "Select Upper Folder Level", OPCHK_IsFileBrowser, 0, 0, OPINV_FileBrowserUpLevel, 0, U'🢰', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2285. laCreateOperatorType("LA_file_dialog_confirm", "Confirm", "Confirm selection", OPCHK_FileBrowserCanConfirm, 0, 0, OPINV_FileBrowserConfirm, OPMOD_FileBrowserConfirm, U'✔', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  2286. at = laCreateOperatorType("LA_file_dialog", "File Dialog", "Do File Operations", 0, 0, OPEXT_FileBrowser, OPINV_FileBrowser, OPMOD_FileBrowser, U'🗐', LA_ACTUATOR_SYSTEM);
  2287. pc = laDefineOperatorProps(at, 1);
  2288. at->UiDefine = laui_FileBrowserFileList;
  2289. _LA_PROP_FILE_BROWSER = pc;
  2290. laAddStringProperty(pc, "path", "Path", "Directort path", 0, 0, 0, "/", 0, offsetof(laFileBrowser, Path), 0, 0, laset_FileBrowserPath, 0, LA_UDF_LOCAL);
  2291. laAddStringProperty(pc, "file_name", "File Name", "File name", 0, 0, 0, 0, 0, offsetof(laFileBrowser, FileName), 0, 0, laset_FileBrowserFileName, 0, LA_UDF_LOCAL);
  2292. laAddStringProperty(pc, "temp_str", "Temp String", "Temp string", 0, 0, 0, "", 0, offsetof(laFileBrowser, TempStr), 0, 0, 0, 0, LA_UDF_LOCAL);
  2293. laAddStringProperty(pc, "filter_name", "Filter Name", "Filter file name", 0, 0, 0, 0, 0, offsetof(laFileBrowser, FilterName), 0, 0, laset_FileBrowserFilterName, 0, LA_UDF_LOCAL);
  2294. laAddSubGroup(pc, "file_list", "File List", "List Of Files And Directories Under A Specific Path", "file_item",0,0,laui_FileBrowserFileItem, -1, 0, laget_FileBrowserActiveFile, 0, 0, 0, laset_FileBrowserSelectFile, offsetof(laFileBrowser, FileList), 0);
  2295. laAddSubGroup(pc, "disk_list", "Disk List", "List Of All Logical Drives (In Windows)", "disk_item",0, 0, 0, -1, 0, 0, 0, 0, 0, laset_FileBrowserActiveDisk, offsetof(laFileBrowser, Disks), 0);
  2296. laAddSubGroup(pc, "bookmarks", "Bookmarks", "Bookmarked directories in GTK3", "bookmarked_folder",0, 0, 0, -1, 0, 0, 0, laset_FileBrowserBookmark, 0, 0, offsetof(laFileBrowser, Bookmarks), 0);
  2297. laAddSubGroup(pc, "available_extensions", "Available Extensions", "List of all available extensions", "la_extension_type",0, 0, 0, -1, laget_FileBrowserAcceptedExtensionsFrist, 0, laget_FileBrowserAcceptedExtensionsNext,laset_FileBrowserExtension,0,0,0,0);
  2298. laAddIntProperty(pc,"use_type","Use Type","Use file type",0,0,0,0,0,0,0,0,offsetof(laFileBrowser,UseType),0,0,0,0,0,0,0,0,0,0,LA_READ_ONLY);
  2299. ep = laAddEnumProperty(pc, "select_what", "Select What", "Select folder or file", 0, 0, 0, 0, 0, offsetof(laFileBrowser, SelectFolder), 0, 0, 0, 0, 0, 0, 0, 0, 0,LA_READ_ONLY);{
  2300. laAddEnumItemAs(ep, "file", "File", "File", LA_FILE_SELECT_FILE, U'📁');
  2301. laAddEnumItemAs(ep, "folder", "Folder", "Folder", LA_FILE_SELECT_FOLDER, U'🖹');
  2302. }
  2303. laAddOperatorProperty(pc, "new_directory", "New Directory", "Create a new directory", "LA_file_dialog_new_directory", U'📁', 0);
  2304. laAddOperatorProperty(pc, "refresh", "Refresh", "Refresh file list", "LA_file_dialog_refresh", U'🗘', 0);
  2305. laAddOperatorProperty(pc, "folder_up", "Up", "Select Upper Folder Level In File Browsers", "LA_file_dialog_up", U'🢰', 0);
  2306. laAddOperatorProperty(pc, "confirm", "Confirm", "Confirm selection", "LA_file_dialog_confirm", U'✔', 0);
  2307. p = laAddPropertyContainer("disk_item", "Disk Item", "A logical drive (in Windows)", 0, laui_FileBrowserDiskItem, 0, 0, 0, 1);{
  2308. laAddStringProperty(p, "id", "ID", "Disk identifier", 0, 0, 0, 0, 0, 0, 0, laget_FileBrowserDiskID, 0, 0, 0);
  2309. laAddFloatProperty(p, "total_gb", "Total", "Disk total compacity in gigabytes", 0, 0, "GB", 0, 0, 0, 0, 0, offsetof(laDiskItem, Total_GB), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,LA_READ_ONLY);
  2310. laAddFloatProperty(p, "free_gb", "Free", "Disk Free Space Size In Gigabytes", 0, 0, "GB", 0, 0, 0, 0, 0, offsetof(laDiskItem, Free_GB), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,LA_READ_ONLY);
  2311. }
  2312. p = laAddPropertyContainer("file_item", "File Item", "A file item in a list", U'🖹', 0, 0, 0, 0, 0);{
  2313. laAddStringProperty(p, "name", "Name", "The name of the file (with extension)", 0, 0, 0, 0, 0, offsetof(laFileItem, Name), 0, 0, 0, 0, LA_UDF_LOCAL);
  2314. laAddIntProperty(p, "is_folder", "Is Folder", "File is a folder or actual file", 0, 0, 0, 1, 0, 0, 0, 0, offsetof(laFileItem, IsFolder), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,LA_READ_ONLY);
  2315. laAddSubGroup(p, "time_modified", "Time Last Modified", "The Time When The File Was Last Modified", "time_info",0, 0, 0, offsetof(laFileItem, TimeModified), 0, 0, 0, 0, 0, 0, 0, LA_UDF_LOCAL);
  2316. laAddIntProperty(p, "size", "Size", "File Size In Bytes", 0, 0, "Bytes", 0, 0, 0, 0, 0, offsetof(laFileItem, Size), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,LA_READ_ONLY);
  2317. laAddStringProperty(p, "size_string", "Size String", "File size in convenient string", 0, 0, 0, 0, 0, 0, 0, laget_FileBrowserFileSizeString, 0, 0, LA_READ_ONLY);
  2318. ep = laAddEnumProperty(p, "type", "Type", "General type of the file", 0, 0, 0, 0, 0, offsetof(laFileItem, Type), 0, 0, 0, 0, 0, 0, 0, 0, 0,LA_READ_ONLY);{
  2319. laAddEnumItemAs(ep, "unknown", "Unknown", "Unknown/Uncategorized File Type", LA_FILETYPE_UNKNOWN, U'🖹');
  2320. laAddEnumItemAs(ep, "udf", "UDF", "Uniform Data Format", LA_FILETYPE_UDF, U'📦');
  2321. laAddEnumItemAs(ep, "document", "Document", "Document File", LA_FILETYPE_DOCUMENT, U'🖹');
  2322. laAddEnumItemAs(ep, "image", "Image", "Image File", LA_FILETYPE_IMAGE, U'🖻');
  2323. laAddEnumItemAs(ep, "audio", "Audio", "Audio File", LA_FILETYPE_AUDIO, U'𝄞');
  2324. laAddEnumItemAs(ep, "video", "Video", "Video File", LA_FILETYPE_VIDEO, U'🎞');
  2325. laAddEnumItemAs(ep, "compressed", "Compressed", "Compressed File", LA_FILETYPE_COMPRESSED, U'🗜');
  2326. laAddEnumItemAs(ep, "font", "Font", "Font File", LA_FILETYPE_FONT, U'🗚');
  2327. laAddEnumItemAs(ep, "vector", "Vector", "Vector File", LA_FILETYPE_VECTOR, U'🞎');
  2328. laAddEnumItemAs(ep, "webpage", "Webpage", "Webpage", LA_FILETYPE_WEBPAGE, U'🌐');
  2329. laAddEnumItemAs(ep, "meta", "Meta Data", "Meta Data Package", LA_FILETYPE_META, U'🖹');
  2330. laAddEnumItemAs(ep, "blend", "Blend", "Blend File", LA_FILETYPE_BLEND, U'🖹');
  2331. laAddEnumItemAs(ep, "pdf", "PDF", "PDF File", LA_FILETYPE_PDF, U'🖹');
  2332. laAddEnumItemAs(ep, "exe", "Executable", "SYSWINDOW Executable", LA_FILETYPE_EXEC, U'🖦');
  2333. laAddEnumItemAs(ep, "sys", "System", "System Files", LA_FILETYPE_SYS, U'🖹');
  2334. laAddEnumItemAs(ep, "folder", "Folder", "Folder", LA_FILETYPE_FOLDER, U'📁');
  2335. laAddEnumItemAs(ep, "lasdexchange", "LaSDExchange", "LA Scene Descriptive Exchange File", LA_FILETYPE_LASDEXCHANGE, 0);
  2336. }
  2337. }
  2338. p = laAddPropertyContainer("bookmarked_folder", "Bookmarked_folder", "A bookmarked folder from GTK3", 0, laui_IdentifierOnly, sizeof(laBookmarkedFolder), 0, 0, 0);{
  2339. laAddStringProperty(p, "name", "Name", "Bookmark name", 0, 0, 0, 0, 0, offsetof(laBookmarkedFolder, Name), 0, 0, 0, 0, LA_AS_IDENTIFIER|LA_UDF_LOCAL);
  2340. laAddStringProperty(p, "path", "Path", "Bookmark path", 0, 0, 0, 0, 0, offsetof(laBookmarkedFolder, Path), 0, 0, 0, 0, LA_UDF_LOCAL);
  2341. }
  2342. ep = laAddEnumProperty(pc, "show_backups", "Show Backups", "Show backup files", 0, 0, 0, 0, 0, offsetof(laFileBrowser, ShowBackups), 0, laset_FileBrowserShowBackups, 0, 0, 0, 0, 0, 0, 0,0);{
  2343. laAddEnumItemAs(ep, "NONE", "None", "Don't show backup files", 0, U'~');
  2344. laAddEnumItemAs(ep, "SHOWN", "Shown", "Show backup files", 1, U'~');
  2345. }
  2346. ep = laAddEnumProperty(pc, "show_thumbnail", "Show Thumbnail", "Show thumbnail", 0, 0, 0, 0, 0, offsetof(laFileBrowser, ShowThumbnail), 0, laset_FileBrowserShowThumbnail, 0, 0, 0, 0, 0, 0, 0,0);{
  2347. laAddEnumItemAs(ep, "NONE", "None", "Don't show thumbnail files", 0, U'🖼');
  2348. laAddEnumItemAs(ep, "SHOWN", "Shown", "Show thumbnail files", 1, U'🖼');
  2349. }
  2350. ep = laAddEnumProperty(pc, "sort_name", "Name", "Sort by names",LA_WIDGET_ENUM_CYCLE, 0, 0, 0, 0, 0, laget_FileBrowserSortName,laset_FileBrowserSortName, 0, 0, 0, 0, 0, 0, 0,0);{
  2351. laAddEnumItemAs(ep, "NONE", "None", "Don't sort", 0, 0);
  2352. laAddEnumItemAs(ep, "SORT", "Sort", "Sort accending", 1, U'🔻');
  2353. laAddEnumItemAs(ep, "REV", "Reversed", "Sort Descending", 2, U'🔺');
  2354. }
  2355. ep = laAddEnumProperty(pc, "sort_time", "Time", "Sort by times",LA_WIDGET_ENUM_CYCLE, 0, 0, 0, 0, 0, laget_FileBrowserSortTime,laset_FileBrowserSortTime, 0, 0, 0, 0, 0, 0, 0,0);{
  2356. laAddEnumItemAs(ep, "NONE", "None", "Don't sort", 0, 0);
  2357. laAddEnumItemAs(ep, "SORT", "Sort", "Sort accending", 1, U'🔻');
  2358. laAddEnumItemAs(ep, "REV", "Reversed", "Sort Descending", 2, U'🔺');
  2359. }
  2360. ep = laAddEnumProperty(pc, "sort_size", "Size", "Sort by sizes",LA_WIDGET_ENUM_CYCLE, 0, 0, 0, 0, 0, laget_FileBrowserSortSize,laset_FileBrowserSortSize, 0, 0, 0, 0, 0, 0, 0,0);{
  2361. laAddEnumItemAs(ep, "NONE", "None", "Don't sort", 0, 0);
  2362. laAddEnumItemAs(ep, "SORT", "Sort", "Sort accending", 1, U'🔻');
  2363. laAddEnumItemAs(ep, "REV", "Reversed", "Sort Descending", 2, U'🔺');
  2364. }
  2365. at = laCreateOperatorType("LA_udf_read", "Read", "Read a UDF file", 0, 0, OPEXT_UDFOperation, OPINV_UDFRead, OPMOD_UDFRead, U'📑', LA_ACTUATOR_SYSTEM);
  2366. pc = laDefineOperatorProps(at, 0);
  2367. at->UiDefine = laui_LinkerPanel;
  2368. at = laCreateOperatorType("LA_udf_save_instance", "Save Instance", "Save a instance as a UDF block", 0, 0, OPEXT_UDFOperation, OPINV_UDFSaveInstance, OPMOD_UDFSaveInstance, U'📑', LA_ACTUATOR_SYSTEM);
  2369. at = laCreateOperatorType("LA_managed_save", "Save as", "Save managed data blocks", 0, 0, OPEXT_ManagedSave, OPINV_ManagedSave, OPMOD_ManagedSave, U'🖫', LA_ACTUATOR_SYSTEM);
  2370. pc = laDefineOperatorProps(at, 1);
  2371. ep=laAddEnumProperty(pc, "show_page", "Show Page", "Show whether data blocks or UDF files", 0,0,0,0,0,offsetof(laManagedSaveExtra, ShowPage),0,laset_ManagedSavePage,0,0,0,0,0,0,0,0);
  2372. laAddEnumItemAs(ep, "DATA_BLOCKS", "Data Blocks", "All data blocks", 0, 0);
  2373. laAddEnumItemAs(ep, "FILES", "Files", "All Files", 1, 0);
  2374. at->UiDefine = laui_ManagedSavePanel;
  2375. laCreateOperatorType("LA_udf_propagate", "Propagate", "Propagate this file to all unassigned child nodes", 0, 0, 0, OPINV_UDFPropagate, 0, 0, LA_ACTUATOR_SYSTEM);
  2376. laCreateOperatorType("LA_managed_save_new_file", "New File", "New managed UDF file", 0, 0, OPEXT_ManagedSave, OPINV_ManagedSaveNewFile, OPMOD_ManagedSaveNewFile, U'+', LA_ACTUATOR_SYSTEM);
  2377. laCreateOperatorType("LA_manage_udf", "UDF Manager", "Operations on all managed UDF files", 0, 0, 0, OPINV_UDFManager, 0, U'🔍', LA_ACTUATOR_SYSTEM);
  2378. laCreateOperatorType("LA_add_resource_folder", "Add Resource Folder", "Add a resource folder entry for searching UDF references",
  2379. 0, 0, 0, OPINV_AddResourceFolder, 0, U'🞧', LA_ACTUATOR_SYSTEM);
  2380. laCreateOperatorType("LA_remove_resource_folder", "Remove Resource Folder", "Remove a resource folder entry",
  2381. 0, 0, 0, OPINV_RemoveResourceFolder, 0, U'🞫', LA_ACTUATOR_SYSTEM);
  2382. laCreateOperatorType("LA_new_input_mapping", "New Mapping", "New input mapping", 0, 0, 0, OPINV_NewInputMapping, 0, '+', LA_ACTUATOR_SYSTEM);
  2383. laCreateOperatorType("LA_new_input_mapping_entry", "New Entry", "New input mapping entry", 0, 0, 0, OPINV_NewInputMappingEntry, 0, '+', LA_ACTUATOR_SYSTEM);
  2384. laCreateOperatorType("LA_remove_input_mapping", "Remove Mapping", "Remove input mapping", 0, 0, 0, OPINV_RemoveInputMapping, OPMOD_RemoveInputMapping, U'🞫', LA_ACTUATOR_SYSTEM);
  2385. laCreateOperatorType("LA_remove_input_mapping_entry", "Remove Entry", "Remove input mapping entry", 0, 0, 0, OPINV_RemoveInputMappingEntry, OPMOD_RemoveInputMappingEntry, U'🞫', LA_ACTUATOR_SYSTEM);
  2386. laCreateOperatorType("LA_reset_input_mapping_fields", "Reset Entry", "Reset mapping entry", 0, 0, 0, OPINV_ClearInputMappingFields, 0, U'⮌', LA_ACTUATOR_SYSTEM);
  2387. at = laCreateOperatorType("LA_input_mapping_entry_select_signal", "Select Signal", "Select signal for this entry", 0, 0, 0, OPINV_InputMappingEntrySelectSignal, OPMOD_InputMappingEntrySelectSignal, U'⯆', LA_ACTUATOR_SYSTEM);
  2388. at->UiDefine = laui_InputMappingEntrySignalSelector;
  2389. at = laCreateOperatorType("LA_input_mapping_entry_select_operator", "Select Operator", "Select operator for this entry", 0, 0, 0, OPINV_InputMappingEntrySelectOperator, OPMOD_InputMappingEntrySelectOperator, U'⯆', LA_ACTUATOR_SYSTEM);
  2390. at->UiDefine = laui_InputMappingEntryOperatorSelector;
  2391. at = laCreateOperatorType("LA_input_mapping_entry_select_key", "Select Key", "Select key for this entry", 0, 0, OPEXT_InputMappingEntrySelectKey, OPINV_InputMappingEntrySelectKey, OPMOD_InputMappingEntrySelectKey, U'K', LA_ACTUATOR_SYSTEM);
  2392. at->UiDefine = laui_InputMappingEntryKeySelector;
  2393. pc = laDefineOperatorProps(at, 1);
  2394. laAddStringProperty(pc,"pressed_string","Pressed String","String of the pressed key",LA_WIDGET_STRING_PLAIN,0,0,0,1,-1,0,laget_KeyDetectorPressedString,0,0,LA_READ_ONLY);
  2395. laCreateOperatorType("LA_save_user_preferences", "Save Preferences", "Save user preferences", 0, 0, 0, OPINV_SaveUserPreferences, 0, 0, LA_ACTUATOR_SYSTEM);
  2396. laCreateOperatorType("LA_restore_factory", "Restore Factory Settings", "Restore factory settings", 0, 0, 0, OPINV_RestoreFactorySettings, OPMOD_RestoreFactorySettings, 0, LA_ACTUATOR_SYSTEM);
  2397. laCreateOperatorType("LA_confirm", "Confirm", "Confirm The Statement", 0, 0, 0, OPINV_DoNothing, 0, U'✔', LA_ACTUATOR_SYSTEM)
  2398. ->ExtraInstructions = "feedback=CONFIRM;";
  2399. laCreateOperatorType("LA_cancel", "Cancel", "Ignore The Statement", 0, 0, 0, OPINV_DoNothing, 0, U'🞫', LA_ACTUATOR_SYSTEM)
  2400. ->ExtraInstructions = "feedback=CANCEL;";
  2401. laCreateOperatorType("LA_pure_yes_no", "Yes Or No", "Show Yes Or No Box", 0, 0, 0, OPINV_PureYesNo, 0, U'❓', LA_ACTUATOR_SYSTEM);
  2402. laCreateOperatorType("LA_delete_theme", "Delete Theme", "Delete a theme",
  2403. 0, 0, 0, OPINV_DeleteTheme, 0, U'🞫', LA_ACTUATOR_SYSTEM);
  2404. }