From 5242e9022431ffbfdb3e547e73c4fd3b1003fc1b Mon Sep 17 00:00:00 2001 From: martin-s Date: Thu, 6 Nov 2008 20:16:05 +0000 Subject: [PATCH] Add:core:Added possibility to use pngs as cursor, added cursor desings from nekohayo git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1662 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/attr_def.h | 1 + navit/navit/cursor.c | 2 +- navit/navit/graphics.c | 57 +++++- navit/navit/graphics.h | 2 +- .../gtk_drawing_area/graphics_gtk_drawing_area.c | 23 ++- .../graphics/qt_qpainter/graphics_qt_qpainter.cpp | 2 +- navit/navit/layout.c | 4 +- navit/navit/layout.h | 1 + navit/navit/navit.c | 2 +- navit/navit/xmlconfig.c | 3 +- navit/navit/xpm/cursor.png | Bin 0 -> 864 bytes navit/navit/xpm/cursor.svg | 187 ++++++++++++++++++ navit/navit/xpm/cursor.xml | 20 ++ navit/navit/xpm/cursor225.png | Bin 0 -> 1014 bytes navit/navit/xpm/cursor225.svg | 200 +++++++++++++++++++ navit/navit/xpm/cursor450.png | Bin 0 -> 807 bytes navit/navit/xpm/cursor450.svg | 191 ++++++++++++++++++ navit/navit/xpm/cursor675.png | Bin 0 -> 1012 bytes navit/navit/xpm/cursor675.svg | 200 +++++++++++++++++++ navit/navit/xpm/cursor_still.png | Bin 0 -> 626 bytes navit/navit/xpm/cursor_still.svg | 217 +++++++++++++++++++++ 21 files changed, 1100 insertions(+), 12 deletions(-) create mode 100644 navit/navit/xpm/cursor.png create mode 100644 navit/navit/xpm/cursor.svg create mode 100644 navit/navit/xpm/cursor.xml create mode 100644 navit/navit/xpm/cursor225.png create mode 100644 navit/navit/xpm/cursor225.svg create mode 100644 navit/navit/xpm/cursor450.png create mode 100644 navit/navit/xpm/cursor450.svg create mode 100644 navit/navit/xpm/cursor675.png create mode 100644 navit/navit/xpm/cursor675.svg create mode 100644 navit/navit/xpm/cursor_still.png create mode 100644 navit/navit/xpm/cursor_still.svg diff --git a/navit/navit/attr_def.h b/navit/navit/attr_def.h index 97d9c5d..43b3de7 100644 --- a/navit/navit/attr_def.h +++ b/navit/navit/attr_def.h @@ -81,6 +81,7 @@ ATTR(text_size) ATTR(level) ATTR(icon_w) ATTR(icon_h) +ATTR(rotation) ATTR2(0x00028000,type_boolean_begin) /* boolean */ ATTR(overwrite) diff --git a/navit/navit/cursor.c b/navit/navit/cursor.c index 56b156e..8738fa4 100644 --- a/navit/navit/cursor.c +++ b/navit/navit/cursor.c @@ -69,7 +69,7 @@ cursor_draw_do(struct cursor *this_, int lazy) return; if (!this_->gra) return; - transform_set_angle(this_->trans, this_->angle); + transform_set_angle(this_->trans, -this_->angle); graphics_draw_mode(this_->gra, draw_mode_begin); p.x=0; p.y=0; diff --git a/navit/navit/graphics.c b/navit/navit/graphics.c index 212f117..f712893 100644 --- a/navit/navit/graphics.c +++ b/navit/navit/graphics.c @@ -281,7 +281,32 @@ struct graphics_image * graphics_image_new_scaled(struct graphics *gra, char *pa this_=g_new0(struct graphics_image,1); this_->height=h; this_->width=w; - this_->priv=gra->meth.image_new(gra->priv, &this_->meth, path, &this_->width, &this_->height, &this_->hot); + this_->priv=gra->meth.image_new(gra->priv, &this_->meth, path, &this_->width, &this_->height, &this_->hot, 0); + if (! this_->priv) { + g_free(this_); + this_=NULL; + } + return this_; +} + +/** + * Create a new image from file path scaled to w and h pixels and possibly rotated + * @param gra the graphics instance + * @param path path of the image to load + * @param w width to rescale to + * @param h height to rescale to + * @param rotate angle to rotate the image. Warning, graphics might only support 90 degree steps here + * @returns <> + * @author Martin Schaller (04/2008) +*/ +struct graphics_image * graphics_image_new_scaled_rotated(struct graphics *gra, char *path, int w, int h, int rotate) +{ + struct graphics_image *this_; + + this_=g_new0(struct graphics_image,1); + this_->height=h; + this_->width=w; + this_->priv=gra->meth.image_new(gra->priv, &this_->meth, path, &this_->width, &this_->height, &this_->hot, rotate); if (! this_->priv) { g_free(this_); this_=NULL; @@ -717,7 +742,7 @@ static void xdisplay_draw_elements(struct graphics *gra, GHashTable *display_lis case element_icon: if (!img) { sprintf(path,"%s/xpm/%s", navit_sharedir, e->u.icon.src); - img=graphics_image_new_scaled(gra, path, e->u.icon.width, e->u.icon.height); + img=graphics_image_new_scaled_rotated(gra, path, e->u.icon.width, e->u.icon.height, e->u.icon.rotation); if (! img) dbg(0,"failed to load icon '%s'\n", e->u.icon.src); } @@ -758,14 +783,24 @@ graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transfor { GList *es; struct point p; + struct coord c; char *label=NULL; struct graphics_gc *gc = NULL; + struct graphics_image *img; + char path[PATH_MAX]; es=itm->elements; + c.x=0; + c.y=0; while (es) { struct element *e=es->data; int count=e->coord_count; - struct point pnt[count]; - transform(t, projection_screen, e->coord, pnt, count, 0); + struct point pnt[count+1]; + if (count) + transform(t, projection_screen, e->coord, pnt, count, 0); + else { + transform(t, projection_screen, &c, pnt, 1, 0); + count=1; + } gc=graphics_gc_new(gra); gc->meth.gc_set_foreground(gc->priv, &e->color); switch (e->type) { @@ -790,7 +825,19 @@ graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transfor gra->font[e->text_size]=graphics_font_new(gra, e->text_size*20, 0); gra->meth.draw_text(gra->priv, gra->gc[2]->priv, gra->gc[1]->priv, gra->font[e->text_size]->priv, label, &p, 0x10000, 0); } - break; + break; + case element_icon: + sprintf(path,"%s/xpm/%s", navit_sharedir, 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) + dbg(0,"failed to load icon '%s'\n", e->u.icon.src); + else { + p.x=pnt[0].x - img->hot.x; + p.y=pnt[0].y - img->hot.y; + gra->meth.draw_image(gra->priv, gc->priv, &p, img->priv); + graphics_image_free(gra, img); + } + break; default: dbg(0,"dont know how to draw %d\n", e->type); } diff --git a/navit/navit/graphics.h b/navit/navit/graphics.h index f1831ef..a168d6f 100644 --- a/navit/navit/graphics.h +++ b/navit/navit/graphics.h @@ -61,7 +61,7 @@ struct graphics_methods { struct graphics_gc_priv *(*gc_new)(struct graphics_priv *gr, struct graphics_gc_methods *meth); void (*background_gc)(struct graphics_priv *gr, struct graphics_gc_priv *gc); struct graphics_priv *(*overlay_new)(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int alpha); - struct graphics_image_priv *(*image_new)(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot); + struct graphics_image_priv *(*image_new)(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation); void *(*get_data)(struct graphics_priv *gr, char *type); void (*image_free)(struct graphics_priv *gr, struct graphics_image_priv *priv); void (*get_text_bbox)(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret); diff --git a/navit/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c b/navit/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c index 551edd3..66bdeac 100644 --- a/navit/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c +++ b/navit/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c @@ -171,7 +171,7 @@ static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics static struct graphics_image_priv * -image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h, struct point *hot) +image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h, struct point *hot, int rotation) { GdkPixbuf *pixbuf; struct graphics_image_priv *ret; @@ -183,6 +183,27 @@ image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *n pixbuf=gdk_pixbuf_new_from_file_at_size(name, *w, *h, NULL); if (! pixbuf) return NULL; + if (rotation) { + GdkPixbuf *tmp; + switch (rotation) { + case 90: + rotation=270; + break; + case 180: + break; + case 270: + rotation=90; + break; + default: + return NULL; + } + tmp=gdk_pixbuf_rotate_simple(pixbuf, rotation); + g_object_unref(pixbuf); + if (! tmp) { + return NULL; + } + pixbuf=tmp; + } ret=g_new0(struct graphics_image_priv, 1); ret->pixbuf=pixbuf; ret->w=gdk_pixbuf_get_width(pixbuf); diff --git a/navit/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp b/navit/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp index 8605ceb..fc4d506 100644 --- a/navit/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp +++ b/navit/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp @@ -405,7 +405,7 @@ static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics //# Comment: //# Authors: Martin Schaller (04/2008) //############################################################################################################## -static struct graphics_image_priv * image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot) +static struct graphics_image_priv * image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation) { struct graphics_image_priv *ret; diff --git a/navit/navit/layout.c b/navit/navit/layout.c index 41722a2..a183fe8 100644 --- a/navit/navit/layout.c +++ b/navit/navit/layout.c @@ -285,7 +285,7 @@ struct icon * icon_new(struct attr *parent, struct attr **attrs) { struct element *e; - struct attr *src,*w,*h; + struct attr *src,*w,*h,*rotation; src=attr_search(attrs, NULL, attr_src); if (! src) return NULL; @@ -301,6 +301,8 @@ icon_new(struct attr *parent, struct attr **attrs) e->u.icon.height=h->u.num; else e->u.icon.height=-1; + if ((rotation=attr_search(attrs, NULL, attr_rotation))) + e->u.icon.rotation=rotation->u.num; strcpy(e->u.icon.src,src->u.str); return (struct icon *)e; diff --git a/navit/navit/layout.h b/navit/navit/layout.h index ea2e885..a0254d4 100644 --- a/navit/navit/layout.h +++ b/navit/navit/layout.h @@ -50,6 +50,7 @@ struct element { char *src; int width; int height; + int rotation; } icon; } u; int coord_count; diff --git a/navit/navit/navit.c b/navit/navit/navit.c index b085347..76d7d2b 100644 --- a/navit/navit/navit.c +++ b/navit/navit/navit.c @@ -1628,7 +1628,7 @@ navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point * pro=transform_get_projection(this_->trans); transform(this_->trans, pro, &nv->coord, &cursor_pnt, 1, 0); } - cursor_draw(cursor.u.cursor, this_->gra, &cursor_pnt, pnt ? 0:1, transform_get_angle(this_->trans, 0)-nv->dir, nv->speed); + cursor_draw(cursor.u.cursor, this_->gra, &cursor_pnt, pnt ? 0:1, nv->dir-transform_get_angle(this_->trans, 0), nv->speed); #if 0 if (pnt) pnt2=*pnt; diff --git a/navit/navit/xmlconfig.c b/navit/navit/xmlconfig.c index 2dae988..d086bb6 100644 --- a/navit/navit/xmlconfig.c +++ b/navit/navit/xmlconfig.c @@ -301,7 +301,8 @@ struct element_func { { "itemgra", "layer", NULL, NEW(itemgra_new), ADD(itemgra_add_attr)}, { "circle", "itemgra", NULL, NEW(circle_new), ADD(element_add_attr)}, { "coord", "circle", NULL, NEW(coord_new_from_attrs)}, - { "icon", "itemgra", NULL, NEW(icon_new)}, + { "icon", "itemgra", NULL, NEW(icon_new), ADD(element_add_attr)}, + { "coord", "icon", NULL, NEW(coord_new_from_attrs)}, { "image", "itemgra", NULL, NEW(image_new)}, { "text", "itemgra", NULL, NEW(text_new)}, { "polygon", "itemgra", NULL, NEW(polygon_new), ADD(element_add_attr)}, diff --git a/navit/navit/xpm/cursor.png b/navit/navit/xpm/cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..ebac5d5c80f7ae456d58759d1de5b30c03f3f58c GIT binary patch literal 864 zcmV-m1E2hfP)85od(h4rR69ii+iUAR;QmQRt(~6D8WahZIlSw9t zRRmu+i+efunU^#7oU25H)ufaP1D$RFOaW6Ol3w+oh*Sh%0#|{zfcz%jx;bW5Mipoh zc;*32OK3?5?FV(VB=lbK1J8hDIY*V2LMb%>+yR1wBGB0ftw~S@XAW$kF;v6N@s}VD z%%@;#7&40hS>T+A-1Arkuu>`sJO_eo>V}RJVATT9voprnU@xYjIDY*x4<_I1)43lo zJp%8Z6yUo>Bn4o&P!kyPpnFbw&>b5hj9%=)G7Su+7(Rc9u0&LWty-PCsT&{&47n@~ z2Ce{Igd*Cht96lj#s`nmSXblig@OSdUO7TM+EBa!9VZ|Z0qAmB9{4PvYw9{}sIwRw z>?PJxPq|u~LyQgf(iEyGI`8bGlx4X0G=XX99|Z(VgOLk8?25NkKnvOy3v>U{VJy@2 z)|v#<0!S#O!Ulzl-@G1_PP%ovn|)i`$Yk@Y#@_a|+#cxGU}b2AR%gHiN8$j4>w`?Z znq%VC901YAS}q^!@VUJ){(_I`jJFQg2T8AFHRH>S2lgqwl4bPijJJ+Q8#uLpvoGh- z^ek^aE&sMm00DIG!{Udk3AW>~u>9S(m$#kjv?61w2ws}i9iibS}8Syol7vEg0}4y?#dnKsyUudft>@G5s`Gk-d+8jVcn)BvK?VzIpd3pQsjQ< zvn8wo_!=-tW>NQksbjasrIB~az|$jzVKnKo2mpwPt(58qp7ZWW5b%bO?Nrt{mv@Rz z{X?i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/navit/navit/xpm/cursor.xml b/navit/navit/xpm/cursor.xml new file mode 100644 index 0000000..3afede1 --- /dev/null +++ b/navit/navit/xpm/cursor.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/navit/navit/xpm/cursor225.png b/navit/navit/xpm/cursor225.png new file mode 100644 index 0000000000000000000000000000000000000000..6e49c46de9558bc05727141803220911791f5d42 GIT binary patch literal 1014 zcmVp}jDaq{TG2S1SA2tvVO0G<9bcY0r)4Ub#J(o((oq=+L8?sRYbVDlA%=guyYP}uE^hchr5o8R}tc7 zO*sG()%Rfyhyb89))C;jfiCXkOW3(0cFrN4E%M11lYDpe7TLlkC!W|>6G=5A*TA2B z$SgNN4P7Jk@NVo}kyz9q7S*|SdxP^A7dU@$f&RS-UVZ8jBD#j_RbYK3be%SUDF8NZ zf=Jzz9o*B3<9ejCTi}Vy*Q@JuH#5vl1X?5&*tiug%@`tLE2UN_my)c_LuY^0@zIV4 zuyaMMs6i~E<9Zc-TTC}C8EXsRZ33)_NG3eT=Kz@c63Qh2cE+M;nj#%E&CWY~KetMy znasM5?_0wP!Jh%YQpmvU*8uF=VFnG`YTDG2-8|YW7eX;`+YF1BEF~Ut z>>cc!K`d%uMRf8-mqMvr4=k7bK(<6^R75td{mJVu# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/navit/navit/xpm/cursor450.png b/navit/navit/xpm/cursor450.png new file mode 100644 index 0000000000000000000000000000000000000000..353c4ddfee2c5adc829fa54750eb22a3e6a73d6d GIT binary patch literal 807 zcmV+?1K9kDP)Wyei8Xt04t>|z$|crwmvvMTA1t9 zZ0vQ~jnqoob{d@;A0ja(Z(cXybHFJP`D^ML00f6yICo1Jo)Cs7Wn(|V%3a;D#nHg zSEgR`;N{|$@MtotH(I*DssVVFQcZQ3h3{^q^7M81(ys*ZwOmzrG?6h{%3uKCFM?hB ztFCDD^dW|N+lZ&KRpCW&8N+X_N;Bf@u>%Yo@e*6hR*X3{n+{G^jsaNFYZv0*$_Dxm zH`8;_Lp+r$>z|olqM_c(*nkhGW-DKDkr66_W2P-Ax?0_IH1DZ^K3|A%_gT2`JT~AX znl!;;FbuGWtSY6JShd@alD;*T;Y=+$y{dQN}Hr*+>bVO3mdSN9;U{)@PF z)#GZg^Cz7nwDg;rwmm;paiy!8kgIzT*U1ZPSnPa{Cbx$E&xFh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/navit/navit/xpm/cursor675.png b/navit/navit/xpm/cursor675.png new file mode 100644 index 0000000000000000000000000000000000000000..53a33582bbb17a4c5e8f4947aa2eff8860595115 GIT binary patch literal 1012 zcmV(Jp9sNRTdCrA5Ssh*YV76g#0rP2y5D zwr4zJ9~Se7U7N7sNLMp+b4u~*t0QSEM!3Y3BEr3<4xAxICVg3UA zcG-iEiO5YKtd!D#tH9HwCn58CQ~rq~PmxY`^TiLhn9da_n|AXCKYj{JS8&^MKtyUD z_!w}CXdGUA7xZvb-e~U*uDHilIr z64d;)R;|wa7jn+Wj+6(^=zs-4y+$;w^VqH~_N5Z+j&%?X=~SvUci8^35qx@Pk^I_y z=Of_H2LnJBpxZ9e8}B668OF3-kmUilpm*+7u-!XdwdB#uy=ZTn zqbacoaTia}B^dmSf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/navit/navit/xpm/cursor_still.png b/navit/navit/xpm/cursor_still.png new file mode 100644 index 0000000000000000000000000000000000000000..f9ea8dff71fff3448b3c9a4a4432e22cf880ecdf GIT binary patch literal 626 zcmV-&0*(ENP)VSo#)106sQuuk}mo61Om`apdIa5Kt$ zUO9Wo*nHlsML(zm{y0bWmqJ8t0WX1BvK|y}zzHA38B22rKLTjJhTR^(Z{W77Zj4wK zEFwPe8JJ~Z1(w$!b8KQ6>F>ezCVc&9;pbE}7=cB^1wH{q7FOW=&B?%V)n8e71Gu27 z1DoSLph(s;J3XwH*C6Ww6hqc%#~mQg#XFE&ip9*h4&{>1<)xDVY_)c%R0IADhH-ee z1s`4jd{Nai0?YwD+zecQ9&6N$>+t@;HC7jMF-EQ3<;vr?akviQ&0QGu0XzqL@QWdf!C+R&JIheZ-y>AKUR%_?Lz*Jwv zXhz^)-%SJdsZtH7wY!P<{9 M07*qoM6N<$g7m}<5&!@I literal 0 HcmV?d00001 diff --git a/navit/navit/xpm/cursor_still.svg b/navit/navit/xpm/cursor_still.svg new file mode 100644 index 0000000..80ec5d2 --- /dev/null +++ b/navit/navit/xpm/cursor_still.svg @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + -- 2.7.4