From 4bdbccb9354ec68dbe9037cd1e35a093a7397ab3 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Fri, 7 Aug 2015 14:55:16 +0000 Subject: [PATCH] Eolite 3.0 beta: rewrote list functions, fixed rarely crash while window resize git-svn-id: svn://kolibrios.org@5694 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/eolite/Eolite.c | 210 ++++++++++++----------------- programs/cmm/eolite/include/copy.h | 2 +- programs/cmm/eolite/include/gui.h | 2 +- programs/cmm/lib/list_box.h | 72 +++++++--- 4 files changed, 139 insertions(+), 147 deletions(-) diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index bae7ffa48c..15fdfa4ee2 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -103,8 +103,8 @@ enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir enum { CREATE_FILE=1, CREATE_FOLDER, RENAME_ITEM }; //NewElement -#define TITLE "Eolite File Manager v2.96" -#define ABOUT_TITLE "Eolite 2.96" +#define TITLE "Eolite File Manager v3.0 beta" +#define ABOUT_TITLE "Eolite 3.0 beta" dword col_padding, col_selec, col_lpanel; int toolbar_buttons_x[7]={9,46,85,134,167,203}; @@ -119,6 +119,8 @@ byte menu_call_mouse=0; llist files; +byte list_full_redraw; + byte path[4096], file_path[4096], @@ -142,7 +144,7 @@ dword eolite_ini_path; dword menu_stak,about_stak,properties_stak,settings_stak,copy_stak; proc_info Form; -int mouse_dd, scroll_used, sc_slider_h, sorting_arrow_x, kolibrios_drive; +int mouse_dd, sc_slider_h, sorting_arrow_x, kolibrios_drive; dword buf; dword file_mas[6898]; int j, i; @@ -152,13 +154,13 @@ int selected_count; byte CMD_REFRESH; signed x_old, y_old, dif_x, dif_y, adif_x, adif_y; -byte stats; + edit_box edit2 = {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xFFFFFF,0,248,#file_name,#mouse_dd,64,6,6}; edit_box new_file_ed = {171,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0,248,#new_element_name,#mouse_dd,100000000000010b,6,0}; PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0}; PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0}; -byte cmd_free; +byte cmd_free=0; #include "include\copy.h" #include "include\gui.h" #include "include\sorting.h" @@ -173,7 +175,8 @@ byte cmd_free; void main() { - word key, id, can_show, can_select, m_selected; + word key, id; + char can_show, can_select, scroll_used, stats; dword selected_offset; dword IPC_LEN,IPC_ID; char IPC_BUF[10]; @@ -232,7 +235,7 @@ void main() { if (HistoryPath(GO_FORWARD)) { - files.first=files.current=NULL; + files.KeyHome(); Open_Dir(#path,WITH_REDRAW); } stats = 0; @@ -259,11 +262,14 @@ void main() { if (mouse.y>=files.y)//&&(mouse.click) { - id = mouse.y - files.y / files.line_h; - IF (files.current!=id) + id = mouse.y - files.y / files.line_h + files.first; + if (files.current!=id) { mouse.clearTime(); - if(!mouse.up)&&(id=files.y)//&&(mouse.click) + + if (files.MouseOver(mouse.x, mouse.y)) { - id = mouse.y - files.y / files.line_h; - if (files.current!=id) List_Current(id-files.current); - //SwitchToAnotherThread(); + files.current = mouse.y - files.y / files.line_h + files.first; menu_stak = malloc(4096); - CreateThread(#FileMenu,menu_stak+4092); + CreateThread(#FileMenu,menu_stak+4092); } break; } @@ -361,7 +366,7 @@ void main() case 22: //Forward if (HistoryPath(GO_FORWARD)) { - files.first=files.current=NULL; //aaa?o nienea + files.KeyHome(); Open_Dir(#path,WITH_REDRAW); } break; @@ -391,7 +396,7 @@ void main() DEVICE_MARK: DrawRectangle(17,id-100*16+74,159,16, 0); //auaaeaiea strcpy(#path, #disk_list[id-100].Item); - files.first=files.current=0; + files.KeyHome(); Open_Dir(#path,WITH_REDRAW); pause(5); DrawRectangle(17,id-100*16+74,159,16, 0xFFFFFF); @@ -422,6 +427,11 @@ void main() edit_box_key stdcall (#edit2); break; } + if (files.ProcessKey(key)) + { + List_ReDraw(); + break; + } switch (key) { case 209...217: @@ -484,30 +494,12 @@ void main() if (!itdir) ShowOpenWithDialog(); else Open(1); break; - case ASCII_KEY_UP: - List_Current(-1); - break; - case ASCII_KEY_DOWN: - List_Current(1); - break; - case ASCII_KEY_HOME: - if (files.KeyHome()) List_ReDraw(); - break; - case ASCII_KEY_END: - if (files.KeyEnd()) List_ReDraw(); - break; - case ASCII_KEY_PGDN: - List_Current(files.visible-1); - break; - case ASCII_KEY_PGUP: - List_Current(-files.visible+1); - break; case ASCII_KEY_DEL: Del_Form(); break; case ASCII_KEY_INS: - selected_offset = file_mas[files.current+files.first]*304 + buf+32 + 7; - if (files.current+files.first==0) && (!strncmp(selected_offset+33, "..", 2)) goto _INSERT_END; //do not selec ".." directory + selected_offset = file_mas[files.current]*304 + buf+32 + 7; + if (files.current==0) && (!strncmp(selected_offset+33, "..", 2)) goto _INSERT_END; //do not selec ".." directory if (ESBYTE[selected_offset]) { ESBYTE[selected_offset]=0; @@ -519,18 +511,20 @@ void main() selected_count++; } _INSERT_END: - List_Current(1); + if (files.KeyDown()) List_ReDraw(); break; case 048...059: //F1-F10 FnProcess(key-49); break; default: - for (i=files.current+files.first+1; i2) return; - files.SetSizes(192, 57, Form.cwidth - 210, onTop(57,6), disc_num*16+195,files.line_h); if (Form.height < files.min_h) MoveSize(OLD,OLD,OLD,files.min_h); if (Form.width<480) MoveSize(OLD,OLD,480,OLD); GetProcessInfo(#Form, SelfInfo); //if win_size changed - + files.SetSizes(192, 57, Form.cwidth - 210, onTop(57,6), disc_num*16+195,files.line_h); PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal); DrawBar(127, 8, 1, 25, system.color.work_graph); for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,system.color.work); @@ -638,80 +631,31 @@ void draw_window() } -void KEdit() -{ - if (Form.width<480) return; - PathShow.area_size_x = Form.cwidth-306; - DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff); - PathShow_prepare stdcall(#PathShow); - PathShow_draw stdcall(#PathShow); -} - - -void List_Current(signed int cur) -{ - if (cur<=0) //up - { - if (files.first==0) && (files.current<=0) return; - if (-cur-1cur) - { - Line_ReDraw(0xFFFFFF, files.current); - files.current+=cur; - Line_ReDraw(col_selec, files.current); - return; - } - else - { - if(files.first+files.current+cur>=files.count) - { - files.first=files.count-files.visible; - files.current=cur-files.first+files.current; - } - else - { - files.first+=cur+files.current-files.visible+1; - files.current=files.visible-1; - } - - if (files.current<0) || (files.current>files.visible) - { - files.current=files.visible-1; - } - List_ReDraw(); - } - } -} - - void List_ReDraw() { int paint_y; - //we are in the end of the list => maximize window => there will be white lines after the last element - if (files.count-files.firstfiles.visible-1) - { files.first=files.count-files.visible; files.current=files.visible-1; } - for (j=0; jmaxcount) files.count = maxcount; - if (files.count>0) && (files.current==-1) files.current=0; + if (files.count>0) && (files.current-files.first==-1) files.current=0; } if (files.count!=-1) { - if(!_not_draw)KEdit(); + if(!_not_draw) + { + PathShow.area_size_x = Form.cwidth-306; + DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff); + PathShow_prepare stdcall(#PathShow); + PathShow_draw stdcall(#PathShow); + } HistoryPath(ADD_NEW_PATH); files.visible = files.h / files.line_h; if (files.count < files.visible) files.visible = files.count; @@ -807,10 +757,15 @@ void Open_Dir(dword dir_path, redraw){ if (sort_num==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w; WriteText(sorting_arrow_x,45,0x80,system.color.work_graph,"\x19"); if (redraw!=ONLY_SHOW) Sorting(); + list_full_redraw = true; if (redraw!=ONLY_OPEN)&&(!_not_draw) List_ReDraw(); DrawSystemDiscs(); } - if (files.count==-1) && (redraw!=ONLY_OPEN) {files.visible=files.count=0; if(!_not_draw)List_ReDraw();} + if (files.count==-1) && (redraw!=ONLY_OPEN) + { + files.KeyHome(); + if(!_not_draw) { list_full_redraw=true; List_ReDraw(); } + } } @@ -959,14 +914,15 @@ void Del_File(byte dodel) } -void SelectFile(dword that_file) +void SelectFileByName(dword that_file) { - files.first=files.current=0; + int ind; + files.KeyHome(); Open_Dir(#path,ONLY_OPEN); if (!real_files_names_case) strttl(that_file); - for (i=files.count-1; i>=0; i--;) - if (!strcmp(file_mas[i]*304+buf+72,that_file)) break; - List_Current(i); + for (ind=files.count-1; ind>=0; ind--;) { if (!strcmp(file_mas[ind]*304+buf+72,that_file)) break; } + files.current = ind - 1; + files.KeyDown(); List_ReDraw(); } @@ -980,7 +936,7 @@ void Dir_Up() i = strrchr(#path, '/'); strcpy(#cur_folder, #path+i); path[i]=0x00; - SelectFile(#cur_folder); + SelectFileByName(#cur_folder); } void Open(byte rez) @@ -1015,7 +971,7 @@ inline fastcall void GoBack() { char cur_folder[4096]; strcpy(#cur_folder, GetCurrentFolder()); - if (HistoryPath(GO_BACK)) SelectFile(#cur_folder); + if (HistoryPath(GO_BACK)) SelectFileByName(#cur_folder); } void ShowOpenWithDialog() @@ -1078,7 +1034,7 @@ void NewElement(byte newf) } if (CreateDir(#temp)) CreateDir(#file_path); Open_Dir(#path,WITH_REDRAW); - SelectFile(new_file_ed.text); + SelectFileByName(new_file_ed.text); } else { @@ -1089,7 +1045,7 @@ void NewElement(byte newf) else { Del_File(true); - SelectFile(new_file_ed.text); + SelectFileByName(new_file_ed.text); } } } @@ -1100,7 +1056,7 @@ void NewElement(byte newf) } new_element_active = 0; Open_Dir(#path,WITH_REDRAW); - SelectFile(new_file_ed.text); + SelectFileByName(new_file_ed.text); } new_element_active = 0; Open_Dir(#path,WITH_REDRAW); diff --git a/programs/cmm/eolite/include/copy.h b/programs/cmm/eolite/include/copy.h index 5418955899..d6cbfc9a0e 100644 --- a/programs/cmm/eolite/include/copy.h +++ b/programs/cmm/eolite/include/copy.h @@ -183,5 +183,5 @@ void copyf_Draw_Progress(dword copying_filename) { progressbar_draw stdcall (#copy_bar); progressbar_progress stdcall (#copy_bar); //copy_bar.value++; - pause(100); + //pause(10); } \ No newline at end of file diff --git a/programs/cmm/eolite/include/gui.h b/programs/cmm/eolite/include/gui.h index 85b51822ae..cf94b2bd49 100644 --- a/programs/cmm/eolite/include/gui.h +++ b/programs/cmm/eolite/include/gui.h @@ -2,7 +2,7 @@ dword col_palette[14] = {0xD2D3D3,0xD4D4D4,0xD6D5D6,0xD8D7D8,0xDAD8D9,0xDCDADB, 0xDFDCDD,0xE1DDDE,0xE2DEE0,0xE4DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1}; -void Scroll() { +void Scroll(char scroll_used) { dword i; word sc_x = Form.cwidth - 18; diff --git a/programs/cmm/lib/list_box.h b/programs/cmm/lib/list_box.h index 62d9c1f574..1c0f10b265 100644 --- a/programs/cmm/lib/list_box.h +++ b/programs/cmm/lib/list_box.h @@ -14,13 +14,16 @@ struct llist int count, visible, first, current; //visible = row_max int active; void ClearList(); - int ProcessKey(dword key); int MouseOver(int xx, yy); int ProcessMouse(int xx, yy); + int ProcessKey(dword key); int KeyDown(); int KeyUp(); int KeyHome(); int KeyEnd(); + int KeyPgDown(); + int KeyPgUp(); + void CheckDoesValuesOkey(); void SetSizes(int xx, yy, ww, hh, min_hh, line_hh); int MouseScroll(dword scroll_state); int MouseScrollNoSelection(dword scroll_state); @@ -30,14 +33,10 @@ struct llist void llist::debug_values() { - debug("current: "); - debugi(current); - debug("first: "); - debugi(first); - debug("visible: "); - debugi(visible); - debug("count: "); - debugi(count); + char yi[128]; + sprintf(#yi, "%s %d %s %d %s %d %s %d", "current:", current, "first:", first, + "visible:", visible, "count:", count); + debugln(#yi); } @@ -56,7 +55,7 @@ void llist::SetSizes(int xx, yy, ww, hh, min_hh, line_hh) h = hh; min_h = min_hh; line_h = line_hh; - text_y = line_hh / 2 - 4; + text_y = line_h / 2 - 4; visible = h / line_h; column_max = w / 6; //if (visible > count) visible=count; @@ -128,6 +127,8 @@ int llist::ProcessKey(dword key) case ASCII_KEY_UP: return KeyUp(); case ASCII_KEY_HOME: return KeyHome(); case ASCII_KEY_END: return KeyEnd(); + case ASCII_KEY_PGUP: return KeyPgUp(); + case ASCII_KEY_PGDN: return KeyPgDown(); } return 0; } @@ -136,47 +137,82 @@ int llist::KeyDown() { if (current-first+1=count) return 0; + if (current + 1 >= count) return 0; current++; } else { - if (visible+first>=count) return 0; + if (visible + first >= count) return 0; first++; current++; } + if (current < first) || (current > first + visible) + { + first = current; + CheckDoesValuesOkey(); + } return 1; } int llist::KeyUp() { - if (current>first) + if (current > first) { current--; } else { - if (first==0) return 0; + if (first == 0) return 0; first--; current--; } + if (current < first) || (current > first + visible) + { + first = current; + CheckDoesValuesOkey(); + } return 1; } int llist::KeyHome() { if (current==0) && (first==0) return 0; - current=0; - first=0; + current = first = 0; return 1; } int llist::KeyEnd() { if (current==count-1) && (first==count-visible) return 0; - current=count-1; - first=count-visible; + current = count-1; + first = count - visible; return 1; } +int llist::KeyPgUp() +{ + if (count <= visible) return KeyHome(); + if (first == 0) return 0; + first -= visible; + CheckDoesValuesOkey(); + return 1; +} + +int llist::KeyPgDown() +{ + if (count <= visible) return KeyEnd(); + if (first == count - visible) return 0; + first += visible; + CheckDoesValuesOkey(); + return 1; +} + +void llist::CheckDoesValuesOkey() +{ + if (first < 0) first = 0; + if (visible + first > count) first = count - visible; + if (current >= count) current = count - 1; + if (current < 0) current = 0; +} + #endif \ No newline at end of file