summaryrefslogtreecommitdiff
path: root/navit/gui
diff options
context:
space:
mode:
Diffstat (limited to 'navit/gui')
-rw-r--r--navit/gui/internal/gui_internal.c54
-rw-r--r--navit/gui/internal/gui_internal_widget.c15
2 files changed, 39 insertions, 30 deletions
diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c
index 0cf19f467..3affd52e4 100644
--- a/navit/gui/internal/gui_internal.c
+++ b/navit/gui/internal/gui_internal.c
@@ -1623,13 +1623,13 @@ gui_internal_cmd_bookmarks(struct gui_priv *this, struct widget *wm, void *data)
static void
gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int rotary);
-int
-gui_internal_keynav_find_next(struct widget *wi, struct widget *cur, struct widget **result);
+static int
+gui_internal_keynav_find_next(struct widget *wi, struct widget *current_highlight, struct widget **result);
-int
-gui_internal_keynav_find_prev(struct widget *wi, struct widget *cur, struct widget **result);
+static int
+gui_internal_keynav_find_prev(struct widget *wi, struct widget *current_highlight, struct widget **result);
-struct widget*
+static struct widget*
gui_internal_keynav_find_next_sensitive_child(struct widget *wi);
void
@@ -2694,7 +2694,7 @@ gui_internal_keynav_point(struct widget *w, int dx, int dy, struct point *p)
p->y=w->p.y+w->h;
}
-struct widget*
+static struct widget*
gui_internal_keynav_find_next_sensitive_child(struct widget *wi) {
GList *l=wi->children;
if (wi && wi->state & STATE_SENSITIVE)
@@ -2708,15 +2708,15 @@ gui_internal_keynav_find_next_sensitive_child(struct widget *wi) {
return NULL;
}
-int
-gui_internal_keynav_find_next(struct widget *wi, struct widget *cur, struct widget **result) {
+static int
+gui_internal_keynav_find_next(struct widget *wi, struct widget *current_highlight, struct widget **result) {
GList *l=wi->children;
- if (wi == cur)
+ if (wi == current_highlight)
return 1;
while (l) {
struct widget *child=l->data;
l=g_list_next(l);
- if (gui_internal_keynav_find_next(child, cur, result)) {
+ if (gui_internal_keynav_find_next(child, current_highlight, result)) {
while (l) {
struct widget *new = gui_internal_keynav_find_next_sensitive_child(l->data);
if (new) {
@@ -2736,9 +2736,9 @@ gui_internal_keynav_find_next(struct widget *wi, struct widget *cur, struct widg
#define RESULT_FOUND 1
#define NO_RESULT_YET 0
-int
-gui_internal_keynav_find_prev(struct widget *wi, struct widget *cur, struct widget **result) {
- if (wi == cur && *result) {
+static int
+gui_internal_keynav_find_prev(struct widget *wi, struct widget *current_highlight, struct widget **result) {
+ if (wi == current_highlight && *result) {
// Reached current widget; last widget found is the result.
return RESULT_FOUND;
}
@@ -2747,12 +2747,12 @@ gui_internal_keynav_find_prev(struct widget *wi, struct widget *cur, struct widg
GList *l=wi->children;
while (l) {
struct widget *child=l->data;
- if (gui_internal_keynav_find_prev(child, cur, result) == RESULT_FOUND) {
+ if (gui_internal_keynav_find_prev(child, current_highlight, result) == RESULT_FOUND) {
return RESULT_FOUND;
}
l=g_list_next(l);
}
- // If no sensitive widget is found before "cur", return the last sensitive widget when
+ // If no sensitive widget is found before "current_highlight", return the last sensitive widget when
// recursion terminates.
return NO_RESULT_YET;
}
@@ -2799,16 +2799,28 @@ gui_internal_keynav_find_closest(struct widget *wi, struct point *p, int dx, int
}
}
+/**
+ * @brief Move keyboard focus to the next widget.
+ *
+ * Move keyboard focus to the appropriate next widget, depending on the direction of focus
+ * movement.
+ *
+ * @param this GUI context
+ * @param this dx horizontal movement (-1=left, +1=right), unless rotary==1
+ * @param this dy vertical movement (+1=up, -1=down)
+ * @param rotary (0/1) input from rotary encoder - dx indicates forwards/backwards movement
+ * through all widgets
+ */
static void
gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int rotary)
{
struct widget *result,*menu=g_list_last(this->root.children)->data;
- struct widget *cur = NULL;
+ struct widget *current_highlight = NULL;
struct point p;
int distance;
- if (this->highlighted && this->highlighted_menu == g_list_last(this->root.children)->data) {
+ if (this->highlighted && this->highlighted_menu == menu) {
gui_internal_keynav_point(this->highlighted, dx, dy, &p);
- cur = this->highlighted;
+ current_highlight = this->highlighted;
}
else {
p.x=0;
@@ -2819,15 +2831,15 @@ gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int ro
if (result) {
gui_internal_keynav_point(result, dx, dy, &p);
dbg(lvl_debug,"result origin=%p p=%d,%d\n", result, p.x, p.y);
- cur = result;
+ current_highlight = result;
}
}
result=NULL;
distance=INT_MAX;
if (rotary && dx > 0)
- gui_internal_keynav_find_next(menu, cur, &result);
+ gui_internal_keynav_find_next(menu, current_highlight, &result);
else if (rotary && dx < 0)
- gui_internal_keynav_find_prev(menu, cur, &result);
+ gui_internal_keynav_find_prev(menu, current_highlight, &result);
else
gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
dbg(lvl_debug,"result=%p\n", result);
diff --git a/navit/gui/internal/gui_internal_widget.c b/navit/gui/internal/gui_internal_widget.c
index 524f325f2..e78abb3dd 100644
--- a/navit/gui/internal/gui_internal_widget.c
+++ b/navit/gui/internal/gui_internal_widget.c
@@ -1225,7 +1225,7 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
GList * cur_row = NULL;
GList * current_desc=NULL;
struct table_data * table_data = (struct table_data*)w->data;
- int is_skipped=0;
+ int drawing_space_left=1;
int is_first_page=1;
struct table_column_desc * dim=NULL;
@@ -1291,10 +1291,7 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
if( y + dim->height + bbox_height + this->spacing >= w->p.y + w->h )
{
- /*
- * No more drawing space left.
- */
- is_skipped=1;
+ drawing_space_left=0;
}
for(cur_column = cur_row_widget->children; cur_column;
cur_column=g_list_next(cur_column))
@@ -1302,7 +1299,7 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
struct widget * cur_widget = (struct widget*) cur_column->data;
dim = (struct table_column_desc*)current_desc->data;
- if (!is_skipped) {
+ if (drawing_space_left) {
cur_widget->p.x=x;
cur_widget->w=dim->width;
cur_widget->p.y=y;
@@ -1326,7 +1323,7 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
}
}
- if (!is_skipped) {
+ if (drawing_space_left) {
/* Row object should have its coordinates in actual
* state to be able to pass mouse clicks to Column objects
*/
@@ -1344,7 +1341,7 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
table_data->scroll_buttons.next_button->state&= ~STATE_SENSITIVE;
table_data->scroll_buttons.prev_button->state&= ~STATE_SENSITIVE;
- if(table_data->scroll_buttons.button_box && (is_skipped || !is_first_page) && !table_data->scroll_buttons.button_box_hide )
+ if(table_data->scroll_buttons.button_box && (!drawing_space_left || !is_first_page) && !table_data->scroll_buttons.button_box_hide )
{
table_data->scroll_buttons.button_box->p.y =w->p.y+w->h-table_data->scroll_buttons.button_box->h -
this->spacing;
@@ -1360,7 +1357,7 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
table_data->scroll_buttons.button_box->p.y = w->p.y + w->h -
table_data->scroll_buttons.button_box->h;
}
- if(is_skipped)
+ if(!drawing_space_left)
{
table_data->scroll_buttons.next_button->state|= STATE_SENSITIVE;
}