2014-12-11 21:14:23 +01:00
|
|
|
#include "rect.h"
|
|
|
|
|
|
|
|
void rect_draw(rect* r, __u32 color)
|
|
|
|
{
|
|
|
|
__menuet__bar(r->x,r->y,r->width,r->height,color);
|
|
|
|
}
|
|
|
|
|
|
|
|
__u8 rect_transform(rect* from, rect* to, __u16 step)
|
|
|
|
{
|
|
|
|
if (from->width < to->width)
|
|
|
|
{
|
2014-12-14 18:05:58 +01:00
|
|
|
from->width += (step << 1);
|
2014-12-11 21:14:23 +01:00
|
|
|
if (from->width > to->width) from->width = to->width;
|
|
|
|
}
|
|
|
|
else if (from->width > to->width)
|
|
|
|
{
|
2014-12-14 18:05:58 +01:00
|
|
|
from->width -= (step << 1);
|
2014-12-11 21:14:23 +01:00
|
|
|
if (from->width < to->width) from->width = to->width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (from->height < to->height)
|
|
|
|
{
|
2014-12-14 18:05:58 +01:00
|
|
|
from->height += (step << 1);
|
2014-12-11 21:14:23 +01:00
|
|
|
if (from->height > to->height) from->height = to->height;
|
|
|
|
}
|
|
|
|
else if (from->height > to->height)
|
|
|
|
{
|
2014-12-14 18:05:58 +01:00
|
|
|
from->height -= (step << 1);
|
2014-12-11 21:14:23 +01:00
|
|
|
if (from->height < to->height) from->height = to->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (from->x < to->x)
|
|
|
|
{
|
2014-12-14 18:05:58 +01:00
|
|
|
from->x += step;
|
2014-12-11 21:14:23 +01:00
|
|
|
if (from->x > to->x) from->x = to->x;
|
|
|
|
}
|
|
|
|
else if (from->x > to->x)
|
|
|
|
{
|
2014-12-14 18:05:58 +01:00
|
|
|
from->x -= step;
|
2014-12-11 21:14:23 +01:00
|
|
|
if (from->x < to->x) from->x = to->x;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (from->y < to->y)
|
|
|
|
{
|
2014-12-14 18:05:58 +01:00
|
|
|
from->y += step;
|
2014-12-11 21:14:23 +01:00
|
|
|
if (from->y > to->y) from->y = to->y;
|
|
|
|
}
|
|
|
|
else if (from->y > to->y)
|
|
|
|
{
|
2014-12-14 18:05:58 +01:00
|
|
|
from->y -= step;
|
2014-12-11 21:14:23 +01:00
|
|
|
if (from->y < to->y) from->y = to->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (from->x == to->x) &&
|
|
|
|
(from->y == to->y) &&
|
|
|
|
(from->width == to->width) &&
|
|
|
|
(from->height == to->height);
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:42:18 +01:00
|
|
|
void rect_draw_text(rect *r, char *txt, __u32 len, __u32 color, __u32 frame_color)
|
2014-12-11 21:14:23 +01:00
|
|
|
{
|
2014-12-17 23:42:18 +01:00
|
|
|
// right down shadow
|
|
|
|
__menuet__write_text(r->x + 1 + (r->width - text_length_px(len)) / 2,
|
2014-12-11 21:14:23 +01:00
|
|
|
r->y + 1 + (r->height - FONT_HEIGHT) / 2,
|
2014-12-17 23:42:18 +01:00
|
|
|
frame_color,txt,len);
|
|
|
|
// right shadow
|
|
|
|
__menuet__write_text(r->x + 1 + (r->width - text_length_px(len)) / 2,
|
2014-12-11 21:14:23 +01:00
|
|
|
r->y + (r->height - FONT_HEIGHT) / 2,
|
2014-12-17 23:42:18 +01:00
|
|
|
frame_color,txt,len);
|
|
|
|
// down shadow
|
|
|
|
__menuet__write_text(r->x + (r->width - text_length_px(len)) / 2,
|
2014-12-11 21:14:23 +01:00
|
|
|
r->y + 1 + (r->height - FONT_HEIGHT) / 2,
|
2014-12-17 23:42:18 +01:00
|
|
|
frame_color,txt,len);
|
2014-12-11 21:14:23 +01:00
|
|
|
|
2014-12-17 23:42:18 +01:00
|
|
|
__menuet__write_text(r->x + (r->width - text_length_px(len)) / 2,
|
2014-12-11 21:14:23 +01:00
|
|
|
r->y + (r->height - FONT_HEIGHT) / 2,
|
2014-12-17 23:42:18 +01:00
|
|
|
color,txt,len);
|
2014-12-11 21:14:23 +01:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:42:18 +01:00
|
|
|
void rect_draw_value(rect* r, __u32 v, __u32 color, __u32 frame_color)
|
2014-12-11 21:14:23 +01:00
|
|
|
{
|
|
|
|
char buffer[16] = {0};
|
|
|
|
__u32 length = strlen(itoa(v,buffer,10));
|
2014-12-17 23:42:18 +01:00
|
|
|
rect_draw_text(r,buffer,length,color,frame_color);
|
2014-12-11 21:14:23 +01:00
|
|
|
}
|