*/}}

la_operators.c 94 KB

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