*/}}

la_operators.c 110 KB

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