CMM: optimizations, fixes

git-svn-id: svn://kolibrios.org@4081 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2013-10-24 18:26:04 +00:00
parent a32ea3f480
commit 6ba7bf3033
8 changed files with 49 additions and 59 deletions

View File

@ -142,7 +142,7 @@ void main()
mem_Init(); mem_Init();
if (param) strcpy(#folder_path, #param); if (param) strcpy(#folder_path, #param);
list[SKINS].current = list[WALLPAPERS].current = 0; list[SKINS].current = list[WALLPAPERS].current = -1;
list[SKINS].first = list[WALLPAPERS].first = 0; list[SKINS].first = list[WALLPAPERS].first = 0;
GetFiles(WALLPAPERS); GetFiles(WALLPAPERS);
list[active].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18); list[active].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
@ -154,20 +154,13 @@ void main()
case evMouse: case evMouse:
mm.get(); mm.get();
if (mm.vert) && (list[active].MouseScroll(mm.vert)) Draw_List(); if (mm.vert) && (list[active].MouseScroll(mm.vert)) Draw_List();
/*
if (mouse_clicked) if (mouse_clicked)
{ {
if (!mm.lkm) && (list[active].ProcessMouse(mm.x, mm.y)) Apply(); if (!mm.lkm) && (active==SKINS) && (list[SKINS].ProcessMouse(mm.x, mm.y)) Apply();
if (!mm.lkm) && (active==WALLPAPERS) && (list[WALLPAPERS].ProcessMouse(mm.x, mm.y)) Apply();
mouse_clicked=0; mouse_clicked=0;
} }
if (mm.lkm) && (list[active].MouseOver(mm.x, mm.y)) mouse_clicked=1; if (mm.lkm) && (list[SKINS].MouseOver(mm.x, mm.y)) mouse_clicked=1;
*/
EAX = active;
if (mm.lkm)
{
if (active==SKINS) && (list[SKINS].ProcessMouse(mm.x, mm.y)) Apply();
if if (active==WALLPAPERS) && (list[WALLPAPERS].ProcessMouse(mm.x, mm.y)) Apply();
}
break; break;
case evButton: case evButton:

View File

@ -66,7 +66,7 @@ int action_buf;
void main() void main()
{ {
int btn, key; int key, btn;
int half_scroll_size; int half_scroll_size;
int scroll_used=0, show_menu; int scroll_used=0, show_menu;
@ -98,8 +98,7 @@ void main()
//break; //break;
};*/ };*/
btn=GetProcessSlot(Form.ID); if (!CheckActiveProcess(Form.ID)) break;
if (btn<>GetActiveProcess()) break;
edit_box_mouse stdcall (#address_box); edit_box_mouse stdcall (#address_box);

View File

@ -14,39 +14,36 @@ char *ITEMS_LIST[]={
#endif #endif
0}; 0};
llist menu;
dword col_work = 0xE4DFE1;
dword col_border = 0x9098B0;
void menu_rmb() void menu_rmb()
{ {
mouse mm; mouse mm;
proc_info MenuForm; proc_info MenuForm;
llist menu; int key;
int overid, key, N;
dword col_work = 0xE4DFE1;
dword col_border = 0x9098B0;
menu.first = menu.current = 0; menu.first = menu.current = 0;
while (ITEMS_LIST[menu.count*2]) {menu.count++; menu.visible++;} while (ITEMS_LIST[menu.count*2]) menu.count++;
menu.line_h = 19; menu.SetSizes(2,2,165,menu.count*19,0,19);
menu.w = 165;
menu.h = menu.count * menu.line_h;
SetEventMask(100111b); SetEventMask(100111b);
loop() switch(WaitEvent()) loop() switch(WaitEvent())
{ {
case evMouse: case evMouse:
GetProcessInfo(#MenuForm, SelfInfo); GetProcessInfo(#MenuForm, SelfInfo);
N=GetProcessSlot(MenuForm.ID); if (!CheckActiveProcess(MenuForm.ID)) ExitProcess();
if (N<>GetActiveProcess()) ExitProcess();
mm.get(); mm.get();
if (menu.ProcessMouse(mm.x, mm.y)) goto _ITEMS_DRAW; if (menu.ProcessMouse(mm.x, mm.y)) DrawMenuList();
if (mm.lkm) || (mm.pkm) { action_buf = ITEMS_LIST[menu.current*2+1]; ExitProcess(); } if (mm.lkm) || (mm.pkm) { action_buf = ITEMS_LIST[menu.current*2+1]; ExitProcess(); }
break; break;
case evKey: case evKey:
key = GetKey(); key = GetKey();
if (key==27) ExitProcess(); if (key==27) ExitProcess();
if (menu.ProcessKey(key)) goto _ITEMS_DRAW; if (menu.ProcessKey(key)) DrawMenuList();
if (key==13) if (key==13)
{ {
action_buf = ITEMS_LIST[menu.current*2+1]; action_buf = ITEMS_LIST[menu.current*2+1];
@ -55,26 +52,26 @@ void menu_rmb()
break; break;
case evReDraw: case evReDraw:
DefineAndDrawWindow(Form.left+m.x,Form.top+m.y+GetSkinHeight()+3,menu.w+2,menu.count*menu.line_h+4,0x01, 0, 0, 0x01fffFFF); DefineAndDrawWindow(Form.left+m.x,Form.top+m.y+GetSkinHeight()+3,menu.w+2,menu.h+4,0x01, 0, 0, 0x01fffFFF);
DrawPopup(0,0,menu.w,menu.count*menu.line_h+3,0, col_work,col_border); DrawPopup(0,0,menu.w,menu.h+3,0, col_work,col_border);
DrawMenuList();
_ITEMS_DRAW:
for (N=0; N<menu.count; N++;)
{
if (N==menu.current)
DrawBar(2, N*menu.line_h+2, menu.w-3, menu.line_h, 0x94AECE);
else
{
DrawBar(2, N*menu.line_h+2, menu.w-3, menu.line_h, col_work);
WriteText(19,N*menu.line_h+9,0x80,0xf2f2f2,ITEMS_LIST[N*2]);
}
WriteText(18,N*menu.line_h+8,0x80,0x000000,ITEMS_LIST[N*2]);
}
DrawBar(7, cur_encoding*menu.line_h+9, 4, 4, 0x444444); //show current encoding
} }
} }
void DrawMenuList()
{
int N;
for (N=0; N<menu.count; N++;)
{
if (N==menu.current)
DrawBar(menu.x, N*menu.line_h+menu.y, menu.w-3, menu.line_h, 0x94AECE);
else
{
DrawBar(menu.x, N*menu.line_h+menu.y, menu.w-3, menu.line_h, col_work);
WriteText(19,N*menu.line_h+9,0x80,0xf2f2f2,ITEMS_LIST[N*2]);
}
WriteText(18,N*menu.line_h+8,0x80,0x000000,ITEMS_LIST[N*2]);
}
DrawBar(7, cur_encoding*menu.line_h+9, 4, 4, 0x444444); //show current encoding
}

View File

@ -170,10 +170,8 @@ void main()
loop() switch(WaitEvent()) loop() switch(WaitEvent())
{ {
case evMouse: case evMouse:
IF (del_active) break; if (del_active) || (!CheckActiveProcess(Form.ID)) || (Form.status_window>2) break;
id=GetProcessSlot(Form.ID); if (rename_active) { edit_box_mouse stdcall(#edit2); break; }
IF (id!=GetActiveProcess()) || (Form.status_window>2) break;
IF (rename_active) { edit_box_mouse stdcall(#edit2); break; }
m.get(); m.get();

View File

@ -48,7 +48,7 @@ int cur_action_buf;
void FileMenu() void FileMenu()
{ {
mouse mm; mouse mm;
word slot, key; word key;
proc_info MenuForm; proc_info MenuForm;
int index; int index;
@ -69,8 +69,7 @@ void FileMenu()
loop() switch(WaitEvent()) loop() switch(WaitEvent())
{ {
case evMouse: case evMouse:
slot = GetProcessSlot(MenuForm.ID); if (!CheckActiveProcess(MenuForm.ID)) ExitProcess();
if (slot != GetActiveProcess()) ExitProcess();
mm.get(); mm.get();
if (menu.ProcessMouse(mm.x, mm.y)) MenuListRedraw(); if (menu.ProcessMouse(mm.x, mm.y)) MenuListRedraw();
if (mm.lkm) {action_buf = cur_action_buf; pause(5); ExitProcess(); } if (mm.lkm) {action_buf = cur_action_buf; pause(5); ExitProcess(); }

View File

@ -64,20 +64,19 @@ void OpenWith()
#define PADDING 8 #define PADDING 8
int WIN_H; int WIN_H;
mouse mm; mouse mm;
word key, slot; word key;
proc_info MenuForm; proc_info MenuForm;
app_list.ClearList(); app_list.ClearList();
app_list.SetSizes(PADDING,PANEL_H+1,WIN_W-PADDING-PADDING,OPEN_LIST_VISIBLE_N*OPEN_LIST_LINE_H,150,OPEN_LIST_LINE_H);
if (!app_list.count) if (GetListOfPrograms()==-1) return; if (!app_list.count) if (GetListOfPrograms()==-1) return;
app_list.SetSizes(PADDING,PANEL_H+1,WIN_W-PADDING-PADDING,OPEN_LIST_VISIBLE_N*OPEN_LIST_LINE_H,150,OPEN_LIST_LINE_H);
SetEventMask(100111b); SetEventMask(100111b);
goto _APP_LIST_DRAW; goto _APP_LIST_DRAW;
loop() switch(WaitEvent()) loop() switch(WaitEvent())
{ {
case evMouse: case evMouse:
slot = GetProcessSlot(MenuForm.ID); if (!CheckActiveProcess(MenuForm.ID)) ExitProcess();
if (slot != GetActiveProcess()) ExitProcess();
mm.get(); mm.get();
if (mm.vert) && (app_list.MouseScroll(mm.vert)) DrawAppList(); if (mm.vert) && (app_list.MouseScroll(mm.vert)) DrawAppList();
if (app_list.ProcessMouse(mm.x, mm.y)) DrawAppList(); if (app_list.ProcessMouse(mm.x, mm.y)) DrawAppList();

View File

@ -218,6 +218,13 @@ inline fastcall int GetActiveProcess()
$int 0x40 $int 0x40
} }
:int CheckActiveProcess(int Form_ID)
{
int id=GetProcessSlot(Form_ID);
if (id==GetActiveProcess()) return 1;
return 0;
}
inline fastcall void ActivateWindow( ECX) inline fastcall void ActivateWindow( ECX)
{ {
EAX = 18; EAX = 18;

View File

@ -80,10 +80,8 @@ void window()
loop() switch(WaitEvent()) loop() switch(WaitEvent())
{ {
case evMouse: case evMouse:
if (!CheckActiveProcess(MenuForm.ID)) ExitProcess();
m.get(); m.get();
id1=GetProcessSlot(MenuForm.ID);
if (id1<>GetActiveProcess()) ExitProcess();
id1=m.y-1/ITEM_HEIGHT; id1=m.y-1/ITEM_HEIGHT;
if (m.y<0) || (id1+1>items_num) || (m.x<0) || (m.x>ITEM_WIDTH) break; if (m.y<0) || (id1+1>items_num) || (m.x<0) || (m.x>ITEM_WIDTH) break;
if (m.lkm) || (m.pkm) if (m.lkm) || (m.pkm)