summaryrefslogtreecommitdiff
path: root/navit
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-11-20 08:26:57 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-11-20 08:26:57 +0000
commit79b473045f5d13d72b704b3e6f61bf5a515c1375 (patch)
tree205954c3308c09fbf7a7af5454be4bf53d65afbc /navit
parentcbb09981f86428b013103f97cb684ebb057d4326 (diff)
downloadnavit-79b473045f5d13d72b704b3e6f61bf5a515c1375.tar.gz
Add:gui_internal:Further export of menus
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2767 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r--navit/command.c2
-rw-r--r--navit/gui.c12
-rw-r--r--navit/gui.h2
-rw-r--r--navit/gui/internal/gui_internal.c97
-rw-r--r--navit/navit.c3
-rw-r--r--navit/navit_shipped.xml11
-rw-r--r--navit/xmlconfig.c2
7 files changed, 53 insertions, 76 deletions
diff --git a/navit/command.c b/navit/command.c
index 58d414e8e..1258fc5df 100644
--- a/navit/command.c
+++ b/navit/command.c
@@ -659,6 +659,8 @@ eval_assignment(struct context *ctx, struct result *res)
if (!get_op(ctx,0,"=",NULL)) return;
eval_conditional(ctx, &tmp);
if (ctx->error) return;
+ resolve(ctx, &tmp, NULL);
+ if (ctx->error) return;
resolve_object(ctx, res);
command_set_attr(ctx, res, &tmp);
}
diff --git a/navit/gui.c b/navit/gui.c
index a05d3d8ab..8dc1dca3c 100644
--- a/navit/gui.c
+++ b/navit/gui.c
@@ -75,6 +75,18 @@ gui_get_attr(struct gui *this_, enum attr_type type, struct attr *attr, struct a
return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
}
+
+int
+gui_set_attr(struct gui *this_, struct attr *attr)
+{
+ int ret=1;
+ if (this_->meth.set_attr)
+ ret=this_->meth.set_attr(this_->priv, attr);
+ if (ret == 1)
+ this_->attrs=attr_generic_set_attr(this_->attrs, attr);
+ return ret != 0;
+}
+
int
gui_add_attr(struct gui *this_, struct attr *attr)
{
diff --git a/navit/gui.h b/navit/gui.h
index 81dcd31e8..b19b5126b 100644
--- a/navit/gui.h
+++ b/navit/gui.h
@@ -39,6 +39,7 @@ struct gui_methods {
void (*disable_suspend)(struct gui_priv *priv);
int (*get_attr)(struct gui_priv *priv, enum attr_type type, struct attr *attr);
int (*add_attr)(struct gui_priv *priv, struct attr *attr);
+ int (*set_attr)(struct gui_priv *priv, struct attr *attr);
};
@@ -54,6 +55,7 @@ struct menu;
struct pcoord;
struct gui *gui_new(struct attr *parent, struct attr **attrs);
int gui_get_attr(struct gui *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
+int gui_set_attr(struct gui *this_, struct attr *attr);
int gui_add_attr(struct gui *this_, struct attr *attr);
struct menu *gui_menubar_new(struct gui *gui);
struct menu *gui_popup_new(struct gui *gui);
diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c
index 73ef47317..714fd5d1e 100644
--- a/navit/gui/internal/gui_internal.c
+++ b/navit/gui/internal/gui_internal.c
@@ -1358,7 +1358,6 @@ gui_internal_cmd2_back_to_map(struct gui_priv *this, char *function, struct attr
gui_internal_prune_menu(this, NULL);
}
-
static void
gui_internal_cmd_main_menu(struct gui_priv *this, struct widget *wm, void *data)
{
@@ -3055,7 +3054,7 @@ gui_internal_cmd2_town(struct gui_priv *this, char *function, struct attr **in,
}
static void
-gui_internal_cmd_layout(struct gui_priv *this, struct widget *wm, void *data)
+gui_internal_cmd2_setting_layout(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
{
struct attr attr;
struct widget *w,*wb,*wl;
@@ -3077,75 +3076,6 @@ gui_internal_cmd_layout(struct gui_priv *this, struct widget *wm, void *data)
}
static void
-gui_internal_cmd_fullscreen(struct gui_priv *this, struct widget *wm, void *data)
-{
- graphics_draw_mode(this->gra, draw_mode_end);
- if (this->fullscreen != 2)
- this->fullscreen=!this->fullscreen;
- this->win->fullscreen(this->win, this->fullscreen != 0);
- graphics_draw_mode(this->gra, draw_mode_begin);
-}
-
-static void
-gui_internal_cmd_2d(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct transformation *trans=navit_get_trans(this->nav);
- transform_set_pitch(trans, 0);
- this->redraw=1;
- gui_internal_prune_menu(this, NULL);
-}
-
-static void
-gui_internal_cmd_3d(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct transformation *trans=navit_get_trans(this->nav);
- transform_set_pitch(trans, this->pitch);
- this->redraw=1;
- gui_internal_prune_menu(this, NULL);
-}
-
-static void
-gui_internal_cmd2_setting_display(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *w;
- struct transformation *trans;
-
- w=gui_internal_menu(this, _("Display"));
- gui_internal_widget_append(w,
- gui_internal_button_new_with_callback(this, _("Layout"),
- image_new_l(this, "gui_display"), gravity_center|orientation_vertical,
- gui_internal_cmd_layout, NULL));
-
- if(this->fullscreen != 2) {
- if (this->fullscreen) {
- gui_internal_widget_append(w,
- gui_internal_button_new_with_callback(this, _("Window Mode"),
- image_new_l(this, "gui_leave_fullscreen"), gravity_center|orientation_vertical,
- gui_internal_cmd_fullscreen, NULL));
- } else {
- gui_internal_widget_append(w,
- gui_internal_button_new_with_callback(this, _("Fullscreen"),
- image_new_l(this, "gui_fullscreen"), gravity_center|orientation_vertical,
- gui_internal_cmd_fullscreen, NULL));
- }
- }
- trans=navit_get_trans(this->nav);
- if (transform_get_pitch(trans)) {
- gui_internal_widget_append(w,
- gui_internal_button_new_with_callback(this, _("2D"),
- image_new_l(this, "gui_map"), gravity_center|orientation_vertical,
- gui_internal_cmd_2d, NULL));
-
- } else {
- gui_internal_widget_append(w,
- gui_internal_button_new_with_callback(this, _("3D"),
- image_new_l(this, "gui_map"), gravity_center|orientation_vertical,
- gui_internal_cmd_3d, NULL));
- }
- gui_internal_menu_render(this);
-}
-
-static void
gui_internal_cmd2_quit(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
{
struct attr navit;
@@ -3904,6 +3834,9 @@ gui_internal_get_attr(struct gui_priv *this, enum attr_type type, struct attr *a
return 0;
*attr=*this->position_coord_geo;
break;
+ case attr_pitch:
+ attr->u.num=this->pitch;
+ break;
default:
return 0;
}
@@ -3924,6 +3857,24 @@ gui_internal_add_attr(struct gui_priv *this, struct attr *attr)
}
}
+static int
+gui_internal_set_attr(struct gui_priv *this, struct attr *attr)
+{
+ switch (attr->type) {
+ case attr_fullscreen:
+ if ((this->fullscreen > 0) != (attr->u.num > 0)) {
+ graphics_draw_mode(this->gra, draw_mode_end);
+ this->win->fullscreen(this->win, attr->u.num > 0);
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ }
+ this->fullscreen=attr->u.num;
+ return 1;
+ default:
+ dbg(0,"%s\n",attr_to_name(attr->type));
+ return 0;
+ }
+}
+
//##############################################################################################################
//# Description: Function to handle mouse clicks and scroll wheel movement
@@ -4246,6 +4197,7 @@ struct gui_methods gui_internal_methods = {
gui_internal_disable_suspend,
gui_internal_get_attr,
gui_internal_add_attr,
+ gui_internal_set_attr,
};
static void
@@ -5294,7 +5246,6 @@ static struct command_table commands[] = {
{"abort_navigation()",command_cast(gui_internal_cmd2_abort_navigation)},
{"back_to_map",command_cast(gui_internal_cmd2_back_to_map)},
{"bookmarks",command_cast(gui_internal_cmd2_bookmarks)},
- {"fullscreen",command_cast(gui_internal_cmd_fullscreen)},
{"get_data",command_cast(gui_internal_get_data)},
{"locale",command_cast(gui_internal_cmd2_locale)},
{"log",command_cast(gui_internal_cmd_log)},
@@ -5302,7 +5253,7 @@ static struct command_table commands[] = {
{"position",command_cast(gui_internal_cmd2_position)},
{"route_description",command_cast(gui_internal_cmd2_route_description)},
{"route_height_profile",command_cast(gui_internal_cmd2_route_height_profile)},
- {"setting_display",command_cast(gui_internal_cmd2_setting_display)},
+ {"setting_layout",command_cast(gui_internal_cmd2_setting_layout)},
{"setting_maps",command_cast(gui_internal_cmd2_setting_maps)},
{"setting_rules",command_cast(gui_internal_cmd2_setting_rules)},
{"setting_vehicle",command_cast(gui_internal_cmd2_setting_vehicle)},
diff --git a/navit/navit.c b/navit/navit.c
index 5e9ab6e6f..8f7283d04 100644
--- a/navit/navit.c
+++ b/navit/navit.c
@@ -1861,6 +1861,9 @@ navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, stru
case attr_osd_configuration:
attr->u.num=this_->osd_configuration;
break;
+ case attr_pitch:
+ attr->u.num=transform_get_pitch(this_->trans);
+ break;
case attr_projection:
if(this_->trans) {
attr->u.num=transform_get_projection(this_->trans);
diff --git a/navit/navit_shipped.xml b/navit/navit_shipped.xml
index d41f3be87..689850bd6 100644
--- a/navit/navit_shipped.xml
+++ b/navit/navit_shipped.xml
@@ -42,7 +42,7 @@
<gui type="internal" enabled="yes"><![CDATA[
<html>
- <a name='Main Menu'>Main menu
+ <a name='Main Menu'><text>Main menu</text>
<a href='#Actions'><img src='gui_actions'>Actions</img></a>
<img cond='flags&amp;2' src='gui_map' onclick='back_to_map()'><text>Show
Map</text></img>
@@ -60,11 +60,18 @@ Map</text></img>
Navigation</text></img>
</a>
<a name='Settings'><text>Settings</text>
- <img src='gui_display' onclick='setting_display()'><text>Display</text></img>
+ <a href='#Settings Display'><img src='gui_display'><text>Display</text></img></a>
<img src='gui_maps' onclick='setting_maps()'><text>Maps</text></img>
<img src='gui_vehicle' onclick='setting_vehicle()'><text>Vehicle</text></img>
<img src='gui_rules' onclick='setting_rules()'><text>Rules</text></img>
</a>
+ <a name='Settings Display'><text>Display</text>
+ <img src='gui_display' onclick='setting_layout()'><text>Layout</text></img>
+ <img cond='fullscreen==0' src='gui_fullscreen' onclick='fullscreen=1'><text>Fullscreen</text></img>
+ <img cond='fullscreen==1' src='gui_leave_fullscreen' onclick='fullscreen=0'><text>Window Mode</text></img>
+ <img cond='navit.pitch==0' src='gui_map' onclick='navit.pitch=pitch;redraw_map();back_to_map()'><text>3D</text></img>
+ <img cond='navit.pitch!=0' src='gui_map' onclick='navit.pitch=0;redraw_map();back_to_map()'><text>2D</text></img>
+ </a>
<a name='Tools'><text>Tools</text>
<img src='gui_actions' onclick='locale()'><text>Show Locale</text></img>
</a>
diff --git a/navit/xmlconfig.c b/navit/xmlconfig.c
index f0661a923..76d3d96b6 100644
--- a/navit/xmlconfig.c
+++ b/navit/xmlconfig.c
@@ -244,7 +244,7 @@ static struct object_func object_funcs[] = {
{ attr_cursor, NEW(cursor_new), NULL, NULL, NULL, NULL, ADD(cursor_add_attr)},
{ attr_debug, NEW(debug_new)},
{ attr_graphics, NEW(graphics_new)},
- { attr_gui, NEW(gui_new), GET(gui_get_attr), NULL, NULL, NULL, ADD(gui_add_attr)},
+ { attr_gui, NEW(gui_new), GET(gui_get_attr), NULL, NULL, SET(gui_set_attr), ADD(gui_add_attr)},
{ attr_icon, NEW(icon_new), NULL, NULL, NULL, NULL, ADD(element_add_attr)},
{ attr_image, NEW(image_new)},
{ attr_itemgra, NEW(itemgra_new), NULL, NULL, NULL, NULL, ADD(itemgra_add_attr)},