*/}}

2 Commits 45e1b100c6 ... 87f604ea28

Author SHA1 Message Date
  YimingWu 87f604ea28 File browser filter 5 days ago
  YimingWu 5af4b93603 Various 5 days ago
6 changed files with 42 additions and 13 deletions
  1. 8 6
      la_data.c
  2. 3 0
      la_interface.h
  3. 10 1
      la_kernel.c
  4. 8 0
      resources/la_properties.c
  5. 10 4
      resources/la_templates.c
  6. 3 2
      resources/la_widgets.c

+ 8 - 6
la_data.c

@@ -2230,9 +2230,11 @@ void la_GetWorkingDirectoryInternal(){
     char mbuf[2048];
 #ifdef LA_LINUX
     readlink("/proc/self/exe", mbuf, 2048);
+    strDiscardLastSegmentSeperateBy(mbuf, '/');
 #endif
 #ifdef _WIN32
     GetModuleFileName(NULL, mbuf, 2048);
+    strDiscardLastSegmentSeperateBy(mbuf, '\\');
 #endif
     int len=strlen(mbuf);if(mbuf[len]!=LA_PATH_SEP){ mbuf[len]=LA_PATH_SEP; mbuf[len+1]=0; }
     strSafeSet(&MAIN.WorkingDirectory, mbuf);
@@ -3648,10 +3650,10 @@ laManagedUDF* la_EnsureManagedUDF(char* FileName, int PutAtTop){
     return m;
 }
 void la_MakeDummyManagedUDF(){
-    MAIN.DummyManageUDF=la_EnsureManagedUDF("< Save as a new file >", 1);
+    MAIN.DummyManageUDF=la_EnsureManagedUDF(transLate("< Save as a new file >"), 1);
     if(!MAIN.DummyManageUDFSingle){
-        MAIN.DummyManageUDFSingle=memAcquire(sizeof(laManagedUDF)); strSafeSet(&MAIN.DummyManageUDFSingle->BaseName, "< Choose file >");
-        MAIN.DummyManageUDFSingleForce=memAcquire(sizeof(laManagedUDF)); strSafeSet(&MAIN.DummyManageUDFSingleForce->BaseName, "< Force >");
+        MAIN.DummyManageUDFSingle=memAcquire(sizeof(laManagedUDF)); strSafeSet(&MAIN.DummyManageUDFSingle->BaseName, transLate("< Choose file >"));
+        MAIN.DummyManageUDFSingleForce=memAcquire(sizeof(laManagedUDF)); strSafeSet(&MAIN.DummyManageUDFSingleForce->BaseName, transLate("< Force >"));
     }
 }
 laManagedSaveProp* laSaveProp(char* path){
@@ -4652,12 +4654,12 @@ void laRedo(){ laDiff* d; if(d=laSwapDBState(1)){ la_ExecUndoPtrSync(d); laNotif
 
 void laPrintDBInst(laDBInst* dbi, int Level){
     if(dbi!=&MAIN.RootDBInst){
-        printf("%*c", Level, ' ');
-        printf("%s  |  %.6x [%.6x] %.6x  |  %.6x [%.6x] %.6x\n",
+        logPrintNew("%*c", Level, ' ');
+        logPrint("%s  |  %.6x [%.6x] %.6x  |  %.6x [%.6x] %.6x\n",
             dbi->pc->Identifier, dbi->Item.pPrev, dbi, dbi->Item.pNext,
             dbi->Item.pPrev?((laDBInst*)dbi->Item.pPrev)->OriginalInstance:0, dbi->OriginalInstance, dbi->Item.pNext?((laDBInst*)dbi->Item.pNext)->OriginalInstance:0);
     }else{
-        printf("Root:\n");
+        logPrintNew("Root:\n");
     }
     for(laDBProp* dbp=dbi->Props.pFirst;dbp;dbp=dbp->Item.pNext){
         if(dbp->p->PropertyType==LA_PROP_SUB && !dbp->p->UDFIsRefer){

+ 3 - 0
la_interface.h

@@ -576,6 +576,7 @@ STRUCTURE(LA){
     laManagedUDF* DummyManageUDFSingleForce;
     int          ManagerDefaultView;
     int          SetUDFPending;
+    int          ManagerFilterInstances;
     laPropContainer* SaverDummyContainer;
 
     laListHandle DBInstPendingAcquireDBP;
@@ -1250,6 +1251,8 @@ STRUCTURE(laWidget){
 #define LA_UI_SOCKET_LABEL_W LA_TEXT_ALIGN_CENTER
 #define LA_UI_SOCKET_LABEL_E LA_TEXT_ALIGN_AUTO
 
+#define LA_UI_COLLECTION_MANAGER_FILTER LA_TEXT_ONE_LINE
+
 extern laWidget* LA_WIDGET_FIXED_GROUP;
 extern laWidget* LA_WIDGET_TAB;
 extern laWidget* LA_WIDGET_COLLECTION;

+ 10 - 1
la_kernel.c

@@ -1378,6 +1378,8 @@ int laGetReadyWith(laInitArguments* ia){
     MAIN.WireThickness = 5;
     MAIN.WireSaggyness = 0.5;
 
+    MAIN.ManagerFilterInstances = 1;
+
 #ifdef LAGUI_ANDROID
     laAddResourceFolder("");
 #else
@@ -5691,6 +5693,11 @@ laUiList* la_GiveExistingPage(laListHandle* from, void* instance){
     for(laUiList* uil=from->pFirst;uil;uil=uil->Item.pNext){ if(uil->Instance == instance){ lstRemoveItem(from,uil); return uil; } } return 0;
 }
 void la_SwitchThemeQuick(laTheme* t, laTheme* DefaultTheme);
+int laget_Hyper2InstanceModified(void* instance){
+    int level; laMemNodeHyper* m=memGetHead(instance,&level);
+    if(level==2) return m->Modified?1:0;
+    return 1;
+}
 int la_UpdateUiListRecursive(laUiList *uil, int U, int L, int R, int B, int Fast, laPanel *ParentPanel){
     laUiItem *ui; laListHandle TempPages={0}; laUiList* FoundUil;
     laBoxedTheme *bt;
@@ -5885,7 +5892,9 @@ int la_UpdateUiListRecursive(laUiList *uil, int U, int L, int R, int B, int Fast
                     }
                 }
                 while (TInstance){
-                    if(uisp->UiFilter && (!uisp->UiFilter(ui->PP.LastPs->UseInstance, TInstance))){
+                    int UiFilterSkip = uisp->UiFilter && (!uisp->UiFilter(ui->PP.LastPs->UseInstance, TInstance));
+                    int ManagerFilterSkip = MAIN.ManagerFilterInstances && (ui->Flags&LA_UI_COLLECTION_MANAGER_FILTER) && (!laget_Hyper2InstanceModified(TInstance));
+                    if(UiFilterSkip || ManagerFilterSkip){
                         TInstance = laGetNextInstance(ui->PP.LastPs->p, TInstance, &pi);
                         Template = ui->Template?ui->Template:laGetPropertyUiDefine(&ui->PP, TInstance);
                         ui->PP.EndInstance = TInstance; continue;

+ 8 - 0
resources/la_properties.c

@@ -464,6 +464,10 @@ void laget_MainIdentifier(laUDF *udf, char *result, char** here){
 void laget_UDFFilePath(laUDF *udf, char *result, char** here){
     *here=udf->FileName->Ptr;
 }
+void laset_ManagerFilterInstances(void* unused, int val){
+    MAIN.ManagerFilterInstances = val;
+    laRedrawAllWindows();
+}
 
 void lapost_PropPack(laPropPack *pp);
 void laget_ConditionNodePropPath(laUiConditionNode *ucn, char *result, char** here){
@@ -1772,6 +1776,10 @@ void la_RegisterInternalProps(){
                 laAddEnumItemAs(ep, "DATA_BLOCKS", "Data Blocks", "All data blocks", 0,0);
                 laAddEnumItemAs(ep, "FILES", "Files", "All Files", 1, 0);
             }
+            ep = laAddEnumProperty(p, "manager_filter_instances", "Filter Instances", "Whether to show only unsaved stuff or everything", 0,0,0,0,0,offsetof(LA, ManagerFilterInstances), 0,laset_ManagerFilterInstances,0,0,0,0,0,0,0,0);{
+                laAddEnumItemAs(ep, "ALL", "All", "All Instances", 0,0);
+                laAddEnumItemAs(ep, "Modified", "Modified", "Modified and unsigned instances", 1, 0);
+            }
             ep = laAddEnumProperty(p, "save_preferences_on_exit", "Save On Exit", "Save user preferences before exiting the program", 0,0,0,0,0,offsetof(LA, SavePreferenceOnExit), 0,0,0,0,0,0,0,0,0,0);{
                 laAddEnumItemAs(ep, "NONE", "Don't save", "Not saving user preferences on exit", 0,0);
                 laAddEnumItemAs(ep, "SAVE", "Save", "Saving user preferences on exit", 1, 0);

+ 10 - 4
resources/la_templates.c

@@ -1132,9 +1132,10 @@ void laui_ManagedPropInstance(laUiList *uil, laPropPack *Base, laPropPack *Opera
             laShowItem(uil,crr,Base,"__single_saver_dummy.__file");
             continue;
         }
-        laUiItem* b=laOnConditionToggle(uil,c,0,0,0,0,0);{ strSafePrint(&b->ExtraInstructions,"text=📦 %s;",transLate(p->Name));
+        laUiItem* b=laOnConditionToggle(uil,cr,0,0,0,0,0);{ strSafePrint(&b->ExtraInstructions,"text=📦 %s;",transLate(p->Name));
             b->Flags|=LA_UI_FLAGS_NO_DECAL|LA_TEXT_ALIGN_LEFT; b->State=LA_BT_ACTIVE;
-            laShowItemFull(uil,cr,Base,p->Identifier,0, 0,laui_ManagedPropInstance,0)->Flags|=LA_UI_FLAGS_NO_DECAL|LA_UI_COLLECTION_NO_HIGHLIGHT;
+            laShowItemFull(uil,cr,Base,p->Identifier,0, 0,laui_ManagedPropInstance,0)
+                ->Flags|=LA_UI_FLAGS_NO_DECAL|LA_UI_COLLECTION_NO_HIGHLIGHT|LA_UI_COLLECTION_MANAGER_FILTER;
         }laEndCondition(uil,b);
     }
     if(pc->UDFPropagate){
@@ -1152,7 +1153,8 @@ void laui_ManagedProp(laUiList *uil, laPropPack *Base, laPropPack *OperatorInst,
     
     laShowLabel(uil,clr,"UID",0,0)->Flags|=LA_UI_FLAGS_DISABLED|LA_TEXT_ALIGN_CENTER;
     laShowLabel(uil,cr,"File",0,0)->Flags|=LA_UI_FLAGS_DISABLED|LA_TEXT_ALIGN_CENTER;
-    laShowItemFull(uil,c,0,msp->Path->Ptr,0, 0,laui_ManagedPropInstance,0)->Flags|=LA_UI_FLAGS_NO_DECAL|LA_UI_COLLECTION_NO_HIGHLIGHT;
+    laShowItemFull(uil,c,0,SSTR(msp->Path),0, 0,laui_ManagedPropInstance,0)
+        ->Flags|=LA_UI_FLAGS_NO_DECAL|LA_UI_COLLECTION_NO_HIGHLIGHT|LA_UI_COLLECTION_MANAGER_FILTER;
 
     laShowSeparator(uil,c);
 }
@@ -1167,7 +1169,11 @@ void laui_ManagedSavePanel(laUiList *uil, laPropPack *Base, laPropPack *Operator
 
     laUiItem* r=laBeginRow(uil,c,0,0);
     laShowLabel(uil,c,"Viewing",0,0);
-    laShowItem(uil,c,Operator,"show_page")->Flags|=LA_UI_FLAGS_EXPAND;
+    laUiItem* btn=laShowItem(uil,c,Operator,"show_page");btn->Flags|=LA_UI_FLAGS_EXPAND;
+    laUiItem* b=laOnConditionThat(uil,c,laNot(laPropExpression(&btn->PP,0)));{
+        laShowSeparator(uil,c);
+        laShowItem(uil,c,0,"la.user_preferences.manager_filter_instances")->Flags|=LA_UI_FLAGS_EXPAND;
+    }laEndCondition(uil,b);
     laEndRow(uil,r);
     laUiItem* g=laMakeEmptyGroup(uil,c,"List",0);{ g->State=LA_UI_ACTIVE;
         laUiList* gu=g->Page; gu->HeightCoeff=mse->OnExit?-4:-3; laColumn* gc=laFirstColumn(gu);

+ 3 - 2
resources/la_widgets.c

@@ -1371,8 +1371,8 @@ void la_MenuItemDraw(laUiItem *ui, int h){
 }
 void la_ConditionToggleDraw(laUiItem *ui, int h){
     laBoxedTheme *bt = (*ui->Type->Theme);
-    char temp[128] = {0};
     char *buf[LA_RAW_CSTR_MAX_LEN];
+    char *buf2[LA_RAW_CSTR_MAX_LEN];
     uint32_t IconID;
     int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
 
@@ -1406,7 +1406,8 @@ void la_ConditionToggleDraw(laUiItem *ui, int h){
             ui->Type->OperatorType->ParseArgs(ui->Instructions, &IconID, buf);
         }
     }
-    if (buf[0]) tnsDrawStringAuto(transLate(buf), laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
+    if (buf[0]){ sprintf(buf2,"%s%s",transLate(buf),(NoDecal&&(ui->State==LA_UI_NORMAL))?" [...]":""); }
+    if (buf2[0]) tnsDrawStringAuto(buf2, laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
     else
         tnsDrawStringAuto(ui->State == LA_UI_ACTIVE ? "⯆" : "⯈", laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
 }