*/}}
Browse Source

Usability Improvements

YimingWu 7 months ago
parent
commit
bb6601db20
4 changed files with 21 additions and 6 deletions
  1. 1 0
      la_interface.h
  2. 9 1
      resources/la_operators.c
  3. 8 3
      resources/la_templates.c
  4. 3 2
      resources/la_widgets.c

+ 1 - 0
la_interface.h

@@ -2204,6 +2204,7 @@ STRUCTURE(laFileBrowser){
     char FileName[512];
     char TempStr[512];
     char MD5[128];
+    char FilterName[512];
     tnsImage* Thumbnail;
     laDiskItem *RootDisk;
     laFileItem *Active;

+ 9 - 1
resources/la_operators.c

@@ -252,6 +252,7 @@ void la_FileBrowserRebuildList(laFileBrowser *fb){
     for(int i=0;i<NumFiles;i++){
         struct dirent* d = NameList[i];
         if(!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")){continue;}
+        if(fb->FilterName[0] && !strcasestr(d->d_name,fb->FilterName)){continue;}
         struct stat s;
         sprintf(Final, "%s%s",fb->Path,d->d_name);
         stat(Final, &s);
@@ -298,6 +299,7 @@ void la_FileBrowserRebuildList(laFileBrowser *fb){
     if (hFind == INVALID_HANDLE_VALUE){ return; }
 
     while (1) {
+        if(fb->FilterName[0] && !strcasestr(FindFileData.cFileName,fb->FilterName)){goto findnext;}
         if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
             if (FindFileData.cFileName[0] != '.') {
                 fi = memAcquireSimple(sizeof(laFileItem));
@@ -326,6 +328,7 @@ void la_FileBrowserRebuildList(laFileBrowser *fb){
             lstAppendItem(&Files, fi);
             //lstAppendItem(&fb->FileList, fi);
         }
+findnext:
         if (!FindNextFile(hFind, &FindFileData))
             break;
     }
@@ -425,7 +428,7 @@ void laset_FileBrowserSelectFile(laFileBrowser *fb, laFileItem *fi, int State){
             if (fb->Path[len - 1] != LA_PATH_SEP) strcat(fb->Path, LA_PATH_SEPSTR);
             strcat(fb->Path, fi->Name);
             la_FileBrowserRebuildList(fb);
-            fb->FileName[0] = 0;
+            fb->FileName[0] = 0; fb->FilterName[0]=0;
             laRecalcCurrentPanelImmediate();
         }
     }else{
@@ -482,6 +485,10 @@ void laset_FileBrowserFileName(laFileBrowser *fb, char *content){
     la_FileBrowserRebuildList(fb);
     laRecalcCurrentPanel();
 }
+void laset_FileBrowserFilterName(laFileBrowser *fb, char *content){
+    strCopyFull(fb->FilterName, content); int file_okay=0;
+    la_FileBrowserRebuildList(fb); laRecalcCurrentPanel();
+}
 void* laget_FileBrowserAcceptedExtensionsFrist(laFileBrowser* fb, laPropIterator* pi){
     if(!fb->UseType){ return 0; }
     for(laExtensionType*et=MAIN.ExtraExtensions.pFirst;et;et=et->Item.pNext){
@@ -2410,6 +2417,7 @@ void la_RegisterBuiltinOperators(){
     laAddStringProperty(pc, "path", "Path", "Directort path", 0, 0, 0, "/", 0, offsetof(laFileBrowser, Path), 0, 0, laset_FileBrowserPath, 0, LA_UDF_LOCAL);
     laAddStringProperty(pc, "file_name", "File Name", "File name", 0, 0, 0, 0, 0, offsetof(laFileBrowser, FileName), 0, 0, laset_FileBrowserFileName, 0, LA_UDF_LOCAL);
     laAddStringProperty(pc, "temp_str", "Temp String", "Temp string", 0, 0, 0, "", 0, offsetof(laFileBrowser, TempStr), 0, 0, 0, 0, LA_UDF_LOCAL);
+    laAddStringProperty(pc, "filter_name", "Filter Name", "Filter file name", 0, 0, 0, 0, 0, offsetof(laFileBrowser, FilterName), 0, 0, laset_FileBrowserFilterName, 0, LA_UDF_LOCAL);
     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);
     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);
     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);

+ 8 - 3
resources/la_templates.c

@@ -945,9 +945,14 @@ void laui_FileBrowserFileList(laUiList *uil, laPropPack *THIS_UNUSED, laPropPack
     laShowItemFull(uil, cl, Operator, "new_directory", LA_WIDGET_BUTTON_NO_CONFIRM,0,0,0);
     laEndRow(uil,row);
 
-    laUiItem* r=laBeginRow(uil,cr,0,0);
-    laShowItem(uil, cr, Operator, "file_name")->Expand=1;
-    laShowItem(uil, cr, Operator, "confirm")->Flags|=LA_UI_FLAGS_HIGHLIGHT|LA_UI_FLAGS_NO_CONFIRM;
+    laSplitColumn(uil,cr,0.5);
+    laColumn *fnamel=laLeftColumn(cr,0),*fnamer=laRightColumn(cr,15);
+
+    laShowItem(uil, fnamel, Operator, "file_name");
+    laUiItem* r=laBeginRow(uil,fnamer,0,0);
+    laShowLabel(uil,fnamer,"🔍",0,0);
+    laUiItem* ui=laShowItem(uil, fnamer, Operator, "filter_name"); ui->Expand=1; ui->Flags|=LA_UI_FLAGS_IMMEDIATE_INPUT;
+    laShowItem(uil, fnamer, Operator, "confirm")->Flags|=LA_UI_FLAGS_HIGHLIGHT|LA_UI_FLAGS_NO_CONFIRM;
     laEndRow(uil,r);
 
     laShowSeparator(uil,col);

+ 3 - 2
resources/la_widgets.c

@@ -866,6 +866,7 @@ void la_EnumSelectorDraw(laUiItem *ui, int h){
     int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
     int NoEvent=ui->Flags&LA_UI_FLAGS_NO_EVENT;
     int Highlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
+    int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
     // norm      e1
     // expand    e1 e2 e3
     // expand vertical  (vertical)
@@ -920,8 +921,8 @@ void la_EnumSelectorDraw(laUiItem *ui, int h){
             }
             _B=_U+LA_RH; _R=_L+_W;
 
-            int ExtraState=ui->State;
-            if(IsExpand&&!IsCycle){ use_ei = ei; ei=ei->Item.pNext; ExtraState=(use_ei==Data[i])?LA_BT_ACTIVE:0; }
+            int ExtraState=IsDisabled?LA_BT_DISABLED:ui->State;
+            if(IsExpand&&!IsCycle){ use_ei = ei; ei=ei->Item.pNext; ExtraState=(use_ei==Data[i])?LA_BT_ACTIVE:ExtraState; }
             else{ use_ei = Data[i]; if(Highlight && Data[i]->Index!=0){ ExtraState=LA_BT_ACTIVE; } }
 
             if(!NoDecal){