softkeyboard added, gui changed..

master
steffen 13 years ago
parent 1a0e4a2af0
commit 5057228a2e

@ -1,6 +1,13 @@
Version 0.0.2: name changed to spOSMroute, since on there had been another
OSMroute already.
=============================================================================
(2013-03-11):
- rewrote most parts of the gui handling.
- added software keyboard.
- added config screen (config map, gps device, softkeyboard, debug).
(2013-02-14):
- android: changed to GLES2.0. Offscreen rendering works fine. Enabled
gui on android.

@ -1,4 +1,4 @@
/* $Id: gui.c,v 1.20 2013/03/10 23:32:28 steffen Exp $ */
/* $Id: gui.c,v 1.21 2013/03/11 23:08:39 steffen Exp $ */
/***************************************************************************
* gui.c
*
@ -172,7 +172,6 @@ int gui_event (GUIEvent event) {
if (event_called) return 1;
event_called = 1;
// d_printf ("********event: currentwin:%p, softkeyb:%p softkeyb->enabled:%d", currentwin, softkeyb, softkeyb == NULL ? 0 : softkeyb->enabled);
if (currentwin) {
winpos.x = event.mousepos.x - currentwin->x;
@ -181,7 +180,7 @@ int gui_event (GUIEvent event) {
item = currentwin->focus;
/* check if softkeyb if opened */
if ((softkeyb && softkeyb->enabled)
if ((softkeyb && softkeyb->enabled && softkeyb->screen)
&& (event.event == EGUI_MOUSERELEASED || event.event == EGUI_MOUSEPRESSED)) {
int x1 = (gfx_screensize.x-softkeyb->screen->width)/2,
x2 = gfx_screensize.x-(gfx_screensize.x-softkeyb->screen->width)/2,
@ -200,22 +199,21 @@ int gui_event (GUIEvent event) {
if (GUI_ITEM_IS_INSIDE (currentwin->items[i], winpos))
item = currentwin->items[i];
// d_printf ("item:%p , type:%d , focus:%p , event:%d", item, item ? item->type : -1, currentwin->focus, event.event);
if (item) switch (item->type) {
case (GUI_BUTTON):
gui_event_addmousepos (&event, winpos, -1);
event.mousepos = winpos;
gui_button_event (item, &event);
event_called = 0;
return 1;
break;
case (GUI_ENTRY):
gui_event_addmousepos (&event, winpos, -1);
event.mousepos = winpos;
gui_entry_event (item, &event);
event_called = 0;
return 1;
break;
case (GUI_LIST):
event.mousepos = winpos;
gui_list_event (item, &event);
event_called = 0;
return 1;

@ -198,6 +198,7 @@ extern GUIItem *gui_label_new (char *text, int x, int y);
extern void gui_entry_draw (GUIItem *item);
extern int gui_entry_event (GUIItem *item, GUIEvent *event);
extern GUIItem *gui_entry_new (char *text, int x, int y, int w, int h);
extern void gui_entry_settext (GUIItem *item, char *text);
/* list functions */
#define GUI_LIST_T(_item_) ((GUIList*)(_item_)->data)

@ -1,4 +1,4 @@
/* $Id: gui_entry.c,v 1.12 2013/03/10 23:32:28 steffen Exp $ */
/* $Id: gui_entry.c,v 1.13 2013/03/11 23:08:39 steffen Exp $ */
/***************************************************************************
* gui_entry.c
*
@ -139,3 +139,13 @@ GUIItem *gui_entry_new (char *text, int x, int y, int w, int h) {
return item;
};
void gui_entry_settext (GUIItem *item, char *text) {
GUIEntry *entry = NULL;
if (item) entry = (GUIEntry *) item->data;
strncpy (entry->text, text, GUI_TEXTLEN);
entry->curpos = strlen (entry->text);
currentwin->screen_changed = 1;
};

@ -1,4 +1,4 @@
/* $Id: gui_list.c,v 1.7 2013/03/10 00:09:40 steffen Exp $ */
/* $Id: gui_list.c,v 1.8 2013/03/11 23:08:39 steffen Exp $ */
/***************************************************************************
* gui_list.c
*
@ -52,7 +52,7 @@ void gui_list_draw (GUIItem *item) {
/* find last max */
max = 0;
// for (max = 0; list->data[max] != NULL; max++);
for (max = 0; list->data[max] != NULL; max++);
/* range to display */
i = max - item->h/16;
@ -60,7 +60,7 @@ void gui_list_draw (GUIItem *item) {
if (list->vs < 0) list->vs = 0;
for (i = list->vs; i < (list->vs + item->h/16) && i < max; i++) {
if (i == list->selected) gfx_draw_text (currentwin->screen, item->x + 5, item->y + 5 + 16 * (i - list->vs), list->data[i], &color[COLOR_red][1]);
if (i == list->selected) gfx_draw_text (currentwin->screen, item->x + 5, item->y + 5 + 16 * (i - list->vs), list->data[i], &color[COLOR_red][2]);
else gfx_draw_text (currentwin->screen, item->x + 5, item->y + 5 + 16 * (i - list->vs), list->data[i], &color[COLOR_white][3]);
}
@ -99,7 +99,6 @@ int gui_list_event (GUIItem *item, GUIEvent *event) {
i = (y-5)/16 + list->vs;
list->selected = i;
if (list->callback_selectitem) list->callback_selectitem (i);
d_printf ("selected nr: %d", i);
}
}
currentwin->screen_changed = 1;

@ -29,6 +29,8 @@
void gui_config_close ();
void gui_config_seldir ();
void gui_config_gpsfile ();
void gui_config_gpslist (int nr);
void gui_config_checkbox_changed ();
GUIWindow wcfg = {0};
@ -39,10 +41,30 @@ GUIItem *gps_list = NULL;
GUIItem *gps_file = NULL;
GUIItem *log_file = NULL;
GUIItem *cb_debug = NULL;
GUIItem *cb_softkeyb = NULL;
GUIItem *wcfg_close = NULL;
GUIItem *label1 = NULL;
GUIItem *label2 = NULL;
char gpscfg_dev[8][LEN_FILENAME] = {
"serial:/dev/rfcomm0",
"serial:com1,38400",
"serial:com1,4800",
"",
"",
"",
"",
""};
char *gpscfg_dev_ptr[8] = {
gpscfg_dev[0],
gpscfg_dev[1],
gpscfg_dev[2],
NULL,
NULL,
NULL,
NULL,
NULL
};
void gui_config_show () {
if (wcfg.screen == NULL) gui_window_new (&wcfg, 220, 280, _("Config"));
@ -59,13 +81,14 @@ void gui_config_show () {
GUI_BUTTON_T (map_seldir)->callback_clicked = gui_config_seldir;
gui_window_item_add (&wcfg, map_seldir);
if (label2 == NULL) label2 = gui_label_new (_("gps device:"), 5, 66);
gui_window_item_add (&wcfg, label2);
if (gps_device == NULL) gps_device = gui_entry_new (cfg.gps_device, 10, 82, 150, 20);
gui_window_item_add (&wcfg, gps_device);
if (gps_list == NULL) gps_list = gui_list_new (10, 112, 150, 60);
GUI_LIST_T (gps_list)->callback_selectitem = gui_config_gpslist;
GUI_LIST_T (gps_list)->data = gpscfg_dev_ptr;
gui_window_item_add (&wcfg, gps_list);
if (gps_file == NULL) gps_file = gui_button_new (_("File"), 170, 112, 40, 20);
GUI_BUTTON_T (gps_file)->callback_clicked = gui_config_gpsfile;
@ -74,10 +97,17 @@ void gui_config_show () {
if (log_file == NULL)
log_file = gui_checkbox_new (_("Create GPS-Log"), cfg.gps_flags & GPSF_LOG, 10, 172);
gui_window_item_add (&wcfg, log_file);
GUI_CHECKBOX_T (log_file)->callback_changed = gui_config_checkbox_changed;
if (cb_debug == NULL)
cb_debug = gui_checkbox_new (_("Enable Debug-Logfile"), cfg.debug, 5, 200);
cb_debug = gui_checkbox_new (_("Debug"), cfg.debug, 5, 200);
gui_window_item_add (&wcfg, cb_debug);
GUI_CHECKBOX_T (cb_debug)->callback_changed = gui_config_checkbox_changed;
if (cb_softkeyb == NULL)
cb_softkeyb = gui_checkbox_new (_("Softkeyboard"), cfg.softkeyboard, 100, 200);
gui_window_item_add (&wcfg, cb_softkeyb);
GUI_CHECKBOX_T (cb_softkeyb)->callback_changed = gui_config_checkbox_changed;
if (wcfg_close == NULL) wcfg_close =
gui_button_new (_("Close"), 5, wcfg.h-25, wcfg.w-10, 20);
@ -89,10 +119,22 @@ void gui_config_show () {
void gui_config_close () {
strncpy (cfg.mappath, GUI_ENTRY_T(map_path)->text, LEN_FILENAME);
strncpy (cfg.gps_device, GUI_ENTRY_T(gps_device)->text, LEN_FILENAME);
gui_config_checkbox_changed ();
gui_close ();
};
void gui_config_checkbox_changed () {
cfg.debug = GUI_CHECKBOX_T(cb_debug)->checked;
cfg.softkeyboard = GUI_CHECKBOX_T(cb_softkeyb)->checked;
if (GUI_CHECKBOX_T(log_file)->checked) cfg.gps_flags |= GPSF_LOG;
else cfg.gps_flags &= (0x0FFFF-GPSF_LOG);
gui_close ();
};
void gui_config_gpslist (int nr) {
d_printf ("select nr:%d", nr);
if (nr >= 0 && nr < 8)
gui_entry_settext (gps_device, gpscfg_dev[nr]);
};

Loading…
Cancel
Save