Eolite/KFM2: rework header, refactoring, fixes

git-svn-id: svn://kolibrios.org@8952 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2021-06-27 22:16:37 +00:00
parent 298053d7f9
commit 0f76213e5a
6 changed files with 105 additions and 98 deletions

View File

@ -1,11 +1,17 @@
//Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2021 //Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2021
//GNU GPL license. //GNU GPL license.
// 70.5 - get volume info and label /*
TODO:
- fix a kfm2 bug with selected files on window deactivation
- click on a path bar opens edit
- click to show breadcrumbs
- 70.5 - get volume info and label
*/
#define ABOUT_TITLE "EOLITE 5 Beta10" #define ABOUT_TITLE "EOLITE 5 Beta11"
#define TITLE_EOLITE "Eolite File Manager 5 Beta10" #define TITLE_EOLITE "Eolite File Manager 5 Beta11"
#define TITLE_KFM "Kolibri File Manager 2 Beta10"; #define TITLE_KFM "Kolibri File Manager 2 Beta11";
#define MEMSIZE 1024 * 250 #define MEMSIZE 1024 * 250
#include "../lib/clipboard.h" #include "../lib/clipboard.h"
@ -24,10 +30,8 @@
#include "../lib/obj/libimg.h" #include "../lib/obj/libimg.h"
#include "../lib/patterns/history.h" #include "../lib/patterns/history.h"
#include "../lib/patterns/toolbar_button.h"
#include "imgs/images.h" #include "imgs/images.h"
#include "include/const.h" #include "include/const.h"
_history history; _history history;
@ -55,13 +59,6 @@ bool efm = false;
int toolbar_buttons_x[7]={9,46,85,134,167,203}; int toolbar_buttons_x[7]={9,46,85,134,167,203};
bool dir_at_fat16 = NULL;
dword about_thread_id;
dword settings_window;
bool active_about = false;
bool active_settings = false;
byte del_active=0; byte del_active=0;
byte new_element_active=0; byte new_element_active=0;
@ -75,6 +72,7 @@ bool list_full_redraw;
int selected_count; int selected_count;
int folder_count; int folder_count;
dword path; dword path;
bool dir_at_fat16 = NULL;
//Sselected element data //Sselected element data
byte file_path[4096]; byte file_path[4096];
@ -92,13 +90,19 @@ bool list_full_redraw;
int status_bar_h; int status_bar_h;
int icon_size = 18; int icon_size = 18;
int active_panel=0; //Threads data
int disk_popin_active_on_panel=0; dword about_thread_id;
#define PANES_COUNT 2 dword settings_window;
dword location[PANES_COUNT]; bool active_about = false;
bool active_settings = false;
dword about_stak=0,properties_stak=0,settings_stak=0;
byte cmd_free=0;
dword about_stak=0,properties_stak=0,settings_stak=0; //Multipanes
byte cmd_free=0; int active_panel=0;
int disk_popin_active_on_panel=0;
#define PANES_COUNT 2
dword location[PANES_COUNT];
libimg_image icons16_default; libimg_image icons16_default;
libimg_image icons16_selected; libimg_image icons16_selected;
@ -327,13 +331,8 @@ void main()
EventOpenDiskPopin(active_panel); EventOpenDiskPopin(active_panel);
break; break;
case BACK_BTN...PASTE_BTN: case BACK_BTN...PASTE_BTN:
SetActivePanel(0);
EventToolbarButtonClick(id); EventToolbarButtonClick(id);
break; break;
case BACK_BTN+100...PASTE_BTN+100:
SetActivePanel(1);
EventToolbarButtonClick(id-100);
break;
case 31...33: case 31...33:
EventSort(id-30); EventSort(id-30);
break; break;
@ -521,8 +520,8 @@ void draw_window()
if (rand_n) rand_n = random(80); if (rand_n) rand_n = random(80);
if (show_status_bar.checked) { if (show_status_bar.checked) {
#define STBAR_EOLITE_H 16; #define STBAR_EOLITE_H 16
#define STBAR_KFM_H 21+16; #define STBAR_KFM_H 21
if (efm) status_bar_h = STBAR_KFM_H; if (efm) status_bar_h = STBAR_KFM_H;
else status_bar_h = STBAR_EOLITE_H; else status_bar_h = STBAR_EOLITE_H;
} else { } else {
@ -537,7 +536,12 @@ void draw_window()
SetAppColors(); SetAppColors();
if (efm) { if (efm) {
if (screen.width > 693) && (Form.width < 693) { MoveSize(OLD,OLD,693,OLD); return; } if (screen.width > 693) && (Form.width < 693) { MoveSize(OLD,OLD,693,OLD); return; }
DrawBar(0, 0, Form.cwidth, 34, sc.work); DrawBar(0, 4, Form.cwidth, SELECTY-5, sc.work);
DrawBar(0, SELECTY+KFM2_DEVH+1, Form.cwidth, 3, sc.work);
DrawBar(0, SELECTY-1, 1, KFM2_DEVH+2, sc.work);
DrawBar(Form.cwidth-1, SELECTY-1, 1, KFM2_DEVH+2, sc.work);
DrawBar(Form.cwidth/2-16, SELECTY-1, 16, KFM2_DEVH+2, sc.work);
/*
#define PAD 7 #define PAD 7
#define GAP_S 26+5 #define GAP_S 26+5
#define GAP_B 26+14 #define GAP_B 26+14
@ -553,6 +557,7 @@ void draw_window()
i+=100; i+=100;
} }
//DrawTopPanelButton(51, Form.cwidth-GAP_S-PAD, PAD, -1, false); //burger menu //DrawTopPanelButton(51, Form.cwidth-GAP_S-PAD, PAD, -1, false); //burger menu
*/
} else { } else {
if (Form.width < 480) { MoveSize(OLD,OLD,480,OLD); return; } if (Form.width < 480) { MoveSize(OLD,OLD,480,OLD); return; }
ESDWORD[#toolbar_pal] = sc.work; ESDWORD[#toolbar_pal] = sc.work;
@ -574,7 +579,9 @@ void draw_window()
for (i=0; i<6; i++) DrawBar(0, 5-i, Form.cwidth, 1, MixColors(sc.work_light, sc.work, i*10)); for (i=0; i<6; i++) DrawBar(0, 5-i, Form.cwidth, 1, MixColors(sc.work_light, sc.work, i*10));
llist_copy(#files_active, #files); llist_copy(#files_active, #files);
DrawStatusBar(); DrawStatusBar();
if (!selected_count) Open_Dir(path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001] if (!selected_count) {
Open_Dir(path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001]
}
DrawFilePanels(); DrawFilePanels();
disk_popin_active_on_panel = 0; disk_popin_active_on_panel = 0;
} }
@ -619,23 +626,21 @@ void DrawStatusBar()
int go_up_folder_exists=0; int go_up_folder_exists=0;
if (efm) { if (efm) {
DrawBar(0, Form.cheight - status_bar_h+15, Form.cwidth, 3, sc.work); DrawBar(0, Form.cheight - status_bar_h, Form.cwidth, 2, sc.work);
DrawBar(0, Form.cheight - 2, Form.cwidth, 2, sc.work); DrawBar(0, Form.cheight - 2, Form.cwidth, 2, sc.work);
DrawBar(Form.cwidth-1, Form.cheight - 19, 1, 17, sc.work); DrawBar(Form.cwidth-1, Form.cheight - 19, 1, 17, sc.work);
DrawFuncButtonsInKfm(); DrawFuncButtonsInKfm();
DrawPathBar(); } else {
return; if (!show_status_bar.checked) return;
} if (files.count>0) && (streq(items.get(0)*304+buf+72,"..")) go_up_folder_exists=1;
DrawBar(0, Form.cheight - status_bar_h, Form.cwidth, status_bar_h, sc.work);
if (!show_status_bar.checked) return; sprintf(#status_bar_str, T_STATUS_EVEMENTS, folder_count-go_up_folder_exists, files.count-folder_count);
if (files.count>0) && (streq(items.get(0)*304+buf+72,"..")) go_up_folder_exists=1; WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str);
DrawBar(0, Form.cheight - status_bar_h, Form.cwidth, status_bar_h, sc.work); if (selected_count) {
sprintf(#status_bar_str, T_STATUS_EVEMENTS, folder_count-go_up_folder_exists, files.count-folder_count); sprintf(#status_bar_str, T_STATUS_SELECTED, selected_count);
WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str); WriteText(Form.cwidth - calc(strlen(#status_bar_str)*6)-6,Form.cheight - 13,
if (selected_count) { 0x80,sc.work_text,#status_bar_str);
sprintf(#status_bar_str, T_STATUS_SELECTED, selected_count); }
WriteText(Form.cwidth - calc(strlen(#status_bar_str)*6)-6,Form.cheight - 13,
0x80,sc.work_text,#status_bar_str);
} }
} }
@ -650,9 +655,13 @@ void DrawFilePanels()
files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h); files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h);
DrawButtonsAroundList(); DrawButtonsAroundList();
List_ReDraw(); List_ReDraw();
DrawPathBar();
} }
else else
{ {
llist_copy(#files_active, #files);
llist_copy(#files, #files_inactive);
if (!active_panel) { if (!active_panel) {
files.SetSizes(Form.cwidth/2, files_y, w2-17, h2, files.item_h); files.SetSizes(Form.cwidth/2, files_y, w2-17, h2, files.item_h);
} else { } else {
@ -662,8 +671,9 @@ 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(location[active_panel^1],WITH_REDRAW); Open_Dir(path,WITH_REDRAW);
llist_copy(#files_inactive, #files); if (!selected_count) files_inactive.count = files.count;
llist_copy(#files, #files_active);
if (!active_panel) { if (!active_panel) {
files.SetSizes(2, files_y, Form.cwidth/2-2-17, h2, files.item_h); files.SetSizes(2, files_y, Form.cwidth/2-2-17, h2, files.item_h);
@ -673,7 +683,7 @@ void DrawFilePanels()
DrawButtonsAroundList(); DrawButtonsAroundList();
path = location[active_panel]; path = location[active_panel];
Open_Dir(location[active_panel],WITH_REDRAW); Open_Dir(path,WITH_REDRAW);
} }
} }
@ -828,8 +838,7 @@ void Open_Dir(dword dir_path, redraw){
selected_count = 0; selected_count = 0;
if (buf) free(buf); if (buf) free(buf);
errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT); if (errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT))
if (errornum)
{ {
history.add(path); history.add(path);
EventHistoryGoBack(); EventHistoryGoBack();
@ -846,11 +855,11 @@ void Open_Dir(dword dir_path, redraw){
Sorting(); Sorting();
list_full_redraw = true; list_full_redraw = true;
SetCurDir(dir_path); SetCurDir(dir_path);
DrawPathBar();
if (redraw!=ONLY_OPEN) { if (redraw!=ONLY_OPEN) {
history.add(path); history.add(path);
List_ReDraw(); List_ReDraw();
DrawStatusBar(); DrawStatusBar();
DrawPathBar();
} }
} }
@ -955,6 +964,7 @@ void Dir_Up()
strcpy(#old_folder_name, path+iii); strcpy(#old_folder_name, path+iii);
if (iii>1) ESBYTE[path+iii-1]=NULL; else ESBYTE[path+iii]=NULL; if (iii>1) ESBYTE[path+iii-1]=NULL; else ESBYTE[path+iii]=NULL;
SelectFileByName(#old_folder_name); SelectFileByName(#old_folder_name);
if(efm)DrawPathBarKfm();
} }
void EventOpenSelected() void EventOpenSelected()
@ -1369,10 +1379,10 @@ void EventOpenDiskPopin(int panel_n)
DefineHiddenButton(0,0,5000,3000,9999+BT_NOFRAME); DefineHiddenButton(0,0,5000,3000,9999+BT_NOFRAME);
if (panel_n==0) { if (panel_n==0) {
disk_popin_active_on_panel = 1; disk_popin_active_on_panel = 1;
SystemDiscs.DrawOptions(Form.cwidth/2-DDW); SystemDiscs.DrawOptions(1);
} else { } else {
disk_popin_active_on_panel = 2; disk_popin_active_on_panel = 2;
SystemDiscs.DrawOptions(Form.cwidth-DDW-2); SystemDiscs.DrawOptions(Form.cwidth/2-1);
} }
} }

View File

@ -4,7 +4,7 @@
// // // //
//===================================================// //===================================================//
#ifdef LANG_RUS #ifdef LANG_RUS
#define T_FILE "” ©«" #define T_FILE "ˆ¬ï"
#define T_TYPE "’¨¯" #define T_TYPE "’¨¯"
#define T_SIZE "<22> §¬¥à" #define T_SIZE "<22> §¬¥à"
#define T_NEW_FOLDER "<22>®¢ ï ¯ ¯ª " #define T_NEW_FOLDER "<22>®¢ ï ¯ ¯ª "
@ -68,7 +68,7 @@ char *actions[] = {
// // // //
//===================================================// //===================================================//
#else #else
#define T_FILE "File" #define T_FILE "Name"
#define T_TYPE "Type" #define T_TYPE "Type"
#define T_SIZE "Size" #define T_SIZE "Size"
#define T_NEW_FOLDER "New folder" #define T_NEW_FOLDER "New folder"
@ -180,5 +180,6 @@ char *devinfo = {
}; };
#define DEV_H 17 #define DEV_H 17
#define DDW 120 #define DDW 110
#define KFM2_DEVH 20 #define KFM2_DEVH 20
#define SELECTY 10

View File

@ -107,13 +107,13 @@ void PasteThread()
char copy_rezult; char copy_rezult;
int j, i, slash_count=0; int j, i, slash_count=0;
int paste_elements_count = 0; int paste_elements_count = 0;
dword buf; dword clipbuf;
dword path_offset; dword path_offset;
buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1); clipbuf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1);
if (DSDWORD[buf+4] != 3) return; if (DSDWORD[clipbuf+4] != 3) return;
paste_elements_count = ESINT[buf+8]; paste_elements_count = ESINT[clipbuf+8];
path_offset = buf + 10; path_offset = clipbuf + 10;
if (cut_active) { if (cut_active) {
DisplayOperationForm(MOVE_FLAG); DisplayOperationForm(MOVE_FLAG);
@ -138,13 +138,13 @@ void PasteThread()
} }
_DIFFERENT_DRIVES: _DIFFERENT_DRIVES:
path_offset = buf + 10; path_offset = clipbuf + 10;
for (j = 0; j < paste_elements_count; j++) { for (j = 0; j < paste_elements_count; j++) {
copy_bar.max += GetFilesCount(path_offset); copy_bar.max += GetFilesCount(path_offset);
path_offset += strlen(path_offset) + 1; path_offset += strlen(path_offset) + 1;
} }
path_offset = buf + 10; path_offset = clipbuf + 10;
for (j = 0; j < paste_elements_count; j++) { for (j = 0; j < paste_elements_count; j++) {
strcpy(#copy_from, path_offset); strcpy(#copy_from, path_offset);
if (!copy_from) DialogExit(); if (!copy_from) DialogExit();
@ -212,23 +212,23 @@ void DeleteThread()
{ {
int j; int j;
int elements_count = 0; int elements_count = 0;
dword buf; dword clipbuf;
dword path_offset; dword path_offset;
DisplayOperationForm(DELETE_FLAG); DisplayOperationForm(DELETE_FLAG);
buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1); clipbuf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1);
Clipboard__DeleteLastSlot(); Clipboard__DeleteLastSlot();
if (DSDWORD[buf+4] != 3) return; if (DSDWORD[clipbuf+4] != 3) return;
elements_count = ESINT[buf+8]; elements_count = ESINT[clipbuf+8];
path_offset = buf + 10; path_offset = clipbuf + 10;
for (j = 0; j < elements_count; j++) { for (j = 0; j < elements_count; j++) {
copy_bar.max += GetFilesCount(path_offset); copy_bar.max += GetFilesCount(path_offset);
path_offset += strlen(path_offset) + 1; path_offset += strlen(path_offset) + 1;
} }
path_offset = buf + 10; path_offset = clipbuf + 10;
for (j = 0; j < elements_count; j++) { for (j = 0; j < elements_count; j++) {
RecursiveDelete(path_offset, true); RecursiveDelete(path_offset, true);
path_offset += strlen(path_offset) + 1; path_offset += strlen(path_offset) + 1;

View File

@ -171,9 +171,13 @@ void DrawPathBar()
{ {
if (efm) { if (efm) {
DrawPathBarKfm(); DrawPathBarKfm();
return; } else {
DrawPathEolite();
} }
}
void DrawPathEolite()
{
if (show_breadcrumb.checked) { if (show_breadcrumb.checked) {
DrawBreadCrumbs(); DrawBreadCrumbs();
return; return;
@ -188,7 +192,7 @@ void DrawPathBar()
DefineHiddenButton(PathShow.start_x-4+1,PathShow.start_y-7+1,PathShow.area_size_x+4-2,20-2,PATH_BTN); DefineHiddenButton(PathShow.start_x-4+1,PathShow.start_y-7+1,PathShow.area_size_x+4-2,20-2,PATH_BTN);
DrawBar(PathShow.start_x-4, PathShow.start_y+14, PathShow.area_size_x+5+18, 1, sc.work_light); DrawBar(PathShow.start_x-4, PathShow.start_y+14, PathShow.area_size_x+5+18, 1, sc.work_light);
DrawFlatButtonSmall(PathShow.start_x+PathShow.area_size_x,PathShow.start_y-7,18,20, 61, "\26"); DrawFlatButtonSmall(PathShow.start_x+PathShow.area_size_x,PathShow.start_y-7,18,20, 61, "\x19");
PathShow.font_color = col.list_gb_text; PathShow.font_color = col.list_gb_text;
PathShow_prepare stdcall(#PathShow); PathShow_prepare stdcall(#PathShow);
@ -197,36 +201,31 @@ void DrawPathBar()
void DrawPathBarKfm() void DrawPathBarKfm()
{ {
dword bgc; dword back_color, text_color;
int draw_x, draw_w;
int i=0; int i=0;
if (!Form.cwidth) return; if (!Form.cwidth) return;
if (skin_is_dark()) { if (skin_is_dark()) {
bgc = col.odd_line; back_color = col.odd_line;
PathShow.font_color = col.list_gb_text; text_color = col.list_gb_text;
} else { } else {
bgc = 0xFFFFCC; back_color = 0xFFFFCC;
PathShow.font_color = 0x222222; text_color = 0x222222;
} }
PathShow.start_y = Form.cheight - status_bar_h+2; draw_x = 3 + DDW;
draw_w = Form.cwidth/2 - draw_x - 17;
PathShow.start_x = 4;
PathShow.area_size_x = Form.cwidth/2-8;
do { do {
DrawBar(PathShow.start_x-2,PathShow.start_y-3,PathShow.area_size_x+5,14,bgc); DrawBar(draw_x, SELECTY-1, draw_w-KFM2_DEVH+1, 1, sc.work_graph);
DrawRectangle(PathShow.start_x-3,PathShow.start_y-4,PathShow.area_size_x+6,15,sc.work_graph); DrawBar(draw_x, SELECTY, draw_w-KFM2_DEVH+1, KFM2_DEVH, back_color);
PathShow.text_pointer = location[i]; DrawBar(draw_x, SELECTY+KFM2_DEVH, draw_w-KFM2_DEVH+1, 1, sc.work_graph);
PathShow_prepare stdcall(#PathShow); kfont.WriteIntoWindow(draw_x + 3, math.max(KFM2_DEVH-kfont.height/2+SELECTY,0),
PathShow_draw stdcall(#PathShow); back_color, text_color, kfont.size.pt, location[i]+strrchr(location[i], '/'));
DrawFlatButtonSmall(draw_x+draw_w-KFM2_DEVH+1, SELECTY-1, KFM2_DEVH-1, KFM2_DEVH+1, 576+i, "\x19");
PathShow.start_x = Form.cwidth/2 + 2; draw_x = Form.cwidth/2 + DDW + 1;
PathShow.area_size_x = Form.cwidth - PathShow.start_x - 5; draw_w = Form.cwidth - draw_x - 2;
i++; i++;
} while (i<2); } while (i<2);
DrawBar(0,PathShow.start_y-2,1,15,sc.work);
DrawBar(Form.cwidth-1,PathShow.start_y-2,1,15,sc.work);
DrawBar(1,PathShow.start_y+12,Form.cwidth-2,1,sc.work_light);
} }
//===================================================// //===================================================//
@ -262,8 +261,6 @@ void DrawBreadCrumbs()
DrawBreadcrumbButton(btn.x, btn.y, btn.w, btn.h, i+BREADCRUMB_ID, text_line); DrawBreadcrumbButton(btn.x, btn.y, btn.w, btn.h, i+BREADCRUMB_ID, text_line);
btn.x += btn.w; btn.x += btn.w;
} }
//DrawFavButton(btn.x);
//btn.x+=20;
btn.x++; btn.x++;
DrawBar(btn.x,btn.y-1,Form.cwidth-btn.x-25,btn.h+3,sc.work); DrawBar(btn.x,btn.y-1,Form.cwidth-btn.x-25,btn.h+3,sc.work);
} }

View File

@ -64,8 +64,8 @@ void _SystemDiscs::Draw()
int draw_y, draw_x; int draw_y, draw_x;
if (efm) { if (efm) {
DrawSelect(Form.cwidth/2-DDW, KFM_DEV_DROPDOWN_1, location[0]); DrawSelect(2, KFM_DEV_DROPDOWN_1, location[0]);
DrawSelect(Form.cwidth-DDW-2, KFM_DEV_DROPDOWN_2, location[sizeof(dword)]); DrawSelect(Form.cwidth/2, KFM_DEV_DROPDOWN_2, location[sizeof(dword)]);
files.y = 40 + 17; files.y = 40 + 17;
} else { } else {
Tip(56, T_DEVICES, 55, "="); Tip(56, T_DEVICES, 55, "=");
@ -97,14 +97,13 @@ void _SystemDiscs::Draw()
draw_y += DEV_H; draw_y += DEV_H;
} }
DrawBar(draw_x+6, draw_y, 18, 1, 0xFFFfff); DrawBar(draw_x+6, draw_y, 18, 1, 0xFFFfff);
ActionsDraw(SystemDiscs.list.count*DEV_H+108); ActionsDraw(list.count*DEV_H+108);
DrawLeftPanelBg(SystemDiscs.list.count*DEV_H); DrawLeftPanelBg(list.count*DEV_H);
} }
} }
void _SystemDiscs::DrawSelect(int draw_x, btid, dword _path) void _SystemDiscs::DrawSelect(int draw_x, btid, dword _path)
{ {
#define SELECTY 10
char dev_name[15], disc_name[100], i, dev_icon; char dev_name[15], disc_name[100], i, dev_icon;
if (ESBYTE[_path+1]=='\0') { if (ESBYTE[_path+1]=='\0') {

View File

@ -1,5 +1,5 @@
unsigned int DrawTopPanelButton(dword _button_id, _x, _y, signed int _icon_n, bool pressed) :unsigned int DrawTopPanelButton(dword _button_id, _x, _y, signed int _icon_n, bool pressed)
{ {
#define TSZE 25 #define TSZE 25
static libimg_image top_icons; static libimg_image top_icons;