From 6af3da26581c794ce6c72b3d54506d94d5f6db13 Mon Sep 17 00:00:00 2001 From: tegzed Date: Thu, 27 Jan 2011 19:43:54 +0000 Subject: [PATCH] Add:core:added command to toggle active state of a named layer of the current layout git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@4055 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/navit.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/navit/navit/navit.c b/navit/navit/navit.c index e308c50..d6e9aac 100644 --- a/navit/navit/navit.c +++ b/navit/navit/navit.c @@ -752,6 +752,36 @@ navit_cmd_set_int_var(struct navit *this, char *function, struct attr **in, stru } /** + * command to toggle the active state of a named layer of the current layout + * + * @param navit The navit instance + * @param function unused (needed to match command function signiture) + * @param in input attribute in[0] is the name of the layer + * @param out output unused + * @param valid unused + * @returns nothing + */ +static void +navit_cmd_toggle_layer(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) +{ + if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) { + if(this->layout_current && this->layout_current->layers) { + GList* layers = this->layout_current->layers; + while (layers) { + struct layer*l=layers->data; + if(l && !strcmp(l->name,in[0]->u.str) ) { + l->active ^= 1; + navit_draw(this); + return; + } + layers=g_list_next(layers); + } + } + } +} + + +/** * Get value given a key string for the command system * * @param navit The navit instance @@ -924,6 +954,7 @@ static struct command_table commands[] = { {"push_int",command_cast(navit_cmd_push_int)}, {"pop_int",command_cast(navit_cmd_pop_int)}, {"int_stack_size",command_cast(navit_cmd_int_stack_size)}, + {"toggle_layer",command_cast(navit_cmd_toggle_layer)}, }; void -- 2.7.4