From 801e3fdf6c572639b2396aff2bc153ef646cf347 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Tue, 22 May 2018 21:02:03 +0000 Subject: [PATCH] Aelia: links refactoring git-svn-id: svn://kolibrios.org@7291 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/aelia/aelia.c | 16 +++++---- programs/cmm/aelia/link.h | 57 ++++++++++++++++++++----------- programs/cmm/aelia/prepare_page.h | 3 +- programs/cmm/tmpdisk/tmpdisk.c | 2 +- 4 files changed, 50 insertions(+), 28 deletions(-) diff --git a/programs/cmm/aelia/aelia.c b/programs/cmm/aelia/aelia.c index 0daff3c35d..eaf26b3eeb 100644 --- a/programs/cmm/aelia/aelia.c +++ b/programs/cmm/aelia/aelia.c @@ -56,11 +56,7 @@ enum { }; char address[UML]="http://"; -int mouse_address_box; -edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,UML,#address,#mouse_address_box,2,19,19}; - -CustomCursor CursorPointer; -dword CursorFile = FROM "pointer.cur"; +edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,UML,#address,NULL,2,19,19}; #include "favicon.h" #include "ini.h" @@ -222,7 +218,15 @@ void HandleMouseEvent() edit_box_mouse stdcall (#address_box); mouse.get(); list.wheel_size = 7; - link.hover(); + if (link.hover()) { + if (link.active == -1) { + debugln("unhovered"); + } + else { + debugln(link.text.get(link.active)); + debugln(link.url.get(link.active)); + } + } if (list.MouseScroll(mouse.vert)) { DrawPage(); return; diff --git a/programs/cmm/aelia/link.h b/programs/cmm/aelia/link.h index f5fcbbe6d9..06f49f2665 100644 --- a/programs/cmm/aelia/link.h +++ b/programs/cmm/aelia/link.h @@ -1,5 +1,8 @@ +dword CursorFile = FROM "pointer.cur"; + struct _link { + CustomCursor CursorPointer; int count; int x[4096], y[4096], w[4096], h[4096]; collection text; @@ -8,6 +11,7 @@ struct _link void add(); int hover(); int active; + void draw_underline(); } link; void _link::clear() @@ -29,33 +33,46 @@ void _link::add(int _xx, _yy, _ww, _hh, dword _textt, _urll ) count++; } +void _link::draw_underline(dword i, color) +{ + DrawBar(x[i]+list.x, -list.first*list.item_h+y[i]+list.y+h[i]-1, w[i], 1, color); +} + int _link::hover() { - //char tempp[4096]; - dword color; int i; - active = -1; + int new_active = -1; + int link_start_y = list.first*list.item_h; mouse.x = mouse.x - list.x; mouse.y = mouse.y - list.y; - for (i=0; ilist.first*list.item_h) && (link.y[i]link.x[i]) - && (-list.first*list.item_h+link.y[i]mouse.y) { - color = 0xFFFfff; - CursorPointer.Load(#CursorFile); - CursorPointer.Set(); - active = i; + for (i=0; i link_start_y) && (y[i] < link_start_y+list.h) { + // debugln( sprintf(#param, "mx:%i my:%i x[i]:%i y[i]:%i", mx, my, x[i], y[i]) ); + if (mouse.x > x[i]) + && (mouse.x < x[i]+w[i]) + && (mouse.y > y[i]-link_start_y) + && (mouse.y < h[i]-link_start_y+link.y[i]) { + new_active = i; + break; } - else { - color = 0x0000FF; - } - DrawBar(link.x[i]+list.x, -list.first*list.item_h+link.y[i]+list.y+link.h[i]-1, link.w[i], 1, color); } } - if (active==-1) CursorPointer.Restore(); + + if (new_active != active) + { + if (-1 == new_active) { + draw_underline(active, 0x0000FF); + CursorPointer.Restore(); + } + else { + draw_underline(active, 0x0000FF); + draw_underline(new_active, 0xFFFfff); + CursorPointer.Load(#CursorFile); + CursorPointer.Set(); + } + active = new_active; + return true; + } + return false; } \ No newline at end of file diff --git a/programs/cmm/aelia/prepare_page.h b/programs/cmm/aelia/prepare_page.h index 083bfac4fc..ab7549a703 100644 --- a/programs/cmm/aelia/prepare_page.h +++ b/programs/cmm/aelia/prepare_page.h @@ -283,7 +283,8 @@ void _dom::apply_text() kfont.bold = style.bold; canvas.write_text(draw.x, draw.y, style.color, text.start); if (style.a) { - canvas.draw_hor_line(draw.x+1, draw.y + list.item_h-2, kfont.get_label_width(text.start), style.color); + canvas.draw_hor_line(draw.x, draw.y + list.item_h-1, kfont.get_label_width(text.start), style.color); + link.add(draw.x, draw.y, kfont.get_label_width(text.start), list.item_h, text.start, "http://kolibrios.org"); } } } diff --git a/programs/cmm/tmpdisk/tmpdisk.c b/programs/cmm/tmpdisk/tmpdisk.c index 23a2608a16..838d25f58f 100644 --- a/programs/cmm/tmpdisk/tmpdisk.c +++ b/programs/cmm/tmpdisk/tmpdisk.c @@ -82,7 +82,7 @@ void main() void GetDiskSizesFromIni() { char i, key[2]; - if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini"); + load_dll(libini, #lib_init, 1); key[1]=0; for (i=0; i<=9; i++) {