summaryrefslogtreecommitdiff
path: root/navit/graphics
diff options
context:
space:
mode:
authorPierre GRANDIN <pgrandin@users.noreply.github.com>2016-02-22 15:13:56 -0800
committerPierre GRANDIN <pgrandin@users.noreply.github.com>2016-02-22 15:13:56 -0800
commit2c77286a6c08af6f77866671af31d3f99719d22a (patch)
tree4b505b22819fc04898c04376defc896a3d8aa251 /navit/graphics
parent7eaf614763af6a9a4b1c9d3753e35c5bdbcfa8ee (diff)
parent0c95f9992ce02fe6c4da86005f69ba433842aa5f (diff)
downloadnavit-2c77286a6c08af6f77866671af31d3f99719d22a.tar.gz
Merge pull request #73 from mvglasow/android-laf-rebasedR6603
Add:port_android:Look and feel update
Diffstat (limited to 'navit/graphics')
-rw-r--r--navit/graphics/android/graphics_android.c68
1 files changed, 64 insertions, 4 deletions
diff --git a/navit/graphics/android/graphics_android.c b/navit/graphics/android/graphics_android.c
index 2bfbacab4..2bf9ed952 100644
--- a/navit/graphics/android/graphics_android.c
+++ b/navit/graphics/android/graphics_android.c
@@ -39,7 +39,8 @@ struct graphics_priv {
jmethodID NavitGraphics_draw_polyline, NavitGraphics_draw_polygon, NavitGraphics_draw_rectangle,
NavitGraphics_draw_circle, NavitGraphics_draw_text, NavitGraphics_draw_image,
NavitGraphics_draw_image_warp, NavitGraphics_draw_mode, NavitGraphics_draw_drag,
- NavitGraphics_overlay_disable, NavitGraphics_overlay_resize, NavitGraphics_SetCamera;
+ NavitGraphics_overlay_disable, NavitGraphics_overlay_resize, NavitGraphics_SetCamera,
+ NavitGraphics_setBackgroundColor;
jclass PaintClass;
jmethodID Paint_init,Paint_setStrokeWidth,Paint_setARGB;
@@ -64,6 +65,8 @@ struct graphics_priv {
struct callback_list *cbl;
struct window win;
+ struct padding *padding;
+ jint bgcolor;
};
struct graphics_font_priv {
@@ -419,9 +422,11 @@ static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graph
static void *
get_data(struct graphics_priv *this, const char *type)
{
- if (strcmp(type,"window"))
- return NULL;
- return &this->win;
+ if (!strcmp(type,"padding"))
+ return this->padding;
+ if (!strcmp(type,"window"))
+ return &this->win;
+ return NULL;
}
static void image_free(struct graphics_priv *gr, struct graphics_image_priv *priv)
@@ -463,6 +468,18 @@ set_attr(struct graphics_priv *gra, struct attr *attr)
case attr_use_camera:
(*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_SetCamera, attr->u.num);
return 1;
+ case attr_background_color:
+ gra->bgcolor = (attr->u.color->a / 0x101) << 24
+ | (attr->u.color->r / 0x101) << 16
+ | (attr->u.color->g / 0x101) << 8
+ | (attr->u.color->b / 0x101);
+ dbg(lvl_debug, "set attr_background_color %04x %04x %04x %04x (%08x)\n",
+ attr->u.color->r, attr->u.color->g, attr->u.color->b, attr->u.color->a, gra->bgcolor);
+ if (gra->NavitGraphics_setBackgroundColor != NULL)
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_setBackgroundColor, gra->bgcolor);
+ else
+ dbg(lvl_error, "NavitGraphics.setBackgroundColor not found, cannot set background color\n");
+ return 1;
default:
return 0;
}
@@ -496,10 +513,21 @@ static void
resize_callback(struct graphics_priv *gra, int w, int h)
{
dbg(lvl_debug,"w=%d h=%d ok\n",w,h);
+ dbg(lvl_debug,"gra=%p, %d callbacks in list\n", gra, g_list_length(gra->cbl));
callback_list_call_attr_2(gra->cbl, attr_resize, (void *)w, (void *)h);
}
static void
+padding_callback(struct graphics_priv *gra, int left, int top, int right, int bottom)
+{
+ dbg(lvl_debug, "win.padding left=%d top=%d right=%d bottom=%d ok\n", left, top, right, bottom);
+ gra->padding->left = left;
+ gra->padding->top = top;
+ gra->padding->right = right;
+ gra->padding->bottom = bottom;
+}
+
+static void
motion_callback(struct graphics_priv *gra, int x, int y)
{
struct point p;
@@ -569,6 +597,8 @@ graphics_android_init(struct graphics_priv *ret, struct graphics_priv *parent, s
jmethodID cid, Context_getPackageName;
dbg(lvl_debug,"at 2 jnienv=%p\n",jnienv);
+ if (parent)
+ ret->padding = parent->padding;
if (!find_class_global("android/graphics/Paint", &ret->PaintClass))
return 0;
if (!find_method(ret->PaintClass, "<init>", "(I)V", &ret->Paint_init))
@@ -644,6 +674,14 @@ graphics_android_init(struct graphics_priv *ret, struct graphics_priv *parent, s
cb=callback_new_1(callback_cast(resize_callback), ret);
(*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setPaddingChangedCallback", "(I)V");
+ if (cid == NULL) {
+ dbg(lvl_error,"no SetPaddingCallback method found\n");
+ return 0; /* exception thrown */
+ }
+ cb=callback_new_1(callback_cast(padding_callback), ret);
+ (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
+
cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setButtonCallback", "(I)V");
if (cid == NULL) {
dbg(lvl_error,"no SetButtonCallback method found\n");
@@ -790,6 +828,7 @@ graphics_android_new(struct navit *nav, struct graphics_methods *meth, struct at
struct attr *attr;
int use_camera=0;
jmethodID cid;
+ jint android_bgcolor;
dbg(lvl_debug, "enter\n");
if (!event_request_system("android","graphics_android"))
@@ -801,6 +840,23 @@ graphics_android_new(struct navit *nav, struct graphics_methods *meth, struct at
ret->win.priv=ret;
ret->win.fullscreen=graphics_android_fullscreen;
ret->win.disable_suspend=graphics_android_disable_suspend;
+ ret->padding = g_new0(struct padding, 1);
+ ret->padding->left = 0;
+ ret->padding->top = 0;
+ ret->padding->right = 0;
+ ret->padding->bottom = 0;
+ /* attr_background_color is the background color for system bars (API 17+ only) */
+ if ((attr=attr_search(attrs, NULL, attr_background_color))) {
+ ret->bgcolor = (attr->u.color->a / 0x101) << 24
+ | (attr->u.color->r / 0x101) << 16
+ | (attr->u.color->g / 0x101) << 8
+ | (attr->u.color->b / 0x101);
+ dbg(lvl_debug, "attr_background_color %04x %04x %04x %04x (%08x)\n",
+ attr->u.color->r, attr->u.color->g, attr->u.color->b, attr->u.color->a, ret->bgcolor);
+ } else {
+ /* default is the same as for OSD */
+ ret->bgcolor = 0x60000000;
+ }
if ((attr=attr_search(attrs, NULL, attr_use_camera))) {
use_camera=attr->u.num;
}
@@ -825,6 +881,10 @@ graphics_android_new(struct navit *nav, struct graphics_methods *meth, struct at
dbg(lvl_debug, "attr_has_menu_button=%d\n", attr->u.num);
g_free(attr);
}
+ ret->NavitGraphics_setBackgroundColor = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setBackgroundColor", "(I)V");
+ if (ret->NavitGraphics_setBackgroundColor != NULL) {
+ (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, ret->NavitGraphics_setBackgroundColor, ret->bgcolor);
+ }
dbg(lvl_debug,"returning %p\n",ret);
return ret;
} else {