working on soft keyboard..

master
steffen 13 years ago
parent b0143e2a8c
commit 1529314588

@ -156,7 +156,7 @@ extern void gfx_draw_img (struct image *dimg, int dx, int dy, int dw, int dh, st
extern void gfx_draw_line (struct image *dimg, int x1, int y1, int x2, int y2, struct line_style style); extern void gfx_draw_line (struct image *dimg, int x1, int y1, int x2, int y2, struct line_style style);
extern void gfx_draw_text (struct image *dimg, int x, int y, char *text, struct color *c); extern void gfx_draw_text (struct image *dimg, int x, int y, char *text, struct color *c);
extern void gfx_draw_polygon (struct image *dimg, iPoint *p, int pcnt, struct line_style style, struct color c); extern void gfx_draw_polygon (struct image *dimg, iPoint *p, int pcnt, struct line_style style, struct color c);
extern void gfx_draw_rect (struct image *dimg, int x1, int y1, int x2, int y2, struct color *c); // extern void gfx_draw_rect (struct image *dimg, int x1, int y1, int x2, int y2, struct color *c);
extern void gfx_clear (struct image *dimg, struct color *c); extern void gfx_clear (struct image *dimg, struct color *c);
extern struct image *gfx_img_alloc (int w, int h); extern struct image *gfx_img_alloc (int w, int h);

@ -1,4 +1,4 @@
/* $Id: gui.c,v 1.18 2013/03/07 23:09:33 steffen Exp $ */ /* $Id: gui.c,v 1.19 2013/03/09 00:02:30 steffen Exp $ */
/*************************************************************************** /***************************************************************************
* gui.c * gui.c
* *
@ -149,10 +149,10 @@ void gui_draw () {
softkeyb->screen->width, softkeyb->screen->height, softkeyb->screen, 0, 0); softkeyb->screen->width, softkeyb->screen->height, softkeyb->screen, 0, 0);
/* drawing part of the screen where the entry element is set up.. */ /* drawing part of the screen where the entry element is set up.. */
ys = currentwin->focus->y; ys = currentwin->focus->y- 16;
yh = gfx_screensize.y-softkeyb->screen->height; yh = gfx_screensize.y-softkeyb->screen->height;
currentwin->y = -ys; currentwin->y = -ys;
if ((currentwin->h - currentwin->focus->y) < yh) yh = currentwin->h - currentwin->focus->y; if ((currentwin->h - (currentwin->focus->y-16)) < yh) yh = currentwin->h - (currentwin->focus->y - 16);
gfx_draw_img (NULL, currentwin->x, 0, currentwin->w, yh, currentwin->screen, 0, ys); gfx_draw_img (NULL, currentwin->x, 0, currentwin->w, yh, currentwin->screen, 0, ys);
} }
else gfx_draw_img (NULL, currentwin->x, currentwin->y, currentwin->w, currentwin->h, currentwin->screen, 0, 0); else gfx_draw_img (NULL, currentwin->x, currentwin->y, currentwin->w, currentwin->h, currentwin->screen, 0, 0);

@ -148,6 +148,8 @@ enum {
struct _GUISoftkeyboard_ { struct _GUISoftkeyboard_ {
int mode; int mode;
int enabled; int enabled;
int linepos[2][4]; /* y positions of lines */
int btnpos[2][4]; /* holds position keys: Shift, Symbols, Space, Close */
struct image *screen; struct image *screen;
char keys[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_Y][GUI_SOFTKEYB_X]; char keys[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_Y][GUI_SOFTKEYB_X];
} typedef GUISoftkeyboard; } typedef GUISoftkeyboard;

@ -1,4 +1,4 @@
/* $Id: gui_softkeyboard.c,v 1.1 2013/03/06 23:28:15 steffen Exp $ */ /* $Id: gui_softkeyboard.c,v 1.2 2013/03/09 00:02:30 steffen Exp $ */
/*************************************************************************** /***************************************************************************
* gui_softkeyboard.c * gui_softkeyboard.c
* *
@ -31,6 +31,9 @@
GUISoftkeyboard *softkeyb = NULL; GUISoftkeyboard *softkeyb = NULL;
void gui_softkeyb_getpos (int row, int btnnr, int *x1, int *x2, int *y1, int *y2);
void gui_softkeyb_show (int enable) { void gui_softkeyb_show (int enable) {
/* keys which are displayed.. */ /* keys which are displayed.. */
char line[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_X][GUI_SOFTKEYB_X] = { char line[GUI_SOFTKEYB_MODE_MAX][GUI_SOFTKEYB_X][GUI_SOFTKEYB_X] = {
@ -67,12 +70,52 @@ void gui_softkeyb_show (int enable) {
/* only preparing the screen image... copying to the screen will be done later... */ /* only preparing the screen image... copying to the screen will be done later... */
static float _linepos[2][4] = { { 5.0, 25.0, 45.0, 65.0 },
{ 20.0, 40.0, 60.0, 95.0 } };
static float _btnpos[2][4] = { { 5.0, 20.0, 35.0, 65.0 },
{ 15.0, 30.0, 60.0, 95.0 } };
void gui_softkeyb_getpos (int row, int btnnr, int *x1, int *y1, int *x2, int *y2) {
if (row < 3) {
*x1 = 5 + (btnnr * (softkeyb->screen->width - 10)) / GUI_SOFTKEYB_X;
*x2 = 5 + ((btnnr + 1) * (softkeyb->screen->width - 10)) / GUI_SOFTKEYB_X;
*y1 = (_linepos[0][row] * softkeyb->screen->height)/100;
*y2 = (_linepos[1][row] * softkeyb->screen->height)/100;
}
};
void gui_softkeyb_draw () { void gui_softkeyb_draw () {
struct line_style ls;
int i, j, x1, x2, y1, y2;
if (softkeyb == NULL || gfx_screensize.x < 0 || softkeyb->enabled == FALSE) return; if (softkeyb == NULL || gfx_screensize.x < 0 || softkeyb->enabled == FALSE) return;
if (softkeyb->screen == NULL || softkeyb->screen->width != gfx_screensize.x) { if (softkeyb->screen == NULL || softkeyb->screen->width != gfx_screensize.x) {
if (softkeyb->screen) gfx_img_free (softkeyb->screen); if (softkeyb->screen) gfx_img_free (softkeyb->screen);
softkeyb->screen = gfx_img_alloc (gfx_screensize.x, gfx_screensize.y * 0.8); softkeyb->screen = gfx_img_alloc (gfx_screensize.x, gfx_screensize.y * 0.8);
} }
/* setup the lines... */
for (j = 0; j < 2; j++) for (i = 0; i < 4; i++) {
softkeyb->linepos[j][i] = _linepos[j][i] * softkeyb->screen->width;
softkeyb->btnpos[j][i] = _btnpos[j][i] * softkeyb->screen->height;
}
/* draw border */
ls.c = color[COLOR_white][2];
ls.width = 1;
gfx_clear (softkeyb->screen, &color[COLOR_white][1]); gfx_clear (softkeyb->screen, &color[COLOR_white][1]);
draw_rectangle (softkeyb->screen, 1, 1, softkeyb->screen->width-2, softkeyb->screen->height-2, ls);
/* draw 3 key rows.. */
ls.c = color[COLOR_blue][2];
ls.width = 1;
for (j = 0; j < 3; j++) {
for (i = 0; i < GUI_SOFTKEYB_X; i++) {
gui_softkeyb_getpos (j, i, &x1, &y1, &x2, &y2);
draw_rectangle (softkeyb->screen, x1, y1, x2, y2, ls);
}
}
/* draw the last keys */
}; };

@ -297,6 +297,7 @@ void gfx_img_free (struct image *img) {
}; };
/*
void gfx_draw_rect (struct image *dimg, int x1, int y1, int x2, int y2, struct color *c) { void gfx_draw_rect (struct image *dimg, int x1, int y1, int x2, int y2, struct color *c) {
d_printf ("rect..."); d_printf ("rect...");
// int i; // int i;
@ -315,7 +316,7 @@ void gfx_draw_rect (struct image *dimg, int x1, int y1, int x2, int y2, struct c
// glVertex2i (p[i].x, p[i].y); // glVertex2i (p[i].x, p[i].y);
// glEnd (); // glEnd ();
}; };
*/
#define HEADER_SIZE 8 #define HEADER_SIZE 8

@ -34,6 +34,8 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include <SDL.h>
/***************************************************************************** /*****************************************************************************
* gfx stuff... * gfx stuff...

Loading…
Cancel
Save