summaryrefslogtreecommitdiff
path: root/navit/osd.c
diff options
context:
space:
mode:
authormdankov <mdankov@ffa7fe5e-494d-0410-b361-a75ebd5db220>2014-10-02 20:35:49 +0000
committermdankov <mdankov@ffa7fe5e-494d-0410-b361-a75ebd5db220>2014-10-02 20:35:49 +0000
commit5ef7233fe1de6dc2a5f38e5b0bfd391b06a51bf1 (patch)
tree9a4b7061c854d0dbbb7dd4292e24a9fd813dd551 /navit/osd.c
parentc86ad2c13629a155f716a20fb2e7a06818a9e74e (diff)
downloadnavit-5ef7233fe1de6dc2a5f38e5b0bfd391b06a51bf1.tar.gz
Fix:osd:Handle osd positions specified in percent|thank you mvglasow
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5901 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/osd.c')
-rw-r--r--navit/osd.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/navit/osd.c b/navit/osd.c
index bec0b4166..00e2411fb 100644
--- a/navit/osd.c
+++ b/navit/osd.c
@@ -158,26 +158,54 @@ osd_std_resize(struct osd_item *item)
graphics_overlay_resize(item->gr, &item->p, item->w, item->h, 65535, 1);
}
+/**
+ * @brief Calculates the size and position of an OSD item.
+ *
+ * If the geometry of the OSD item is specified relative to screen dimensions,
+ * this function will set its absolute dimensions accordingly.
+ * @param item
+ * @param w Available screen width in pixels (the width that corresponds to
+ * 100%)
+ * @param h Available screen height in pixels (the height that corresponds to
+ * 100%)
+ */
static void
-osd_std_calculate_sizes(struct osd_item *item, struct osd_priv *priv, int w, int h)
+osd_std_calculate_sizes(struct osd_item *item, int w, int h)
{
- struct attr vehicle_attr;
-
if (item->rel_w) {
item->w = (item->rel_w * w) / 100;
}
-
+
if (item->rel_h) {
item->h = (item->rel_h * h) / 100;
}
-
+
if (item->rel_x) {
item->p.x = (item->rel_x * w) / 100;
}
-
+
if (item->rel_y) {
item->p.y = (item->rel_y * h) / 100;
}
+}
+
+/**
+ * @brief Recalculates the size and position of an OSD item and
+ * triggers a redraw of the item.
+ *
+ * @param item
+ * @param priv
+ * @param w Available screen width in pixels (the width that corresponds to
+ * 100%)
+ * @param h Available screen height in pixels (the height that corresponds to
+ * 100%)
+ */
+static void
+osd_std_calculate_sizes_and_redraw(struct osd_item *item, struct osd_priv *priv, int w, int h)
+{
+ struct attr vehicle_attr;
+
+ osd_std_calculate_sizes(item, w, h);
osd_std_resize(item);
if (item->meth.draw) {
@@ -364,6 +392,7 @@ osd_set_std_graphic(struct navit *nav, struct osd_item *item, struct osd_priv *p
struct graphics *navit_gr;
navit_gr = navit_get_graphics(nav);
+ osd_std_calculate_sizes(item, navit_get_width(nav), navit_get_height(nav));
item->gr = graphics_overlay_new(navit_gr, &item->p, item->w, item->h, 65535, 1);
item->graphic_bg = graphics_gc_new(item->gr);
@@ -381,7 +410,7 @@ osd_set_std_graphic(struct navit *nav, struct osd_item *item, struct osd_priv *p
osd_set_std_config(nav, item);
- item->resize_cb = callback_new_attr_2(callback_cast(osd_std_calculate_sizes), attr_resize, item, priv);
+ item->resize_cb = callback_new_attr_2(callback_cast(osd_std_calculate_sizes_and_redraw), attr_resize, item, priv);
graphics_add_callback(navit_gr, item->resize_cb);
osd_set_keypress(nav, item);
}