Eolite/KFM2 RC6: show breadcrumbs on path dropdown

git-svn-id: svn://kolibrios.org@8956 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2021-06-28 17:00:57 +00:00
parent 035673385a
commit d311715575
4 changed files with 83 additions and 100 deletions

View File

@ -4,16 +4,13 @@
/* /*
BUGS: BUGS:
- fix a kfm2 bug with selected files on window deactivation - fix a kfm2 bug with selected files on window deactivation
- back button broken
- bug with going to wrong path (related to prior issue?)
TODO: TODO:
- 70.5 - get volume info and label - 70.5 - get volume info and label
- click on a path bar dropdown opens breadcrumbs
*/ */
#define ABOUT_TITLE "EOLITE 5 Beta12" #define ABOUT_TITLE "EOLITE 5 RC6"
#define TITLE_EOLITE "Eolite File Manager 5 Beta12" #define TITLE_EOLITE "Eolite File Manager 5 RC6"
#define TITLE_KFM "Kolibri File Manager 2 Beta12"; #define TITLE_KFM "Kolibri File Manager 2 RC6";
#define MEMSIZE 1024 * 250 #define MEMSIZE 1024 * 250
#include "../lib/clipboard.h" #include "../lib/clipboard.h"
@ -60,7 +57,7 @@ dword waves_pal[256];
_history history; _history history;
//Folder data //Folder data
dword buf; dword buf, buf_inactive;
collection_int items=0; collection_int items=0;
int selected_count; int selected_count;
int folder_count; int folder_count;
@ -94,7 +91,6 @@ dword waves_pal[256];
//Multipanes //Multipanes
int active_panel=0; int active_panel=0;
int disk_popin_active_on_panel=0;
#define PANES_COUNT 2 #define PANES_COUNT 2
dword location[PANES_COUNT]; dword location[PANES_COUNT];
llist files, files_active, files_inactive; llist files, files_active, files_inactive;
@ -189,7 +185,7 @@ void main()
handle_param(); handle_param();
SystemDiscs.Get(); SystemDiscs.Get();
Open_Dir(path,ONLY_OPEN); OpenDir(ONLY_OPEN);
llist_copy(#files_inactive, #files); llist_copy(#files_inactive, #files);
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
loop() switch(@WaitEventTimeout(100)) loop() switch(@WaitEventTimeout(100))
@ -304,15 +300,19 @@ void main()
} }
if (active_popin) { if (active_popin) {
if (POPUP_BTN2==id) { EventClosePopinForm(); break; }
if (POPUP_BTN1==id) { EventPopinClickOkay(); break; }
if (POPIN_DISK==active_popin) { if (POPIN_DISK==active_popin) {
if (id>=100) && (id<=120) { active_popin = NULL;
active_popin = NULL; EventDriveClick(id-100);
EventDriveClick(id); }
}
EventClosePopinForm(); //POPIN_DISK create close btn with POPUP_BTN2 if (POPIN_BREADCR==active_popin) {
break; } EventClosePopinForm();
if (POPUP_BTN2==id) EventClosePopinForm(); ClickOnBreadCrumb(id-BREADCRUMB_ID);
if (POPUP_BTN1==id) EventPopinClickOkay(); }
break; break;
} }
@ -343,10 +343,7 @@ void main()
FnProcess(id-50); FnProcess(id-50);
break; break;
case 100...120: case 100...120:
EventDriveClick(id); EventDriveClick(id-100);
break;
case BREADCRUMB_ID...360:
ClickOnBreadCrumb(id-BREADCRUMB_ID);
break; break;
case KFM_FUNC_ID...KFM_FUNC_ID+10: case KFM_FUNC_ID...KFM_FUNC_ID+10:
FnProcess(id-KFM_FUNC_ID); FnProcess(id-KFM_FUNC_ID);
@ -366,8 +363,8 @@ void main()
if (POPIN_DISK == active_popin) { if (POPIN_DISK == active_popin) {
if (key_scancode >= SCAN_CODE_1) if (key_scancode >= SCAN_CODE_1)
&& (key_scancode >= SCAN_CODE_10) { && (key_scancode <= SCAN_CODE_10) {
EventDriveClick(key_scancode-1+100); EventDriveClick(key_scancode-2);
} }
} else { } else {
if (key_scancode == SCAN_CODE_ENTER) EventPopinClickOkay(); if (key_scancode == SCAN_CODE_ENTER) EventPopinClickOkay();
@ -415,10 +412,10 @@ void main()
key_scancode-=2; key_scancode-=2;
if (key_scancode >= SystemDiscs.list.count) break; if (key_scancode >= SystemDiscs.list.count) break;
if (!efm) { if (!efm) {
DrawRectangle(17,key_scancode*16+74,159,16, 0); //display click DrawRectangle(17,key_scancode*17+74,159,17, 0); //display click
pause(7); pause(7);
} }
SystemDiscs.Click(key_scancode); EventDriveClick(key_scancode);
break; break;
case SCAN_CODE_KEY_X: case SCAN_CODE_KEY_X:
CopyFilesListToClipboard(CUT); CopyFilesListToClipboard(CUT);
@ -582,10 +579,13 @@ void draw_window()
llist_copy(#files_active, #files); llist_copy(#files_active, #files);
DrawStatusBar(); DrawStatusBar();
if (!selected_count) { if (!selected_count) {
Open_Dir(path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001] OpenDir(ONLY_OPEN); //if there are no selected files -> refresh folder [L001]
} }
DrawFilePanels(); DrawFilePanels();
disk_popin_active_on_panel = 0;
if (files.x!=files_inactive.x) {
if (active_popin) ShowPopinForm(active_popin);
}
} }
void DrawButtonsAroundList() void DrawButtonsAroundList()
@ -673,7 +673,7 @@ void DrawFilePanels()
files_inactive.x = files.x; files_inactive.x = files.x;
DrawButtonsAroundList(); DrawButtonsAroundList();
path = location[active_panel^1]; path = location[active_panel^1];
Open_Dir(path,WITH_REDRAW); OpenDir(WITH_REDRAW);
if (!selected_count) files_inactive.count = files.count; if (!selected_count) files_inactive.count = files.count;
llist_copy(#files, #files_active); llist_copy(#files, #files_active);
@ -685,7 +685,7 @@ void DrawFilePanels()
DrawButtonsAroundList(); DrawButtonsAroundList();
path = location[active_panel]; path = location[active_panel];
Open_Dir(path,WITH_REDRAW); OpenDir(WITH_REDRAW);
} }
} }
@ -727,10 +727,6 @@ void List_ReDraw()
DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h, separator_color); DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h, separator_color); DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
DrawScroll(scroll_used); DrawScroll(scroll_used);
if (files.x!=files_inactive.x) {
if (active_popin) ShowPopinForm(active_popin);
}
} }
void Line_ReDraw(dword bgcol, filenum){ void Line_ReDraw(dword bgcol, filenum){
@ -836,12 +832,12 @@ void Line_ReDraw(dword bgcol, filenum){
} }
void Open_Dir(dword dir_path, redraw){ void OpenDir(char redraw){
int errornum; int errornum;
selected_count = 0; selected_count = 0;
if (buf) free(buf); if (buf) free(buf);
if (errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT)) if (errornum = GetDir(#buf, #files.count, path, DIRS_NOROOT))
{ {
history.add(path); history.add(path);
EventHistoryGoBack(); EventHistoryGoBack();
@ -850,16 +846,15 @@ void Open_Dir(dword dir_path, redraw){
} }
if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0; if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
history.add(path);
SystemDiscs.Draw(); SystemDiscs.Draw();
files.visible = files.h / files.item_h; files.visible = math.min(files.h / files.item_h, files.count);
if (files.count < files.visible) files.visible = files.count; if (!strncmp(path, "/rd/1",5)) || (!strncmp(path, "/sys/",4))
if (!strncmp(dir_path, "/rd/1",5)) || (!strncmp(dir_path, "/sys/",4))
dir_at_fat16 = true; else dir_at_fat16 = false; dir_at_fat16 = true; else dir_at_fat16 = false;
Sorting(); Sorting();
list_full_redraw = true; list_full_redraw = true;
SetCurDir(dir_path); SetCurDir(path);
if (redraw!=ONLY_OPEN) { if (redraw!=ONLY_OPEN) {
history.add(path);
List_ReDraw(); List_ReDraw();
DrawStatusBar(); DrawStatusBar();
DrawPathBar(); DrawPathBar();
@ -914,7 +909,7 @@ void SelectFileByName(dword that_file)
{ {
int ind; int ind;
files.KeyHome(); files.KeyHome();
Open_Dir(path,ONLY_OPEN); OpenDir(ONLY_OPEN);
if (dir_at_fat16) && (file_name_is_8_3(that_file)) strttl(that_file); if (dir_at_fat16) && (file_name_is_8_3(that_file)) strttl(that_file);
for (ind=files.count-1; ind>=0; ind--;) { if (!strcmpi(items.get(ind)*304+buf+72,that_file)) break; } for (ind=files.count-1; ind>=0; ind--;) { if (!strcmpi(items.get(ind)*304+buf+72,that_file)) break; }
files.cur_y = ind - 1; files.cur_y = ind - 1;
@ -967,20 +962,32 @@ void EventOpen(byte _new_window)
if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; } if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
strcpy(path, #file_path); strcpy(path, #file_path);
files.first=files.cur_y=0; files.first=files.cur_y=0;
Open_Dir(path,WITH_REDRAW); OpenDir(WITH_REDRAW);
} }
} }
inline fastcall void EventHistoryGoBack() void EventHistoryGoBack()
{ {
char cur_folder[4096]; char cur_folder[4096];
strcpy(#cur_folder, path); strcpy(#cur_folder, path);
if (history.back()) { if (history.back()) {
strcpy(path, history.current()); strcpy(path, history.current());
SelectFileByName(#cur_folder+strrchr(#cur_folder,'/')); SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
DrawPathBar();
} }
} }
void EventHistoryGoForward()
{
if (history.forward()) {
strcpy(path, history.current());
files.KeyHome();
OpenDir(WITH_REDRAW);
DrawPathBar();
}
}
void ShowOpenWithDialog() void ShowOpenWithDialog()
{ {
byte open_param[4097]; byte open_param[4097];
@ -1017,7 +1024,6 @@ bool EventCreateAndRename()
} }
} }
} }
Open_Dir(path,WITH_REDRAW);
SelectFileByName(popin_text.text); SelectFileByName(popin_text.text);
return true; return true;
__FAIL: __FAIL:
@ -1030,7 +1036,7 @@ void EventPopinClickOkay()
switch(active_popin) { switch(active_popin) {
case POPIN_PATH: case POPIN_PATH:
strcpy(path, #popin_string); strcpy(path, #popin_string);
Open_Dir(path, WITH_REDRAW); OpenDir(WITH_REDRAW);
break; break;
case POPIN_DELETE: case POPIN_DELETE:
CopyFilesListToClipboard(DELETE); CopyFilesListToClipboard(DELETE);
@ -1091,7 +1097,7 @@ void ShowPopinForm(byte _popin_type)
WriteTextCenter(popinx, 192, POPIN_W, sc.work_text, #param); WriteTextCenter(popinx, 192, POPIN_W, sc.work_text, #param);
break; break;
case POPIN_DISK: case POPIN_DISK:
DefineHiddenButton(0,0,5000,3000,9999+BT_NOFRAME); DefineHiddenButton(0,0,5000,3000,POPUP_BTN2+BT_NOFRAME);
if (active_panel==0) { if (active_panel==0) {
SystemDiscs.DrawOptions(1); SystemDiscs.DrawOptions(1);
} else { } else {
@ -1099,9 +1105,8 @@ void ShowPopinForm(byte _popin_type)
} }
break; break;
case POPIN_BREADCR: case POPIN_BREADCR:
notify("'Not implemented yet' C"); DefineHiddenButton(0,0,5000,3000,POPUP_BTN2+BT_NOFRAME);
return; DrawBreadCrumbs();
//DrawBreadCrumbs();
break; break;
} }
active_popin = _popin_type; active_popin = _popin_type;
@ -1229,7 +1234,7 @@ void EventRefreshDisksAndFolders()
SystemDiscs.Draw(); SystemDiscs.Draw();
} }
} }
if(GetRealFileCountInFolder(path) != files.count) Open_Dir(path,WITH_REDRAW); if(GetRealFileCountInFolder(path) != files.count) OpenDir(WITH_REDRAW);
} }
void EventManualFolderRefresh() void EventManualFolderRefresh()
@ -1246,19 +1251,10 @@ void EventSort(dword id)
else sort_type = id; else sort_type = id;
strcpy(#selected_filename, #file_name); strcpy(#selected_filename, #file_name);
DrawButtonsAroundList(); DrawButtonsAroundList();
Open_Dir(path,WITH_REDRAW); OpenDir(WITH_REDRAW);
SelectFileByName(#selected_filename); SelectFileByName(#selected_filename);
} }
void EventHistoryGoForward()
{
if (history.forward()) {
strcpy(path, history.current());
files.KeyHome();
Open_Dir(path,WITH_REDRAW);
}
}
void EventOpenNewEolite() void EventOpenNewEolite()
{ {
RunProgram(I_Path, path); RunProgram(I_Path, path);
@ -1368,10 +1364,14 @@ void EventToolbarButtonClick(int _btid)
void EventDriveClick(int __id) void EventDriveClick(int __id)
{ {
if (__id >= SystemDiscs.list.count) return;
if (efm) { if (efm) {
EventClosePopinForm();
draw_window(); draw_window();
} }
SystemDiscs.Click(__id-100); strcpy(path, SystemDiscs.list.get(__id));
files.KeyHome();
OpenDir(WITH_REDRAW);
} }
stop: stop:

View File

@ -178,8 +178,6 @@ void DrawPathBar()
void DrawPathEolite() void DrawPathEolite()
{ {
PathShow.text_pointer = location[0]; PathShow.text_pointer = location[0];
PathShow.start_x = 250;
PathShow.start_y = 17;
PathShow.area_size_x = Form.cwidth-300; PathShow.area_size_x = Form.cwidth-300;
DrawBar(PathShow.start_x-3, PathShow.start_y-6, PathShow.area_size_x+3, 19, col.odd_line); DrawBar(PathShow.start_x-3, PathShow.start_y-6, PathShow.area_size_x+3, 19, col.odd_line);
DrawRectangle(PathShow.start_x-4,PathShow.start_y-7,PathShow.area_size_x+4,20,sc.work_graph); DrawRectangle(PathShow.start_x-4,PathShow.start_y-7,PathShow.area_size_x+4,20,sc.work_graph);
@ -232,13 +230,14 @@ void DrawPathBarKfm()
void DrawBreadCrumbs() void DrawBreadCrumbs()
collection_int breadCrumb=0; collection_int breadCrumb=0;
char PathShow_path[4096]; char PathShow_path[4096];
block btn; int btnx;
int i; int i;
unsigned text_line;
{ {
strcat(#PathShow_path, path);
for (i=0; i<50; i++) DeleteButton(i+BREADCRUMB_ID);
breadCrumb.drop(); breadCrumb.drop();
strcpy(#PathShow_path, "/<root>");
if (ESBYTE[path+1]) {
strcat(#PathShow_path, path);
}
for (i=0; (PathShow_path[i]) && (i<sizeof(PathShow_path)-1); i++) for (i=0; (PathShow_path[i]) && (i<sizeof(PathShow_path)-1); i++)
{ {
if (PathShow_path[i]=='/') { if (PathShow_path[i]=='/') {
@ -247,38 +246,29 @@ void DrawBreadCrumbs()
} }
} }
breadCrumb.add(i+1); breadCrumb.add(i+1);
btn.set_size(246,10,NULL,20);
//area_w = Form.cwidth - btn.x - 20; if (!efm) btnx = 250-4;
for (i=0; i<breadCrumb.count-1; i++) else btnx = Form.cwidth/2-2*active_panel + DDW + 2;
{
text_line = breadCrumb.get(i) + #PathShow_path; ///EDI! for (i=0; i<breadCrumb.count-1; i++) {
btn.w = strlen(text_line)*8+10; EDI = breadCrumb.get(i) + #PathShow_path;
DrawBreadcrumbButton(btn.x, btn.y, btn.w, btn.h, i+BREADCRUMB_ID, text_line); DrawFlatButtonSmall(btnx, KFM2_DEVH-1*i+SELECTY+KFM2_DEVH,
btn.y += btn.h; 250, KFM2_DEVH, i+BREADCRUMB_ID, EDI);
} }
btn.x++;
DrawBar(btn.x,btn.y-1,Form.cwidth-btn.x-25,btn.h+3,sc.work);
} }
void ClickOnBreadCrumb(unsigned clickid) void ClickOnBreadCrumb(unsigned clickid)
{ {
int i, slashpos = path; int i, slashpos = path;
for (i=0; i!=clickid+2; i++) { if (!clickid) {
slashpos=strchr(slashpos,'/')+1; ESBYTE[path+1] = '\0';
} else {
for (i=1; i!=clickid+2; i++) {
slashpos=strchr(slashpos,'/')+1;
}
ESBYTE[slashpos-1] = '\0';
} }
ESBYTE[slashpos-1] = NULL; OpenDir(WITH_REDRAW);
Open_Dir(path,WITH_REDRAW);
}
void DrawBreadcrumbButton(dword x,y,w,h,id,text)
{
int i;
DrawRectangle(x,y,w,h,sc.work_graph);
for (i=0; (i<h-1) & (i<20); i++) DrawBar(x+1, y+i+1, w-1, 1, col.work_gradient[20-i]);
DrawRectangle3D(x+1,y+1,w-2,h-2,sc.work_light, sc.work_dark);
DefineHiddenButton(x+1,y+1,w-2,h-2,id);
WriteText(-strlen(text)*8+w/2+x,h/2+y-7,0x90,sc.work_text,text);
DrawBar(x, y+h+1, w+1, 1, sc.work_light);
} }
//===================================================// //===================================================//

View File

@ -7,7 +7,6 @@ struct _SystemDiscs
void Draw(); void Draw();
void DrawSelect(); void DrawSelect();
void DrawOptions(); void DrawOptions();
void Click();
} SystemDiscs=0; } SystemDiscs=0;
void _SystemDiscs::Get() void _SystemDiscs::Get()
@ -149,10 +148,4 @@ void _SystemDiscs::DrawOptions(int draw_x)
} }
} }
void _SystemDiscs::Click(int n)
{
strcpy(path, list.get(n));
files.KeyHome();
Open_Dir(path,WITH_REDRAW);
}

View File

@ -131,7 +131,7 @@ void SetProperties(int mode)
} }
cmd_free=3; cmd_free=3;
Open_Dir(path,ONLY_OPEN); OpenDir(ONLY_OPEN);
ExitProcess(); ExitProcess();
} }