Add kolibri font viewer, separate font.text into font.prepare and font.show

git-svn-id: svn://kolibrios.org@5776 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2015-08-27 08:33:51 +00:00
parent eccb53cd41
commit ee1f775549
10 changed files with 73 additions and 77 deletions

View File

@ -673,7 +673,7 @@ void Line_ReDraw(dword bgcol, filenum){
ext1 = strrchr(file_name_off,'.') + file_name_off; ext1 = strrchr(file_name_off,'.') + file_name_off;
if (ext1==file_name_off) ext1 = " \0"; //if no extension then show nothing if (ext1==file_name_off) ext1 = " \0"; //if no extension then show nothing
Put_icon(ext1, files.x+3, files.line_h/2-7+y, bgcol, 0); Put_icon(ext1, files.x+3, files.line_h/2-7+y, bgcol, 0);
WriteText(7-strlen(ConvertSize(file.sizelo))*6+files.x+files.w - 58, files.text_y + y,files.font_type,0,ConvertSize(file.sizelo)); WriteText(7-strlen(ConvertSize(file.sizelo))*6+files.x+files.w - 58, files.text_y + y +1,files.font_type,0,ConvertSize(file.sizelo));
} }
else else
{ {
@ -698,7 +698,7 @@ void Line_ReDraw(dword bgcol, filenum){
FileShow.font_color = text_col; FileShow.font_color = text_col;
FileShow.area_size_x = files.w - 164; FileShow.area_size_x = files.w - 164;
FileShow.text_pointer = file_name_off; FileShow.text_pointer = file_name_off;
FileShow.start_y = files.text_y + y; FileShow.start_y = files.text_y + y + 1;
PathShow_prepare stdcall(#FileShow); PathShow_prepare stdcall(#FileShow);
PathShow_draw stdcall(#FileShow); PathShow_draw stdcall(#FileShow);
} }
@ -706,7 +706,8 @@ void Line_ReDraw(dword bgcol, filenum){
else else
{ {
font.bg_color = bgcol; font.bg_color = bgcol;
font.text(files.x + 23, files.line_h - font.height / 2 - 1 + y, file_name_off); font.prepare(0, 0, file_name_off);
font.show(files.x + 23, files.line_h - font.size.height / 2 + y);
} }
DrawBar(files.x+files.w-141,y,1,files.line_h,system.color.work); //gray line 1 DrawBar(files.x+files.w-141,y,1,files.line_h,system.color.work); //gray line 1
DrawBar(files.x+files.w-68,y,1,files.line_h,system.color.work); //gray line 2 DrawBar(files.x+files.w-68,y,1,files.line_h,system.color.work); //gray line 2

View File

@ -43,7 +43,7 @@ void Put_icon(dword extension, xx, yy, fairing_color, icon_n)
ficons_pal[0] = fairing_color; ficons_pal[0] = fairing_color;
PutPaletteImage(icon_n*16*15+#ficons,16,15,xx,yy,8,#ficons_pal); PutPaletteImage(icon_n*16*15+#ficons,16,15,xx,yy,8,#ficons_pal);
if (fairing_color!=0xFFFfff) IconFairing(icon_n, xx, yy, fairing_color); if (fairing_color!=0xFFFfff) IconFairing(icon_n, xx, yy, fairing_color);
if (icon_n!=17) && (strlen(extension)<9) WriteText(-FileShow.font_size_x/2*strlen(extension)+files.x+files.w-103,yy+4,files.font_type,0,extension); if (icon_n!=17) && (strlen(extension)<9) WriteText(-FileShow.font_size_x/2*strlen(extension)+files.x+files.w-103,yy+3,files.font_type,0,extension);
} }

View File

@ -43,7 +43,7 @@ void settings_dialog()
else if (id==21) { action_buf=109; real_files_names_case ^= 1; } else if (id==21) { action_buf=109; real_files_names_case ^= 1; }
else if (id==22) info_after_copy ^= 1; else if (id==22) info_after_copy ^= 1;
else if (id==24) two_panels ^= 1; else if (id==24) two_panels ^= 1;
else if (id==25) files.line_h++; else if (id==25) { files.line_h++; files_active.line_h = files_inactive.line_h = files.line_h; }
else if (id==26) && (files.line_h>18) files.line_h--; else if (id==26) && (files.line_h>18) files.line_h--;
else if (id==27) MOUSE_TIME++; else if (id==27) MOUSE_TIME++;
else if (id==28) && (MOUSE_TIME>29) MOUSE_TIME--; else if (id==28) && (MOUSE_TIME>29) MOUSE_TIME--;

View File

@ -1,5 +1,5 @@
#define TITLE "Eolite File Manager v3.13" #define TITLE "Eolite File Manager v3.14"
#define ABOUT_TITLE "Eolite 3.13" #define ABOUT_TITLE "Eolite 3.14"
#ifdef LANG_RUS #ifdef LANG_RUS
?define T_FILE "” ©«" ?define T_FILE "” ©«"

View File

@ -1,59 +0,0 @@
#define MEMSIZE 0x7E80
#include "../lib/font.h"
byte id,key;
void main()
{
SetEventMask(1100111b);
font.load("font/Verdana.kf");
loop()
{
switch(WaitEvent())
{
case evMouse:
mouse.get();
break;
case evButton:
id=GetButtonID();
if (id==1) ExitProcess();
break;
case evKey:
key = GetKey();
if (key==013){ //Enter
draw_window();
}
break;
case evReDraw:
draw_window();
break;
}
}
}
char buf[40];
void draw_window()
{
proc_info Form;
int i =8;
int ii = 0;
DefineAndDrawWindow(215,100,450,500,0x33,0xFFFFFF,"Window header");
GetProcessInfo(#Form, SelfInfo);
while(i<=45)
{
sprintf(#buf,"Ðàçìåð øðèôòà/size font %d ïèêñåëåé.",i);
font.text(0,ii,#buf,0,i);
ii+=font.height;
i++;
}
}

View File

@ -1,7 +1,7 @@
C-- "example original font.c" C-- "kolibri font viewer.c"
@del "example original font" @del "kolibri font viewer"
@rename "example original font.com" "example original font" @rename "kolibri font viewer.com" "kolibri font viewer"
kpack "example original" kpack "kolibri font viewer"
@del warning.txt @del warning.txt
@pause @pause
@rem ====== Automatically add binnary to kolibri.img and then run QEMU ===== @rem ====== Automatically add binnary to kolibri.img and then run QEMU =====

View File

@ -0,0 +1,50 @@
#define MEMSIZE 0xEE80
#include "../lib/font.h"
#include "../lib/gui.h"
void main()
{
word i, y, btn;
char line[256], title[4196];
font.no_bg_copy = true;
font.color = 0;
font.bg_color = 0xFFFFFF;
if (!param) strcpy(#param, "/sys/fonts/Tahoma.kf");
font.load(#param);
strcpy(#title, "Kolibri font preview: ");
strcat(#title, #param);
loop()
{
switch(WaitEvent())
{
case evButton:
btn = GetButtonID();
if (btn==1) ExitProcess();
if (btn==2) font.weight ^=1;
if (btn==3) font.italic ^=1;
if (btn==4) font.no_bg_copy ^=1;
case evReDraw:
DefineAndDrawWindow(215,100,500,320,0x33,0xFFFFFF,#title);
DrawBar(0, 0, 500-9, 30, 0xCCCccc);
CheckBox2(10, 8, 2, "Bold", font.weight);
CheckBox2(70, 8, 3, "Italic", font.italic);
CheckBox2(140, 8, 4, "Smooth", font.no_bg_copy);
if (!font.data)
{
WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
}
else for (i=10, y=40; i<22; i++, y+=font.height;)
{
font.size.text = i;
sprintf(#line,"<EFBFBD> §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
font.prepare(10,y,#line);
font.show(10, y);
}
}
}
}
void CheckBox2(dword x, y, id, text, byte value) {
CheckBox(x, y, 14, 14, id, text, system.color.work_graph, system.color.work_text, value);
}

View File

@ -37,7 +37,8 @@
byte load(...); byte load(...);
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 text(word x,y;dword text1); dword prepare(word x,y;dword text1);
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);
@ -192,7 +193,7 @@ FONT font = 0;
IF(s=='_') size.width--; IF(s=='_') size.width--;
IF(size.offset_x<0)size.offset_x = X; IF(size.offset_x<0)size.offset_x = X;
} }
:dword FONT::text(word x,y;dword text1) :dword FONT::prepare(word x,y;dword text1)
{ {
signed len=0; signed len=0;
dword c; dword c;
@ -245,18 +246,21 @@ FONT font = 0;
text1++; text1++;
} }
IF (no_bg_copy) && (!color) SmoothFont(buffer, size.width, size.height); IF (no_bg_copy) && (!color) SmoothFont(buffer, size.width, size.height);
_PutImage(x,y,size.width,size.height,buffer);
return len; return len;
} }
:void FONT::show(word x,y)
{
_PutImage(x,y,size.width,size.height,buffer);
}
inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; } inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
:void SmoothFont(dword color_image, w, h) :void SmoothFont(dword image, w, h)
{ {
byte rr,gg,bb; byte rr,gg,bb;
dword i,line_w,to, pixel; dword i,line_w,to, pixel;
line_w = w * 3; line_w = w * 3;
to = w*h*3 + color_image - line_w - 3; to = w*h*3 + image - line_w - 3;
for (i = color_image; i < to; i+=3) { for (i = image; i < to; i+=3) {
if (i-color_image%line_w +3 == line_w) continue; if (i-image%line_w +3 == line_w) continue;
if (b24(i)==0x000000) && (b24(i+3)!=0x000000) && (b24(i+line_w)!=0x000000) && (b24(i+3+line_w)==0x000000) if (b24(i)==0x000000) && (b24(i+3)!=0x000000) && (b24(i+line_w)!=0x000000) && (b24(i+3+line_w)==0x000000)
{ {
ShadowImage(i+3, 1, 1, 2); ShadowImage(i+3, 1, 1, 2);