Eolite 2.50: better code, a little bit faster and smaller

git-svn-id: svn://kolibrios.org@5441 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2015-02-21 12:24:30 +00:00
parent 595abd6a2b
commit f6f01fd6de
4 changed files with 49 additions and 51 deletions

View File

@ -83,8 +83,8 @@
enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir
#define TITLE "Eolite File Manager v2.49"
#define ABOUT_TITLE "Eolite v2.49"
#define TITLE "Eolite File Manager v2.50"
#define ABOUT_TITLE "Eolite v2.50"
dword col_padding, col_selec, col_lpanel;
int toolbar_buttons_x[7]={9,46,85,134,167,203};
@ -113,6 +113,8 @@ byte
sort_num=2,
itdir;
dword eolite_ini_path;
proc_info Form;
system_colors sc;
mouse m;
@ -142,15 +144,15 @@ void main()
{
word key, id, can_show, can_select, m_selected;
dword selected_offset;
randomize();
rand_n = random(40);
files.line_h=18;
mem_Init();
if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(ERROR_1);
if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini");
SystemDiscsGet();
GetIni();
eolite_ini_path = abspath("Eolite.ini");
LoadIniSettings();
GetSystemDiscs();
SetAppColors();
if (param)
{
@ -226,7 +228,7 @@ void main()
if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>40) && (m.y<files.y)
{
IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),41,14,14,0xC7C7C7,0xFFFFFF);
IF (m.lkm==1) DrawRectangle3D(Form.cwidth - 17,41,14,14,0xC7C7C7,0xFFFFFF);
WHILE (m.lkm==1) && (files.first>0)
{
pause(8);
@ -234,12 +236,12 @@ void main()
List_ReDraw();
m.get();
}
DrawRectangle3D(onLeft(26,0),41,14,14,0xFFFFFF,0xC7C7C7);
DrawRectangle3D(Form.cwidth - 17,41,14,14,0xFFFFFF,0xC7C7C7);
}
if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>onTop(22,0)+1) && (m.y<onTop(22,0)+16)
{
IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xC7C7C7,0xFFFFFF);
IF (m.lkm==1) DrawRectangle3D(Form.cwidth - 17,onTop(21,0),14,14,0xC7C7C7,0xFFFFFF);
while (m.lkm==1) && (files.first<files.count-files.visible)
{
pause(8);
@ -247,7 +249,7 @@ void main()
List_ReDraw();
m.get();
}
DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xFFFFFF,0xC7C7C7);
DrawRectangle3D(Form.cwidth - 17,onTop(21,0),14,14,0xFFFFFF,0xC7C7C7);
}
//Scrooll
@ -327,7 +329,7 @@ void main()
tmp_disk_del_param[1] = id - 130 + 48;
RunProgram("/sys/tmpdisk", #tmp_disk_del_param);
pause(10);
SystemDiscsGet();
GetSystemDiscs();
Open_Dir(#path,WITH_REDRAW);
DrawLeftPanel();
//m.get();
@ -479,7 +481,7 @@ void draw_window()
DefineAndDrawWindow(GetScreenWidth()-550/4+rand_n,rand_n+30,550,500,0x73,sc.work,TITLE,0);
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) return;
files.SetSizes(192, 57, onLeft(192,27), onTop(57,6), disc_num*16+195,files.line_h);
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
@ -488,10 +490,10 @@ void draw_window()
DrawBar(127, 8, 1, 25, sc.work_graph);
for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,sc.work);
for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,sc.work);
DrawBar(246,0,onLeft(246,60),12, sc.work); //upper editbox
DrawBar(246,29,onLeft(246,60),5,sc.work); //under editbox
DrawRectangle(246,12,onLeft(66,246),16,sc.work_graph);
DefineButton(onLeft(34,0),6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about
DrawBar(246,0,Form.cwidth - 297,12, sc.work); //upper editbox
DrawBar(246,29,Form.cwidth - 297,5,sc.work); //under editbox
DrawRectangle(246,12,Form.cwidth - 303,16,sc.work_graph);
DefineButton(Form.cwidth - 25,6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about
PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal);
//main rectangles
DrawRectangle(1,40,Form.cwidth-3,onTop(46,0),sc.work_graph);
@ -499,9 +501,9 @@ void draw_window()
for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]);
DrawLeftPanel();
//ListBox
DrawFlatButton(files.x,40,onLeft(files.x,168),16,31,sc.work,T_FILE);
DrawFlatButton(onLeft(168,0),40,73,16,32,sc.work,T_TYPE);
DrawFlatButton(onLeft(95,0),40,68,16,33,sc.work,T_SIZE);
DrawFlatButton(files.x,40,Form.cwidth + files.x - 159,16,31,sc.work,T_FILE);
DrawFlatButton(Form.cwidth + 159,40,73,16,32,sc.work,T_TYPE);
DrawFlatButton(Form.cwidth + 96,40,68,16,33,sc.work,T_SIZE);
DrawBar(files.x+files.w,files.y,1,onTop(22,files.y),sc.work_graph); //line to the left from the scroll
DrawFlatButton(files.x+files.w,40,16,16,0,sc.work,"\x18");
DrawFlatButton(files.x+files.w,onTop(22,0),16,16,0,sc.work,"\x19");
@ -614,7 +616,7 @@ void Line_ReDraw(dword color, filenum){
if (! TestBit(file.attr, 4) ) //file or folder?
{
Put_icon(file_name_off+_strrchr(file_name_off,'.'), files.x+3, files.line_h/2-7+y, color, 0);
WriteText(7-strlen(ConvertSize(file.sizelo))*6+onLeft(75,0),files.line_h-6/2+y,0x80,0,ConvertSize(file.sizelo));
WriteText(7-strlen(ConvertSize(file.sizelo))*6+Form.cwidth - 76,files.line_h-6/2+y,0x80,0,ConvertSize(file.sizelo));
}
else
{
@ -957,8 +959,8 @@ void FnProcess(char N)
Tip(56, T_DEVICES, 55, "-");
Open_Dir(#path,WITH_REDRAW);
pause(10);
GetIni();
SystemDiscsGet();
LoadIniSettings();
GetSystemDiscs();
Open_Dir(#path,WITH_REDRAW);
DrawLeftPanel();
break;
@ -1006,7 +1008,6 @@ void FnProcess(char N)
}
//need to remove these functiones, they are a very old shit :)
dword onLeft(dword right,left) {EAX=Form.width-right-left;}
dword onTop(dword down,up) {EAX=Form.height-GetSkinHeight()-down-up;}

View File

@ -16,17 +16,17 @@ inline fastcall void Scroll() { //
if (scroll_size<20) scroll_size = 20; //устанавливаем минимальный размер скролла
if (scroll_size>onTop(22,57)-on_y+56) || (files.first+files.visible>=files.count) on_y=onTop(23+scroll_size,0); //для большого списка
}
DrawFlatButton(onLeft(27,0),on_y,16,scroll_size,0,-1,"");//ïîëçóíîê
if (!scroll_used) for (i=0; i<13; i++) DrawBar(onLeft(25-i,0), on_y+2, 1, scroll_size-3, col_palette[13-i]);
if (scroll_used) for (i=0; i<13; i++) DrawBar(onLeft(25-i,0), on_y+2, 1, scroll_size-3, col_palette[i]);
DrawFlatButton(Form.cwidth - 18,on_y,16,scroll_size,0,-1,"");//ïîëçóíîê
if (!scroll_used) for (i=0; i<13; i++) DrawBar(Form.cwidth - 16 + i, on_y+2, 1, scroll_size-3, col_palette[13-i]);
if (scroll_used) for (i=0; i<13; i++) DrawBar(Form.cwidth - 16 + i, on_y+2, 1, scroll_size-3, col_palette[i]);
//поле до ползунка
if (on_y>58) DrawBar(onLeft(26,0),57,15,1, 0xC7C9C9);
DrawBar(onLeft(26,0),58,1, on_y-58,0xC7C9C9);
DrawBar(onLeft(25,0),58,14,on_y-58,0xCED0D0);
if (on_y>58) DrawBar(Form.cwidth - 17,57,15,1, 0xC7C9C9);
DrawBar(Form.cwidth - 17,58,1, on_y-58,0xC7C9C9);
DrawBar(Form.cwidth - 16,58,14,on_y-58,0xCED0D0);
//поле после ползунка
if (onTop(22,57)-scroll_size+55>on_y) DrawBar(onLeft(26,0),on_y+scroll_size+1,15,1,0xC7C9C9);
DrawBar(onLeft(26,0),on_y+scroll_size+2,1,onTop(22,57)-scroll_size-on_y+55,0xC7C9C9);
DrawBar(onLeft(25,0),on_y+scroll_size+2,14,onTop(22,57)-scroll_size-on_y+55,0xCED0D0);
if (onTop(22,57)-scroll_size+55>on_y) DrawBar(Form.cwidth - 17,on_y+scroll_size+1,15,1,0xC7C9C9);
DrawBar(Form.cwidth - 17,on_y+scroll_size+2,1,onTop(22,57)-scroll_size-on_y+55,0xC7C9C9);
DrawBar(Form.cwidth - 16,on_y+scroll_size+2,14,onTop(22,57)-scroll_size-on_y+55,0xCED0D0);
}
void DrawFlatButton(dword x,y,width,height,id,color,text)

View File

@ -47,7 +47,7 @@ int disc_num;
dword devbuf;
void SystemDiscsGet()
void GetSystemDiscs()
{
char dev_name[10], sys_discs[10];
int i1, j1, dev_num, dev_disc_num;
@ -85,7 +85,7 @@ void SystemDiscsGet()
}
void SystemDiscsDraw()
void DrawSystemDiscs()
{
char dev_name[15], disc_name[100];
int i, dev_icon;
@ -161,7 +161,7 @@ void ActionsDraw()
}
void LeftPanelBgDraw()
void DrawLeftPanelBg()
{
int actions_y=disc_num*16;
int start_y = actions_y+156;
@ -185,7 +185,7 @@ void LeftPanelBgDraw()
void DrawLeftPanel()
{
SystemDiscsDraw();
DrawSystemDiscs();
ActionsDraw();
LeftPanelBgDraw();
DrawLeftPanelBg();
}

View File

@ -31,7 +31,6 @@ void settings_dialog()
byte id;
unsigned int key;
proc_info settings_form;
dword eolite_ini_path = abspath("Eolite.ini");
if (active_about) ExitProcess();
active_about=1;
@ -46,11 +45,7 @@ void settings_dialog()
id=GetButtonID();
if (id==10)
{
if ( asm test ShowDeviceName_chb.flags, 2) ini_set_int stdcall (eolite_ini_path, "Config", "ShowDeviceName", 1);
ELSE ini_set_int stdcall (eolite_ini_path, "Config", "ShowDeviceName", 0);
if ( asm test RealFileNamesCase_chb.flags, 2) ini_set_int stdcall (eolite_ini_path, "Config", "RealFileNamesCase", 1);
ELSE ini_set_int stdcall (eolite_ini_path, "Config", "RealFileNamesCase", 0);
if (LineHeight_ed.size) ini_set_int stdcall (eolite_ini_path, "Config", "LineHeight", atoi(#lineh_s));
SaveIniSettings();
active_about=0;
action_buf = 300;
ExitProcess();
@ -109,9 +104,8 @@ void settings_dialog()
}
void GetIni()
void LoadIniSettings()
{
dword eolite_ini_path = abspath("Eolite.ini");
ini_get_color stdcall (eolite_ini_path, "Config", "SelectionColor", 0x94AECE);
edit2.shift_color = EAX;
col_selec = EAX;
@ -123,6 +117,16 @@ void GetIni()
real_files_names_case = EAX;
}
void SaveIniSettings()
{
if (ShowDeviceName_chb.flags==6) show_dev_name=1; else show_dev_name=0;
if (RealFileNamesCase_chb.flags==6) real_files_names_case=1; else real_files_names_case=0;
ini_set_int stdcall (eolite_ini_path, "Config", "ShowDeviceName", show_dev_name);
ini_set_int stdcall (eolite_ini_path, "Config", "RealFileNamesCase", real_files_names_case);
ini_set_int stdcall (eolite_ini_path, "Config", "LineHeight", atoi(#lineh_s));
}
void Write_Error(int error_number)
{
@ -147,11 +151,4 @@ void SetAppColors()
col_padding = 0xC8C9C9;
//col_selec = 0x94AECE;
col_lpanel = 0x00699C;
/*
sc.get();
for (i=0; i<=14; i++) col_palette[i] = sc.work;
toolbar_pal[0]= goto_about_pal[0] = sc.work = sc.work;
col_lpanel = sc.work_graph;
for (i=0; i<=99; i++) blue_hl_pal[i] = sc.work_graph;
*/
}