forked from KolibriOS/kolibrios
Aelia: links refactoring
git-svn-id: svn://kolibrios.org@7291 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
1489fafd26
commit
801e3fdf6c
@ -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;
|
||||
|
@ -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; i<link.count; i++) {
|
||||
if(link.y[i]>list.first*list.item_h) && (link.y[i]<list.first*list.item_h+list.h) {
|
||||
// sprintf(#tempp, "mx:%i my:%i x[i]:%i y[i]:%i", mx, my, x[i], y[i]);
|
||||
// sprintf(#tempp);
|
||||
if (mouse.x>link.x[i])
|
||||
&& (-list.first*list.item_h+link.y[i]<mouse.y)
|
||||
&& (mouse.x<link.x[i]+link.w[i])
|
||||
&& (-list.first*list.item_h+link.y[i]+link.h[i]>mouse.y) {
|
||||
color = 0xFFFfff;
|
||||
CursorPointer.Load(#CursorFile);
|
||||
CursorPointer.Set();
|
||||
active = i;
|
||||
for (i=0; i<count; i++) {
|
||||
if(y[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;
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user