//##############################################################################################################
//#
//# File: graphics.c
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//#
//##############################################################################################################
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
struct graphics
struct displaylist_icon_cache {
unsigned int seq;
-
+
};
static void draw_circle(struct point *pnt, int diameter, int scale, int start, int len, struct point *res, int *pos, int dir);
* @param alpha The new alpha of the overlay
* @param wraparound The new wraparound of the overlay
*/
-void
+void
graphics_overlay_resize(struct graphics *this_, struct point *p, int w, int h, int alpha, int wraparound)
{
if (! this_->meth.overlay_resize) {
return;
}
-
+
this_->meth.overlay_resize(this_->priv, p, w, h, alpha, wraparound);
}
* @returns nothing
* @author Sarah Nordstrom (05/2008)
*/
-void graphics_font_destroy_all(struct graphics *gra)
-{
- int i;
- for(i = 0 ; i < gra->font_len; i++) {
- if(!gra->font[i]) continue;
- gra->font[i]->meth.font_destroy(gra->font[i]->priv);
- gra->font[i] = NULL;
+void graphics_font_destroy_all(struct graphics *gra)
+{
+ int i;
+ for(i = 0 ; i < gra->font_len; i++) {
+ if(!gra->font[i]) continue;
+ gra->font[i]->meth.font_destroy(gra->font[i]->priv);
+ gra->font[i] = NULL;
}
}
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_gc_set_stipple(struct graphics_gc *gc, struct graphics_image *img)
+void graphics_gc_set_stipple(struct graphics_gc *gc, struct graphics_image *img)
{
gc->meth.gc_set_stipple(gc->priv, img ? img->priv : NULL);
}
*/
void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r)
{
- this_->meth.draw_circle(this_->priv, gc->priv, p, r);
+ struct point pnt[r*4+64];
+ int i=0;
+
+ if(this_->meth.draw_circle)
+ this_->meth.draw_circle(this_->priv, gc->priv, p, r);
+ else
+ {
+ draw_circle(p, r, 0, -1, 1026, pnt, &i, 1);
+ pnt[i] = pnt[0];
+ i++;
+ this_->meth.draw_lines(this_->priv, gc->priv, pnt, i);
+ }
}
/**
#if 0
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
static void popup_view_html(struct popup_item *item, char *file)
enum projection pg;
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
static void graphics_popup(struct display_list *list, struct popup_item **popup)
} else
*p++='\0';
}
- } else
+ } else
di->label=NULL;
di->count=count;
memcpy(di->c, c, count*sizeof(*c));
#if 0
dbg(0,"display_text: '%s', %d, %d, %d, %d %d\n", label, x, y, dx*0x10000/l, dy*0x10000/l, l);
#endif
- if (x < gra->r.rl.x && x + tl > gra->r.lu.x && y + tl > gra->r.lu.y && y - tl < gra->r.rl.y)
+ if (x < gra->r.rl.x && x + tl > gra->r.lu.x && y + tl > gra->r.lu.y && y - tl < gra->r.rl.y)
gra->meth.draw_text(gra->priv, fg->priv, bg?bg->priv:NULL, font->priv, label, &p_t, dx*0x10000/l, dy*0x10000/l);
}
}
int i,dx,dy,l;
struct point p;
for (i = 0 ; i < count-1 ; i++) {
- dx=pnt[i+1].x-pnt[i].x;
+ dx=pnt[i+1].x-pnt[i].x;
dy=pnt[i+1].y-pnt[i].y;
l=sqrt(dx*dx+dy*dy);
if (l) {
calc_offsets(int wi, int l, int dx, int dy, struct offset *res)
{
int x,y;
-
+
x = (dx * wi) / l;
y = (dy * wi) / l;
if (x < 0) {
#endif
fow=fowler(-dy, dx);
}
- if (! l)
+ if (! l)
l=1;
if (wi*lscale > 10000)
lscale=10000/wi;
neg.y = pnt[i].y + o.nx;
if (! i)
state=0;
- else if (i == count-1)
+ else if (i == count-1)
state=2;
else if (npos < max_circle_points || ppos >= maxpoints-max_circle_points)
state=3;
if (step) {
wi=*width;
calc_offsets(wi*lscale, l, dx, dy, &oo);
- } else
+ } else
oo=o;
dxo = -dx;
dyo = -dy;
}
if (i == count-1 || (code & 4)) {
if (out > 1) {
- if (poly) {
+ if (poly) {
graphics_draw_polyline_as_polygon(gra, gc, p, out, w, step);
} else
gra->meth.draw_lines(gra->priv, gc->priv, p, out);
p1=g_new(struct point, count_in*8+1);
p2=g_new(struct point, count_in*8+1);
}
-
+
pout=p1;
for (edge = 0 ; edge < 4 ; edge++) {
p=pin;
size=64;
if (size >= gra->font_len) {
gra->font=g_renew(struct graphics_font *, gra->font, size+1);
- while (gra->font_len <= size)
+ while (gra->font_len <= size)
gra->font[gra->font_len++]=NULL;
}
if (! gra->font[size])
dbg(1,"enter %s\n",icon);
if (strchr(icon, '$')) {
wordexp=file_wordexp_new(icon);
- if (file_wordexp_get_count(wordexp))
+ if (file_wordexp_get_count(wordexp))
icon=file_wordexp_get_array(wordexp)[0];
}
if (icon[0] == '/')
count=limit_count(di->c, count);
if (dc->type == type_poly_water_tiled)
mindist=0;
- if (dc->e->type == element_polyline)
+ if (dc->e->type == element_polyline)
count=transform(dc->trans, dc->pro, di->c, pa, count, mindist, e->u.polyline.width, width);
else
count=transform(dc->trans, dc->pro, di->c, pa, count, mindist, 0, NULL);
{
gc->meth.gc_set_linewidth(gc->priv, 1);
if (e->u.polyline.width > 0 && e->u.polyline.dash_num > 0)
- graphics_gc_set_dashes(gc, e->u.polyline.width,
+ graphics_gc_set_dashes(gc, e->u.polyline.width,
e->u.polyline.offset,
e->u.polyline.dash_table,
e->u.polyline.dash_num);
break;
case element_circle:
if (count) {
- if (e->u.circle.width > 1)
+ if (e->u.circle.width > 1)
gc->meth.gc_set_linewidth(gc->priv, e->u.polyline.width);
- gra->meth.draw_circle(gra->priv, gc->priv, pa, e->u.circle.radius);
+ graphics_draw_circle(gra, gc, pa, e->u.circle.radius);
if (di->label && e->text_size) {
struct graphics_font *font=get_font(gra, e->text_size);
struct graphics_gc *gc_background=dc->gc_background;
path=graphics_icon_path(icon);
g_free(icon);
} else
- path=graphics_icon_path(e->u.icon.src);
+ path=graphics_icon_path(e->u.icon.src);
img=graphics_image_new_scaled_rotated(gra, path, e->u.icon.width, e->u.icon.height, e->u.icon.rotation);
if (img)
dc->img=img;
break;
default:
printf("Unhandled element type %d\n", e->type);
-
+
}
di=di->next;
}
{
GList *lays;
struct layer *lay;
-
+
lays=l->layers;
while (lays) {
lay=lays->data;
profile(0,NULL);
pro=transform_get_projection(displaylist->dc.trans);
while (!cancel) {
- if (!displaylist->msh)
+ if (!displaylist->msh)
displaylist->msh=mapset_open(displaylist->ms);
if (!displaylist->m) {
displaylist->m=mapset_next(displaylist->msh, 1);
continue;
}
entry=get_hash_entry(displaylist, item->type);
- if (!entry)
+ if (!entry)
continue;
count=item_coord_get_within_selection(item, ca, item->type < type_line ? 1: max, displaylist->sel);
if (! count)
continue;
- if (displaylist->dc.pro != pro)
+ if (displaylist->dc.pro != pro)
transform_from_to_count(ca, displaylist->dc.pro, ca, pro, count);
if (count == max) {
dbg(0,"point count overflow %d for %s "ITEM_ID_FMT"\n", count,item_to_name(item->type),ITEM_ID_ARGS(*item));
displaylist->busy=0;
graphics_process_selection(displaylist->dc.gra, displaylist);
profile(1,"draw\n");
- if (! cancel)
+ if (! cancel)
graphics_displaylist_draw(displaylist->dc.gra, displaylist, displaylist->dc.trans, displaylist->layout, flags);
map_rect_destroy(displaylist->mr);
if (!route_selection)
gra->meth.draw_mode(gra->priv, (flags & 8)?draw_mode_begin_clear:draw_mode_begin);
if (!(flags & 2))
gra->meth.draw_rectangle(gra->priv, gra->gc[0]->priv, &gra->r.lu, gra->r.rl.x-gra->r.lu.x, gra->r.rl.y-gra->r.lu.y);
- if (l)
+ if (l)
xdisplay_draw(displaylist, gra, l, order+l->order_delta);
if (flags & 1)
callback_list_call_attr_0(gra->cbl, attr_postdraw);
*/
struct item * graphics_displayitem_get_item(struct displayitem *di)
{
- return &di->item;
+ return &di->item;
}
int
int
graphics_displayitem_get_displayed(struct displayitem *di)
{
- return 1;
+ return 1;
}
/**
if (p->y > line_p0->y + dist)
return 0;
}
-
+
vx=line_p1->x-line_p0->x;
vy=line_p1->y-line_p0->y;
wx=p->x-line_p0->x;
for (i = 0, j = count-1; i < count; j = i++) {
if ((((poly_pnt[i].y <= p->y) && ( p->y < poly_pnt[j].y )) ||
((poly_pnt[j].y <= p->y) && ( p->y < poly_pnt[i].y))) &&
- (p->x < (poly_pnt[j].x - poly_pnt[i].x) * (p->y - poly_pnt[i].y) / (poly_pnt[j].y - poly_pnt[i].y) + poly_pnt[i].x))
+ (p->x < (poly_pnt[j].x - poly_pnt[i].x) * (p->y - poly_pnt[i].y) / (poly_pnt[j].y - poly_pnt[i].y) + poly_pnt[i].x))
c = !c;
}
if (! c)
int count;
count=transform(displaylist->dc.trans, displaylist->dc.pro, di->c, pa, di->count, 1, 0, NULL);
-
+
if (di->item.type < type_line) {
return within_dist_point(p, &pa[0], dist);
}
#include "item.h"
#include "attr.h"
#include "callback.h"
-#include "navit/font/freetype/font_freetype.h"
+#include "font/freetype/font_freetype.h"
#include <SDL/SDL.h>
#include <math.h>
static struct graphics_gc_methods gc_methods = {
gc_destroy,
gc_set_linewidth,
- gc_set_dashes,
- gc_set_foreground,
- gc_set_background
+ gc_set_dashes,
+ gc_set_foreground,
+ gc_set_background
};
static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
int n,len,x=0,y=0;
bbox.xMin = bbox.yMin = 32000;
- bbox.xMax = bbox.yMax = -32000;
+ bbox.xMax = bbox.yMax = -32000;
FT_Set_Transform( font->face, &matrix, &pen );
len=g_utf8_strlen(text, -1);
for ( n = 0; n < len; n++ ) {
bbox.xMax = glyph_bbox.xMax;
if ( glyph_bbox.yMax > bbox.yMax )
bbox.yMax = glyph_bbox.yMax;
- }
+ }
if ( bbox.xMin > bbox.xMax ) {
bbox.xMin = 0;
bbox.yMin = 0;
/* FIXME: should just draw a half circle */
- /* now some circular endcaps, if the width is over 2 */
+ /* now some circular endcaps, if the width is over 2 */
if(lw > 2)
{
if(i == 0)
SDL_Surface *glyph_surface =
SDL_CreateRGBSurfaceFrom(shadow, g->w + 2, g->h + 2,
32,
- stride,
+ stride,
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
if (glyph_surface) {
SDL_Rect r;
&white, &transparent);
SDL_Surface *glyph_surface =
SDL_CreateRGBSurfaceFrom(glyph, g->w, g->h, 32,
- stride * 4,
+ stride * 4,
0x000000ff,0x0000ff00, 0x00ff0000,0xff000000);
if (glyph_surface) {
SDL_Rect r;
pGlyph += 4;
}
SDL_Surface *glyph_surface =
- SDL_CreateRGBSurfaceFrom(glyph, g->w, g->h, 32,
+ SDL_CreateRGBSurfaceFrom(glyph, g->w, g->h, 32,
stride,
0x000000ff,0x0000ff00,0x00ff0000,0xff000000);
if (glyph_surface) {
gr->screen = SDL_SetVideoMode(gr->screen->w, gr->screen->h, gr->video_bpp, gr->video_flags);
if(gr->screen == NULL) {
navit_destroy(gr->nav);
- }
+ }
else {
callback_list_call_attr_2(gr->cbl, attr_resize, (void *)gr->screen->w, (void *)gr->screen->h);
}
draw_lines,
draw_polygon,
draw_rectangle,
- draw_circle,
+ NULL /*draw_circle*/,
draw_text,
draw_image,
draw_image_warp,
amask = gr->screen->format->Amask;
}
- ov->screen = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ ov->screen = SDL_CreateRGBSurface(SDL_SWSURFACE,
w, h,
gr->screen->format->BitsPerPixel,
rmask, gmask, bmask, amask);
bot right = 63,1872
calibrate your TS using input_event_dump
- and touching all four corners. use the most extreme values.
+ and touching all four corners. use the most extreme values.
*/
#define INPUT_TS_LEFT 1978
4: type =EV_SYN
- once hit, if the contact point changes, we'll get more
+ once hit, if the contact point changes, we'll get more
EV_ABS (for 1 or both axes), followed by an EV_SYN.
and, on a lift:
input_ts_map(&p.x, &p.y, gr->ts_x, gr->ts_y);
/* always send MOUSE_MOTION (first) */
- callback_list_call_attr_1(gr->cbl, attr_motion, (void *)&p);
+ callback_list_call_attr_1(gr->cbl, attr_motion, (void *)&p);
if(gr->ts_hit > 0)
{
- callback_list_call_attr_3(gr->cbl, attr_button, (void *)1, (void *)SDL_BUTTON_LEFT, (void *)&p);
+ callback_list_call_attr_3(gr->cbl, attr_button, (void *)1, (void *)SDL_BUTTON_LEFT, (void *)&p);
}
else if(gr->ts_hit == 0)
{
- callback_list_call_attr_3(gr->cbl, attr_button, (void *)0, (void *)SDL_BUTTON_LEFT, (void *)&p);
+ callback_list_call_attr_3(gr->cbl, attr_button, (void *)0, (void *)SDL_BUTTON_LEFT, (void *)&p);
}
/* reset ts_hit */
{
p.x = ev.motion.x;
p.y = ev.motion.y;
- callback_list_call_attr_1(gr->cbl, attr_motion, (void *)&p);
+ callback_list_call_attr_1(gr->cbl, attr_motion, (void *)&p);
break;
}
p.x = ev.button.x;
p.y = ev.button.y;
- callback_list_call_attr_3(gr->cbl, attr_button, (void *)1, (void *)(int)ev.button.button, (void *)&p);
+ callback_list_call_attr_3(gr->cbl, attr_button, (void *)1, (void *)(int)ev.button.button, (void *)&p);
break;
}
p.x = ev.button.x;
p.y = ev.button.y;
- callback_list_call_attr_3(gr->cbl, attr_button, (void *)0, (void *)(int)ev.button.button, (void *)&p);
+ callback_list_call_attr_3(gr->cbl, attr_button, (void *)0, (void *)(int)ev.button.button, (void *)&p);
break;
}
if ((attr=attr_search(attrs, NULL, attr_bpp)))
this->video_bpp=attr->u.num;
if ((attr=attr_search(attrs, NULL, attr_flags))) {
- if (attr->u.num & 1)
+ if (attr->u.num & 1)
this->video_flags = SDL_SWSURFACE;
}
if ((attr=attr_search(attrs, NULL, attr_frame))) {