Eolite 2.0a: fixes in OpenWith scroll, add End/Home key support

git-svn-id: svn://kolibrios.org@4063 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2013-10-20 22:47:10 +00:00
parent cc2ccf46ee
commit 415e0de801
3 changed files with 35 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@ -106,14 +106,22 @@ void OpenWith()
key = GetKey();
if (key==27) ExitProcess();
if (key==13) { RunProgram(#app_paths[app_list.current].item, #file_path); ExitProcess(); }
if (key==177) //down
if (key==177)
{
if (app_list.KeyDown()) DrawAppList();
}
if (key==178) //up
if (key==178)
{
if (app_list.KeyUp()) DrawAppList();
}
if (key==180)
{
if (app_list.KeyHome()) DrawAppList();
}
if (key==181)
{
if (app_list.KeyEnd()) DrawAppList();
}
break;
case evReDraw: _APP_LIST_DRAW:
@ -144,9 +152,10 @@ void DrawAppList()
Put_icon(#app_paths[index+app_list.first].ext, app_list.x+4, index*app_list.line_h+app_list.y+2, col_bg, 6);
WriteText(app_list.x+25, index*app_list.line_h+app_list.y+7, 0x80, 0, #app_paths[index+app_list.first].item);
}
tiny_scroll.h = app_list.w*app_list.visible/app_list.count;
tiny_scroll.x = app_list.x+app_list.w-SCROLL_WIDTH-1;
tiny_scroll.y = app_list.first * app_list.h / app_list.count + app_list.y;
if (tiny_scroll.y + tiny_scroll.h - app_list.y > app_list.h) tiny_scroll.y = app_list.y + app_list.h - tiny_scroll.h-1;
tiny_scroll.h = app_list.h * app_list.visible / app_list.count;
tiny_scroll.y = app_list.h * app_list.first / app_list.count + app_list.y;
debugi(tiny_scroll.y + tiny_scroll.h - app_list.y - app_list.h);
if (tiny_scroll.y + tiny_scroll.h - app_list.y - app_list.h >= 0) tiny_scroll.y = app_list.y + app_list.h - tiny_scroll.h-1;
DrawBar(tiny_scroll.x, tiny_scroll.y, SCROLL_WIDTH, tiny_scroll.h, 0x555555); //scroll
}

View File

@ -8,6 +8,8 @@ struct llist
void ClearList();
int KeyDown();
int KeyUp();
int KeyHome();
int KeyEnd();
void SetSizes(int xx, yy, ww, hh, min_hh, line_hh);
int MouseScroll(dword scroll_state);
};
@ -51,12 +53,12 @@ int llist::KeyDown()
{
if (current-first+1<visible)
{
if (current+1>=count) return -1;
if (current+1>=count) return 0;
current++;
}
else
{
if (visible+first>=count) return -1;
if (visible+first>=count) return 0;
first++;
current++;
}
@ -71,9 +73,25 @@ int llist::KeyUp()
}
else
{
if (first==0) return -1;
if (first==0) return 0;
first--;
current--;
}
return 1;
}
int llist::KeyHome()
{
if (current==0) && (first==0) return 0;
current=0;
first=0;
return 1;
}
int llist::KeyEnd()
{
if (current==count-1) && (first==count-visible) return 0;
current=count-1;
first=count-visible;
return 1;
}