font.h: code clear, prepare draw in bug function, webview simplify scroll code

git-svn-id: svn://kolibrios.org@5782 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2015-09-01 13:11:07 +00:00
parent 31fc4fdbc0
commit 76d05f09cc
2 changed files with 89 additions and 87 deletions

View File

@ -128,21 +128,12 @@ void main()
if (bufsize) && (mouse.pkm) && (mouse.up) { CreateThread(#menu_rmb,#stak+4092); break; } if (bufsize) && (mouse.pkm) && (mouse.up) { CreateThread(#menu_rmb,#stak+4092); break; }
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
} }
//Drag scroller scrollbar_v_mouse (#scroll_wv);
scroll_wv.all_redraw = 0; if (WB1.list.first != scroll_wv.position)
if (!mouse.lkm) scroll_used=0;
if (mouse.x>=scroll_wv.start_x) && (mouse.x<=scroll_wv.start_x+scroll_wv.size_x)
&& (mouse.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>mouse.y)
&& (WB1.list.count>WB1.list.visible) && (mouse.lkm) scroll_used=1;
if (scroll_used)
{ {
mouse.y = mouse.y + 5; WB1.list.first = scroll_wv.position;
half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2; WB1.DrawPage();
if (half_scroll_size+WB1.list.y>mouse.y) || (mouse.y<0) || (mouse.y>4000) mouse.y=half_scroll_size+WB1.list.y; break;
btn=WB1.list.first;
WB1.list.first = mouse.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
if (btn!=WB1.list.first) WB1.DrawPage();
} }
break; break;

View File

@ -9,10 +9,6 @@
#include "../lib/io.h" #include "../lib/io.h"
#endif #endif
#define CP866 0
#define ANSI 1
:struct __SIZE :struct __SIZE
{ {
word width,height; word width,height;
@ -38,43 +34,34 @@
byte symbol(word x;byte s;dword c); byte symbol(word x;byte s;dword c);
byte symbol_size(byte s); byte symbol_size(byte s);
dword prepare(word x,y;dword text1); dword prepare(word x,y;dword text1);
void prepare_buf(word x,y,w,h;dword text1);
void show(word x,y); void show(word x,y);
byte textcenter(word x,y,w,h;dword txt); byte textcenter(word x,y,w,h;dword txt);
dword getsize(dword text1); dword getsize(dword text1);
dword textarea(word x,y;dword text,c); dword textarea(word x,y;dword text,c);
byte changeSIZE(); byte changeSIZE();
void PixelRGB(word x,y); void PixelRGB(word x,y);
dword GetPixel(word x,y); //dword GetPixel(word x,y);
dword tmp_y,tmp_height,tmp_x;
byte no_bg_copy; byte no_bg_copy;
dword bg_color; dword bg_color;
}; };
FONT font = 0; FONT font = 0;
/*
:dword FONT::GetPixel(word x,y) :dword FONT::GetPixel(word x,y)
{ {
dword tmp; dword tmp = y*size.width*3;
tmp = y*size.width*3; tmp += x*3 + buffer;
tmp += x*3;
tmp += buffer;
r = DSBYTE[tmp]; r = DSBYTE[tmp];
tmp++; g = DSBYTE[tmp+1];
g = DSBYTE[tmp]; b = DSBYTE[tmp+2];
tmp++; }*/
b = DSBYTE[tmp];
}
:void FONT::PixelRGB(dword x,y) :void FONT::PixelRGB(dword x,y)
{ {
dword tmp; dword tmp = y*size.width*3;
tmp = y*size.width*3; tmp += x*3 + buffer;
tmp += x*3;
tmp += buffer;
DSBYTE[tmp] = r; DSBYTE[tmp] = r;
tmp++; DSBYTE[tmp+1] = g;
DSBYTE[tmp] = g; DSBYTE[tmp+2] = b;
tmp++;
DSBYTE[tmp] = b;
} }
:byte FONT::changeSIZE() :byte FONT::changeSIZE()
{ {
@ -163,8 +150,7 @@ FONT font = 0;
} }
yi = 0; yi = 0;
iii = 0; iii = 0;
tmp = 4*block*s; tmp = 4*block*s + data;
tmp +=data;
while(yi<height) while(yi<height)
{ {
xi = 0; xi = 0;
@ -199,7 +185,6 @@ FONT font = 0;
{ {
signed len=0; signed len=0;
dword c; dword c;
word _tmp_h;
c = color; c = color;
IF(!text1)return false; IF(!text1)return false;
IF(size.text)IF(!changeSIZE())return false; IF(size.text)IF(!changeSIZE())return false;
@ -214,7 +199,6 @@ FONT font = 0;
b = AL; b = AL;
getsize(text1); getsize(text1);
y -= size.offset_y; y -= size.offset_y;
tmp_y = y;
EDX = size.width*size.height*3; EDX = size.width*size.height*3;
IF(!buffer_size) IF(!buffer_size)
@ -305,60 +289,87 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
tmp +=data; tmp +=data;
while(yi<height) while(yi<height)
{ {
xi = 0; xi = 0;
TMP = size.offset_y+yi; TMP = size.offset_y+yi;
while(xi<width) while(xi<width)
{ {
IF(iii%32) _ >>= 1; IF(iii%32) _ >>= 1;
ELSE ELSE
{ {
tmp += 4; tmp += 4;
_ = DSDWORD[tmp]; _ = DSDWORD[tmp];
} }
if(_&1) if(_&1)
{ {
IF(xi>rw)rw=xi; IF(xi>rw)rw=xi;
___x = x+xi; ___x = x+xi;
IF(italic)___x+=math.ceil(ital); IF(italic)___x+=math.ceil(ital);
if(___x<Form_SELF_FONTS.cwidth)&&(tmp_y+yi<Form_SELF_FONTS.cheight) PixelRGB(___x,TMP);
{ _TMP_WEIGHT = size.TMP_WEIGHT;
PixelRGB(___x,TMP); WHILE(_TMP_WEIGHT)
_TMP_WEIGHT = size.TMP_WEIGHT; {
WHILE(_TMP_WEIGHT) IF(weight) PixelRGB(___x+_TMP_WEIGHT,TMP);
{ _TMP_WEIGHT--;
IF(weight) PixelRGB(___x+_TMP_WEIGHT,TMP); }
_TMP_WEIGHT--; }
} xi++;
} iii++;
} }
xi++; yi++;
iii++; IF(italic) ital-=size.offset_i;
}
yi++;
IF(italic) ital-=size.offset_i;
} }
return rw; return rw;
} }
:byte FONT::load(dword path) :byte FONT::load(dword path)
{ {
dword tmp;
buffer_size = 0; buffer_size = 0;
IF(data)free(data); IF(data)free(data);
if (!io.readKPACK(path)) if (!io.readKPACK(path)) { debug("Error while loading font: "); debugln(path); return false; }
{ begin = data = io.buffer_data;
debug("Error while loading font: ");
debugln(path);
return false;
}
begin = tmp = data = io.buffer_data;
size_file = io.FILES_SIZE; size_file = io.FILES_SIZE;
tmp +=size_file; EBX = begin + size_file;
tmp--; height = DSBYTE[EBX - 1];
height = DSBYTE[tmp]; width = DSBYTE[EBX - 2];
tmp--;
width = DSBYTE[tmp];
block = math.ceil(height*width/32); block = math.ceil(height*width/32);
return true; return true;
} }
:void FONT::prepare_buf(word x,y,w,h; dword text1)
{
signed len=0;
dword c;
c = color;
IF(!text1)return;
IF(size.text)IF(!changeSIZE())return;
GetProcessInfo(#Form_SELF_FONTS, SelfInfo);
AX = c; r = AL; g = AH; c>>=16; AX = c; b = AL;
getsize(text1);
y -= size.offset_y;
size.width = w;
size.height = y;
EDX = size.width*size.height*3;
IF(!buffer_size)
{
buffer_size = EDX;
buffer = malloc(buffer_size);
EBX = bg_color;
EDI = buffer;
EAX = buffer_size+EDI;
WHILE (EDI<EAX)
{
ESDWORD[EDI] = EBX;
$add edi,3
}
}
WHILE(DSBYTE[text1])
{
x+=symbol(x,DSBYTE[text1]);
IF(weight)x+=math.ceil(size.text/17);
text1++;
}
return;
}
#endif #endif