From 1215c13d00b4ca94b1e328eb1c59f6dde2b5905e Mon Sep 17 00:00:00 2001 From: martin-s Date: Sat, 23 Aug 2008 09:44:16 +0000 Subject: [PATCH] Add:gui_internal:Made the menu appears on map click feature configurable, fixed a bug with menu generation from osd button git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1311 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/attr_def.h | 1 + navit/navit/gui/internal/gui_internal.c | 19 +++++++++++++++---- navit/navit/osd/core/osd_core.c | 1 - 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/navit/navit/attr_def.h b/navit/navit/attr_def.h index 6487aea..011f449 100644 --- a/navit/navit/attr_def.h +++ b/navit/navit/attr_def.h @@ -82,6 +82,7 @@ ATTR(predraw) ATTR(postdraw) ATTR(button) ATTR(ondemand) +ATTR(menu_on_map_click) ATTR2(0x0002ffff,type_int_end) ATTR2(0x00030000,type_string_begin) ATTR(type) diff --git a/navit/navit/gui/internal/gui_internal.c b/navit/navit/gui/internal/gui_internal.c index 43c411c..43a7a90 100644 --- a/navit/navit/gui/internal/gui_internal.c +++ b/navit/navit/gui/internal/gui_internal.c @@ -167,6 +167,8 @@ struct gui_priv { int clickp_valid, vehicle_valid; struct pcoord clickp, vehiclep; struct search_list *sl; + int ignore_button; + int menu_on_map_click; }; static void gui_internal_widget_render(struct gui_priv *this, struct widget *w); @@ -2141,13 +2143,15 @@ static void gui_internal_menu_root(struct gui_priv *this) } static void -gui_internal_cmd_menu(struct gui_priv *this, struct point *p) +gui_internal_cmd_menu(struct gui_priv *this, struct point *p, int ignore) { struct graphics *gra=this->gra; struct transformation *trans; struct coord c; struct attr attr,attrp; + this->ignore_button=ignore; + navit_block(this->nav, 1); graphics_overlay_disable(gra, 1); trans=navit_get_trans(this->nav); @@ -2185,11 +2189,13 @@ static void gui_internal_button(void *data, int pressed, int button, struct poin struct graphics *gra=this->gra; // if still on the map (not in the menu, yet): - if (!this->root.children) { + if (!this->root.children || this->ignore_button) { + this->ignore_button=0; // check whether the position of the mouse changed during press/release OR if it is the scrollwheel if (!navit_handle_button(this->nav, pressed, button, p, NULL) || button >=4) // Maybe there's a better way to do this return; - gui_internal_cmd_menu(this, p); + if (this->menu_on_map_click) + gui_internal_cmd_menu(this, p, 0); return; } @@ -2348,10 +2354,15 @@ struct gui_methods gui_internal_methods = { static struct gui_priv * gui_internal_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs) { struct gui_priv *this; + struct attr *attr; *meth=gui_internal_methods; this=g_new0(struct gui_priv, 1); this->nav=nav; - navit_command_register(nav,"gui_internal_menu",callback_new_2(gui_internal_cmd_menu,this,NULL)); + if ((attr=attr_search(attrs, NULL, attr_menu_on_map_click))) + this->menu_on_map_click=attr->u.num; + else + this->menu_on_map_click=1; + navit_command_register(nav,"gui_internal_menu",callback_new_3(gui_internal_cmd_menu,this,NULL,1)); navit_command_register(nav,"gui_internal_fullscreen",callback_new_2(gui_internal_cmd_fullscreen,this,NULL)); return this; } diff --git a/navit/navit/osd/core/osd_core.c b/navit/navit/osd/core/osd_core.c index 53ceac8..bbbbd3a 100644 --- a/navit/navit/osd/core/osd_core.c +++ b/navit/navit/osd/core/osd_core.c @@ -614,7 +614,6 @@ osd_button_click(struct osd_button *this, struct navit *nav, int pressed, int bu { struct point bp=this->p; wrap_point(&bp, this->nav); - dbg(0,"%d,%d-%d,%d %d,%d\n", bp.x, bp.y, bp.x+this->img->width, bp.y+this->img->height, p->x, p->y); if ((p->x < bp.x || p->y < bp.y || p->x > bp.x+this->img->width || p->y > bp.y+this->img->height) && !this->pressed) return; navit_ignore_button(nav); -- 2.7.4