ATTR(animate)
ATTR(lazy)
ATTR(mkdir)
+ATTR(predraw)
+ATTR(postdraw)
+ATTR(button)
ATTR2(0x0002ffff,type_int_end)
ATTR2(0x00030000,type_string_begin)
ATTR(type)
ATTR(position_nmea)
ATTR(gpsd_query)
ATTR(on_eof)
+ATTR(command)
ATTR2(0x0003ffff,type_string_end)
ATTR(order_limit)
ATTR2(0x00050000,type_double_start)
callback_list_call(l, 0, NULL);
}
+static inline void callback_list_call_attr_0(struct callback_list *l, enum attr_type type)
+{
+ callback_list_call_attr(l, type, 0, NULL);
+}
+
static inline void callback_list_call_attr_1(struct callback_list *l, enum attr_type type, void *p1)
{
void *p[1];
callback_list_call(l, 2, p);
}
+static inline void callback_list_call_attr_4(struct callback_list *l, enum attr_type type, void *p1, void *p2, void *p3, void *p4)
+{
+ void *p[4];
+ p[0]=p1;
+ p[1]=p2;
+ p[2]=p3;
+ p[3]=p4;
+ callback_list_call_attr(l, type, 4, p);
+}
+
+
#define callback_cast(x) (void (*)(void))(x)
#ifdef __cplusplus
}
#include "layout.h"
#include "route.h"
#include "util.h"
+#include "callback.h"
//##############################################################################################################
//# Description:
struct graphics_font *font[16];
struct graphics_gc *gc[3];
struct attr **attrs;
+ struct callback_list *cbl;
int ready;
};
//##############################################################################################################
if (! graphicstype_new)
return NULL;
this_=g_new0(struct graphics, 1);
+ this_->cbl=callback_list_new();
this_->priv=(*graphicstype_new)(&this_->meth, attrs);
this_->attrs=attr_list_dup(attrs);
return this_;
this_->meth.register_keypress_callback(this_->priv, callback, data);
}
+void graphics_add_callback(struct graphics *this_, struct callback *cb)
+{
+ callback_list_add(this_->cbl, cb);
+}
+
//##############################################################################################################
//# Description:
//# Comment:
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l)
+void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int callback)
{
int order=transform_get_order(trans);
struct point p;
gra->meth.draw_mode(gra->priv, draw_mode_begin);
gra->meth.draw_rectangle(gra->priv, gra->gc[0]->priv, &p, 32767, 32767);
xdisplay_draw(displaylist->dl, gra, l, order);
+ if (callback)
+ callback_list_call_attr_0(gra->cbl, attr_postdraw);
gra->meth.draw_mode(gra->priv, draw_mode_end);
}
profile(0,NULL);
do_draw(displaylist, trans, mapsets, order);
// profile(1,"do_draw");
- graphics_displaylist_draw(gra, displaylist, trans, l);
+ graphics_displaylist_draw(gra, displaylist, trans, l, 1);
profile(1,"xdisplay_draw");
profile(0,"end");
void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img);
void display_add(struct displaylist *displaylist, struct item *item, int count, struct point *pnt, char *label);
int graphics_ready(struct graphics *this_);
-void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l);
+void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int callback);
void graphics_displaylist_move(struct displaylist *displaylist, int dx, int dy);
void graphics_draw(struct graphics *gra, struct displaylist *displaylist, GList *mapsets, struct transformation *trans, struct layout *l);
struct displaylist_handle *graphics_displaylist_open(struct displaylist *displaylist);
struct point pressed, last, current;
int button_pressed,moved,popped;
guint button_timeout, motion_timeout;
+ int ignore_button;
struct log *textfile_debug_log;
struct pcoord destination;
int destination_valid;
navit_draw_displaylist(struct navit *this_)
{
if (this_->ready == 3)
- graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current);
+ graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current, 1);
}
void
return FALSE;
}
+int
+navit_ignore_button(struct navit *this_)
+{
+ this_->ignore_button=1;
+}
int
navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback)
{
int border=16;
+ callback_list_call_attr_4(this_->attr_cbl, attr_button, this_, pressed, button, p);
+ if (this_->ignore_button) {
+ this_->ignore_button=0;
+ return 0;
+ }
if (pressed) {
this_->pressed=*p;
this_->last=*p;
if (dx || dy) {
this_->last=this_->current;
graphics_displaylist_move(this_->displaylist, dx, dy);
- graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current);
+ graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current, 0);
this_->moved=1;
}
this_->motion_timeout=0;
return (struct osd_priv *) this;
}
+struct osd_button {
+ struct point p;
+ struct navit *nav;
+ struct graphics *gra;
+ struct graphics_gc *gc;
+ struct callback *navit_init_cb;
+ struct callback *draw_cb;
+ struct graphics_image *img;
+};
+
+static void
+osd_button_click(struct osd_button *this, struct navit *nav, int pressed, int button, struct point *p)
+{
+ if (p->x < this->p.x || p->y < this->p.y || p->x > this->p.x+this->img->width || p->y > this->p.y+this->img->height)
+ return;
+ navit_ignore_button(nav);
+ if (pressed) {
+ dbg(0,"enter\n");
+ }
+}
+
+static void
+osd_button_draw(struct osd_button *this)
+{
+ graphics_draw_image(this->gra,this->gc, &this->p, this->img);
+}
+
+static void
+osd_button_init(struct osd_button *this, struct navit *nav)
+{
+ struct graphics *gra=navit_get_graphics(nav);
+ dbg(0,"enter\n");
+ this->nav=nav;
+ this->gra=gra;
+ this->gc=graphics_gc_new(gra);
+ this->img=graphics_image_new(gra, "xpm/gui_map.svg");
+ navit_add_callback(nav, this->navit_init_cb=callback_new_attr_1(callback_cast(osd_button_click), attr_button, this));
+ graphics_add_callback(gra, this->draw_cb=callback_new_attr_1(callback_cast(osd_button_draw), attr_postdraw, this));
+}
+
+static struct osd_priv *
+osd_button_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs)
+{
+ struct osd_button *this=g_new0(struct osd_button, 1);
+ struct attr *attr;
+ attr=attr_search(attrs, NULL, attr_x);
+ if (attr)
+ this->p.x=attr->u.num;
+ attr=attr_search(attrs, NULL, attr_y);
+ if (attr)
+ this->p.y=attr->u.num;
+ navit_add_callback(nav, this->navit_init_cb=callback_new_attr_1(callback_cast(osd_button_init), attr_navit, this));
+
+ return (struct osd_priv *) this;
+}
+
void
plugin_init(void)
{
plugin_register_osd_type("eta", osd_eta_new);
plugin_register_osd_type("navigation", osd_navigation_new);
plugin_register_osd_type("street_name", osd_street_name_new);
+ plugin_register_osd_type("button", osd_button_new);
}