summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOLFDB <olf@eisenzelt.de>2021-03-05 15:19:38 +0100
committerOLFDB <olf@eisenzelt.de>2021-03-05 15:19:38 +0100
commit1307ceb718988c188d0510b5e9b5c81fc99f1ac0 (patch)
tree3747ed3e9513847aa1dbb1c18199a0a820971444
parent0f150a640e4afec7a021e51315775d463d94112f (diff)
downloadnavit-1307ceb718988c188d0510b5e9b5c81fc99f1ac0.tar.gz
attributes tunnel_nightlayout, nightlayout_auto, sunrise_degrees added
-rw-r--r--navit/attr_def.h3
-rw-r--r--navit/navit.c78
-rw-r--r--navit/navit.dtd3
3 files changed, 67 insertions, 17 deletions
diff --git a/navit/attr_def.h b/navit/attr_def.h
index e498a40a8..e5f3033ff 100644
--- a/navit/attr_def.h
+++ b/navit/attr_def.h
@@ -203,6 +203,7 @@ ATTR(nav_status)
ATTR(virtual_dpi)
ATTR(real_dpi)
ATTR(underground_alpha)
+ATTR(sunrise_degrees)
ATTR2(0x00027500,type_rel_abs_begin)
/* These attributes are int that can either hold relative or absolute values. See the
* documentation of ATTR_REL_RELSHIFT for details.
@@ -264,6 +265,8 @@ ATTR(no_warning_if_map_file_missing)
ATTR(duplicate)
ATTR(has_menu_button)
ATTR(oneway)
+ATTR(tunnel_nightlayout)
+ATTR(layout_daynightauto)
ATTR2(0x0002ffff,type_int_end)
ATTR2(0x00030000,type_string_begin)
ATTR(type)
diff --git a/navit/navit.c b/navit/navit.c
index 99c64ea17..a4ab0b62f 100644
--- a/navit/navit.c
+++ b/navit/navit.c
@@ -180,6 +180,9 @@ struct navit {
int waypoints_flag;
struct coord_geo center;
int auto_switch; /*auto switching between day/night layout enabled ?*/
+ int tunnel_nightlayout; /* switch to nightlayout if we are in a tunnel? */
+ char* layout_before_tunnel;
+ int sunrise_degrees;
};
struct gui *main_loop_gui;
@@ -1484,6 +1487,9 @@ navit_new(struct attr *parent, struct attr **attrs) {
this_->radius = 30;
this_->border = 16;
this_->auto_switch = TRUE;
+ this_->tunnel_nightlayout = FALSE;
+ this_->layout_before_tunnel = "";
+ this_->sunrise_degrees = -5;
transform_from_geo(pro, &g, &co);
center.x=co.x;
@@ -2731,6 +2737,18 @@ static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init) {
attr_updated=(this_->waypoints_flag != !!attr->u.num);
this_->waypoints_flag=!!attr->u.num;
break;
+ case attr_tunnel_nightlayout:
+ attr_updated = (this_->tunnel_nightlayout != !!attr->u.num);
+ this_->tunnel_nightlayout = !!attr->u.num;
+ break;
+ case attr_layout_daynightauto:
+ attr_updated = (this_->auto_switch != !!attr->u.num);
+ this_->auto_switch = !!attr->u.num;
+ break;
+ case attr_sunrise_degrees:
+ attr_updated = (this_->sunrise_degrees != attr->u.num);
+ this_->sunrise_degrees = attr->u.num;
+ break;
default:
dbg(lvl_debug, "calling generic setter method for attribute type %s", attr_to_name(attr->type))
return navit_object_set_attr((struct navit_object *) this_, attr);
@@ -2946,6 +2964,15 @@ int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr,
case attr_waypoints_flag:
attr->u.num=this_->waypoints_flag;
break;
+ case attr_tunnel_nightlayout:
+ attr->u.num=this_->tunnel_nightlayout;
+ break;
+ case attr_layout_daynightauto:
+ attr->u.num=this_->auto_switch;
+ break;
+ case attr_sunrise_degrees:
+ attr->u.num=this_->sunrise_degrees;
+ break;
default:
dbg(lvl_debug, "calling generic getter method for attribute type %s", attr_to_name(type))
return navit_object_get_attr((struct navit_object *) this_, type, attr, iter);
@@ -3494,25 +3521,39 @@ void navit_layout_switch(struct navit *n) {
if (n->auto_switch == FALSE)
return;
- if (n->tracking->tunnel) {
- // We are in a tunnel and if we have a nightlayout -> switch to nightlayout
- if (l->nightname) {
- navit_set_layout_by_name(n, l->nightname);
- dbg(lvl_debug, "tunnel -> nightlayout");
- return;
- } else {
- // We are already in nightmode, no matter of the sun
- return;
- }
- } else {
- if (l->dayname) {
- navit_set_layout_by_name(n, l->dayname);
- dbg(lvl_debug, "tunnel end -> daylayout");
+ if (n->tunnel_nightlayout) {
+
+ if (n->tracking->tunnel) {
+
+ // store the current layout name
+ if(!strcmp(n->layout_before_tunnel, ""))
+ n->layout_before_tunnel = n->layout_current->name;
+
+ // We are in a tunnel and if we have a nightlayout -> switch to nightlayout
+ if (l->nightname) {
+ navit_set_layout_by_name(n, l->nightname);
+ dbg(lvl_debug, "tunnel -> nightlayout");
+ }
+
return;
+
} else {
- // We are already in nightmode, no matter of the sun
- return;
+
+ if (l->dayname) {
+
+ if (!strcmp(l->dayname, n->layout_before_tunnel)) {
+ // restore previous layout
+ navit_set_layout_by_name(n, l->dayname);
+ dbg(lvl_debug, "tunnel end -> daylayout");
+ }
+
+ // We were in nightlayout before the tunnel, keep it
+ n->layout_before_tunnel="";
+ return;
+
+ }
}
+
}
if (currTs-(n->prevTs)<60) {
@@ -3533,7 +3574,8 @@ void navit_layout_switch(struct navit *n) {
}
//We calculate sunrise anyway, cause it is needed both for day and for night
- if (__sunriset__(year,month,day,geo_attr.u.coord_geo->lng,geo_attr.u.coord_geo->lat,-5,1,&trise,&tset)!=0) {
+ if (__sunriset__(year,month,day,geo_attr.u.coord_geo->lng,geo_attr.u.coord_geo->lat,n->sunrise_degrees,1,&trise,
+ &tset)!=0) {
dbg(lvl_debug,"near the pole sun never rises/sets, so we should never switch profiles");
dbg(lvl_debug,"trise: %u:%u",HOURS(trise),MINUTES(trise));
dbg(lvl_debug,"tset: %u:%u",HOURS(tset),MINUTES(tset));
@@ -3549,6 +3591,8 @@ void navit_layout_switch(struct navit *n) {
after_sunrise = TRUE;
}
+ dbg(lvl_error, "%i %i %d", HOURS(tset)*60, MINUTES(tset), (currTs%86400)/60);
+
if (((HOURS(tset)*60+MINUTES(tset)<(currTs%86400)/60)) ||
((HOURS(trise_actual)*60+MINUTES(trise_actual)>(currTs%86400)/60))) {
after_sunset = TRUE;
diff --git a/navit/navit.dtd b/navit/navit.dtd
index 6ab800b96..4d6b4cfe6 100644
--- a/navit/navit.dtd
+++ b/navit/navit.dtd
@@ -25,6 +25,9 @@
<!ATTLIST navit recent_dest CDATA #IMPLIED>
<!ATTLIST navit drag_bitmap CDATA #IMPLIED>
<!ATTLIST navit default_layout CDATA #IMPLIED>
+<!ATTLIST navit tunnel_nightlayout CDATA #IMPLIED>
+<!ATTLIST navit nightlayout_auto CDATA #IMPLIED>
+<!ATTLIST navit sunrise_degrees CDATA #IMPLIED>
<!ELEMENT gui ANY>
<!ATTLIST gui type CDATA #REQUIRED>
<!ATTLIST gui menubar CDATA #IMPLIED>