cmm: fix regression which increased all app size

git-svn-id: svn://kolibrios.org@7450 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-10-11 14:32:24 +00:00
parent ce3c40a673
commit bb682b53c1
11 changed files with 71 additions and 58 deletions

View File

@ -196,7 +196,7 @@ void main()
break;
case evReDraw:
if (menu.list.cur_y)
if (menu.cur_y)
{
EventMenuClick();
}
@ -396,7 +396,7 @@ void DrawVerticalScroll()
void EventMenuClick()
{
switch(menu.list.cur_y)
switch(menu.cur_y)
{
//File
case FILE_SUBMENU_ID_OPEN:
@ -413,7 +413,7 @@ void EventMenuClick()
break;
//Encoding
case MENU_ID_ENCODING...MENU_ID_ENCODING+9:
EventChangeEncoding(menu.list.cur_y-MENU_ID_ENCODING);
EventChangeEncoding(menu.cur_y-MENU_ID_ENCODING);
break;
//Reopen
case FILE_SUBMENU_ID_TINYPAD:
@ -435,7 +435,7 @@ void EventMenuClick()
EventOpenFileInAnotherProgram("/sys/develop/heed");
break;
}
menu.list.cur_y = 0;
menu.cur_y = 0;
}
void EventShowMenu(dword _menu_item_x, _menu_list, _id, _selected)

View File

@ -1,9 +1,9 @@
#define MEMSIZE 4096*100
#include "../lib/gui.h"
#include "../lib/kfont.h"
#include "../lib/io.h"
#include "../lib/gui.h"
#include "../lib/list_box.h"
#include "../lib/cursor.h"
#include "../lib/obj/box_lib.h"
#include "../lib/obj/libini.h"
@ -11,7 +11,6 @@
#include "../lib/obj/libimg.h"
#include "../lib/obj/proc_lib.h"
#include "../lib/obj/http.h"
#include "../lib/cursor.h"
#include "../lib/patterns/simple_open_dialog.h"
#include "../lib/patterns/history.h"
@ -111,19 +110,19 @@ void main()
break;
case evReDraw:
draw_window();
if (menu.list.cur_y>=10) && (menu.list.cur_y<20) {
encoding = menu.list.cur_y - 10;
if (menu.cur_y>=10) && (menu.cur_y<20) {
encoding = menu.cur_y - 10;
EventPageRefresh();
menu.list.cur_y = 0;
menu.cur_y = 0;
}
if (menu.list.cur_y>=20) {
menu.list.cur_y-=20;
if (menu.list.cur_y==0) EventPageRefresh();
if (menu.list.cur_y==1) EventRunEdit();
if (menu.list.cur_y==2) EventShowHistory();
if (menu.list.cur_y==3) EventShowDownloader();
if (menu.list.cur_y==4) EventShowInfo();
menu.list.cur_y = 0;
if (menu.cur_y>=20) {
menu.cur_y-=20;
if (menu.cur_y==0) EventPageRefresh();
if (menu.cur_y==1) EventRunEdit();
if (menu.cur_y==2) EventShowHistory();
if (menu.cur_y==3) EventShowDownloader();
if (menu.cur_y==4) EventShowInfo();
menu.cur_y = 0;
}
}
}

View File

@ -152,10 +152,10 @@ void main()
case evReDraw:
draw_window();
if (menu.list.cur_y) {
if (menu.list.cur_y == 10) EventOpenFile();
if (menu.list.cur_y == 11) EventDeleteFile();
menu.list.cur_y = 0;
if (menu.cur_y) {
if (menu.cur_y == 10) EventOpenFile();
if (menu.cur_y == 11) EventDeleteFile();
menu.cur_y = 0;
};
}
}

View File

@ -176,9 +176,9 @@ void main()
break;
case evReDraw:
if (menu.list.cur_y) {
ProcessEvent(menu.list.cur_y);
menu.list.cur_y = 0;
if (menu.cur_y) {
ProcessEvent(menu.cur_y);
menu.cur_y = 0;
}
DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,col_bg,0,0);
GetProcessInfo(#Form, SelfInfo);

View File

@ -55,8 +55,8 @@ void main()
break;
case evReDraw:
if (menu.list.cur_y) {
if (menu.list.cur_y > butv.id) && (menu.list.cur_y < buta.id) category = menu.list.cur_y - butv.id;
if (menu.cur_y) {
if (menu.cur_y > butv.id) && (menu.cur_y < buta.id) category = menu.cur_y - butv.id;
}
DefineAndDrawWindow(215,100,350,300,0x34,0xFFFFFF,"Window header",0);
GetProcessInfo(#Form, SelfInfo);

View File

@ -862,10 +862,10 @@ void EventShowImageMenu()
void EventCheckMenuItemSelected()
{
if (menu.list.cur_y) {
if (20 == menu.list.cur_y) EventCountColorsUsed();
if (21 == menu.list.cur_y) EventReplaceImageColors(color1, color2);
menu.list.cur_y = 0;
if (menu.cur_y) {
if (20 == menu.cur_y) EventCountColorsUsed();
if (21 == menu.cur_y) EventReplaceImageColors(color1, color2);
menu.cur_y = 0;
}
}

View File

@ -19,10 +19,17 @@
#include "../lib/gui/tabs.h"
#include "../lib/gui/more_less_box.h"
#ifndef INCLUDE_CHECKBOX
#include "../lib/gui/checkbox.h"
#endif
#include "../lib/gui/child_window.h"
#include "../lib/gui/text_view_area.h"
#ifndef INCLUDE_MENU_H
#include "../lib/gui/menu.h"
#endif
:int last_free_button_id = 1000;
:int GetFreeButtonId()

View File

@ -1,3 +1,6 @@
#ifndef INCLUDE_CHECKBOX
#define INCLUDE_CHECKBOX
:unsigned char checkbox_flag[507] = {
0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC,
0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4,
@ -86,3 +89,5 @@ struct checkbox
{
draw(x,y);
}
#endif

View File

@ -1,30 +1,31 @@
#ifndef INCLUDE_MENU_H
#define INCLUDE_MENU_H
#ifndef INCLUDE_LIST_BOX
#include "../lib/list_box.h"
#endif
:dword menu_process_id;
:struct _menu
:struct _menu : llist
{
dword appear_x, appear_y, text, identifier, selected;
llist list;
void show();
char stak[4096];
} menu;
void _menu::show(dword _appear_x, _appear_y, _menu_width, _text, _identifier)
:void _menu::show(dword _appear_x, _appear_y, _menu_width, _menu_text, _identifier)
{
#define ITEM_H 21
appear_x = _appear_x;
appear_y = _appear_y;
text = _text;
text = _menu_text;
identifier = _identifier;
list.cur_y = -1;
list.ClearList();
list.count = chrnum(text, '\n')+1;
list.SetSizes(2,2,_menu_width,list.count*ITEM_H,ITEM_H);
cur_y = -1;
ClearList();
count = chrnum(text, '\n')+1;
SetSizes(2,2,_menu_width,count*ITEM_H,ITEM_H);
menu_process_id = CreateThread(#_menu_thread,#stak+4092);
}
@ -39,18 +40,18 @@ void _menu::show(dword _appear_x, _appear_y, _menu_width, _text, _identifier)
GetProcessInfo(#MenuForm, SelfInfo);
if (!CheckActiveProcess(MenuForm.ID)) _menu_no_item_click();
mouse.get();
if (menu.list.ProcessMouse(mouse.x, mouse.y)) _menu_draw_list();
if (menu.ProcessMouse(mouse.x, mouse.y)) _menu_draw_list();
if (mouse.lkm)&&(mouse.up) _menu_item_click();
break;
case evKey:
GetKeys();
if (key_scancode==SCAN_CODE_ESC) _menu_no_item_click();
if (key_scancode==SCAN_CODE_ENTER) _menu_item_click();
if (menu.list.ProcessKey(key_scancode)) _menu_draw_list();
if (menu.ProcessKey(key_scancode)) _menu_draw_list();
break;
case evReDraw:
DefineAndDrawWindow(menu.appear_x,menu.appear_y,menu.list.w+2,menu.list.h+4,0x01, 0, 0, 0x01fffFFF);
DrawPopup(0,0,menu.list.w,menu.list.h+3,0, 0xE4DFE1,0x9098B0);
DefineAndDrawWindow(menu.appear_x,menu.appear_y,menu.w+2,menu.h+4,0x01, 0, 0, 0x01fffFFF);
DrawPopup(0,0,menu.w,menu.h+3,0, 0xE4DFE1,0x9098B0);
_menu_draw_list();
}
}
@ -58,24 +59,24 @@ void _menu::show(dword _appear_x, _appear_y, _menu_width, _text, _identifier)
:void _menu_draw_list()
{
int N, bgcol;
for (N=0; N<menu.list.count; N++;)
for (N=0; N<menu.count; N++;)
{
if (N==menu.list.cur_y) bgcol=0xFFFfff; else bgcol=0xE4DFE1;
DrawBar(menu.list.x, N*menu.list.item_h+menu.list.y, menu.list.w-3, menu.list.item_h, bgcol);
if (N==menu.cur_y) bgcol=0xFFFfff; else bgcol=0xE4DFE1;
DrawBar(menu.x, N*menu.item_h+menu.y, menu.w-3, menu.item_h, bgcol);
}
WriteTextLines(13, menu.list.item_h-8/2+menu.list.y, 0x80, 0, menu.text, menu.list.item_h);
if (menu.selected) WriteText(5, menu.selected-1*menu.list.item_h+8, 0x80, 0xEE0000, "\x10");
WriteTextLines(13, menu.item_h-8/2+menu.y, 0x80, 0, menu.text, menu.item_h);
if (menu.selected) WriteText(5, menu.selected-1*menu.item_h+8, 0x80, 0xEE0000, "\x10");
}
:void _menu_item_click()
{
menu.list.cur_y = menu.identifier + menu.list.cur_y;
menu.cur_y = menu.identifier + menu.cur_y;
KillProcess(menu_process_id);
}
:void _menu_no_item_click()
{
menu.list.cur_y = 0;
menu.cur_y = 0;
KillProcess(menu_process_id);
}

View File

@ -25,21 +25,22 @@
:dword _rgb::RgbToDword()
{
/*
dword _r, _g, _b;
_r = r << 16;
_g = g << 8;
_b = b;
return _r + _g + _b;
*/
EAX = r << 16;
EAX += g << 8;
EAX += b;
}
:dword MixColors(dword _base, _overlying, dword a)
{
_rgb rgb1, rgb2, rgb_final;
dword n_a;
if (a<0) || (a>255) {
debug("Wrong alpha param in MixColors()!");
debugval("alpha", a);
}
rgb1.DwordToRgb(_base);
rgb2.DwordToRgb(_overlying);

View File

@ -97,11 +97,11 @@ void main()
HandleButtonEvent();
break;
case evReDraw:
if (menu.list.cur_y) {
encoding = menu.list.cur_y - 10;
if (menu.cur_y) {
encoding = menu.cur_y - 10;
OpenFile(#param);
PreparePage();
menu.list.cur_y = NULL;
menu.cur_y = NULL;
};
draw_window();
}