*/}}

la_operators.c 97 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272
  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->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. int OPCHK_AlwaysTrue(laPropPack *pp, laStringSplitor *ss){
  58. return 1;
  59. }
  60. int OPINV_DoNothing(laOperator *a, laEvent *e){
  61. return LA_FINISHED;
  62. }
  63. int OPINV_PureYesNo(laOperator *a, laEvent *e){
  64. laEnableYesNoPanel(a, 0, "Please Consider:", "Are You Sure?", 80, 80, 250, e);
  65. return LA_FINISHED;
  66. }
  67. #define DEFINE_FORMAT(str, type) \
  68. if (!strcmp(format, str)) return type;
  69. int la_DetectFileItemType(char* format){
  70. for(laExtensionType* et=MAIN.ExtraExtensions.pFirst;et;et=et->Item.pNext){ DEFINE_FORMAT(et->Extension, et->FileType); }
  71. DEFINE_FORMAT("lasdexchange", LA_FILETYPE_LASDEXCHANGE);
  72. DEFINE_FORMAT("odt", LA_FILETYPE_DOCUMENT);
  73. DEFINE_FORMAT("ods", LA_FILETYPE_DOCUMENT);
  74. DEFINE_FORMAT("odp", LA_FILETYPE_DOCUMENT);
  75. DEFINE_FORMAT("txt", LA_FILETYPE_DOCUMENT);
  76. DEFINE_FORMAT("c", LA_FILETYPE_DOCUMENT);
  77. DEFINE_FORMAT("cpp", LA_FILETYPE_DOCUMENT);
  78. DEFINE_FORMAT("cxx", LA_FILETYPE_DOCUMENT);
  79. DEFINE_FORMAT("cs", LA_FILETYPE_DOCUMENT);
  80. DEFINE_FORMAT("pas", LA_FILETYPE_DOCUMENT);
  81. DEFINE_FORMAT("h", LA_FILETYPE_DOCUMENT);
  82. DEFINE_FORMAT("hpp", LA_FILETYPE_DOCUMENT);
  83. DEFINE_FORMAT("hxx", LA_FILETYPE_DOCUMENT);
  84. DEFINE_FORMAT("inl", LA_FILETYPE_DOCUMENT);
  85. DEFINE_FORMAT("doc", LA_FILETYPE_DOCUMENT);
  86. DEFINE_FORMAT("docx", LA_FILETYPE_DOCUMENT);
  87. DEFINE_FORMAT("xls", LA_FILETYPE_DOCUMENT);
  88. DEFINE_FORMAT("xlsx", LA_FILETYPE_DOCUMENT);
  89. DEFINE_FORMAT("ppt", LA_FILETYPE_DOCUMENT);
  90. DEFINE_FORMAT("pptx", LA_FILETYPE_DOCUMENT);
  91. DEFINE_FORMAT("rtf", LA_FILETYPE_DOCUMENT);
  92. DEFINE_FORMAT("md", LA_FILETYPE_DOCUMENT);
  93. DEFINE_FORMAT("jpg", LA_FILETYPE_IMAGE);
  94. DEFINE_FORMAT("jpeg", LA_FILETYPE_IMAGE);
  95. DEFINE_FORMAT("png", LA_FILETYPE_IMAGE);
  96. DEFINE_FORMAT("tga", LA_FILETYPE_IMAGE);
  97. DEFINE_FORMAT("bmp", LA_FILETYPE_IMAGE);
  98. DEFINE_FORMAT("exr", LA_FILETYPE_IMAGE);
  99. DEFINE_FORMAT("psd", LA_FILETYPE_IMAGE);
  100. DEFINE_FORMAT("kra", LA_FILETYPE_IMAGE);
  101. DEFINE_FORMAT("dng", LA_FILETYPE_IMAGE);
  102. DEFINE_FORMAT("cr2", LA_FILETYPE_IMAGE);
  103. DEFINE_FORMAT("dds", LA_FILETYPE_IMAGE);
  104. DEFINE_FORMAT("mp3", LA_FILETYPE_AUDIO);
  105. DEFINE_FORMAT("wav", LA_FILETYPE_AUDIO);
  106. DEFINE_FORMAT("ape", LA_FILETYPE_AUDIO);
  107. DEFINE_FORMAT("flac", LA_FILETYPE_AUDIO);
  108. DEFINE_FORMAT("cue", LA_FILETYPE_AUDIO);
  109. DEFINE_FORMAT("wma", LA_FILETYPE_AUDIO);
  110. DEFINE_FORMAT("aac", LA_FILETYPE_AUDIO);
  111. DEFINE_FORMAT("m4a", LA_FILETYPE_AUDIO);
  112. DEFINE_FORMAT("ogg", LA_FILETYPE_AUDIO);
  113. DEFINE_FORMAT("mp4", LA_FILETYPE_VIDEO);
  114. DEFINE_FORMAT("mov", LA_FILETYPE_VIDEO);
  115. DEFINE_FORMAT("avi", LA_FILETYPE_VIDEO);
  116. DEFINE_FORMAT("avchd", LA_FILETYPE_VIDEO);
  117. DEFINE_FORMAT("mkv", LA_FILETYPE_VIDEO);
  118. DEFINE_FORMAT("qt", LA_FILETYPE_VIDEO);
  119. DEFINE_FORMAT("flv", LA_FILETYPE_VIDEO);
  120. DEFINE_FORMAT("zip", LA_FILETYPE_COMPRESSED);
  121. DEFINE_FORMAT("rar", LA_FILETYPE_COMPRESSED);
  122. DEFINE_FORMAT("gz", LA_FILETYPE_COMPRESSED);
  123. DEFINE_FORMAT("bz", LA_FILETYPE_COMPRESSED);
  124. DEFINE_FORMAT("7z", LA_FILETYPE_COMPRESSED);
  125. DEFINE_FORMAT("iso", LA_FILETYPE_COMPRESSED);
  126. DEFINE_FORMAT("dmg", LA_FILETYPE_COMPRESSED);
  127. DEFINE_FORMAT("ttf", LA_FILETYPE_FONT);
  128. DEFINE_FORMAT("otf", LA_FILETYPE_FONT);
  129. DEFINE_FORMAT("woff", LA_FILETYPE_FONT);
  130. DEFINE_FORMAT("svg", LA_FILETYPE_VECTOR);
  131. DEFINE_FORMAT("dwg", LA_FILETYPE_VECTOR);
  132. DEFINE_FORMAT("dxf", LA_FILETYPE_VECTOR);
  133. DEFINE_FORMAT("cdr", LA_FILETYPE_VECTOR);
  134. DEFINE_FORMAT("htm", LA_FILETYPE_WEBPAGE);
  135. DEFINE_FORMAT("html", LA_FILETYPE_WEBPAGE);
  136. DEFINE_FORMAT("xhtml", LA_FILETYPE_WEBPAGE);
  137. DEFINE_FORMAT("xml", LA_FILETYPE_META);
  138. DEFINE_FORMAT("dat", LA_FILETYPE_META);
  139. DEFINE_FORMAT("json", LA_FILETYPE_META);
  140. DEFINE_FORMAT("blend", LA_FILETYPE_BLEND);
  141. DEFINE_FORMAT("pdf", LA_FILETYPE_PDF);
  142. DEFINE_FORMAT("exe", LA_FILETYPE_EXEC);
  143. DEFINE_FORMAT("dll", LA_FILETYPE_SYS);
  144. DEFINE_FORMAT("sys", LA_FILETYPE_SYS);
  145. return 0;
  146. }
  147. int la_AcceptFileFormat(laFileBrowser* fb, char* format){
  148. if(!format || !format[0]) return 1;
  149. if(fb->FilterType){
  150. for(laExtensionType* et=MAIN.ExtraExtensions.pFirst;et;et=et->Item.pNext){ if(et->FileType==fb->FilterType && strSame(format, et->Extension)) return 1; }
  151. return 0;
  152. }
  153. if(!fb->ss_filter_extensions) return 1;
  154. for(laStringPart* sp=fb->ss_filter_extensions->parts.pFirst;sp;sp=sp->Item.pNext){
  155. if(!strcmp(sp->Content, format)) return 1;
  156. }
  157. return 0;
  158. }
  159. void la_FileBrowserRebuildList(laFileBrowser *fb){
  160. laFileItem *fi = 0;
  161. laDiskItem *dl = 0;
  162. laListHandle Files = {0};
  163. char Lookup[2048]={0};
  164. char Final[2048]={0};
  165. char DiskLabels[256] = {0};
  166. char *pd = DiskLabels;
  167. int len = strlen(fb->Path);
  168. int NumDisks = 0;
  169. u64bit FreeAvailable = 0;
  170. u64bit FreeSpace_UNUSED = 0;
  171. u64bit TotalSpace = 0;
  172. real Ratio = 0;
  173. #ifdef __linux__
  174. if (fb->Path[len - 1] != U'/') strcat(fb->Path, "/");
  175. struct dirent **NameList=0;
  176. int NumFiles=scandir(fb->Path,&NameList,0,alphasort);
  177. while (fi = lstPopItem(&fb->FileList)) memFree(fi);
  178. for(int i=0;i<NumFiles;i++){
  179. struct dirent* d = NameList[i];
  180. if(!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")){continue;}
  181. struct stat s;
  182. sprintf(Final, "%s%s",fb->Path,d->d_name);
  183. stat(Final, &s);
  184. if (S_ISDIR(s.st_mode)){
  185. fi = memAcquireSimple(sizeof(laFileItem));
  186. strcpy(fi->Name, d->d_name);
  187. fi->IsFolder = 1;
  188. fi->Type = LA_FILETYPE_FOLDER;
  189. lstAppendItem(&fb->FileList, fi);
  190. }elif (!fb->SelectFolder){
  191. char *format = strGetLastSegment(d->d_name, '.');
  192. if(!la_AcceptFileFormat(fb,format)){ continue; }
  193. fi = memAcquireSimple(sizeof(laFileItem));
  194. strcpy(fi->Name, d->d_name);
  195. fi->Size = s.st_size;
  196. fi->Type = la_DetectFileItemType(format);
  197. struct tm *t = localtime(&s.st_ctime);
  198. fi->TimeModified.Year = t->tm_year+1900;
  199. fi->TimeModified.Month = t->tm_mon+1;;
  200. fi->TimeModified.Day = t->tm_mday;
  201. fi->TimeModified.Hour = t->tm_hour;
  202. fi->TimeModified.Minute = t->tm_min;
  203. fi->TimeModified.Second = t->tm_sec;
  204. lstAppendItem(&Files, fi);
  205. //lstAppendItem(&fb->FileList, fi);
  206. }
  207. }
  208. for (int i = 0; i < NumFiles; i++) { free(NameList[i]); } free(NameList);
  209. #endif
  210. #ifdef _WIN32
  211. WIN32_FIND_DATA FindFileData;
  212. HANDLE hFind;
  213. SYSTEMTIME stUTC, stLocal;
  214. strCopyFull(Lookup, fb->Path);
  215. if (Lookup[len - 1] != U'\\') strcat(Lookup, "\\*.*"); else strcat(Lookup, "*.*");
  216. hFind = FindFirstFile(Lookup, &FindFileData);
  217. while (fi = lstPopItem(&fb->FileList)) memFree(fi);
  218. if (hFind == INVALID_HANDLE_VALUE){ return; }
  219. while (1) {
  220. if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  221. if (FindFileData.cFileName[0] != '.') {
  222. fi = memAcquireSimple(sizeof(laFileItem));
  223. strcpy(fi->Name, FindFileData.cFileName);
  224. fi->IsFolder = 1;
  225. fi->Type = LA_FILETYPE_FOLDER;
  226. lstAppendItem(&fb->FileList, fi);
  227. }
  228. }elif(!fb->SelectFolder) {
  229. fi = memAcquireSimple(sizeof(laFileItem));
  230. strCopyFull(fi->Name, FindFileData.cFileName);
  231. fi->Size = FindFileData.nFileSizeLow;
  232. fi->Type = la_DetectFileItemType(fi);
  233. FileTimeToSystemTime(&(FindFileData.ftLastWriteTime), &stUTC);
  234. SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
  235. fi->TimeModified.Year = stLocal.wYear;
  236. fi->TimeModified.Month = stLocal.wMonth;
  237. fi->TimeModified.Day = stLocal.wDay;
  238. fi->TimeModified.Hour = stLocal.wHour;
  239. fi->TimeModified.Minute = stLocal.wMinute;
  240. fi->TimeModified.Second = stLocal.wSecond;
  241. lstAppendItem(&Files, fi);
  242. //lstAppendItem(&fb->FileList, fi);
  243. }
  244. if (!FindNextFile(hFind, &FindFileData))
  245. break;
  246. }
  247. #endif
  248. lstCombineLists(&fb->FileList, &Files);
  249. while (dl = lstPopItem(&fb->Disks)) memFree(dl);
  250. #ifdef _WIN32
  251. NumDisks = GetLogicalDriveStrings(256, DiskLabels) / 4;
  252. while (*pd){
  253. char Name[3] = "*:";
  254. Name[0] = *pd;
  255. if (GetDiskFreeSpaceEx(Name, &FreeAvailable, &TotalSpace, &FreeSpace_UNUSED)){
  256. dl = memAcquire(sizeof(laDiskItem));
  257. dl->ID = *pd;
  258. dl->Total_GB = (real)TotalSpace / 1073741824.0f; //B->GB
  259. dl->Free_GB = (real)FreeAvailable / 1073741824.0f; //B->GB
  260. if (Name[0] == fb->Path[0])
  261. fb->RootDisk = dl;
  262. lstAppendItem(&fb->Disks, dl);
  263. }
  264. pd += 4;
  265. }
  266. #endif
  267. fb->Active = 0;
  268. }
  269. laFileBrowser *la_FileBrowserInit(laOperator *a){
  270. laFileBrowser *fb = memAcquireHyper(sizeof(laFileBrowser));
  271. char* arg=0;
  272. strcpy(fb->Path, MAIN.WorkingDirectory->Ptr);
  273. if (strArgumentMatch(a->ExtraInstructionsP, "select", "folder")){ fb->SelectFolder = LA_FILE_SELECT_FOLDER; }
  274. if (strArgumentMatch(a->ExtraInstructionsP, "warn_file_exists", "true")){ fb->WarnFileExists = 1; }
  275. if ((arg=strGetArgumentString(a->ExtraInstructionsP, "filter_extensions"))){ fb->ss_filter_extensions=strSplitPath(arg,','); }
  276. if ((arg=strGetArgumentString(a->ExtraInstructionsP, "use_extension"))){ strcpy(fb->UseExtension, arg); }
  277. if ((arg=strGetArgumentString(a->ExtraInstructionsP, "filter_type"))){ sscanf(arg,"%d",&fb->FilterType); }
  278. if ((arg=strGetArgumentString(a->ExtraInstructionsP, "use_type"))){ sscanf(arg,"%d",&fb->UseType); }
  279. #ifdef __linux__
  280. char BookmarkPath[1024];
  281. strcat(strcpy(BookmarkPath, getenv("HOME")), "/.config/gtk-3.0/bookmarks");
  282. FILE* f=fopen(BookmarkPath, "r");
  283. if(f){ char entry[1024]={0};
  284. while(fgets(entry,1024,f)){ laBookmarkedFolder* bf=memAcquireSimple(sizeof(laBookmarkedFolder));
  285. entry[strlen(entry)-1]=0;
  286. strcpy(bf->Path,&entry[7]);
  287. strcpy(bf->Name,strGetLastSegment(&entry[7],'/')); lstAppendItem(&fb->Bookmarks,bf);
  288. }
  289. fclose(f);
  290. }
  291. #endif
  292. la_FileBrowserRebuildList(fb);
  293. fb->FileName[0] = 0;
  294. return fb;
  295. }
  296. void laset_FileBrowserSelectFile(laFileBrowser *fb, laFileItem *fi, int State){
  297. int len;
  298. if (fb->Active == fi){
  299. if (fi->IsFolder){
  300. len = strlen(fb->Path);
  301. if (fb->Path[len - 1] != LA_PATH_SEP) strcat(fb->Path, LA_PATH_SEPSTR);
  302. strcat(fb->Path, fi->Name);
  303. la_FileBrowserRebuildList(fb);
  304. fb->FileName[0] = 0;
  305. laRecalcCurrentPanelImmediate();
  306. }
  307. }else{
  308. if (!fi->IsFolder){
  309. strCopyFull(fb->FileName, fi->Name);
  310. }
  311. fb->Active = fi;
  312. }
  313. }
  314. void la_FileBrowserGetFullPath(laFileBrowser *fb,char* buf){
  315. buf[0]=0; int plen;
  316. if (!fb->SelectFolder && fb->FileName[0] == U'\0') return;
  317. plen = strlen(fb->Path);
  318. if (fb->Path[plen - 1] != LA_PATH_SEP) strcat(fb->Path, LA_PATH_SEPSTR);
  319. strCopyFull(buf, fb->Path);
  320. strcat(buf, fb->FileName);
  321. }
  322. int la_FileBrowserConfirm(laOperator *a, laFileBrowser *fb){
  323. char buf[2048];
  324. la_FileBrowserGetFullPath(fb,buf);
  325. laConfirmString(a, buf, LA_CONFIRM_OK);
  326. return 1;
  327. }
  328. void *laget_FileBrowserFirstFile(laFileBrowser *fb, void* unused){
  329. return fb->FileList.pFirst;
  330. }
  331. void *laget_FileBrowserActiveFile(laFileBrowser *fb){
  332. return fb->Active;
  333. }
  334. void laget_FileBrowserDiskID(laDiskItem *di, char *result){
  335. result[0] = di->ID;
  336. result[1] = U':';
  337. result[2] = LA_PATH_SEP;
  338. result[3] = U'\0';
  339. }
  340. void *laset_FileBrowserActiveDisk(laFileBrowser *fb, laDiskItem *di, int UNUSED_State){
  341. fb->RootDisk = di;
  342. laget_FileBrowserDiskID(di, fb->Path);
  343. la_FileBrowserRebuildList(fb);
  344. fb->FileName[0] = 0;
  345. }
  346. void laset_FileBrowserPath(laFileBrowser *fb, char *content){
  347. strCopyFull(fb->Path, content); la_FileBrowserRebuildList(fb); fb->FileName[0] = 0; laRecalcCurrentPanel();
  348. }
  349. void *laset_FileBrowserBookmark(laFileBrowser *fb, laBookmarkedFolder *bf){
  350. strcpy(fb->Path,bf->Path); la_FileBrowserRebuildList(fb); fb->FileName[0] = 0;
  351. }
  352. void laset_FileBrowserFileName(laFileBrowser *fb, char *content){
  353. strCopyFull(fb->FileName, content); int file_okay=0;
  354. char* ext=strGetLastSegment(fb->FileName,'.');
  355. if(fb->UseExtension[0] && strcmp(ext,fb->UseExtension)){ strcat(fb->FileName,"."); strcat(fb->FileName,fb->UseExtension); }
  356. else if(fb->UseType){ int file_okay=0; laExtensionType* FirstET=0;
  357. for(laExtensionType*et=MAIN.ExtraExtensions.pFirst;et;et=et->Item.pNext){
  358. if((!FirstET) && et->FileType==fb->UseType) FirstET=et;
  359. if(et->FileType==fb->UseType && strSame(ext,et->Extension)){ file_okay=1; break; }
  360. }
  361. if((!file_okay) && FirstET){ strcat(fb->FileName,"."); strcat(fb->FileName,FirstET->Extension); }
  362. }
  363. la_FileBrowserRebuildList(fb);
  364. laRecalcCurrentPanel();
  365. }
  366. void* laget_FileBrowserAcceptedExtensionsFrist(laFileBrowser* fb, laPropIterator* pi){
  367. if(!fb->UseType){ return 0; }
  368. for(laExtensionType*et=MAIN.ExtraExtensions.pFirst;et;et=et->Item.pNext){
  369. if(et->FileType==fb->UseType){ return et; }
  370. }
  371. }
  372. void* laget_FileBrowserAcceptedExtensionsNext(laExtensionType* et, laPropIterator* pi){
  373. for(laExtensionType*iet=et->Item.pNext;iet;iet=iet->Item.pNext){
  374. if(et->FileType==iet->FileType){ return iet; }
  375. }
  376. }
  377. void* laset_FileBrowserExtension(laFileBrowser* fb, laExtensionType* et){
  378. if(fb->UseType && fb->FileName[0] && et){ char* ext=strGetLastSegment(fb->FileName,'.');
  379. if(!ext){ sprintf(fb->FileName,".%s",ext); }
  380. elif(strcmp(et->Extension,ext)){ sprintf(ext,"%s",et->Extension); }
  381. la_FileBrowserRebuildList(fb); laRecalcCurrentPanel();
  382. }
  383. }
  384. void la_FileBrowserUpLevel(laFileBrowser *fb){
  385. char *p = fb->Path;
  386. char *LastP = 0;
  387. int Count = 0;
  388. for (p; *p; p++){
  389. if (*p && *p == LA_PATH_SEP && p[1]!=0){
  390. LastP = p;
  391. Count++;
  392. }
  393. }
  394. if (Count > 1) *LastP = 0;
  395. else if(LastP) *(LastP + 1) = 0;
  396. la_FileBrowserRebuildList(fb); fb->FileName[0] = 0;
  397. }
  398. int OPINV_FileBrowser(laOperator *a, laEvent *e){
  399. a->CustomData = la_FileBrowserInit(a);
  400. laEnableOperatorPanel(a, 0, LA_RH2, LA_RH2, 500, 500, 0, 0, 0, 0, LA_RH2, LA_RH2, LA_RH2, LA_RH2, e);
  401. return LA_RUNNING;
  402. }
  403. int OPEXT_FileBrowser(laOperator *a, int mark){
  404. laFileBrowser *fb = a->CustomData;
  405. void* f;
  406. while (f=lstPopItem(&fb->Disks)) memFree(f);
  407. while (f=lstPopItem(&fb->FileList)) memFree(f);
  408. while (f=lstPopItem(&fb->Bookmarks)) memFree(f);
  409. strDestroyStringSplitor(&fb->ss_filter_extensions);
  410. memFree(fb);
  411. return 0;
  412. }
  413. int OPMOD_FileBrowser(laOperator *a, laEvent *e){
  414. laFileBrowser *fb = a->CustomData;
  415. if (a->ConfirmData){
  416. if (a->ConfirmData->Mode == LA_CONFIRM_CANCEL){
  417. if(fb->StatusWaitingWarning){ fb->StatusWaitingWarning=0; return LA_RUNNING; }
  418. laConfirmSameDataIfAny(a); return LA_FINISHED_PASS;
  419. }
  420. if (a->ConfirmData->Mode == LA_CONFIRM_OK){
  421. la_FileBrowserConfirm(a, fb); return LA_FINISHED_PASS;
  422. }
  423. }
  424. if (e->Type == LA_ESCAPE_DOWN){
  425. laConfirmInt(a, 0, LA_CONFIRM_CANCEL);
  426. return LA_FINISHED;
  427. }
  428. return LA_RUNNING;
  429. }
  430. int OPCHK_IsFileBrowser(laPropPack *This, laStringSplitor *ss){
  431. if (This && This->LastPs->p->SubProp == _LA_PROP_FILE_BROWSER) return 1;
  432. return 0;
  433. }
  434. int OPINV_FileBrowserUpLevel(laOperator *a, laEvent *e){
  435. if (a->This){
  436. la_FileBrowserUpLevel(a->This->LastPs->UseInstance);
  437. laNotifyUsersPPPath(a->This, "path");
  438. laRecalcCurrentPanel();
  439. }
  440. return LA_FINISHED_PASS;
  441. }
  442. int OPCHK_FileBrowserCanConfirm(laPropPack *This, laStringSplitor *ss){
  443. if(!OPCHK_IsFileBrowser(This,ss)) return 0;
  444. laFileBrowser* fb=This->EndInstance;
  445. if(fb->SelectFolder) return 1;
  446. if(fb->FileName[0]) return 1;
  447. return 0;
  448. }
  449. int OPINV_FileBrowserConfirm(laOperator *a, laEvent *e){
  450. if (a->This){
  451. laFileBrowser* fb=a->This->LastPs->UseInstance;
  452. if(fb->WarnFileExists){
  453. char path[2048]; la_FileBrowserGetFullPath(fb, path);
  454. #ifdef __linux__
  455. if(access(path, F_OK)==0)
  456. #endif
  457. #ifdef _WIN32
  458. if (PathFileExists(path))
  459. #endif
  460. {
  461. laEnableYesNoPanel(a,0,"File exists","Selected file already exists. Overwrite the file?",e->x-LA_RH,e->y-LA_RH,200,e);
  462. fb->StatusWaitingWarning=1; return LA_RUNNING;
  463. }
  464. }
  465. laConfirmInt(a, 0, LA_CONFIRM_OK); return LA_FINISHED_PASS;
  466. }
  467. return LA_FINISHED_PASS;
  468. }
  469. int OPMOD_FileBrowserConfirm(laOperator *a, laEvent *e){
  470. laFileBrowser* fb=a->This->LastPs->UseInstance;
  471. if (a->ConfirmData){
  472. if (a->ConfirmData->Mode == LA_CONFIRM_CANCEL){
  473. if(fb->StatusWaitingWarning){ fb->StatusWaitingWarning=0; return LA_FINISHED; }
  474. }
  475. if (a->ConfirmData->Mode == LA_CONFIRM_OK){
  476. laConfirmInt(a, 0, LA_CONFIRM_OK); return LA_FINISHED_PASS;
  477. }
  478. return LA_FINISHED;
  479. }
  480. return LA_RUNNING;
  481. }
  482. void la_DestroyUDFContentNodeTreeRecursive(laUDFContentNode* ucn, int FreeRoot);
  483. int OPEXT_UDFOperation(laOperator *a, laEvent *e){
  484. laUDFPreviewExtra *upe = a->CustomData;
  485. laUDFContentNode *ucni, *NextUCNI;
  486. for (ucni = upe->ContentNodes.pFirst; ucni; ucni = NextUCNI){
  487. NextUCNI = ucni->Item.pNext;
  488. la_FreePropStepCache(ucni->PP.Go);
  489. la_DestroyUDFContentNodeTreeRecursive(ucni, 1);
  490. }
  491. memFree(upe);
  492. }
  493. int OPINV_UDFRead(laOperator *a, laEvent *e){
  494. laInvoke(a, "LA_file_dialog", e, 0, "filter_type=1;", 0);
  495. a->CustomData = memAcquireSimple(sizeof(laUDFPreviewExtra));
  496. laUDFPreviewExtra *upe = a->CustomData;
  497. if(strArgumentMatch(a->ExtraInstructionsP,"mode","append")){ upe->Append=1; }
  498. return LA_RUNNING;
  499. }
  500. int OPMOD_UDFRead(laOperator *a, laEvent *e){
  501. laUDFPreviewExtra *upe = a->CustomData;
  502. if (a->ConfirmData){
  503. if (a->ConfirmData->StrData){
  504. laManagedUDF* m;
  505. upe->UDF = laOpenUDF(a->ConfirmData->StrData, 1, 0, &m);
  506. if (upe->UDF){
  507. laExtractUDF(upe->UDF, m, upe->Append?LA_UDF_MODE_APPEND:LA_UDF_MODE_OVERWRITE, 0);
  508. laCloseUDF(upe->UDF);
  509. laRecordEverythingAndPush();
  510. return LA_FINISHED;
  511. }
  512. }
  513. return LA_FINISHED;
  514. }
  515. return LA_RUNNING;
  516. }
  517. int OPINV_UDFSaveInstance(laOperator *a, laEvent *e){
  518. laInvoke(a, "LA_file_dialog", e, 0, 0, 0);
  519. a->CustomData = memAcquireSimple(sizeof(laUDFPreviewExtra));
  520. return LA_RUNNING;
  521. }
  522. int OPMOD_UDFSaveInstance(laOperator *a, laEvent *e){
  523. laUDFPreviewExtra *upe = a->CustomData;
  524. laPropPack* pp=a->This; if(!pp||!pp->EndInstance) return LA_CANCELED;
  525. if (a->ConfirmData){
  526. if (a->ConfirmData->StrData){
  527. upe->UDF = laPrepareUDF(a->ConfirmData->StrData);
  528. if (upe->UDF){
  529. laWritePropP(upe->UDF, pp);
  530. laPackUDF(upe->UDF, 0, 0);
  531. return LA_FINISHED;
  532. }
  533. }
  534. }
  535. return LA_FINISHED;
  536. }
  537. void* laget_FirstManagedUDF(void* unused, void* unused_pi){ return MAIN.ManagedUDFs.pFirst; }
  538. void laset_ManagedSavePage(laManagedSaveExtra* mse, int p){
  539. mse->ShowPage=p;
  540. laRegisterModifications(0,0,0,0);
  541. }
  542. int OPEXT_ManagedSave(laOperator *a, laEvent *e){
  543. laManagedSaveExtra *upe = a->CustomData;
  544. memFree(upe);
  545. }
  546. int OPINV_ManagedSave(laOperator *a, laEvent *e){
  547. int OnExit=0;
  548. if(a->ExtraInstructionsP){
  549. if(strSame(strGetArgumentString(a->ExtraInstructionsP, "quiet"),"true")){
  550. int empty=0; laRegisterModifications(0,1,&empty,0);
  551. if(strSame(strGetArgumentString(a->ExtraInstructionsP, "ignore_unassigned"),"true")) empty=0;
  552. if(!empty){ laSaveManagedUDF(); return LA_FINISHED; }
  553. }
  554. if(strSame(strGetArgumentString(a->ExtraInstructionsP, "on_exit"),"true")){ OnExit=1; }
  555. }
  556. if(laOperatorExistsT(a->Type)) return LA_CANCELED;
  557. a->CustomData = memAcquire(sizeof(laManagedSaveExtra));
  558. laManagedSaveExtra* mse=a->CustomData;
  559. mse->OnExit=OnExit;
  560. mse->ShowPage = MAIN.ManagerDefaultView;
  561. laEnableOperatorPanel(a, 0, LA_RH2,LA_RH2,400,400,0,0,0,0,LA_RH2,LA_RH2,LA_RH2,LA_RH2,e);
  562. return LA_RUNNING;
  563. }
  564. int OPMOD_ManagedSave(laOperator *a, laEvent *e){
  565. laUDFPreviewExtra *upe = a->CustomData;
  566. if (a->ConfirmData){
  567. if(a->ConfirmData->Mode==LA_CONFIRM_CUSTOM_STRING && strSame(a->ConfirmData->StrData,"DISCARD_AND_QUIT")){
  568. return LA_OPERATOR_CALLS_SHUTOFF;
  569. }
  570. if(a->ConfirmData->Mode==LA_CONFIRM_CANCEL||a->ConfirmData->Mode==LA_CONFIRM_OK) return LA_FINISHED;
  571. return LA_RUNNING;
  572. }
  573. return LA_RUNNING;
  574. }
  575. int OPINV_ManagedSaveNewFile(laOperator *a, laEvent *e){
  576. if(MAIN.SetUDFPending) return LA_FINISHED;
  577. MAIN.SetUDFPending=1;
  578. a->CustomData = memAcquireSimple(sizeof(laUDFPreviewExtra));
  579. laInvoke(a, "LA_file_dialog", e, 0, "use_type=1;filter_type=1", 0);
  580. return LA_RUNNING;
  581. }
  582. int OPMOD_ManagedSaveNewFile(laOperator *a, laEvent *e){
  583. laUDFPreviewExtra *upe = a->CustomData;
  584. if (a->ConfirmData){
  585. if(a->ConfirmData->Mode==LA_CONFIRM_CANCEL){ MAIN.SetUDFPending=0; return LA_FINISHED; }
  586. if(a->ConfirmData->Mode==LA_CONFIRM_OK){
  587. if(a->ConfirmData->StrData){
  588. char* path=a->ConfirmData->StrData;
  589. if(la_FindManagedUDF(path)){
  590. laEnableMessagePanel(a, 0, "Duplicated files", "The file you chose already exists in the managed file list.",e->x,e->y,0,e);
  591. return LA_FINISHED;
  592. }
  593. laManagedUDF* m=MAIN.DummyManageUDF;
  594. m->udf = laPrepareUDF(path); strSafeSet(&m->BaseName, strGetLastSegment(path,LA_PATH_SEP));
  595. m->udf->Managed=1;
  596. la_MakeDummyManagedUDF();
  597. laNotifyUsers("la.managed_udfs"); laNotifyUsers("la.managed_props");
  598. }
  599. MAIN.SetUDFPending=0;
  600. return LA_FINISHED;
  601. }
  602. return LA_RUNNING;
  603. }
  604. return LA_RUNNING;
  605. }
  606. int OPINV_UDFManager(laOperator *a, laEvent *e){
  607. laRegisterModifications(0,0,0,0);
  608. laActivatePanel("LAUI_data_manager", e->x, e->y);
  609. return LA_FINISHED;
  610. }
  611. int OPINV_AddResourceFolder(laOperator *a, laEvent *e){
  612. laAddResourceFolder(0);
  613. laNotifyUsers("la.user_preferences.resource_folders");
  614. return LA_FINISHED;
  615. }
  616. int OPINV_RemoveResourceFolder(laOperator *a, laEvent *e){
  617. if(!a->This || !a->This->LastPs->UseInstance) return LA_CANCELED;
  618. laResourceFolder* rf=a->This->LastPs->UseInstance;
  619. laRemoveResourceFolder(rf);
  620. laRefreshUDFRegistries();
  621. laNotifyUsers("la.user_preferences.resource_folders");
  622. return LA_FINISHED;
  623. }
  624. int OPCHK_Undo(laPropPack *This, laStringSplitor *ss){
  625. laDiff* diff=MAIN.HeadDifference; if(!diff) return 0;
  626. diff=diff->Item.pPrev; if(!diff) return 0;
  627. }
  628. int OPCHK_Redo(laPropPack *This, laStringSplitor *ss){
  629. laDiff* diff=MAIN.HeadDifference; if(!diff) return 0;
  630. if(diff==MAIN.Differences.pLast) return 0;
  631. }
  632. int OPINV_Undo(laOperator *a, laEvent *e){
  633. laUndo();
  634. laPrintDBInstInfo();
  635. return LA_FINISHED;
  636. }
  637. int OPINV_Redo(laOperator *a, laEvent *e){
  638. laRedo();
  639. laPrintDBInstInfo();
  640. return LA_FINISHED;
  641. }
  642. int OPINV_UDFPropagate(laOperator *a, laEvent *e){
  643. laProp* p=a->This?a->This->LastPs->p:0; if(!p||p->PropertyType!=LA_PROP_SUB) return LA_FINISHED;
  644. void* instance=a->This->EndInstance; if(!instance) return LA_FINISHED;
  645. laPropContainer* pc=la_EnsureSubTarget(p,instance);
  646. int force=0;
  647. if(strSame(strGetArgumentString(a->ExtraInstructionsP,"force"),"true")){ force=1; }
  648. laPropagateUDF(pc, instance, force);
  649. laNotifyUsers("la.managed_props");
  650. return LA_FINISHED;
  651. }
  652. int OPINV_SaveUserPreferences(laOperator *a, laEvent *e){
  653. laSaveUserPreferences(); return LA_FINISHED;
  654. }
  655. int OPCHK_TerminateProgram(laPropPack *This, laStringSplitor *Instructions){
  656. return 1;
  657. }
  658. int OPINV_TerminateProgram(laOperator *a, laEvent *e){
  659. int empty=0; int mod=laRegisterModifications(1,1,&empty,0);
  660. if(mod || empty){ laInvoke(0, "LA_managed_save", 0,0,"on_exit=true;",0); return LA_FINISHED; }
  661. return LA_OPERATOR_CALLS_SHUTOFF;
  662. }
  663. int OPCHK_IntSetValue(laPropPack *This, laStringSplitor *Instructions){
  664. if (This && (This->LastPs->p->PropertyType == LA_PROP_INT)) return 1;
  665. else
  666. return 0;
  667. }
  668. int OPCHK_FloatSetValue(laPropPack *This, laStringSplitor *Instructions){
  669. if (This && (This->LastPs->p->PropertyType == LA_PROP_FLOAT)) return 1;
  670. else
  671. return 0;
  672. }
  673. int OPCHK_IntArraySetValue(laPropPack *This, laStringSplitor *Instructions){
  674. if (This && (This->LastPs->p->PropertyType == LA_PROP_INT | LA_PROP_ARRAY)) return 1;
  675. else
  676. return 0;
  677. }
  678. int OPCHK_FloatArraySetValue(laPropPack *This, laStringSplitor *Instructions){
  679. if (This && (This->LastPs->p->PropertyType == LA_PROP_FLOAT | LA_PROP_ARRAY)) return 1;
  680. else
  681. return 0;
  682. }
  683. int OPCHK_EnumSetValue(laPropPack *This, laStringSplitor *Instructions){
  684. if (This && (This->LastPs->p->PropertyType == LA_PROP_ENUM)) return 1;
  685. else
  686. return 0;
  687. }
  688. int OPCHK_EnumArraySetValue(laPropPack *This, laStringSplitor *Instructions){
  689. if (This && (This->LastPs->p->PropertyType == LA_PROP_ENUM | LA_PROP_ARRAY)) return 1;
  690. else
  691. return 0;
  692. }
  693. int OPCHK_StringSetValue(laPropPack *This, laStringSplitor *Instructions){
  694. if (This && (This->LastPs->p->PropertyType == LA_PROP_STRING)) return 1;
  695. else
  696. return 0;
  697. }
  698. int OPINV_EnumSetDefault(laOperator *a, laEvent *e){
  699. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_ENUM)){
  700. laEnumProp *ep = a->This->LastPs->p;
  701. laSetEnum(a->This, ep->DefVal);
  702. }
  703. return LA_FINISHED;
  704. }
  705. int OPINV_IntSetDefault(laOperator *a, laEvent *e){
  706. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_INT)){
  707. laIntProp *ip = a->This->LastPs->p;
  708. laSetInt(a->This, ip->DefVal);
  709. }
  710. return LA_FINISHED;
  711. }
  712. int OPINV_FloatSetDefault(laOperator *a, laEvent *e){
  713. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_FLOAT)){
  714. laFloatProp *ip = a->This->LastPs->p;
  715. laSetFloat(a->This, ip->DefVal);
  716. }
  717. return LA_FINISHED;
  718. }
  719. int OPINV_IntSetMax(laOperator *a, laEvent *e){
  720. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_INT)){
  721. laIntProp *ip = a->This->LastPs->p;
  722. laSetInt(a->This, ip->Max);
  723. }
  724. return LA_FINISHED;
  725. }
  726. int OPINV_FloatSetMax(laOperator *a, laEvent *e){
  727. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_FLOAT)){
  728. laFloatProp *ip = a->This->LastPs->p;
  729. laSetFloat(a->This, ip->Max);
  730. }
  731. return LA_FINISHED;
  732. }
  733. int OPINV_IntSetMin(laOperator *a, laEvent *e){
  734. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_INT)){
  735. laIntProp *ip = a->This->LastPs->p;
  736. laSetInt(a->This, ip->Min);
  737. }
  738. return LA_FINISHED;
  739. }
  740. int OPINV_FloatSetMin(laOperator *a, laEvent *e){
  741. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_FLOAT)){
  742. laFloatProp *ip = a->This->LastPs->p;
  743. laSetFloat(a->This, ip->Min);
  744. }
  745. return LA_FINISHED;
  746. }
  747. int OPINV_EnumArraySetDefault(laOperator *a, laEvent *e){
  748. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_ENUM)){
  749. laEnumProp *ep = a->This->LastPs->p;
  750. laSetEnumArrayAll(a->This, ep->DefVal);
  751. }
  752. return LA_FINISHED;
  753. }
  754. int OPINV_IntArraySetDefault(laOperator *a, laEvent *e){
  755. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_INT)){
  756. laIntProp *ip = a->This->LastPs->p;
  757. if (ip->DefArr) laSetIntArrayAllArray(a->This, ip->DefArr);
  758. else
  759. laSetIntArrayAll(a->This, ip->DefVal);
  760. }
  761. return LA_FINISHED;
  762. }
  763. int OPINV_FloatArraySetDefault(laOperator *a, laEvent *e){
  764. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_FLOAT)){
  765. laFloatProp *ip = a->This->LastPs->p;
  766. if (ip->DefArr) laSetFloatArrayAllArray(a->This, ip->DefArr);
  767. else
  768. laSetFloatArrayAll(a->This, ip->DefVal);
  769. }
  770. return LA_FINISHED;
  771. }
  772. int OPINV_IntArraySetMax(laOperator *a, laEvent *e){
  773. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_INT)){
  774. laIntProp *ip = a->This->LastPs->p;
  775. laSetIntArrayAll(a->This, ip->Max);
  776. }
  777. return LA_FINISHED;
  778. }
  779. int OPINV_FloatArraySetMax(laOperator *a, laEvent *e){
  780. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_FLOAT)){
  781. laFloatProp *ip = a->This->LastPs->p;
  782. laSetFloatArrayAll(a->This, ip->Max);
  783. }
  784. return LA_FINISHED;
  785. }
  786. int OPINV_IntArraySetMin(laOperator *a, laEvent *e){
  787. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_INT)){
  788. laIntProp *ip = a->This->LastPs->p;
  789. laSetIntArrayAll(a->This, ip->Min);
  790. }
  791. return LA_FINISHED;
  792. }
  793. int OPINV_FloatArraySetMin(laOperator *a, laEvent *e){
  794. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_FLOAT)){
  795. laFloatProp *ip = a->This->LastPs->p;
  796. laSetFloatArrayAll(a->This, ip->Min);
  797. }
  798. return LA_FINISHED;
  799. }
  800. int OPINV_StringSetDefault(laOperator *a, laEvent *e){
  801. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_STRING)){
  802. laStringProp *sp = a->This->LastPs->p;
  803. if (sp->DefStr) laSetString(a->This, sp->DefStr);
  804. else
  805. laSetString(a->This, "");
  806. }
  807. return LA_FINISHED;
  808. }
  809. int OPINV_StringGetFolderPath(laOperator *a, laEvent *e){
  810. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_STRING)){
  811. laInvoke(a, "LA_file_dialog", e, 0, "select=folder;", 0);
  812. return LA_RUNNING;
  813. }
  814. return LA_FINISHED;
  815. }
  816. int OPINV_StringGetFilePath(laOperator *a, laEvent *e){
  817. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_STRING)){
  818. laInvoke(a, "LA_file_dialog", e, 0, 0, 0);
  819. return LA_RUNNING;
  820. }
  821. return LA_FINISHED;
  822. }
  823. int OPMOD_StringGetFolderOrFilePath(laOperator *a, laEvent *e){
  824. if (a->ConfirmData){
  825. if (a->ConfirmData->StrData){
  826. laStringProp *sp = a->This->LastPs->p;
  827. laSetString(a->This, a->ConfirmData->StrData);
  828. return LA_FINISHED_PASS;
  829. }
  830. return LA_FINISHED_PASS;
  831. }
  832. return LA_RUNNING;
  833. }
  834. int OPINV_StringCopy(laOperator *a, laEvent *e){
  835. laPropPack* pp=a->This; if(!a->This) return LA_FINISHED;
  836. char _buf[256]={0}; char* buf=_buf;
  837. laGetString(pp,_buf,&buf);
  838. laCopyToClipboard(buf);
  839. return LA_FINISHED;
  840. }
  841. int OPINV_StringPaste(laOperator *a, laEvent *e){
  842. if (a->This && (a->This->LastPs->p->PropertyType & LA_PROP_STRING)){
  843. laStringProp *sp = a->This->LastPs->p;
  844. if (sp->DefStr) laSetString(a->This, sp->DefStr);
  845. else laSetString(a->This, "");
  846. }
  847. return LA_FINISHED;
  848. }
  849. int OPCHK_SubPutDataBlock(laPropPack *This, laStringSplitor *Instructions){
  850. //laListItem* Inst;
  851. //void* Actuall=0;
  852. //laProp* p;
  853. //if (!MAIN.RestoreInstance || !This || !Instructions) return 0;
  854. //p = la_PropLookup(&This->LastPs->p->SubProp->Props, strGetArgumentString(Instructions, "identifier"));
  855. //if (!p) return 0;
  856. //for (Inst = &p->SubProp->TrashBin.pFirst; Inst; Inst = Inst->pNext) {
  857. // if (Inst == MAIN.RestoreInstance) {
  858. // Actuall = Inst; break;
  859. // }
  860. //}
  861. //if(!Actuall)
  862. // for (Inst = &p->SubProp->FailedNodes.pFirst; Inst; Inst = Inst->pNext) {
  863. // if (Inst == MAIN.RestoreInstance) {
  864. // Actuall = Inst; break;
  865. // }
  866. // }
  867. //if (!Actuall) return 0;
  868. return 0;
  869. }
  870. int OPINV_SubPutDataBlock(laOperator *a, laEvent *e){
  871. //laProp* p = la_PropLookup(&a->This->LastPs->p->SubProp->Props, strGetArgumentString(a->ExtraInstructionsP, "identifier"));
  872. //lstRemoveItem(&p->SubProp->TrashBin, MAIN.RestoreInstance);
  873. //lstRemoveItem(&p->SubProp->FailedNodes, MAIN.RestoreInstance);
  874. ////laNotifySubPropUsers(p->SubProp, MAIN.RestoreInstance);
  875. //laAppendInstance(p, a->This->EndInstance, MAIN.RestoreInstance);
  876. //laNotifySubPropUsers(p, a->This->EndInstance);
  877. //laNotifySubPropUsers(_LA_PROP_TRASH_ITEM, p->SubProp);
  878. //laNotifySubPropUsers(_LA_PROP_FAILED_ITEM, p->SubProp);
  879. return LA_FINISHED;
  880. }
  881. int OPCHK_SubRestoreDataBlock(laPropPack *This, laStringSplitor *Instructions){
  882. if (This) return 1;
  883. return 0;
  884. }
  885. int OPINV_SubRestoreDataBlock(laOperator *a, laEvent *e){
  886. //if (a->This->EndInstance) {
  887. // MAIN.RestoreInstance = a->This->EndInstance;
  888. //}
  889. //laEnableOperatorPanel(a, 0, e->x, e->y, 600, 600, 2000, 1000, 100, 100, 0, 0, 0, 0, e);
  890. return LA_FINISHED; //will directly finish after actuator panel close or any feedback event and don't pass any feedback.
  891. }
  892. int OPEXT_SubRestoreDataBlock(laOperator *a, int unused){
  893. return 0;
  894. }
  895. int OPCHK_CombineChildBlocks(laPropPack *This, laStringSplitor *Instructions){
  896. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  897. laBlock *b = l->OnBlockSeperator;
  898. if (!(b)) return 0;
  899. }
  900. int OPINV_CombineChildBlocks(laOperator *a, laEvent *e){
  901. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  902. laBlock *b = l->OnBlockSeperator;
  903. if (!b) b = laDetectBlockRecursive(l->FirstBlock, e->x, e->y);
  904. if (b){
  905. laCombineChildBlocks(b);
  906. return LA_FINISHED;
  907. }
  908. return LA_CANCELED;
  909. }
  910. STRUCTURE(laNewPanelData){
  911. laUiTemplate* SelectedTemplate;
  912. laBlock* b;
  913. };
  914. void laui_TitleOnly(laUiList *uil, laPropPack *This, laPropPack *OP_UNUSED, laColumn *Extra, int context){
  915. laColumn *col = Extra, *c, *cl, *cr, *crl, *crr, *cll, *clr, *clrl, *clrr, *clrrl, *clrrr;
  916. laUiItem *ui;
  917. c = laFirstColumn(uil);
  918. laShowItemFull(uil, c, This, "title", LA_WIDGET_STRING_PLAIN, 0, 0, 0);
  919. }
  920. laUiTemplate* laget_FirstPanelTemplate(void* unused1, void* unused2){
  921. return MAIN.PanelTemplates.pFirst;
  922. }
  923. void laset_NewPanelSetTemplate(laNewPanelData *np, laUiTemplate *uit, int State){
  924. np->SelectedTemplate = uit;
  925. }
  926. laUiTemplate* laget_NewPanelGetActiveTemplate(laNewPanelData* np, laUiTemplate* uit){
  927. return np->SelectedTemplate;
  928. }
  929. void laui_PanelTemplateSelect(laUiList *uil, laPropPack *This, laPropPack *OperatorProps, laColumn *UNUSED, int context){
  930. laColumn *c = laFirstColumn(uil);
  931. laUiItem* ui=laShowItem(uil, c, OperatorProps, "template");ui->SymbolID=2; ui->Flags|=LA_UI_FLAGS_NO_DECAL;
  932. }
  933. int OPINV_Fullscreen(laOperator *a, laEvent *e){
  934. laWindow* w=MAIN.CurrentWindow;
  935. int full=1;
  936. if(strArgumentMatch(a->ExtraInstructionsP,"restore","true")){ full=0; }
  937. if(strArgumentMatch(a->ExtraInstructionsP,"toggle","true")){ full=w->IsFullScreen?0:1; }
  938. #ifdef __linux__
  939. XClientMessageEvent msg = {
  940. .type = ClientMessage, .display = MAIN.dpy, .window = w->win,
  941. .message_type = XInternAtom(MAIN.dpy, "_NET_WM_STATE", True), .format = 32,
  942. .data = {.l = {full, XInternAtom(MAIN.dpy, "_NET_WM_STATE_FULLSCREEN", True), None, 0, 1 }}
  943. };
  944. XSendEvent(MAIN.dpy, XRootWindow(MAIN.dpy, XDefaultScreen(MAIN.dpy)), False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent*) &msg);
  945. #endif
  946. #ifdef _WIN32
  947. DWORD dwStyle = GetWindowLong(w->win, GWL_STYLE);
  948. static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
  949. if (full){
  950. MONITORINFO mi = { sizeof(mi) };
  951. if (GetWindowPlacement(w->win, &g_wpPrev) &&
  952. GetMonitorInfo(MonitorFromWindow(w->win,
  953. MONITOR_DEFAULTTOPRIMARY), &mi)) {
  954. SetWindowLong(w->win, GWL_STYLE,
  955. dwStyle & ~WS_OVERLAPPEDWINDOW);
  956. SetWindowPos(w->win, HWND_TOP,
  957. mi.rcMonitor.left, mi.rcMonitor.top,
  958. mi.rcMonitor.right - mi.rcMonitor.left,
  959. mi.rcMonitor.bottom - mi.rcMonitor.top,
  960. SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
  961. }
  962. }else{
  963. SetWindowLong(w->win, GWL_STYLE,dwStyle|WS_OVERLAPPEDWINDOW);
  964. SetWindowPlacement(w->win, &g_wpPrev);
  965. SetWindowPos(w->win,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_FRAMECHANGED);
  966. }
  967. #endif
  968. w->IsFullScreen=full;
  969. laRedrawCurrentWindow();
  970. return LA_FINISHED;
  971. }
  972. int OPINV_NewLayout(laOperator *a, laEvent *e){
  973. laWindow* w=MAIN.CurrentWindow;
  974. laDesignLayout(w, "New Layout");
  975. laRedrawCurrentWindow();
  976. return LA_FINISHED;
  977. }
  978. int OPCHK_RemoveLayout(laPropPack *This, laStringSplitor *Instructions){
  979. laWindow* w=MAIN.CurrentWindow; if(w->Layouts.pFirst==w->Layouts.pLast) return 0;
  980. return 1;
  981. }
  982. int OPINV_RemoveLayout(laOperator *a, laEvent *e){
  983. laWindow* w=MAIN.CurrentWindow; if(w->Layouts.pFirst==w->Layouts.pLast) return LA_FINISHED;
  984. laDestroyLayout(w,w->CurrentLayout); laRedrawCurrentWindow();
  985. return LA_FINISHED;
  986. }
  987. int OPINV_NewPanel(laOperator *a, laEvent *e){
  988. laNewPanelData* np= CreateNew(laNewPanelData);
  989. a->CustomData = np;
  990. laEnableOperatorPanel(a, 0, e->x-50,e->y-50,500,500,10000,0,0,0,0,0,0,0,e);
  991. return LA_RUNNING;
  992. }
  993. int OPMOD_NewPanel(laOperator *a, laEvent *e){
  994. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  995. laNewPanelData* np=a->CustomData;
  996. if(!a->ConfirmData) return LA_RUNNING;
  997. if(a->ConfirmData->Mode == LA_CONFIRM_CANCEL||a->ConfirmData->Mode == LA_CONFIRM_OK) return LA_CANCELED;
  998. if(a->ConfirmData->Mode == LA_CONFIRM_DATA){
  999. if (!np || !np->SelectedTemplate) return LA_CANCELED;
  1000. laPanel *p = la_FindFreePanelByTemplate(MAIN.CurrentWindow, np->SelectedTemplate);
  1001. if (!p){
  1002. p = laCreateTopPanel(MAIN.CurrentWindow, np->SelectedTemplate->Identifier->Ptr, e->x, e->y,0,0,0,0,0,0,0,0,0,0);
  1003. }
  1004. laShowPanelWithExpandEffect(p); laPopPanel(p); free(np);
  1005. return LA_FINISHED;
  1006. }
  1007. return LA_RUNNING;
  1008. }
  1009. int OPINV_BlockFoldTitle(laOperator *a, laEvent *e){
  1010. laBlock* b=a->This?a->This->EndInstance:0;
  1011. if(!b) return LA_CANCELED;
  1012. if(strSame(strGetArgumentString(a->ExtraInstructionsP, "show"), "true")) laUnfoldBlockTitle(b);
  1013. else laFoldBlockTitle(b);
  1014. return LA_FINISHED;
  1015. }
  1016. int OPINV_BlockMaximize(laOperator *a, laEvent *e){
  1017. laBlock* b=a->This?a->This->EndInstance:0;
  1018. if(!b || strSame(strGetArgumentString(a->ExtraInstructionsP, "restore"), "true")) laRestoreToLayout();
  1019. else laMaximizeBlock(b);
  1020. return LA_FINISHED;
  1021. }
  1022. int OPINV_CanvasUiMaximize(laOperator *a, laEvent *e){
  1023. laUiItem* ui=a->This?a->This->EndInstance:0;
  1024. laPanel* p=MAIN.CurrentPanel;
  1025. if(!ui || !p || (!ui->Type->Tag&LA_UI_TAG_IS_OFFSCREEN) || MAIN.CurrentWindow->MaximizedUi ||
  1026. strSame(strGetArgumentString(a->ExtraInstructionsP, "restore"), "true")) laRestoreCanvasUI();
  1027. else laMaximizeCanvasUI(ui,p);
  1028. return LA_FINISHED;
  1029. }
  1030. int OPINV_HideMenuBar(laOperator *a, laEvent *e){
  1031. if(!MAIN.CurrentWindow->MaximizedUi || strSame(strGetArgumentString(a->ExtraInstructionsP, "restore"), "true")) laShowMenuBar();
  1032. else laHideMenuBar();
  1033. return LA_FINISHED;
  1034. }
  1035. int OPINV_BlockTearOffPanel(laOperator *a, laEvent *e){
  1036. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  1037. laBlock* b = l->OperatingBlock;
  1038. if (!b) b = laDetectBlockRecursive(l->FirstBlock, e->x, e->y);
  1039. if(!b) return LA_CANCELED;
  1040. laTearOffPanel(b,0);
  1041. return LA_FINISHED;
  1042. }
  1043. int OPCHK_BlockHasMorePanels(laPropPack *This, laStringSplitor *Instructions){
  1044. laPanel*p = This?This->LastPs->UseInstance:0;
  1045. if(p && p->Mode == LA_PANEL_FLOATING_TOP) return 1;
  1046. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  1047. laBlock *b = l->OperatingBlock;
  1048. if (b && b->Panels.pFirst == b->Panels.pLast) return 0;
  1049. return 1;
  1050. }
  1051. int OPINV_BlockClosePanel(laOperator *a, laEvent *e){
  1052. laPanel*p = a->This?a->This->LastPs->UseInstance:0;
  1053. if(p && p->Mode == LA_PANEL_FLOATING_TOP){
  1054. laDestroySinglePanel(p,0);
  1055. return LA_FINISHED;
  1056. }
  1057. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  1058. laBlock *b = l->OperatingBlock;
  1059. int x = e->x, y = e->y;
  1060. if (!b) b = laDetectBlockRecursive(l->FirstBlock, e->x, e->y);
  1061. if (b){
  1062. if (b->CurrentPanel){
  1063. //laLocalToWindow(a, MAIN.CurrentPanel, &x, &y);
  1064. laEnableYesNoPanel(a, 0, "Caution!", "Are you sure to destroy this panel?", e->x - 250, e->y, 250, e);
  1065. return LA_RUNNING;
  1066. }
  1067. }
  1068. return LA_CANCELED;
  1069. }
  1070. int OPMOD_BlockClosePanel(laOperator *a, laEvent *e){
  1071. laLayout *l = MAIN.CurrentWindow->CurrentLayout;
  1072. laBlock *b = l->OperatingBlock;
  1073. if (e->Type == LA_ESCAPE_DOWN) return LA_FINISHED;
  1074. if (a->ConfirmData){
  1075. if (!b) b = laDetectBlockRecursive(l->FirstBlock, e->x, e->y);
  1076. if (!b) return LA_CANCELED;
  1077. if (a->ConfirmData->Mode == LA_CONFIRM_OK){
  1078. laDestroySinglePanel(b->CurrentPanel,1);
  1079. la_RecalcBlockRecursive(b, b->X, b->Y, b->W, b->H);
  1080. }
  1081. return LA_FINISHED;
  1082. }else
  1083. return LA_RUNNING;
  1084. }
  1085. int laui_BlockEdgeMenu(laOperator *WindowAct, laLayout *l, laBlock *b, laEvent *e){
  1086. laPanel *p;
  1087. laColumn *c, *cl, *cr;
  1088. laUiList *uil;
  1089. p = laDefineAndEnableMenuPanel(0, WindowAct, 0, e->x, e->y, 500, 200, e);
  1090. uil = laPrepareUi(p);
  1091. c = laFirstColumn(uil);
  1092. laSplitColumn(uil, c, 0.5);
  1093. cl = laLeftColumn(c, 0);
  1094. cr = laRightColumn(c, 0);
  1095. laShowItem(uil, c, 0, "LA_combine_child_blocks");
  1096. laEnclosePanelContent(p,uil);
  1097. }
  1098. laBlock* la_MakeDropBlock(laBlock* DropToBlock, int DropLocation){
  1099. switch (DropLocation){
  1100. case 0: return DropToBlock;
  1101. case LA_BLOCK_DROP_LOCATION_U:
  1102. laSplitBlockVertical(DropToBlock, 0.5); laSwapSubBlocks(DropToBlock);
  1103. return DropToBlock->B1;
  1104. case LA_BLOCK_DROP_LOCATION_B:
  1105. laSplitBlockVertical(DropToBlock, 0.5);
  1106. return DropToBlock->B2;
  1107. case LA_BLOCK_DROP_LOCATION_L:
  1108. laSplitBlockHorizon(DropToBlock, 0.5); laSwapSubBlocks(DropToBlock);
  1109. return DropToBlock->B1;
  1110. case LA_BLOCK_DROP_LOCATION_R:
  1111. laSplitBlockHorizon(DropToBlock, 0.5);
  1112. return DropToBlock->B2;
  1113. }
  1114. }
  1115. void la_StartDocking(laWindow* from, laPanel* p){
  1116. for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){ w->DockingFrom = from; w->IsDocking=1; } MAIN.DockingPanel=p;
  1117. }
  1118. void la_StopDocking(){
  1119. for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){ w->DockingFrom = 0; w->IsDocking=0; } MAIN.DockingPanel=0;
  1120. }
  1121. void la_ClearDockingTarget(){
  1122. for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){ w->CurrentLayout->DropToBlock=0; }
  1123. }
  1124. int OPINV_DockPanel(laOperator* a, laEvent* e){
  1125. laPanel*p = a->This?a->This->LastPs->UseInstance:0;
  1126. if(!p) return LA_CANCELED;
  1127. la_StartDocking(MAIN.CurrentWindow, p);
  1128. laRestoreToLayout();
  1129. laRestoreCanvasUI();
  1130. return LA_FINISHED;
  1131. }
  1132. int OPINV_NewWindow(laOperator* a, laEvent* e){
  1133. laWindow* w = a->This?a->This->EndInstance:MAIN.CurrentWindow;
  1134. laWindow* nw =laDesignWindow(w->X,w->Y,w->CW,w->CH);
  1135. laLayout* l=(w->Layouts.pFirst!=w->Layouts.pLast)?w->CurrentLayout:0;
  1136. if (l && !strSame(strGetArgumentString(a->ExtraInstructionsP, "clean"), "true")){
  1137. laLayout* nextl=l->Item.pPrev?l->Item.pPrev:l->Item.pNext;
  1138. w->CurrentLayout=nextl; lstRemoveItem(&w->Layouts, l); lstAppendItem(&nw->Layouts, l); nw->CurrentLayout=l;
  1139. laRenameWindow(nw, l->ID->Ptr);
  1140. laRenameWindow(w, w->CurrentLayout->ID->Ptr);
  1141. }else{
  1142. laDesignLayout(nw, "Empty Layout");
  1143. }
  1144. laStartWindow(nw);
  1145. laRedrawAllWindows();
  1146. return LA_FINISHED;
  1147. }
  1148. void *la_OnBlockSeperator(laBlock *b, laEvent *e){
  1149. int at;
  1150. laBlock *bb;
  1151. if (!b->B1) return 0;
  1152. if (b->Vertical){
  1153. at = b->H * b->SplitRatio + b->Y;
  1154. if (e->x>=b->X && e->x<=b->X+b->W && e->y >= at - LA_SEAM_W && e->y <= at + LA_SEAM_W){
  1155. return b;
  1156. }
  1157. }else{
  1158. at = b->X + b->W * b->SplitRatio;
  1159. if (e->y>=b->Y && e->y<=b->Y+b->H && e->x >= at - LA_SEAM_W && e->x <= at + LA_SEAM_W){
  1160. return b;
  1161. }
  1162. }
  1163. if (bb = la_OnBlockSeperator(b->B1, e)) return bb;
  1164. else
  1165. return la_OnBlockSeperator(b->B2, e);
  1166. }
  1167. int la_DetectBlockDropLocation(laBlock *b, int X, int Y){
  1168. laPanel *p = b->Panels.pFirst;
  1169. if (!p) return 0;
  1170. real L = tnsGetRatiod(p->X, p->X + p->W, X);
  1171. real U = tnsGetRatiod(p->Y, p->Y + p->H, Y);
  1172. if (L > U){
  1173. if (U < 0.25){
  1174. if (L < 0.75) return LA_BLOCK_DROP_LOCATION_U;
  1175. else
  1176. return LA_BLOCK_DROP_LOCATION_R;
  1177. }else{
  1178. if (L < 0.75) return 0;
  1179. else
  1180. return LA_BLOCK_DROP_LOCATION_R;
  1181. }
  1182. }else{
  1183. if (U > 0.75){
  1184. if (L < 0.25) return LA_BLOCK_DROP_LOCATION_L;
  1185. else
  1186. return LA_BLOCK_DROP_LOCATION_B;
  1187. }else{
  1188. if (L < 0.25) return LA_BLOCK_DROP_LOCATION_L;
  1189. else
  1190. return 0;
  1191. }
  1192. }
  1193. }
  1194. int laui_BlockMenu(laOperator *WindowAct, laWindow* w, laLayout *l, laBlock *b, laEvent *e){
  1195. laPanel *p;
  1196. laColumn *c;
  1197. laUiList *uil;
  1198. p = laDefineAndEnableMenuPanel(0, WindowAct, 0, b->X, b->Y + LA_RH + 1, 500, 500, e);
  1199. uil = laPrepareUi(p);
  1200. c = laFirstColumn(uil);
  1201. laPanel* forp=b->CurrentPanel;
  1202. laUiItem* b1=laBeginRow(uil,c,0,0);
  1203. laShowItem(uil,c,&b->PP,"fold");
  1204. laUiItem* b2=laOnConditionThat(uil,c,laPropExpression(&w->PP, "maximized_block"));{
  1205. laShowItemFull(uil,c,&b->PP,"maximize",0,"restore=true;text=Restore;",0,0);
  1206. }laElse(uil,b2);{
  1207. laShowItem(uil,c,&b->PP,"maximize");
  1208. }laEndCondition(uil,b2);
  1209. laEndRow(uil,b1);
  1210. laShowSeparator(uil,c);
  1211. if(forp->PanelTemplate->Header){
  1212. laShowLabel(uil, c, "Panel properties:", 0, 0);
  1213. forp->PanelTemplate->Header(uil, &forp->PP, &forp->PropLinkPP, c, 0);
  1214. }else{
  1215. laShowLabel(uil, c, "Panel doesn't have configurable property.", 0, 0);
  1216. }
  1217. //laShowItem(uil, c, 0, "LA_new_panel");
  1218. //laShowItem(uil, c, 0, "LA_block_close_panel");
  1219. //laShowItem(uil, c, 0, "LA_block_tear_off_panel");
  1220. laEnclosePanelContent(p,uil);
  1221. }
  1222. int la_ProcessBlockEvent(laOperator *a, laBlock *b, laEvent *e){
  1223. int Executed = 0, Ret=1;
  1224. int L = LA_RH+LA_SEAM_W, R, tw = 0;
  1225. real ratio = 1.0f;
  1226. laPanel *p = b->Panels.pFirst;
  1227. laGeneralUiExtraData *uid = a->CustomData;
  1228. laLayout *l;
  1229. if(!b->Panels.pFirst){return 0;}
  1230. if (laIsInBlockHeader(b, e->x, e->y) || MAIN.CurrentWindow->CurrentLayout->ClickedPanel){
  1231. MAIN.CurrentWindow->CurrentLayout->OperatingBlock = b;
  1232. if (b->CurrentPanel){
  1233. if (e->Type == LA_MOUSE_WHEEL_DOWN && b->CurrentPanel->Item.pNext){
  1234. b->CurrentPanel = b->CurrentPanel->Item.pNext;
  1235. Executed = 1;
  1236. }elif (e->Type == LA_MOUSE_WHEEL_UP && b->CurrentPanel->Item.pPrev){
  1237. b->CurrentPanel = b->CurrentPanel->Item.pPrev;
  1238. Executed = 1;
  1239. }
  1240. }
  1241. if(!b->Folded){
  1242. for (p = b->Panels.pFirst; p; p = p->Item.pNext){
  1243. tw += (p->TitleWidth + LA_SEAM_W*2);
  1244. }
  1245. if (tw > b->W - LA_SEAM_W*2 - LA_RH) ratio = (real)(b->W - LA_SEAM_W*2 - LA_RH) / tw;
  1246. if ((e->Type == LA_L_MOUSE_DOWN)){
  1247. uid->LastX = e->x;
  1248. uid->LastY = e->y;
  1249. int LT=0,RT=0;
  1250. for (p = b->Panels.pFirst; p; p = p->Item.pNext){
  1251. RT = LT + p->TitleWidth+LA_SEAM_W*2;
  1252. if (e->x >= b->X + L+LT * ratio && e->x < b->X + L+RT * ratio){
  1253. MAIN.CurrentWindow->CurrentLayout->ClickedPanel = p;
  1254. b->CurrentPanel = p;
  1255. Executed = 1;
  1256. }
  1257. LT = RT;
  1258. }
  1259. }elif (e->Type == LA_MOUSEMOVE){
  1260. if (abs(e->x - uid->LastX) > LA_RH || abs(e->y - uid->LastY) > LA_RH){
  1261. if (MAIN.CurrentWindow->CurrentLayout->ClickedPanel){
  1262. l = MAIN.CurrentWindow->CurrentLayout;
  1263. l->DropToBlock = b;
  1264. l->DropLocation = la_DetectBlockDropLocation(b, e->x, e->y);
  1265. laRefreshWindow();
  1266. }
  1267. }
  1268. }elif (e->Type == LA_L_MOUSE_UP){
  1269. l = MAIN.CurrentWindow->CurrentLayout;
  1270. if (l->DropToBlock){
  1271. l->DropToBlock = la_MakeDropBlock(l->DropToBlock,l->DropLocation);
  1272. p = l->ClickedPanel;
  1273. if(p->Block == l->DropToBlock){
  1274. if(laTearOffPanel(p->Block, p)) Executed=1;
  1275. }else{
  1276. p->Block->CurrentPanel = p->Item.pPrev ? p->Item.pPrev : (p->Item.pNext ? p->Item.pNext : 0);
  1277. lstRemoveItem(&p->Block->Panels, p); laBlock* orig_block=p->Block->parent;
  1278. int clear=0; if(!lstHaveItemInList(&p->Block->Panels)){clear=1;}
  1279. lstPushItem(&l->DropToBlock->Panels, p);
  1280. p->Block = l->DropToBlock;
  1281. if(clear){
  1282. laCombineChildBlocks(orig_block);
  1283. if(!lstFindItem(orig_block->CurrentPanel,nutSameAddress,&orig_block->Panels)){
  1284. orig_block->CurrentPanel = orig_block->Panels.pFirst;
  1285. }
  1286. }
  1287. p->Block->CurrentPanel = p;
  1288. Executed = 1;
  1289. la_RecalcBlockRecursive(p->Block, p->Block->X, p->Block->Y, p->Block->W, p->Block->H);
  1290. if(orig_block!=p->Block){
  1291. la_RecalcBlockRecursive(orig_block, orig_block->X, orig_block->Y, orig_block->W, orig_block->H);
  1292. }
  1293. }
  1294. }
  1295. MAIN.CurrentWindow->CurrentLayout->DropToBlock = 0;
  1296. MAIN.CurrentWindow->CurrentLayout->ClickedPanel = 0;
  1297. return 0;
  1298. }
  1299. }else{
  1300. if(!b->OnButton){ b->OnButton=1; laRefreshWindow(); } Ret=0;
  1301. 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;} }
  1302. 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;} }
  1303. }
  1304. if (Executed){
  1305. laRecalcPanel(b->CurrentPanel);
  1306. la_RecalcBlockRecursive(b, b->X, b->Y, b->W, b->H);
  1307. }
  1308. if (!Executed && e->Type == LA_L_MOUSE_DOWN && laIsInBlockBotton1(b, e->x, e->y)){
  1309. laui_BlockMenu(a, MAIN.CurrentWindow, MAIN.CurrentWindow->CurrentLayout, b, e);
  1310. }
  1311. return Ret;
  1312. }else{
  1313. if(b->OnButton){b->OnButton=0;laRefreshWindow();}
  1314. }
  1315. return 0;
  1316. }
  1317. int la_ProcessBlockEdgeEvent(laOperator *WindowAct, laLayout *l, laBlock *b, laEvent *e){
  1318. laBlock *ob = l->MovingBlock;
  1319. laWindow *w = WindowAct->Instance;
  1320. if (e->Type == LA_MOUSEMOVE && ob && l->MovingBlock && l->IsMoving){
  1321. if (ob->Vertical) ob->SplitRatio = (real)(e->y - ob->Y) / (real)(ob->H);
  1322. else ob->SplitRatio = (real)(e->x - ob->X) / (real)(ob->W);
  1323. la_RecalcBlockRecursive(ob, ob->X, ob->Y, ob->W, ob->H);
  1324. if (ob->B1->CurrentPanel) laRecalcPanel(ob->B1->CurrentPanel);
  1325. if (ob->B2->CurrentPanel) laRecalcPanel(ob->B2->CurrentPanel);
  1326. return 1;
  1327. }
  1328. if (ob = la_OnBlockSeperator(b, e)){
  1329. ob->B1->OnButton=ob->B2->OnButton=0;
  1330. if(l->MovingBlock!=ob){ laRefreshWindow(); }
  1331. l->MovingBlock = ob; laSetWindowCursor(ob->Vertical?LA_UP_AND_DOWN:LA_LEFT_AND_RIGHT);
  1332. if (e->Type == LA_L_MOUSE_DOWN){
  1333. l->IsMoving = 1;
  1334. }elif (e->Type == LA_L_MOUSE_UP){
  1335. l->IsMoving = 0;
  1336. }elif (e->Type == LA_R_MOUSE_DOWN){
  1337. l->OnBlockSeperator = ob;
  1338. laui_BlockEdgeMenu(WindowAct, l, ob, e);
  1339. }
  1340. return 1;
  1341. }
  1342. if(l->MovingBlock){ l->MovingBlock = 0; laRefreshWindow(); laSetWindowCursor(LA_ARROW); }
  1343. return 0;
  1344. }
  1345. real la_ScrollerVerticalPan(int MousePanY, laPanel *p, laUiList *suil, laUiItem *pui){
  1346. int DisplayH, TotalH;
  1347. if (!pui){ DisplayH = p->H-suil->U; }
  1348. else{ DisplayH = pui->Page?(pui->B-pui->Page->U):(pui->B - pui->U); }
  1349. TotalH = suil->B - suil->U;
  1350. return ((real)TotalH * (real)MousePanY / (real)DisplayH);
  1351. }
  1352. real la_ScrollerHorizontalPan(int MousePanX, laPanel *p, laUiList *suil, laUiItem *pui){
  1353. int DisplayW, TotalW;
  1354. DisplayW = pui->Page?(pui->R-pui->Page->L):(pui->R - pui->L);
  1355. TotalW = suil->R - suil->L;
  1356. return ((real)TotalW * (real)MousePanX / (real)DisplayW);
  1357. }
  1358. void laui_LayoutCycle(laUiList *uil, laPropPack *This, laPropPack *OperatorProps, laColumn *UNUSED, int context){
  1359. laColumn *c;
  1360. c = laFirstColumn(uil);
  1361. laShowItemFull(uil, c, 0, "la.windows.layouts", 0, 0, laui_IdentifierOnly, 0);
  1362. laUiItem* b=laBeginRow(uil,c,0,0);
  1363. laShowItem(uil, c, 0, "LA_new_layout")->Expand=1;
  1364. laShowItem(uil, c, 0, "LA_remove_layout")->Flags|=LA_UI_FLAGS_ICON|LA_UI_FLAGS_NO_CONFIRM;
  1365. laEndRow(uil,b);
  1366. }
  1367. int OPINV_SwitchLayout(laOperator *a, laEvent *e){
  1368. laWindow *w = MAIN.CurrentWindow; if (!w) return LA_FINISHED;
  1369. if (strSame(strGetArgumentString(a->ExtraInstructionsP, "show_list"), "true")){
  1370. laPanel* p =laEnableOperatorPanel(a, 0, e->x-LA_RH, e->y-LA_RH, 500, 500, 0,0,0,0,0,0,0,0,e);
  1371. return LA_RUNNING;
  1372. }
  1373. if (strSame(strGetArgumentString(a->ExtraInstructionsP, "reverse"), "true")) w->CurrentLayout = w->CurrentLayout->Item.pPrev ? w->CurrentLayout->Item.pPrev : w->Layouts.pLast;
  1374. else w->CurrentLayout = w->CurrentLayout->Item.pNext ? w->CurrentLayout->Item.pNext : w->Layouts.pFirst;
  1375. laRenameWindow(w, w->CurrentLayout->ID->Ptr);
  1376. la_StopAllOperators();
  1377. laRetriggerOperators();
  1378. laRedrawCurrentWindow();
  1379. laNotifyUsers("la.windows.layouts");
  1380. return LA_FINISHED;
  1381. }
  1382. int OPINV_DeleteTheme(laOperator *a, laEvent *e){
  1383. laTheme* t = a->This?a->This->EndInstance:MAIN.CurrentTheme;
  1384. if(!t || MAIN.Themes.pFirst == MAIN.Themes.pLast) return LA_CANCELED;
  1385. laBoxedTheme* NextBt;
  1386. for(laBoxedTheme* bt=t->BoxedThemes.pFirst; bt; bt=NextBt){
  1387. NextBt = bt->Item.pNext; lstRemoveItem(&t->BoxedThemes, bt); memFree(bt);
  1388. }
  1389. lstRemoveItem(&MAIN.Themes, t); memFree(t);
  1390. if(t==MAIN.CurrentTheme){MAIN.CurrentTheme = MAIN.Themes.pFirst;la_RefreshThemeColor(MAIN.CurrentTheme);}
  1391. laNotifyUsers("themes"); laRedrawCurrentWindow();
  1392. return LA_FINISHED;
  1393. }
  1394. int la_GenericTopPanelProcessing(laOperator* a, laEvent* e){
  1395. laPanel* p;
  1396. if (p = laDetectPanel(e->x, e->y)){
  1397. int x = e->x;
  1398. int y = e->y;
  1399. laWindowToLocal(0, p, &x, &y);
  1400. if (laIsInPanel(p, x, y) /*&& p->Show*/){
  1401. laSetOperatorLocalizer(p);
  1402. laInvokeUi(a, "LA_panel_operator", e, p, 0, 1);
  1403. return LA_RUNNING;
  1404. }
  1405. }
  1406. return 0;
  1407. }
  1408. int la_GeneratePasteEvent(laWindow* w){
  1409. #ifdef __linux__
  1410. XConvertSelection(MAIN.dpy, MAIN.bufid, MAIN.fmtid, MAIN.propid, w->win, CurrentTime);
  1411. #endif
  1412. }
  1413. int OPINV_SystemPaste(laOperator *a, laEvent *e){ la_GeneratePasteEvent(MAIN.CurrentWindow); return LA_FINISHED; }
  1414. int OPINV_Window(laOperator *a, laEvent *e){
  1415. laRetriggerOperators();
  1416. return LA_RUNNING;
  1417. }
  1418. int OPMOD_Window(laOperator *a, laEvent *e){
  1419. laPanel *p;
  1420. laBlock *b = 0;
  1421. laWindow *w = a->Instance;
  1422. laGeneralUiExtraData *uid = a->CustomData;
  1423. if (!uid) uid = memAcquireSimple(sizeof(laGeneralUiExtraData));
  1424. a->CustomData = uid;
  1425. if(laKeyMapExecuteEvent(a, &MAIN.KeyMap, e)) return LA_RUNNING_PASS;
  1426. if(w->IsDocking && MAIN.DockingPanel){
  1427. laRestoreToLayout();
  1428. laRestoreCanvasUI();
  1429. laLayout* l=MAIN.CurrentWindow->CurrentLayout;
  1430. laBlock *Recieve = laDetectBlockRecursive(l->FirstBlock, e->x, e->y);
  1431. if (Recieve){
  1432. la_ClearDockingTarget(); l->DropToBlock = Recieve;
  1433. l->DropLocation = la_DetectBlockDropLocation(Recieve, e->x, e->y);
  1434. laRefreshWindow();
  1435. }else{
  1436. MAIN.CurrentWindow->CurrentLayout->DropToBlock = 0;
  1437. }
  1438. if(e->Type==LA_L_MOUSE_UP && l->DropToBlock){
  1439. l->DropToBlock = la_MakeDropBlock(l->DropToBlock, l->DropLocation);
  1440. laDockPanel(w->DockingFrom, l->DropToBlock, MAIN.DockingPanel);
  1441. la_StopDocking();la_ClearDockingTarget(); return LA_RUNNING;
  1442. }
  1443. if(e->Type==LA_R_MOUSE_DOWN || (e->Type==LA_KEY_DOWN&&e->key==LA_KEY_ESCAPE)){
  1444. la_StopDocking();la_ClearDockingTarget(); return LA_RUNNING;
  1445. }
  1446. return LA_RUNNING;
  1447. }
  1448. if(w->MaximizedUi && w->MaximizedUiPanel){
  1449. if(((e->y<LA_RH && e->x<LA_RH)||e->y<LA_SEAM_W) && uid->Dragging){ laShowMenuBar(); uid->Dragging=0; }
  1450. if(!la_UiOperatorExists(w->MaximizedUi)){
  1451. laSetOperatorLocalizer(0);
  1452. laInvokeUi(a, w->MaximizedUi->Type->OperatorID, e, w->MaximizedUi, 0, 1);
  1453. return LA_RUNNING;
  1454. }
  1455. if(e->y>LA_2RH && e->x>LA_2RH){ if(!uid->Dragging)laRequestDelayEvent(0.5); uid->Dragging=1; }
  1456. if(e->Type==LA_TIME_DELAY){ laHideMenuBar(); }
  1457. }else{
  1458. if(MAIN.PendingSplash){
  1459. laSetOperatorLocalizer(MAIN.PendingSplash);
  1460. laInvokeUi(a, "LA_panel_operator", e, MAIN.PendingSplash, 0, 1);
  1461. laRetriggerOperators();
  1462. MAIN.PendingSplash=0; return LA_RUNNING;
  1463. }
  1464. laBlock* RootBlock=w->MaximizedBlock?w->MaximizedBlock:w->CurrentLayout->FirstBlock;
  1465. if (la_ProcessBlockEdgeEvent(a, w->CurrentLayout, RootBlock, e)) return LA_RUNNING;
  1466. b = w->MaximizedBlock?w->MaximizedBlock:laDetectBlockRecursive(w->CurrentLayout->FirstBlock, e->x, e->y);
  1467. laClearBlockButtonRecursive(RootBlock,b);
  1468. if (b && la_ProcessBlockEvent(a, b, e)) return LA_RUNNING;
  1469. for (p = w->Panels.pFirst; p; p = p->Item.pNext){
  1470. int x = e->x; int y = e->y;
  1471. laWindowToLocal(0, p, &x, &y);
  1472. if (laIsInPanel(p, x, y) && p->Show){
  1473. laSetOperatorLocalizer(p);
  1474. if (!p->LaterDestroy) laInvokeUi(a, "LA_panel_operator", e, p, 0, 1);
  1475. return LA_RUNNING;
  1476. }
  1477. }
  1478. }
  1479. if(la_GenericTopPanelProcessing(a,e)) return LA_RUNNING;
  1480. return LA_RUNNING;
  1481. }
  1482. int OPINV_Panel(laOperator *a, laEvent *e){
  1483. if (!((laPanel *)a->Instance)->Show) return LA_FINISHED;
  1484. a->CustomData = memAcquireSimple(sizeof(laGeneralUiExtraData));
  1485. laRetriggerOperators();
  1486. return LA_RUNNING;
  1487. }
  1488. int OPEXT_Panel(laOperator *a, int ExitCode){
  1489. memFree(a->CustomData);
  1490. return 0;
  1491. }
  1492. int la_ScrollPanel(laGeneralUiExtraData*ex, laPanel*p, laEvent* e){
  1493. int ret=0;
  1494. if(ex->TargetIndexVali==4 && e->Type==LA_MOUSEMOVE){
  1495. laUiList* uuil=ex->Ptr1; laUiItem* upui=ex->Ptr2;
  1496. if(upui){ laPanUiListFree(uuil, ex->LastX-e->x, ex->LastY-e->y);
  1497. //if(uuil->HeightCoeff){
  1498. if(uuil->B-upui->Page->PanY<upui->TB-(*p->BT)->BM-LA_SCROLL_W){
  1499. upui->Page->PanY = (uuil->B-upui->TB+(*p->BT)->BM+LA_SCROLL_W);
  1500. if(upui->Page->PanY<0){upui->Page->PanY=0;}
  1501. }
  1502. //}
  1503. }
  1504. ex->LastX=e->x; ex->LastY=e->y;
  1505. laRedrawCurrentPanel();
  1506. ret= 1;
  1507. }
  1508. if(ex->TargetIndexVali==5 && e->Type==LA_MOUSEMOVE){
  1509. laUiList* uuil=ex->Ptr1; laUiItem* upui=ex->Ptr2;
  1510. if(upui)laScaleUiList(uuil, -(ex->LastY-e->y)*0.005+1, upui->L, upui->R, upui->U, upui->B);
  1511. ex->LastX=e->x; ex->LastY=e->y;
  1512. laRecalcCurrentPanel();
  1513. ret= 1;
  1514. }
  1515. if(e->Type==LA_M_MOUSE_UP){ ex->TargetIndexVali=0; }
  1516. if (e->Type & LA_KEY_MOUSE_SCROLL || e->Type==LA_M_MOUSE_DOWN){
  1517. laUiItem *pui = 0; laListHandle levels={0}; int dir;
  1518. if (e->Type & LA_STATE_DOWN) dir=1;
  1519. elif (e->Type & LA_STATE_UP) dir=-1;
  1520. laUiList *duil = la_DetectUiListRecursiveDeep(p->MenuRefer?p->MenuRefer:&p->UI, e->x, e->y, 10000, &pui, 0, 0, 0, 0, &levels);
  1521. laUiListRecord* lip=levels.pLast; laUiList* uuil=lip->uil; laUiItem* upui=lip->Item.pPrev?((laUiListRecord*)lip->Item.pPrev)->pui:0; int ran=0;
  1522. if(e->SpecialKeyBit == LA_KEY_CTRL){
  1523. if(e->Type==LA_M_MOUSE_DOWN){
  1524. while (lip && upui && (!uuil->AllowScale)) { lip=lip->Item.pPrev; uuil=lip->uil; upui=lip->Item.pPrev?((laUiListRecord*)lip->Item.pPrev)->pui:0; }
  1525. if(uuil) { ex->TargetIndexVali=5; ex->Ptr1=uuil; ex->Ptr2=upui; ex->LastX=e->x; ex->LastY=e->y; ret= 1;}
  1526. }else{
  1527. }
  1528. }else{
  1529. if(e->Type==LA_M_MOUSE_DOWN){
  1530. while (lip && upui && (!uuil->AllowScale)) { lip=lip->Item.pPrev; uuil=lip->uil; upui=lip->Item.pPrev?((laUiListRecord*)lip->Item.pPrev)->pui:0; }
  1531. if(uuil) { ex->TargetIndexVali=4; ex->Ptr1=uuil; ex->Ptr2=upui; ex->LastX=e->x; ex->LastY=e->y; ret= 1;}
  1532. }else{
  1533. while (lip && upui){
  1534. if(uuil->AllowScale){ if((ran=laScaleUiList(uuil, 1.0f-dir*0.1, upui->L, upui->R, upui->U, upui->B))){ laRecalcCurrentPanel(); break;} }
  1535. else{ if((ran=laPanUiListAuto(uuil, 0, dir*MAIN.ScrollingSpeed*LA_RH,
  1536. uuil->L, upui->R-(uuil->ScrollerShownV?(LA_SCROLL_W+(*p->BT)->RM):0),
  1537. uuil->U, upui->B-(*upui->Type->Theme)->BM-(uuil->ScrollerShownH?(LA_SCROLL_W+(*p->BT)->BM):0)))) break; }
  1538. lip=lip->Item.pPrev; uuil=lip->uil; upui=lip->Item.pPrev?((laUiListRecord*)lip->Item.pPrev)->pui:0;
  1539. }
  1540. if(!ran) laPanUiListAuto(p->MenuRefer?p->MenuRefer:&p->UI, 0, dir*MAIN.ScrollingSpeed*LA_RH, 0, p->W, p->TitleBar.B, p->H-(*p->BT)->BM);
  1541. laRedrawCurrentPanel();
  1542. ret= 1;
  1543. }
  1544. }
  1545. while(duil=lstPopPointer(&levels));
  1546. }
  1547. return ret;
  1548. }
  1549. int OPMOD_Panel(laOperator *a, laEvent *e){
  1550. int x = e->x;
  1551. int y = e->y;
  1552. laPanel *p = a->Instance, *dp;
  1553. laUiItem *ui = 0;
  1554. laGeneralUiExtraData *uid = a->CustomData;
  1555. laListHandle Locals = {0};
  1556. int RET=LA_RUNNING|(p->IsMenuPanel?0:LA_PASS_ON);
  1557. if(MAIN.DockingPanel){ return LA_FINISHED; }
  1558. if (!p->Show || (!laIsInPanel(p, x, y) && !uid->TargetIndexVali)){
  1559. if(p->CloseWhenMovedOut==2){
  1560. if(e->Type&LA_STATE_DOWN){
  1561. la_StopUiOperatorService(p); laDestroySinglePanel(p,0); return LA_FINISHED;
  1562. }
  1563. return LA_RUNNING;
  1564. }
  1565. if(p->ShowCorner){ p->ShowCorner=0; laSetWindowCursor(LA_ARROW); laRefreshWindow(); }
  1566. return LA_FINISHED_PASS;
  1567. }
  1568. int NoPrimaryUI=(p==MAIN.CurrentWindow->MaximizedUiPanel);
  1569. if(p->PanelTemplate && laKeyMapExecuteEvent(a, &p->PanelTemplate->KeyMap, e)) return RET;
  1570. int IsTop=laIsTopPanel(p);
  1571. if (!IsTop && !uid->TargetIndexVali){
  1572. laLocalToWindow(0, p, &x, &y);
  1573. dp = laDetectPanel(x, y);
  1574. if (p->Mode && dp != p){
  1575. return LA_FINISHED;
  1576. }else if ((e->Type & LA_MOUSEDOWN) == LA_MOUSEDOWN){
  1577. laPopPanel(p); IsTop=1;
  1578. }else if(p->Mode) return LA_RUNNING;
  1579. laWindowToLocal(0, p, &x, &y);
  1580. }
  1581. if (e->Type == LA_L_MOUSE_DOWN && (!NoPrimaryUI) && e->x + e->y < p->W + p->H - LA_SCROLL_W*2){
  1582. laUiItem *pui = 0; laUiList *suil = 0;laListHandle levels={0};
  1583. laUiList *duil = la_DetectUiListRecursiveDeep(&p->UI, e->x, e->y, 10000, &pui, &suil, 0, 0, 0, &levels);
  1584. while(duil=lstPopPointer(&levels));
  1585. if (suil){
  1586. uid->Ptr1 = suil; uid->Ptr2 = pui;
  1587. uid->TargetIndexVali = 3;
  1588. uid->LastX = e->x; uid->LastY = e->y;
  1589. uid->On=(!pui || e->x>pui->R-LA_SCROLL_W-2*(*p->BT)->RM)?1:0;
  1590. return LA_RUNNING;
  1591. }
  1592. }
  1593. if(la_ScrollPanel(uid,p,e))return LA_RUNNING;
  1594. if (!p->Mode || (IsTop && !uid->TargetIndexVali)){
  1595. if(y<p->TitleBar.B){ ui = la_DetectUiItemRecursive(&p->TitleBar, x, y, 10000, &Locals, 0); }
  1596. elif (!ui && (!NoPrimaryUI)){
  1597. lstClearPointer(&Locals);
  1598. ui = la_DetectUiItemRecursive(&p->UI, x, y, 10000, &Locals, 0);
  1599. }
  1600. }
  1601. if (ui && !a->Child && ui->Type->OperatorType && !la_UiOperatorExists(ui)){
  1602. laSetOperatorLocalizer(p);
  1603. if (laInvokeUiP(a, ui->Type->OperatorType, e, ui, &Locals, 0) >= 0){ laRetriggerOperators(); }
  1604. lstClearPointer(&Locals);
  1605. //return LA_RUNNING;
  1606. }
  1607. lstClearPointer(&Locals);
  1608. if (p->Mode && e->Type&LA_MOUSE_EVENT && !uid->TargetIndexVali && !p->IsMenuPanel){
  1609. if (e->x + e->y > p->W + p->H - LA_SCROLL_W*2){
  1610. if((!a->Item.pPrev) && (!p->ShowCorner)){ p->ShowCorner=1; laSetWindowCursor(LA_CORNER); laRefreshWindow(); }
  1611. if(e->Type==LA_L_MOUSE_DOWN){ uid->TargetIndexVali = 2; uid->LastX=e->x;uid->LastY=e->y; }
  1612. return LA_RUNNING;
  1613. }else{
  1614. if(p->ShowCorner){ p->ShowCorner=0; laSetWindowCursor(LA_ARROW); laRefreshWindow(); }
  1615. if(e->Type==LA_L_MOUSE_DOWN){ uid->TargetIndexVali = 1; uid->LastX=e->x;uid->LastY=e->y; return LA_RUNNING; }
  1616. }
  1617. }
  1618. if (e->Type == LA_MOUSEMOVE){
  1619. if (uid->TargetIndexVali == 1){
  1620. if (!p->SL && !p->SR) p->TX = p->X + e->x - uid->LastX;
  1621. if (!p->ST && !p->SB) p->TY = p->Y + e->y - uid->LastY;
  1622. laNotifyUsersPPPath(&p->PP, "position");
  1623. la_EnsurePanelSnapping(p, MAIN.CurrentWindow->CW, MAIN.CurrentWindow->CH);
  1624. laRecalcCurrentPanel();
  1625. return LA_RUNNING;
  1626. }elif (uid->TargetIndexVali == 2){
  1627. p->TW += e->x - uid->LastX; p->TH += e->y - uid->LastY;
  1628. uid->LastX = e->x; uid->LastY = e->y;
  1629. p->BoundUi=0;
  1630. laNotifyUsersPPPath(&p->PP, "size");
  1631. la_EnsurePanelSnapping(p, MAIN.CurrentWindow->CW, MAIN.CurrentWindow->CH);
  1632. laRecalcCurrentPanel();
  1633. return LA_RUNNING;
  1634. }elif (uid->TargetIndexVali == 3){
  1635. laUiList *suil = uid->Ptr1; laUiItem *pui = uid->Ptr2;
  1636. int IsVertical=uid->On;
  1637. uid->TargetIndexValf+=IsVertical?la_ScrollerVerticalPan(e->y - uid->LastY, p, uid->Ptr1, uid->Ptr2):
  1638. (pui?la_ScrollerHorizontalPan(e->x - uid->LastX, p, uid->Ptr1, uid->Ptr2):0);
  1639. uid->Dragging = (int)uid->TargetIndexValf; uid->TargetIndexValf-=uid->Dragging;
  1640. int pV=uid->Dragging*IsVertical, pH=uid->Dragging*(!IsVertical);
  1641. if (!pui) laPanUiList(suil, pH, pV,0, p->W, suil->U, p->H-(*p->BT)->BM);
  1642. else laPanUiList(suil, pH, pV, suil->L, pui->R-(suil->ScrollerShownV?(LA_SCROLL_W+(*p->BT)->RM):0),
  1643. suil->U, pui->B-(*p->BT)->BM-(suil->ScrollerShownH?(LA_SCROLL_W+(*p->BT)->BM):0));
  1644. uid->LastX = e->x; uid->LastY = e->y;
  1645. laRedrawCurrentPanel();
  1646. return LA_RUNNING;
  1647. }
  1648. }
  1649. if (e->Type == LA_L_MOUSE_UP){
  1650. uid->TargetIndexVali = 0; laSetWindowCursor(LA_ARROW);
  1651. return LA_RUNNING;
  1652. }
  1653. if(p->Mode&&e->Type&LA_MOUSE_EVENT){ return LA_RUNNING; }
  1654. return RET;
  1655. }
  1656. int OPMOD_MenuPanel(laOperator *a, laEvent *e){
  1657. int x = e->x;
  1658. int y = e->y;
  1659. laPanel *p = a->Instance;
  1660. laUiItem *ui;
  1661. laListHandle Locals = {0};
  1662. laGeneralUiExtraData *uid = a->CustomData;
  1663. if(MAIN.DockingPanel){return LA_FINISHED; }
  1664. int IsClose=laIsCloseToPanel(p,x,y);
  1665. int IsIn=laIsInPanel(p, x, y);
  1666. if(p->CloseWhenMovedOut && ((!IsClose) || (!IsIn && e->Type==LA_TIME_IDLE) || e->Type==LA_L_MOUSE_DOWN||e->Type==LA_R_MOUSE_DOWN)){
  1667. la_StopUiOperatorService(p);
  1668. laDestroySinglePanel(p,0);
  1669. return LA_FINISHED_PASS;
  1670. }
  1671. if (e->Type == LA_ESCAPE_DOWN || (e->Type == LA_L_MOUSE_DOWN && !IsIn)){
  1672. laConfirmInt(a, 1, LA_CONFIRM_DATA);
  1673. la_StopUiOperatorService(p);
  1674. laDestroySinglePanel(p,0);
  1675. return LA_FINISHED_PASS;
  1676. }
  1677. if(p->PanelTemplate && laKeyMapExecuteEvent(a, &p->PanelTemplate->KeyMap, e)) return LA_RUNNING_PASS;
  1678. if (e->Type == LA_L_MOUSE_DOWN && e->y < p->H - LA_SCROLL_W){
  1679. laUiItem *pui = 0; laUiList *suil = 0;laListHandle levels={0};
  1680. laUiList *duil = la_DetectUiListRecursiveDeep(p->MenuRefer?p->MenuRefer:&p->UI, e->x, e->y, 10000, &pui, &suil, 0, 0, 0, &levels);
  1681. while(duil=lstPopPointer(&levels));
  1682. if (suil){
  1683. uid->Ptr1 = suil; uid->Ptr2 = pui;
  1684. uid->TargetIndexVali = 3;
  1685. uid->LastX = e->x; uid->LastY = e->y;
  1686. uid->On=(!pui || e->x>pui->R-LA_SCROLL_W-2*(*p->BT)->RM)?1:0;
  1687. return LA_RUNNING;
  1688. }
  1689. }
  1690. if (e->Type == LA_L_MOUSE_UP && uid->TargetIndexVali == 3){
  1691. uid->TargetIndexVali = 0;
  1692. return LA_RUNNING;
  1693. }
  1694. if(la_ScrollPanel(uid,p,e))return LA_RUNNING;
  1695. if (e->Type == LA_MOUSEMOVE){
  1696. if (uid->TargetIndexVali == 3){
  1697. laUiList *suil = uid->Ptr1; laUiItem *pui = uid->Ptr2;
  1698. int IsVertical=uid->On;
  1699. uid->TargetIndexValf+=IsVertical?la_ScrollerVerticalPan(e->y - uid->LastY, p, uid->Ptr1, uid->Ptr2):
  1700. (pui?la_ScrollerHorizontalPan(e->x - uid->LastX, p, uid->Ptr1, uid->Ptr2):0);
  1701. uid->Dragging = (int)uid->TargetIndexValf; uid->TargetIndexValf-=uid->Dragging;
  1702. int pV=uid->Dragging*IsVertical, pH=uid->Dragging*(!IsVertical);
  1703. if (!pui) laPanUiList(suil, pH, pV,0, p->W, suil->U, p->H-(*p->BT)->BM);
  1704. else laPanUiList(suil, pH, pV, suil->L, pui->R-(suil->ScrollerShownV?(LA_SCROLL_W+(*p->BT)->RM):0),
  1705. suil->U, pui->B-(*p->BT)->BM-(suil->ScrollerShownH?(LA_SCROLL_W+(*p->BT)->BM):0));
  1706. uid->LastX = e->x; uid->LastY = e->y;
  1707. laRedrawCurrentPanel();
  1708. return LA_RUNNING;
  1709. }
  1710. }
  1711. ui = la_DetectUiItemRecursive(&p->UI, x, y, 10000, &Locals, 0);
  1712. if (!ui){
  1713. lstClearPointer(&Locals);
  1714. ui = la_DetectUiItemRecursive(p->MenuRefer, x, y, 10000, &Locals, 0);
  1715. }
  1716. if (ui && !la_UiOperatorExists(ui)){
  1717. laSetOperatorLocalizer(p);
  1718. laInvokeUiP(a, ui->Type->OperatorType, e, ui, &Locals, 0);
  1719. }
  1720. lstClearPointer(&Locals);
  1721. if (a->ConfirmData){
  1722. laConfirmInt(a, a->ConfirmData->IData, a->ConfirmData->Mode);
  1723. la_StopUiOperatorService(p);
  1724. laDestroySinglePanel(p,0);
  1725. return LA_FINISHED_PASS;
  1726. }
  1727. return LA_RUNNING;
  1728. }
  1729. int OPMOD_ModalPanel(laOperator *a, laEvent *e){
  1730. int x = e->x;
  1731. int y = e->y;
  1732. laPanel *p = a->Instance;
  1733. laUiItem *ui = 0;
  1734. laListHandle Locals = {0};
  1735. laGeneralUiExtraData *uid = a->CustomData;
  1736. if(MAIN.DockingPanel){return LA_FINISHED; }
  1737. if (e->Type == LA_KEY_DOWN && e->key==LA_KEY_ESCAPE){
  1738. laConfirmInt(a, 0, LA_CONFIRM_CANCEL);
  1739. la_StopUiOperatorService(p);
  1740. laDestroySinglePanel(p,0);
  1741. return LA_FINISHED_PASS;
  1742. }
  1743. if (a->ConfirmData){
  1744. laConfirmSameDataIfAny(a);
  1745. if (a->ConfirmData->Mode == LA_CONFIRM_DATA||a->ConfirmData->Mode==LA_CONFIRM_CUSTOM_STRING){
  1746. return LA_RUNNING_PASS;
  1747. }
  1748. la_StopUiOperatorService(p);
  1749. laDestroySinglePanel(p,0);
  1750. return LA_FINISHED_PASS;
  1751. }
  1752. if (!laIsInPanel(p, e->x, e->y) && !uid->TargetIndexVali){
  1753. if(p->ShowCorner){ p->ShowCorner=0; laSetWindowCursor(LA_ARROW); laRefreshWindow(); } return LA_RUNNING;
  1754. }
  1755. if(p->PanelTemplate && laKeyMapExecuteEvent(a, &p->PanelTemplate->KeyMap, e)) return LA_RUNNING_PASS;
  1756. if (e->Type == LA_L_MOUSE_DOWN && e->y < p->H - LA_SCROLL_W){
  1757. laUiItem *pui = 0; laUiList *suil = 0;laListHandle levels={0};
  1758. laUiList *duil = la_DetectUiListRecursiveDeep(&p->UI, e->x, e->y, 10000, &pui, &suil, 0, 0, 0, &levels);
  1759. while(duil=lstPopPointer(&levels));
  1760. if (suil){
  1761. uid->Ptr1 = suil; uid->Ptr2 = pui;
  1762. uid->TargetIndexVali = 3;
  1763. uid->LastX = e->x; uid->LastY = e->y;
  1764. uid->On=(!pui || e->x>pui->R-LA_SCROLL_W-2*(*p->BT)->RM)?1:0;
  1765. return LA_RUNNING;
  1766. }
  1767. }
  1768. if(la_ScrollPanel(uid,p,e))return LA_RUNNING;
  1769. if (!uid->TargetIndexVali){
  1770. ui = la_DetectUiItemRecursive(&p->TitleBar, x, y, 10000, &Locals, 0);
  1771. if (!ui){
  1772. lstClearPointer(&Locals);
  1773. ui = la_DetectUiItemRecursive(&p->UI, x, y, 10000, &Locals, 0);
  1774. }
  1775. }
  1776. if (ui && !a->Child && ui->Type->OperatorType && !la_UiOperatorExists(ui)){
  1777. laSetOperatorLocalizer(p);
  1778. laInvokeUiP(a, ui->Type->OperatorType, e, ui, &Locals, 0);
  1779. return LA_RUNNING;
  1780. }
  1781. lstClearPointer(&Locals);
  1782. int insize=0; if (e->x + e->y > p->W + p->H - LA_SCROLL_W*2){ insize=1;
  1783. if((!a->Item.pPrev) && (!p->ShowCorner)){ p->ShowCorner=1; laSetWindowCursor(LA_CORNER); laRefreshWindow(); }
  1784. }else{ if(p->ShowCorner){ p->ShowCorner=0; laSetWindowCursor(LA_ARROW); laRefreshWindow(); } }
  1785. if (e->Type == LA_L_MOUSE_DOWN){
  1786. uid->LastX = e->x;
  1787. uid->LastY = e->y;
  1788. if(insize){ uid->TargetIndexVali = 2; laSetWindowCursor(LA_CORNER); }
  1789. else uid->TargetIndexVali = 1;
  1790. return LA_RUNNING;
  1791. }
  1792. if (e->Type == LA_MOUSEMOVE){
  1793. if (uid->TargetIndexVali == 1){
  1794. if (!p->SL && !p->SR) p->TX = p->X + e->x - uid->LastX;
  1795. if (!p->ST && !p->SB) p->TY = p->Y + e->y - uid->LastY;
  1796. laNotifyUsersPPPath(&p->PP, "position");
  1797. la_EnsurePanelSnapping(p, MAIN.CurrentWindow->CW, MAIN.CurrentWindow->CH);
  1798. laRecalcCurrentPanel();
  1799. return LA_RUNNING;
  1800. }elif (uid->TargetIndexVali == 2){
  1801. p->TW += e->x - uid->LastX; p->TH += e->y - uid->LastY;
  1802. uid->LastX = e->x; uid->LastY = e->y;
  1803. p->BoundUi=0;
  1804. laNotifyUsersPPPath(&p->PP, "size");
  1805. la_EnsurePanelSnapping(p, MAIN.CurrentWindow->CW, MAIN.CurrentWindow->CH);
  1806. laRecalcCurrentPanel();
  1807. return LA_RUNNING;
  1808. }elif (uid->TargetIndexVali == 3){
  1809. laUiList *suil = uid->Ptr1; laUiItem *pui = uid->Ptr2;
  1810. int IsVertical=uid->On;
  1811. uid->TargetIndexValf+=IsVertical?la_ScrollerVerticalPan(e->y - uid->LastY, p, uid->Ptr1, uid->Ptr2):
  1812. (pui?la_ScrollerHorizontalPan(e->x - uid->LastX, p, uid->Ptr1, uid->Ptr2):0);
  1813. uid->Dragging = (int)uid->TargetIndexValf; uid->TargetIndexValf-=uid->Dragging;
  1814. int pV=uid->Dragging*IsVertical, pH=uid->Dragging*(!IsVertical);
  1815. if (!pui) laPanUiList(suil, pH, pV,0, p->W, suil->U, p->H-(*p->BT)->BM);
  1816. else laPanUiList(suil, pH, pV, suil->L, pui->R-(suil->ScrollerShownV?(LA_SCROLL_W+(*p->BT)->RM):0),
  1817. suil->U, pui->B-(*p->BT)->BM-(suil->ScrollerShownH?(LA_SCROLL_W+(*p->BT)->BM):0));
  1818. uid->LastX = e->x; uid->LastY = e->y;
  1819. laRedrawCurrentPanel();
  1820. return LA_RUNNING;
  1821. }
  1822. if(uid->TargetIndexVali==2){laSetWindowCursor(LA_CORNER);}
  1823. }
  1824. if (e->Type == LA_L_MOUSE_UP){
  1825. uid->TargetIndexVali = 0; laSetWindowCursor(LA_ARROW);
  1826. return LA_RUNNING;
  1827. }
  1828. return LA_RUNNING;
  1829. }
  1830. int OPCHK_IsPanel(laPropPack *This, laStringSplitor *ss){
  1831. if (This && This->LastPs->p == _LA_PROP_PANEL) return 1;
  1832. else{
  1833. char *PanelInternalID = strGetArgumentString(ss, "panel_id");
  1834. if (!PanelInternalID) return 0;
  1835. else
  1836. return 1;
  1837. }
  1838. return 0;
  1839. }
  1840. int OPCHK_IsPanelNoInstructions(laPropPack *This, laStringSplitor *ss){
  1841. if (This && This->LastPs->p == _LA_PROP_PANEL) return 1;
  1842. return 0;
  1843. }
  1844. int OPINV_HidePanel(laOperator *a, laEvent *e){
  1845. laPanel *p = a->This->LastPs->UseInstance;
  1846. laHidePanelWithDissoveEffect(p);
  1847. return LA_FINISHED;
  1848. }
  1849. int OPINV_ActivatePanel(laOperator *a, laEvent *e){
  1850. laStringSplitor *ss = a->ExtraInstructionsP;
  1851. char *TemplateID = strGetArgumentString(ss, "panel_id");
  1852. if (!TemplateID) return LA_CANCELED;
  1853. laActivatePanel(TemplateID, e->x, e->y);
  1854. return LA_FINISHED;
  1855. }
  1856. int OPINV_PanPanel(laOperator *a, laEvent *e){
  1857. laPanel *p = a->This->LastPs->UseInstance;
  1858. //laHidePanel(p);
  1859. return LA_FINISHED;
  1860. }
  1861. int OPCHK_IsHyper(laPropPack *This, laStringSplitor *ss){
  1862. if (This && This->LastPs->p->Container->Hyper) return 1;
  1863. return 0;
  1864. }
  1865. int OPINV_ViewHyperData(laOperator *a, laEvent *e){
  1866. char buf[2048]={0};
  1867. memHyperInfo(a->This, buf);
  1868. printf("%s",buf);
  1869. return LA_FINISHED;
  1870. }
  1871. int OPINV_TranslationDumpMisMatch(laOperator *a, laEvent *e){
  1872. transDumpMissMatchRecord("TranslationDump.txt");
  1873. laEnableMessagePanel(a, 0, "OK", "Untranslated strings exported to TranslationDump.txt", e->x - 250, e->y - 10, 300, e);
  1874. return LA_FINISHED;
  1875. }
  1876. int OPINV_OpenInternetLink(laOperator *a, laEvent *e){
  1877. char *link = strGetArgumentString(a->ExtraInstructionsP, "link");
  1878. if (link) laOpenInternetLink(link);
  1879. return LA_FINISHED;
  1880. }
  1881. void laget_PanelTemplateCategory(void* rack_unused, laUiTemplate* uit, char* copy, char** ptr);
  1882. void la_RegisterBuiltinOperators(){
  1883. laPropContainer *pc; laProp *p;
  1884. laOperatorType *at;
  1885. laEnumProp *ep;
  1886. laCreateOperatorType("LA_terminate_program", "Quit", "Terminate Program Immediately",
  1887. OPCHK_TerminateProgram, 0, 0, OPINV_TerminateProgram, 0, U'⏻', LA_ACTUATOR_SYSTEM);
  1888. laCreateOperatorType("LA_undo", "Undo", "Undo from recorded data state", OPCHK_Undo, 0, 0, OPINV_Undo, 0, U'⮌', LA_ACTUATOR_SYSTEM);
  1889. laCreateOperatorType("LA_redo", "Redo", "Redo using recorded data state", OPCHK_Redo, 0, 0, OPINV_Redo, 0, U'⮎', LA_ACTUATOR_SYSTEM);
  1890. laCreateOperatorType("LA_translation_dump", "Dump Untranslated Text", "Dump Untranslated Text To File", 0, 0, 0, OPINV_TranslationDumpMisMatch, 0, U'📥', LA_ACTUATOR_SYSTEM);
  1891. laCreateOperatorType("LA_open_internet_link", "Goto", "Open Internet Link", 0, 0, 0, OPINV_OpenInternetLink, 0, U'🌐', LA_ACTUATOR_SYSTEM);
  1892. laCreateOperatorType("LA_system_paste", "SYSWINDOW Paste", "Generate a syetem paste event", 0, 0, 0, OPINV_SystemPaste, 0, U'📋', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  1893. laCreateOperatorType("LA_string_copy", "Copy", "Copy string to clip board", 0, 0, 0, OPINV_StringCopy, 0, U'🗍', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  1894. laCreateOperatorType("LA_window_operator", "SYSWINDOW Operator", "Handle All Unhandled Events", 0, 0, 0, OPINV_Window, OPMOD_Window, U'🖦', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  1895. at = laCreateOperatorType("LA_switch_layout", "Switch Layout", "Cycle All Layouts In Current SYSWINDOW", 0, 0, 0, OPINV_SwitchLayout, OPMOD_FinishOnData, U'↔', LA_ACTUATOR_SYSTEM);
  1896. at->UiDefine=laui_LayoutCycle;
  1897. at = laCreateOperatorType("LA_new_window", "New SYSWINDOW", "Create a new window", 0, 0, 0, OPINV_NewWindow, 0, U'🗗', LA_ACTUATOR_SYSTEM);
  1898. laCreateOperatorType("LA_combine_child_blocks", "Combine Child Block", "If Child Blocks Are Two Panel Blocks, Then Combine Them.",
  1899. OPCHK_CombineChildBlocks, 0, 0, OPINV_CombineChildBlocks, 0, U'□' , LA_ACTUATOR_SYSTEM);
  1900. at = laCreateOperatorType("LA_new_panel", "New Panel", "Create a new panel",
  1901. 0, 0, 0, OPINV_NewPanel, OPMOD_NewPanel, U'🞆', LA_ACTUATOR_SYSTEM);
  1902. pc = laDefineOperatorProps(at, 0);
  1903. 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);
  1904. laSubGroupExtraFunctions(p,0,0,0,laget_PanelTemplateCategory);
  1905. at->UiDefine=laui_PanelTemplateSelect;
  1906. laCreateOperatorType("LA_block_fold_title", "Fold Title", "Fold the tile bar of the block", 0, 0, 0, OPINV_BlockFoldTitle, 0, U'⯅', LA_ACTUATOR_SYSTEM);
  1907. laCreateOperatorType("LA_block_maximize", "Maximize", "Maximize this block", 0, 0, 0, OPINV_BlockMaximize, 0, U'⮼', LA_ACTUATOR_SYSTEM);
  1908. laCreateOperatorType("LA_block_tear_off_panel", "Tear Off", "Tear off current panel in the block",
  1909. OPCHK_BlockHasMorePanels, 0, 0, OPINV_BlockTearOffPanel, 0, U'🗗', LA_ACTUATOR_SYSTEM);
  1910. laCreateOperatorType("LA_block_close_panel", "Close Panel", "Close current panel in the block",
  1911. OPCHK_BlockHasMorePanels, 0, 0, OPINV_BlockClosePanel, OPMOD_BlockClosePanel, U'❌', LA_ACTUATOR_SYSTEM);
  1912. laCreateOperatorType("LA_canvas_ui_maximize", "Maximize", "Maximize this UI item", 0, 0, 0, OPINV_CanvasUiMaximize, 0, U'⮼', LA_ACTUATOR_SYSTEM);
  1913. laCreateOperatorType("LA_hide_menu_bar", "Hide Menu Bar", "Hide menu bar of the window", 0, 0, 0, OPINV_HideMenuBar, 0, U'⯅', LA_ACTUATOR_SYSTEM);
  1914. laCreateOperatorType("LA_fullscreen", "Fullscreen", "Switch full screen for the window",
  1915. 0, 0, 0, OPINV_Fullscreen, 0, U'🡵', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  1916. laCreateOperatorType("LA_new_layout", "New Layout", "Create a new layout in the window",
  1917. 0, 0, 0, OPINV_NewLayout, 0, U'🞦', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  1918. laCreateOperatorType("LA_remove_layout", "Remove Layout", "Remove current layout in the window",
  1919. OPCHK_RemoveLayout, 0, 0, OPINV_RemoveLayout, 0, U'❌', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  1920. laCreateOperatorType("LA_panel_operator", "Panel Operator", "Handle Events On The Panel Level",
  1921. 0, 0, OPEXT_Panel, OPINV_Panel, OPMOD_Panel, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  1922. laCreateOperatorType("LA_modal_panel_operator", "Modal Panel Operator", "Handle Events On Modal Panels Like Yes-No Boxes",
  1923. 0, 0, OPEXT_Panel, OPINV_Panel, OPMOD_ModalPanel, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  1924. laCreateOperatorType("LA_menu_panel_operator", "Menu Panel Operator", "Handle Events On Menu Panel,Recieve And Dispatch Confirm Messages,Then Self-destroy.",
  1925. 0, 0, OPEXT_Panel, OPINV_Panel, OPMOD_MenuPanel, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  1926. laCreateOperatorType("LA_panel_activator", "Panel Activator", "Show A Panel When Invoked.Need An Extra Argument[panel_id]",
  1927. OPCHK_IsPanel, 0, 0, OPINV_ActivatePanel, 0, 0, LA_ACTUATOR_SYSTEM)
  1928. ->ParseArgs = la_PanelActiviatorParser;
  1929. laCreateOperatorType("LA_hide_panel", "Hide Panel", "Hide a panel",
  1930. OPCHK_IsPanel, 0, 0, OPINV_HidePanel, 0, 0, LA_ACTUATOR_SYSTEM);
  1931. laCreateOperatorType("LA_dock_panel", "Dock Panel", "Dock a panel",
  1932. OPCHK_IsPanel, 0, 0, OPINV_DockPanel, 0, 0, LA_ACTUATOR_SYSTEM);
  1933. laCreateOperatorType("LA_int_restore_default", "Restore Default Value", "Restore Int Value To Default", OPCHK_IntSetValue, 0, 0, OPINV_IntSetDefault, 0, U'⭯', LA_ACTUATOR_SYSTEM);
  1934. laCreateOperatorType("LA_real_restore_default", "Restore Default Value", "Restore Float Value To Default", OPCHK_FloatSetValue, 0, 0, OPINV_FloatSetDefault, 0, U'⭯', LA_ACTUATOR_SYSTEM);
  1935. laCreateOperatorType("LA_int_set_max", "Set Max Value", "Set Int Value To Max", OPCHK_IntSetValue, 0, 0, OPINV_IntSetMax, 0, 0, LA_ACTUATOR_SYSTEM);
  1936. laCreateOperatorType("LA_real_set_max", "Set Max Value", "Set Float Value To Max", OPCHK_FloatSetValue, 0, 0, OPINV_FloatSetMax, 0, 0, LA_ACTUATOR_SYSTEM);
  1937. laCreateOperatorType("LA_int_set_min", "Set Min Value", "Set Int Value To Min", OPCHK_IntSetValue, 0, 0, OPINV_IntSetMin, 0, 0, LA_ACTUATOR_SYSTEM);
  1938. laCreateOperatorType("LA_real_set_min", "Set Min Value", "Set Float Value To Min", OPCHK_FloatSetValue, 0, 0, OPINV_FloatSetMin, 0, 0, LA_ACTUATOR_SYSTEM);
  1939. laCreateOperatorType("LA_int_array_restore_default", "Restore Default Array/Value", "Restore Int Values To Default", OPCHK_IntArraySetValue, 0, 0, OPINV_IntArraySetDefault, 0, U'⭯', LA_ACTUATOR_SYSTEM);
  1940. laCreateOperatorType("LA_real_array_restore_default", "Restore Default Array/Value", "Restore Float Values To Default", OPCHK_FloatArraySetValue, 0, 0, OPINV_FloatArraySetDefault, 0, U'⭯', LA_ACTUATOR_SYSTEM);
  1941. laCreateOperatorType("LA_int_array_set_max", "Set Max Values", "Set Int Values To Max", OPCHK_IntArraySetValue, 0, 0, OPINV_IntArraySetMax, 0, 0, LA_ACTUATOR_SYSTEM);
  1942. laCreateOperatorType("LA_real_array_set_max", "Set Max Values", "Set Float Values To Max", OPCHK_FloatArraySetValue, 0, 0, OPINV_FloatArraySetMax, 0, 0, LA_ACTUATOR_SYSTEM);
  1943. laCreateOperatorType("LA_int_array_set_min", "Set Min Values", "Set Int Values To Min", OPCHK_IntArraySetValue, 0, 0, OPINV_IntArraySetMin, 0, 0, LA_ACTUATOR_SYSTEM);
  1944. laCreateOperatorType("LA_real_array_set_min", "Set Min Values", "Set Float Values To Min", OPCHK_FloatArraySetValue, 0, 0, OPINV_FloatArraySetMin, 0, 0, LA_ACTUATOR_SYSTEM);
  1945. laCreateOperatorType("LA_enum_restore_default", "Restore Default Value", "Restore enum value to default", OPCHK_EnumSetValue, 0, 0, OPINV_EnumSetDefault, 0, U'⭯', LA_ACTUATOR_SYSTEM);
  1946. laCreateOperatorType("LA_enum_array_restore_default", "Restore Default Array", "Restore enum array values to default", OPCHK_EnumArraySetValue, 0, 0, OPINV_EnumArraySetDefault, 0, U'⭯', LA_ACTUATOR_SYSTEM);
  1947. laCreateOperatorType("LA_string_set_default", "Set Default Value", "Set default string", OPCHK_StringSetValue, 0, 0, OPINV_StringSetDefault, 0, U'⭯', LA_ACTUATOR_SYSTEM);
  1948. laCreateOperatorType("LA_string_get_folder_path", "Get folder Path", "get folder path", OPCHK_StringSetValue, 0, 0, OPINV_StringGetFolderPath, OPMOD_StringGetFolderOrFilePath, U'📁', LA_ACTUATOR_SYSTEM);
  1949. laCreateOperatorType("LA_string_get_file_path", "Get folder Path", "get file path", OPCHK_StringSetValue, 0, 0, OPINV_StringGetFilePath, OPMOD_StringGetFolderOrFilePath, U'🖹', LA_ACTUATOR_SYSTEM);
  1950. laCreateOperatorType("LA_sub_put_data_block", "Put Data Block", "Put Pending Data Block Here",
  1951. OPCHK_SubPutDataBlock, 0, 0, OPINV_SubPutDataBlock, 0, U'🡮', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  1952. at = laCreateOperatorType("LA_sub_restore_data_block", "Put Data Block", "Put Pending Data Block Here",
  1953. OPCHK_SubRestoreDataBlock, 0, OPEXT_SubRestoreDataBlock, OPINV_SubRestoreDataBlock, 0, U'🔗', LA_ACTUATOR_SYSTEM);
  1954. at->UiDefine = laui_DataRestorePage;
  1955. 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);
  1956. laCreateOperatorType("LA_file_dialog_up", "Up", "Select Upper Folder Level", OPCHK_IsFileBrowser, 0, 0, OPINV_FileBrowserUpLevel, 0, U'🢰', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  1957. laCreateOperatorType("LA_file_dialog_confirm", "Confirm", "Confirm selection", OPCHK_FileBrowserCanConfirm, 0, 0, OPINV_FileBrowserConfirm, OPMOD_FileBrowserConfirm, U'✔', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  1958. at = laCreateOperatorType("LA_file_dialog", "File Dialog", "Do File Operations", 0, 0, OPEXT_FileBrowser, OPINV_FileBrowser, OPMOD_FileBrowser, U'🗐', LA_ACTUATOR_SYSTEM);
  1959. pc = laDefineOperatorProps(at, 2);
  1960. at->UiDefine = laui_FileBrowserFileList;
  1961. _LA_PROP_FILE_BROWSER = pc;
  1962. laAddStringProperty(pc, "path", "Path", "Directort Path", 0, 0, 0, "/", 0, offsetof(laFileBrowser, Path), 0, 0, laset_FileBrowserPath, 0, LA_UDF_LOCAL);
  1963. laAddStringProperty(pc, "file_name", "File Name", "File Name", 0, 0, 0, 0, 0, offsetof(laFileBrowser, FileName), 0, 0, laset_FileBrowserFileName, 0, LA_UDF_LOCAL);
  1964. 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);
  1965. 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);
  1966. 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);
  1967. 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);
  1968. 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);
  1969. 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);{
  1970. laAddEnumItemAs(ep, "file", "File", "File", LA_FILE_SELECT_FILE, U'📁');
  1971. laAddEnumItemAs(ep, "folder", "Folder", "Folder", LA_FILE_SELECT_FOLDER, U'🖹');
  1972. }
  1973. laAddOperatorProperty(pc, "folder_up", "Up", "Select Upper Folder Level In File Browsers", "LA_file_dialog_up", U'🢰', 0);
  1974. laAddOperatorProperty(pc, "confirm", "Confirm", "Confirm selection", "LA_file_dialog_confirm", U'✔', 0);
  1975. p = laAddPropertyContainer("disk_item", "Disk Item", "A Logical Drive (In Windows)", 0, laui_FileBrowserDiskItem, 0, 0, 0, 1);{
  1976. laAddStringProperty(p, "id", "ID", "Disk Identifier", 0, 0, 0, 0, 0, 0, 0, laget_FileBrowserDiskID, 0, 0, 0);
  1977. 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);
  1978. 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);
  1979. }
  1980. p = laAddPropertyContainer("file_item", "File Item", "A File Item In A List", U'🖹', 0, 0, 0, 0, 0);{
  1981. 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);
  1982. 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);
  1983. 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);
  1984. 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);
  1985. 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);{
  1986. laAddEnumItemAs(ep, "unknown", "Unknown", "Unknown/Uncategorized File Type", LA_FILETYPE_UNKNOWN, U'🖹');
  1987. laAddEnumItemAs(ep, "udf", "UDF", "Uniform Data Format", LA_FILETYPE_UDF, U'📦');
  1988. laAddEnumItemAs(ep, "document", "Document", "Document File", LA_FILETYPE_DOCUMENT, U'🖹');
  1989. laAddEnumItemAs(ep, "image", "Image", "Image File", LA_FILETYPE_IMAGE, U'🖻');
  1990. laAddEnumItemAs(ep, "audio", "Audio", "Audio File", LA_FILETYPE_AUDIO, U'𝄞');
  1991. laAddEnumItemAs(ep, "video", "Video", "Video File", LA_FILETYPE_VIDEO, U'🎞');
  1992. laAddEnumItemAs(ep, "compressed", "Compressed", "Compressed File", LA_FILETYPE_COMPRESSED, U'🗜');
  1993. laAddEnumItemAs(ep, "font", "Font", "Font File", LA_FILETYPE_FONT, U'🗚');
  1994. laAddEnumItemAs(ep, "vector", "Vector", "Vector File", LA_FILETYPE_VECTOR, U'🞎');
  1995. laAddEnumItemAs(ep, "webpage", "Webpage", "Webpage", LA_FILETYPE_WEBPAGE, U'🌐');
  1996. laAddEnumItemAs(ep, "meta", "Meta Data", "Meta Data Package", LA_FILETYPE_META, U'🖹');
  1997. laAddEnumItemAs(ep, "blend", "Blend", "Blend File", LA_FILETYPE_BLEND, U'🖹');
  1998. laAddEnumItemAs(ep, "pdf", "PDF", "PDF File", LA_FILETYPE_PDF, U'🖹');
  1999. laAddEnumItemAs(ep, "exe", "Executable", "SYSWINDOW Executable", LA_FILETYPE_EXEC, U'🖦');
  2000. laAddEnumItemAs(ep, "sys", "System", "System Files", LA_FILETYPE_SYS, U'🖹');
  2001. laAddEnumItemAs(ep, "folder", "Folder", "Folder", LA_FILETYPE_FOLDER, U'📁');
  2002. laAddEnumItemAs(ep, "lasdexchange", "LaSDExchange", "LA Scene Descriptive Exchange File", LA_FILETYPE_LASDEXCHANGE, 0);
  2003. }
  2004. }
  2005. p = laAddPropertyContainer("bookmarked_folder", "Bookmarked_folder", "A bookmarked folder from GTK3", 0, laui_IdentifierOnly, sizeof(laBookmarkedFolder), 0, 0, 0);{
  2006. laAddStringProperty(p, "name", "Name", "Bookmark Name", 0, 0, 0, 0, 0, offsetof(laBookmarkedFolder, Name), 0, 0, 0, 0, LA_AS_IDENTIFIER|LA_UDF_LOCAL);
  2007. laAddStringProperty(p, "path", "Path", "Bookmark path", 0, 0, 0, 0, 0, offsetof(laBookmarkedFolder, Path), 0, 0, 0, 0, LA_UDF_LOCAL);
  2008. }
  2009. at = laCreateOperatorType("LA_udf_read", "Read", "Read a UDF file", 0, 0, OPEXT_UDFOperation, OPINV_UDFRead, OPMOD_UDFRead, U'📑', LA_ACTUATOR_SYSTEM);
  2010. pc = laDefineOperatorProps(at, 0);
  2011. at->UiDefine = laui_LinkerPanel;
  2012. laAddSubGroup(pc, "root_nodes", "UDF Nodes", "List Of All Linkable/Appendable Nodes In The File", "udf_content_node",0, 0, laui_LinkerSelectionProp, -1, 0, 0, 0, 0, 0, 0, offsetof(laUDFPreviewExtra, ContentNodes), 0);
  2013. 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);
  2014. at = laCreateOperatorType("LA_managed_save", "Save as", "Save managed data blocks", 0, 0, OPEXT_ManagedSave, OPINV_ManagedSave, OPMOD_ManagedSave, U'🖫', LA_ACTUATOR_SYSTEM);
  2015. pc = laDefineOperatorProps(at, 1);
  2016. 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);
  2017. laAddEnumItemAs(ep, "DATA_BLOCKS", "Data Blocks", "All data blocks", 0, 0);
  2018. laAddEnumItemAs(ep, "FILES", "Files", "All Files", 1, 0);
  2019. at->UiDefine = laui_ManagedSavePanel;
  2020. laCreateOperatorType("LA_udf_propagate", "Propagate", "Propagate this file to all unassigned child nodes", 0, 0, 0, OPINV_UDFPropagate, 0, 0, LA_ACTUATOR_SYSTEM);
  2021. laCreateOperatorType("LA_managed_save_new_file", "New File", "New managed UDF file", 0, 0, OPEXT_ManagedSave, OPINV_ManagedSaveNewFile, OPMOD_ManagedSaveNewFile, U'+', LA_ACTUATOR_SYSTEM);
  2022. laCreateOperatorType("LA_manage_udf", "UDF Manager", "Operations on all managed UDF files", 0, 0, 0, OPINV_UDFManager, 0, U'🔍', LA_ACTUATOR_SYSTEM);
  2023. laCreateOperatorType("LA_add_resource_folder", "Add Resource Folder", "Add a resource folder entry for searching UDF references",
  2024. 0, 0, 0, OPINV_AddResourceFolder, 0, U'🞧', LA_ACTUATOR_SYSTEM);
  2025. laCreateOperatorType("LA_remove_resource_folder", "Remove Resource Folder", "Remove a resource folder entry",
  2026. 0, 0, 0, OPINV_RemoveResourceFolder, 0, U'❌', LA_ACTUATOR_SYSTEM);
  2027. laCreateOperatorType("LA_save_user_preferences", "Save Preferences", "Save user preferences", 0, 0, 0, OPINV_SaveUserPreferences, 0, 0, LA_ACTUATOR_SYSTEM);
  2028. laCreateOperatorType("LA_confirm", "Confirm", "Confirm The Statement", 0, 0, 0, OPINV_DoNothing, 0, U'✔', LA_ACTUATOR_SYSTEM)
  2029. ->ExtraInstructions = "feedback=CONFIRM;";
  2030. laCreateOperatorType("LA_cancel", "Cancel", "Ignore The Statement", 0, 0, 0, OPINV_DoNothing, 0, U'❌', LA_ACTUATOR_SYSTEM)
  2031. ->ExtraInstructions = "feedback=CANCEL;";
  2032. laCreateOperatorType("LA_pure_yes_no", "Yes Or No", "Show Yes Or No Box", 0, 0, 0, OPINV_PureYesNo, 0, U'❓', LA_ACTUATOR_SYSTEM);
  2033. laCreateOperatorType("LA_delete_theme", "Delete Theme", "Delete a theme",
  2034. 0, 0, 0, OPINV_DeleteTheme, 0, U'❌', LA_ACTUATOR_SYSTEM);
  2035. }