summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormvglasow <michael -at- vonglasow.com>2019-08-21 23:26:44 +0300
committermvglasow <michael -at- vonglasow.com>2019-08-21 23:26:44 +0300
commitd36d6d22bc85ba47e318ac779c6ed0e116c44d89 (patch)
tree438585607f4276648ff4b1aa5f0ea3ad39d05a32
parent3cebbfe35a25b23f17bf51d05298b781d5e91ada (diff)
parent792425f3d4de464aa63cdb8bf3db1ad7feec1c0b (diff)
downloadnavit-d36d6d22bc85ba47e318ac779c6ed0e116c44d89.tar.gz
Merge branch 'trunk' into github836
-rwxr-xr-xCMakeLists.txt52
-rw-r--r--navit/track.c3
-rw-r--r--navit/vehicle.c73
3 files changed, 76 insertions, 52 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ce8d4b41..4890afa04 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -154,35 +154,31 @@ INCLUDE (CheckSymbolExists)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
- if (NOT ANDROID)
- pkg_check_modules ( GMODULE gmodule-2.0 )
- if (GMODULE_FOUND)
- set(HAVE_GMODULE 1)
- include_directories(${GMODULE_INCLUDE_DIRS})
- list(APPEND NAVIT_LIBS ${GMODULE_LIBRARIES})
- endif(GMODULE_FOUND)
-
- pkg_check_modules (GLIB2 glib-2.0>=2.10)
- if (GLIB2_FOUND)
- set(HAVE_GLIB 1)
- include_directories(${GLIB2_INCLUDE_DIRS})
- list(APPEND NAVIT_LIBS ${GLIB2_LIBRARIES})
- else(GLIB2_FOUND)
- set_with_reason(support/glib "Glib not found" TRUE ${INTL_LIBS})
- endif(GLIB2_FOUND)
- endif(NOT ANDROID)
+ pkg_check_modules ( GMODULE gmodule-2.0 )
+ if (GMODULE_FOUND)
+ set(HAVE_GMODULE 1)
+ include_directories(${GMODULE_INCLUDE_DIRS})
+ list(APPEND NAVIT_LIBS ${GMODULE_LIBRARIES})
+ endif(GMODULE_FOUND)
+
+ pkg_check_modules (GLIB2 glib-2.0>=2.10)
+ if (GLIB2_FOUND)
+ set(HAVE_GLIB 1)
+ include_directories(${GLIB2_INCLUDE_DIRS})
+ list(APPEND NAVIT_LIBS ${GLIB2_LIBRARIES})
+ else(GLIB2_FOUND)
+ set_with_reason(support/glib "Glib not found" TRUE ${INTL_LIBS})
+ endif(GLIB2_FOUND)
pkg_check_modules(FONTCONFIG "fontconfig >= 2.2.0")
- if (NOT ANDROID)
- pkg_check_modules(DBUS "dbus-1 >= 1.4")
- pkg_check_modules(DBUSGLIB dbus-glib-1)
- if(DBUSGLIB_FOUND)
- include_directories(${DBUSGLIB_INCLUDE_DIRS})
- set_with_reason(binding/dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES})
- set_with_reason(speech/dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES})
- set_with_reason(vehicle/gpsd_dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES})
- endif(DBUSGLIB_FOUND)
- endif(NOT ANDROID)
+ pkg_check_modules(DBUS "dbus-1 >= 1.4")
+ pkg_check_modules(DBUSGLIB dbus-glib-1)
+ if(DBUSGLIB_FOUND)
+ include_directories(${DBUSGLIB_INCLUDE_DIRS})
+ set_with_reason(binding/dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES})
+ set_with_reason(speech/dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES})
+ set_with_reason(vehicle/gpsd_dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES})
+ endif()
pkg_check_modules(LIBLOCATION liblocation)
pkg_check_modules(LIBOSSO libosso)
@@ -744,8 +740,6 @@ if(ANDROID)
set_with_reason(graphics/null "Android detected" FALSE)
set_with_reason(graphics/android "Android detected" TRUE)
set_with_reason(speech/android "Android detected" TRUE)
- set_with_reason(support/ezxml "Android detected" TRUE)
- set_with_reason(support/glib "Android detected" TRUE)
set_with_reason(traffic/traff_android "Android detected" TRUE)
set_with_reason(vehicle/android "Android detected" TRUE)
set_with_reason(vehicle/file "Android detected" FALSE)
diff --git a/navit/track.c b/navit/track.c
index a197a1ea4..37a7d70a4 100644
--- a/navit/track.c
+++ b/navit/track.c
@@ -635,7 +635,8 @@ void tracking_update(struct tracking *tr, struct vehicle *v, struct vehicleprofi
}
if (!vehicle_get_attr(tr->vehicle, attr_position_speed, &speed_attr, NULL) ||
!vehicle_get_attr(tr->vehicle, attr_position_direction, &direction_attr, NULL) ||
- !vehicle_get_attr(tr->vehicle, attr_position_coord_geo, &coord_geo, NULL)) {
+ !vehicle_get_attr(tr->vehicle, attr_position_coord_geo, &coord_geo, NULL) ||
+ !vehicle_get_attr(tr->vehicle, attr_position_time_iso8601, &time_attr, NULL)) {
dbg(lvl_error,"failed to get position data %d %d %d",
vehicle_get_attr(tr->vehicle, attr_position_speed, &speed_attr, NULL),
vehicle_get_attr(tr->vehicle, attr_position_direction, &direction_attr, NULL),
diff --git a/navit/vehicle.c b/navit/vehicle.c
index 5bf16c280..f0094e804 100644
--- a/navit/vehicle.c
+++ b/navit/vehicle.c
@@ -33,6 +33,7 @@
#include <string.h>
#include <glib.h>
#include <time.h>
+#include <math.h> /* for sqrt from coord.h */
#include "config.h"
#include "debug.h"
#include "coord.h"
@@ -69,6 +70,9 @@ struct vehicle {
struct callback *animate_callback;
struct event_timeout *animate_timer;
struct point cursor_pnt;
+ int need_resize;
+ int real_w;
+ int real_h;
struct graphics *gra;
struct graphics_gc *bg;
struct transformation *trans;
@@ -309,7 +313,8 @@ int vehicle_remove_attr(struct vehicle *this_, struct attr *attr) {
* @author Ralph Sennhauser (10/2009)
*/
void vehicle_set_cursor(struct vehicle *this_, struct cursor *cursor, int overwrite) {
- struct point sc;
+ dbg(lvl_debug,"enter this_=%p cursot=%p overwrit=%d, this_->cursor_fixed=%d, this_->gra=%p", this_, cursor, overwrite,
+ this_->cursor_fixed, this_->gra);
if (this_->cursor_fixed && !overwrite)
return;
if (this_->animate_callback) {
@@ -322,26 +327,20 @@ void vehicle_set_cursor(struct vehicle *this_, struct cursor *cursor, int overwr
this_->animate_callback=callback_new_2(callback_cast(vehicle_draw_do), this_, 0);
this_->animate_timer=event_add_timeout(cursor->interval, 1, this_->animate_callback);
}
+ /* we changed the cursor, so the overlay (if existing) may need a resize */
+ this_->need_resize=1;
+ this_->cursor=cursor;
- if (cursor && this_->gra && this_->cursor) {
- this_->cursor_pnt.x+=(this_->cursor->w - cursor->w)/2;
- this_->cursor_pnt.y+=(this_->cursor->h - cursor->h)/2;
- graphics_overlay_resize(this_->gra, &this_->cursor_pnt, cursor->w, cursor->h, 0);
- }
-
- if (cursor) {
- sc.x=cursor->w/2;
- sc.y=cursor->h/2;
- if (!this_->cursor && this_->gra)
+ /* if the graphics was already created, but a NULL cursor was set, we need to disable
+ * otherwise stale overlay
+ */
+ if(this_->gra) {
+ if(this_->cursor)
graphics_overlay_disable(this_->gra, 0);
- } else {
- sc.x=sc.y=0;
- if (this_->cursor && this_->gra)
+ else
graphics_overlay_disable(this_->gra, 1);
}
- transform_set_screen_center(this_->trans, &sc);
-
- this_->cursor=cursor;
+ /* vehicle_draw will care for the graphics */
}
/**
@@ -354,6 +353,7 @@ void vehicle_set_cursor(struct vehicle *this_, struct cursor *cursor, int overwr
* @param speed The speed of the vehicle.
*/
void vehicle_draw(struct vehicle *this_, struct graphics *gra, struct point *pnt, int angle, int speed) {
+ struct point sc;
if (angle < 0)
angle+=360;
dbg(lvl_debug,"enter this=%p gra=%p pnt=%p dir=%d speed=%d", this_, gra, pnt, angle, speed);
@@ -363,11 +363,35 @@ void vehicle_draw(struct vehicle *this_, struct graphics *gra, struct point *pnt
this_->speed=speed;
if (!this_->cursor)
return;
- this_->cursor_pnt.x-=this_->cursor->w/2;
- this_->cursor_pnt.y-=this_->cursor->h/2;
+
+ if((this_->need_resize) || !(this_->gra)) {
+ /* recalculate real size of the required overlay */
+ navit_float radius;
+
+ /* get the radius of the out circle. Pythagoras greets */
+ radius = navit_sqrt((this_->cursor->w * this_->cursor->w) + (this_->cursor->h * this_->cursor->h));
+ /* since we rotate the rectangle around the center to indicate direction, the overlay needs to be at least the
+ * radius of the out circle big. The +1 compensates the rounding error.
+ */
+ this_->real_w = (int)radius +1;
+ this_->real_h = (int)radius +1;
+
+ /* set transform center to the middle of the cursor */
+ sc.x = this_->real_w/2;
+ sc.y = this_->real_h/2;
+ transform_set_screen_center(this_->trans, &sc);
+ }
+
+ /* move the cursor point from te center to the top left*/
+ this_->cursor_pnt.x-=(this_->real_w/2);
+ this_->cursor_pnt.y-=(this_->real_h/2);
+ dbg(lvl_debug,"real point %d,%d real size %d,%d", this_->cursor_pnt.x, this_->cursor_pnt.y, this_->real_w,
+ this_->real_h);
+
if (!this_->gra) {
struct color c;
- this_->gra=graphics_overlay_new(gra, &this_->cursor_pnt, this_->cursor->w, this_->cursor->h, 0);
+ this_->need_resize=0;
+ this_->gra=graphics_overlay_new(gra, &this_->cursor_pnt, this_->real_w, this_->real_h, 0);
if (this_->gra) {
graphics_init(this_->gra);
this_->bg=graphics_gc_new(this_->gra);
@@ -378,7 +402,12 @@ void vehicle_draw(struct vehicle *this_, struct graphics *gra, struct point *pnt
graphics_gc_set_foreground(this_->bg, &c);
graphics_background_gc(this_->gra, this_->bg);
}
+ } else if (this_->need_resize) {
+ /* seems the cursor was changed. Need to resize */
+ this_->need_resize=0;
+ graphics_overlay_resize(this_->gra, &this_->cursor_pnt, this_->real_w, this_->real_h, 0);
}
+
vehicle_draw_do(this_);
}
@@ -400,7 +429,6 @@ static void vehicle_set_default_name(struct vehicle *this_) {
}
}
-
static void vehicle_draw_do(struct vehicle *this_) {
struct point p;
struct cursor *cursor=this_->cursor;
@@ -424,7 +452,8 @@ static void vehicle_draw_do(struct vehicle *this_) {
graphics_draw_mode(this_->gra, draw_mode_begin);
p.x=0;
p.y=0;
- graphics_draw_rectangle(this_->gra, this_->bg, &p, cursor->w, cursor->h);
+ /* clear old content by overwriting with an rectangle */
+ graphics_draw_rectangle(this_->gra, this_->bg, &p, this_->real_w, this_->real_h);
attr=cursor->attrs;
while (*attr) {
if ((*attr)->type == attr_itemgra) {