summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Pohlink <pohlinkzei@gmx-topmail.de>2017-03-02 11:17:06 +0100
committerPierre GRANDIN <pgrandin@users.noreply.github.com>2017-03-02 02:17:06 -0800
commit0702010c7120c3a4904317442b6809385f402fcf (patch)
tree5a2a6abf5ea836614a9a6e15eec3ce3c0acfa4c0
parent9d1d5ab5335dcfae034fb7b22e6fd59ca3f3d1bc (diff)
downloadnavit-R7358.tar.gz
Hide impossible keys at the internal keyboard instead of highlighting the possible ones (leftover from PR5) (#210)R7358
* Add:gui_internal:In search, hide on-screen keys which will not find a result. During incremental search in the search dialog, hide keys on the on-screen keyboard which will not lead to any search result. Before, keys where highlighted if they would lead to a result. * Remap special characters in Search to standard characters to enable useful hide-key-functionality * Fix highlight (hide) possible next keys for search internal Now only shows possible keys, not the nth key of the searched item. Takes care of umlauts. * Add a switch attr for gui internal to decide to use hide_keys or the old highlight key behaviour usage: add the attr 'hide_next_possible_keys="1"' to <gui type="internal" [...] />
-rw-r--r--navit/attr_def.h2
-rw-r--r--navit/gui/internal/gui_internal.c6
-rw-r--r--navit/gui/internal/gui_internal.h2
-rw-r--r--navit/gui/internal/gui_internal_priv.h2
-rw-r--r--navit/gui/internal/gui_internal_search.c41
-rw-r--r--navit/gui/internal/gui_internal_widget.c35
6 files changed, 74 insertions, 14 deletions
diff --git a/navit/attr_def.h b/navit/attr_def.h
index 2b0bad448..04848d987 100644
--- a/navit/attr_def.h
+++ b/navit/attr_def.h
@@ -188,7 +188,7 @@ ATTR_UNUSED
ATTR_UNUSED
ATTR_UNUSED
ATTR_UNUSED
-ATTR_UNUSED
+ATTR(hide_possible_next_keys)
ATTR(turn_around_count)
ATTR(turn_around_penalty)
ATTR(turn_around_penalty2)
diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c
index fd450b57c..add7451fe 100644
--- a/navit/gui/internal/gui_internal.c
+++ b/navit/gui/internal/gui_internal.c
@@ -3437,6 +3437,12 @@ static struct gui_priv * gui_internal_new(struct navit *nav, struct gui_methods
this->radius=10;
if( (attr=attr_search(attrs,NULL,attr_font)))
this->font_name=g_strdup(attr->u.str);
+
+ if((attr=attr_search(attrs, NULL, attr_hide_possible_next_keys)))
+ this->hide_keys = attr->u.num;
+ else
+ this->hide_keys = 0;
+
this->data.priv=this;
this->data.gui=&gui_internal_methods_ext;
this->data.widget=&gui_internal_widget_methods;
diff --git a/navit/gui/internal/gui_internal.h b/navit/gui/internal/gui_internal.h
index ea5ab79ae..1a5cd13d3 100644
--- a/navit/gui/internal/gui_internal.h
+++ b/navit/gui/internal/gui_internal.h
@@ -2,6 +2,8 @@ struct widget;
struct graphics_image;
struct gui_priv;
+#define STATE_INVISIBLE 1
+#define STATE_SELECTED 2
#define STATE_HIGHLIGHTED 4
#define STATE_SENSITIVE 8
#define STATE_EDIT 16
diff --git a/navit/gui/internal/gui_internal_priv.h b/navit/gui/internal/gui_internal_priv.h
index 0dee59db2..37b09d62a 100644
--- a/navit/gui/internal/gui_internal_priv.h
+++ b/navit/gui/internal/gui_internal_priv.h
@@ -144,7 +144,7 @@ struct gui_priv {
} gesture_ring[GESTURE_RINGSIZE];
int gesture_ring_last, gesture_ring_first;
-
+ int hide_keys; //Flag to set the keyboard mode 1: hide impossible keys on search; 0: highlight them.
int results_map_population;
};
diff --git a/navit/gui/internal/gui_internal_search.c b/navit/gui/internal/gui_internal_search.c
index e5e137e07..ceeeb7438 100644
--- a/navit/gui/internal/gui_internal_search.c
+++ b/navit/gui/internal/gui_internal_search.c
@@ -192,14 +192,22 @@ gui_internal_find_next_possible_key(char *search_text, char *wm_name, char *poss
{
gchar* trunk_name;
if (item_name) {
- trunk_name = g_strrstr(item_name, search_text);
+
+ trunk_name = linguistics_expand_special(item_name,1);
+ if(!trunk_name){
+ trunk_name = g_strrstr(item_name, search_text);
+ }
+
if (trunk_name) {
- char next_char = trunk_name[strlen(search_text)];
+ int next_char_pos = strlen(search_text);
+ char next_char = trunk_name[next_char_pos];
int i;
int len = strlen(possible_keys);
+
for(i = 0; (i<len) && (possible_keys[i] != next_char) ;i++) ;
- if (i==len || !len) {
- possible_keys[len]=trunk_name[strlen(search_text)];
+
+ if ((i==len || !len) && !strncmp(trunk_name, search_text, next_char_pos)) {
+ possible_keys[len]=trunk_name[next_char_pos];
possible_keys[len+1]='\0';
}
dbg(lvl_info,"searching for %s, found: %s, currently possible_keys: %s \n", search_text, item_name, possible_keys);
@@ -211,6 +219,7 @@ static void
gui_internal_highlight_possible_keys(struct gui_priv *this, char *possible_keys)
{
struct menu_data *md;
+ int first_available_key_found = 0;
if (!this->keyboard)
return;
@@ -225,12 +234,30 @@ gui_internal_highlight_possible_keys(struct gui_priv *this, char *possible_keys)
while (lk2) {
struct widget *child_=lk2->data;
lk2=g_list_next(lk2);
- if (child_->data && strcmp("\b", child_->data)) { // FIXME don't disable special keys
+ // The data_free part is an evil hack based on the observation that
+ // regular keys have set it to non-NULL whereas special keys appear
+ // to have it set to NULL.
+ if (child_->data && strcmp("\b", child_->data) && child_->data_free) {
if ( (strlen(possible_keys) == 0) ||
(g_strrstr(possible_keys, child_->data)!=NULL ) ) {
- child_->state|= STATE_HIGHLIGHTED|STATE_SENSITIVE|STATE_CLEAR ;
+ if(this->hide_keys){
+ child_->state|= STATE_SENSITIVE|STATE_CLEAR ;
+ child_->state&= ~(STATE_INVISIBLE);
+ }else{
+ child_->state|= STATE_SENSITIVE|STATE_CLEAR|STATE_HIGHLIGHTED ;
+ }
+ // Select and highlight the first possible button.
+ if (!first_available_key_found) {
+ gui_internal_highlight_do(this, child_);
+ first_available_key_found=1;
+ }
} else {
- child_->state&= ~STATE_HIGHLIGHTED;
+ if(this->hide_keys){
+ child_->state&= ~(STATE_SELECTED|STATE_SENSITIVE) ;
+ child_->state|= STATE_INVISIBLE;
+ }else{
+ child_->state&= ~(STATE_HIGHLIGHTED);
+ }
}
gui_internal_widget_render(this,child_);
}
diff --git a/navit/gui/internal/gui_internal_widget.c b/navit/gui/internal/gui_internal_widget.c
index 1dd28837f..3e1993025 100644
--- a/navit/gui/internal/gui_internal_widget.c
+++ b/navit/gui/internal/gui_internal_widget.c
@@ -753,7 +753,7 @@ gui_internal_widget_destroy(struct gui_priv *this, struct widget *w)
void
gui_internal_widget_render(struct gui_priv *this, struct widget *w)
{
- if(w->p.x > this->root.w || w->p.y > this->root.h)
+ if(w->p.x > this->root.w || w->p.y > this->root.h || w->state & STATE_INVISIBLE)
return;
switch (w->type) {
@@ -820,6 +820,10 @@ gui_internal_scroll_buttons_init(struct gui_priv *this, struct widget *widget, s
sb->button_box=gui_internal_box_new(this, gravity_center|orientation_horizontal);
sb->button_box->background=this->background;
+ if(this->hide_keys){
+ sb->prev_button->state |= STATE_INVISIBLE;
+ sb->next_button->state |= STATE_INVISIBLE;
+ }
sb->prev_button->state &= ~STATE_SENSITIVE;
sb->next_button->state &= ~STATE_SENSITIVE;
gui_internal_widget_append(sb->button_box, sb->prev_button);
@@ -1264,7 +1268,12 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
cur_column=g_list_next(cur_column))
{
struct widget * cur_widget = (struct widget*) cur_column->data;
- cur_widget->state |= STATE_OFFSCREEN;
+ if(this->hide_keys){
+ cur_widget->state |= STATE_INVISIBLE;
+ cur_widget->state &= ~STATE_SENSITIVE;
+ }else{
+ cur_widget->state |= STATE_OFFSCREEN;
+ }
}
row = g_list_next(row);
}
@@ -1308,7 +1317,12 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
/* We pack the widget before rendering to ensure that the x and y
* coordinates get pushed down.
*/
- cur_widget->state &= ~STATE_OFFSCREEN;
+ if(this->hide_keys){
+ cur_widget->state &= ~STATE_INVISIBLE;
+ cur_widget->state |= STATE_SENSITIVE;
+ }else{
+ cur_widget->state &= ~STATE_OFFSCREEN;
+ }
gui_internal_widget_pack(this,cur_widget);
gui_internal_widget_render(this,cur_widget);
@@ -1317,8 +1331,13 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
max_height = dim->height;
}
} else {
- /* Mark contents that we don't have space for. */
- cur_widget->state |= STATE_OFFSCREEN;
+ /* Deactivate contents that we don't have space for. */
+ if(this->hide_keys){
+ cur_widget->state |= STATE_INVISIBLE;
+ cur_widget->state &= ~STATE_SENSITIVE;
+ }else{
+ cur_widget->state |= STATE_OFFSCREEN;
+ }
}
}
@@ -1337,6 +1356,10 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
}
/* By default, hide all scroll buttons. */
+ if(this->hide_keys){
+ table_data->scroll_buttons.next_button->state|= STATE_INVISIBLE;
+ table_data->scroll_buttons.prev_button->state|= STATE_INVISIBLE;
+ }
table_data->scroll_buttons.next_button->state&= ~STATE_SENSITIVE;
table_data->scroll_buttons.prev_button->state&= ~STATE_SENSITIVE;
@@ -1359,11 +1382,13 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
if(!drawing_space_left)
{
table_data->scroll_buttons.next_button->state|= STATE_SENSITIVE;
+ table_data->scroll_buttons.next_button->state&= ~STATE_INVISIBLE;
}
if(table_data->top_row != w->children)
{
table_data->scroll_buttons.prev_button->state|= STATE_SENSITIVE;
+ table_data->scroll_buttons.prev_button->state&= ~STATE_INVISIBLE;
}
gui_internal_widget_render(this,table_data->scroll_buttons.button_box);
}