Fix some NXTEXT pop-up window issues
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3757 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
8125671b10
commit
47591cea1f
@ -115,36 +115,6 @@ NXHANDLE g_bgwnd;
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxbg_fillwindow
|
||||
****************************************************************************/
|
||||
|
||||
static inline void nxbg_fillwindow(NXWINDOW hwnd,
|
||||
FAR const struct nxgl_rect_s *rect,
|
||||
FAR struct nxtext_state_s *st)
|
||||
{
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
ret = nx_fill(hwnd, rect, st->wcolor);
|
||||
if (ret < 0)
|
||||
{
|
||||
message("nxbg_fillwindow: nx_fill failed: %d\n", errno);
|
||||
}
|
||||
|
||||
/* Fill each character on the display (Only the characters within rect
|
||||
* will actually be redrawn).
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
nxtext_home(st);
|
||||
for (i = 0; i < st->nchars; i++)
|
||||
{
|
||||
nxtext_fillchar(hwnd, rect, &st->bm[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxbg_redraw
|
||||
****************************************************************************/
|
||||
@ -152,12 +122,11 @@ static inline void nxbg_fillwindow(NXWINDOW hwnd,
|
||||
static void nxbg_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
bool more, FAR void *arg)
|
||||
{
|
||||
FAR struct nxtext_state_s *st = (FAR struct nxtext_state_s *)arg;
|
||||
message("nxbg_redraw: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
|
||||
hwnd, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
|
||||
more ? "true" : "false");
|
||||
|
||||
nxbg_fillwindow(hwnd, rect, st);
|
||||
nxbg_redrawrect(hwnd, rect);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -233,6 +202,7 @@ static void nxbg_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch,
|
||||
|
||||
static void nxbg_scroll(NXWINDOW hwnd, int lineheight)
|
||||
{
|
||||
struct nxgl_rect_s rect;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
@ -240,7 +210,7 @@ static void nxbg_scroll(NXWINDOW hwnd, int lineheight)
|
||||
* do this more than once (unlikely)
|
||||
*/
|
||||
|
||||
while (g_bgstate.pos.y >= g_bgstate.wsize.h - lineheight)
|
||||
while (g_bgstate.fpos.y >= g_bgstate.wsize.h - lineheight)
|
||||
{
|
||||
/* Adjust the vertical position of each character */
|
||||
|
||||
@ -283,12 +253,16 @@ static void nxbg_scroll(NXWINDOW hwnd, int lineheight)
|
||||
|
||||
/* And move the next display position up by one line as well */
|
||||
|
||||
g_bgstate.pos.y -= lineheight;
|
||||
g_bgstate.fpos.y -= lineheight;
|
||||
}
|
||||
|
||||
/* Then re-draw the entire display */
|
||||
|
||||
nxbg_refresh(hwnd);
|
||||
rect.pt1.x = 0;
|
||||
rect.pt1.y = 0;
|
||||
rect.pt2.x = g_bgstate.wsize.w - 1;
|
||||
rect.pt2.y = g_bgstate.wsize.h - 1;
|
||||
nxbg_redrawrect(hwnd, &rect);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -351,7 +325,7 @@ void nxbg_write(NXWINDOW hwnd, FAR const uint8_t *buffer, size_t buflen)
|
||||
{
|
||||
/* Will another character fit on this line? */
|
||||
|
||||
if (g_bgstate.pos.x + g_bgstate.fwidth > g_bgstate.wsize.w)
|
||||
if (g_bgstate.fpos.x + g_bgstate.fwidth > g_bgstate.wsize.w)
|
||||
{
|
||||
/* No.. move to the next line */
|
||||
|
||||
@ -368,7 +342,7 @@ void nxbg_write(NXWINDOW hwnd, FAR const uint8_t *buffer, size_t buflen)
|
||||
|
||||
/* Check if we need to scroll up */
|
||||
|
||||
if (g_bgstate.pos.y >= g_bgstate.wsize.h - lineheight)
|
||||
if (g_bgstate.fpos.y >= g_bgstate.wsize.h - lineheight)
|
||||
{
|
||||
nxbg_scroll(hwnd, lineheight);
|
||||
}
|
||||
@ -380,22 +354,29 @@ void nxbg_write(NXWINDOW hwnd, FAR const uint8_t *buffer, size_t buflen)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxbg_refresh
|
||||
*
|
||||
* Description:
|
||||
* Re-draw the entire background.
|
||||
*
|
||||
* Name: nxbg_redrawrect
|
||||
****************************************************************************/
|
||||
|
||||
void nxbg_refresh(NXWINDOW hwnd)
|
||||
void nxbg_redrawrect(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect)
|
||||
{
|
||||
struct nxgl_rect_s rect;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
rect.pt1.x = 0;
|
||||
rect.pt1.y = 0;
|
||||
rect.pt2.x = g_bgstate.wsize.w - 1;
|
||||
rect.pt2.y = g_bgstate.wsize.h - 1;
|
||||
nxbg_fillwindow(hwnd, &rect, &g_bgstate);
|
||||
ret = nx_fill(hwnd, rect, g_bgstate.wcolor);
|
||||
if (ret < 0)
|
||||
{
|
||||
message("nxbg_redrawrect: nx_fill failed: %d\n", errno);
|
||||
}
|
||||
|
||||
/* Fill each character on the display (Only the characters within rect
|
||||
* will actually be redrawn).
|
||||
*/
|
||||
|
||||
nxtext_home(&g_bgstate);
|
||||
for (i = 0; i < g_bgstate.nchars; i++)
|
||||
{
|
||||
nxtext_fillchar(hwnd, rect, &g_bgstate.bm[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -221,6 +221,7 @@ struct nxtext_state_s
|
||||
|
||||
nxgl_mxpixel_t wcolor[CONFIG_NX_NPLANES]; /* Window color */
|
||||
struct nxgl_size_s wsize; /* Window size */
|
||||
struct nxgl_point_s wpos; /* Window position */
|
||||
|
||||
/* These characterize the font in use */
|
||||
|
||||
@ -228,10 +229,7 @@ struct nxtext_state_s
|
||||
uint8_t fheight; /* Max height of a font in pixels */
|
||||
uint8_t fwidth; /* Max width of a font in pixels */
|
||||
uint8_t spwidth; /* The width of a space */
|
||||
|
||||
/* This is the next display position */
|
||||
|
||||
struct nxgl_point_s pos; /* Next display position */
|
||||
struct nxgl_point_s fpos; /* Next display position */
|
||||
|
||||
/* These describe all text already added to the display */
|
||||
|
||||
@ -289,7 +287,7 @@ extern FAR void *nxtext_listener(FAR void *arg);
|
||||
|
||||
extern FAR struct nxtext_state_s *nxbg_getstate(void);
|
||||
extern void nxbg_write(NXWINDOW hwnd, FAR const uint8_t *buffer, size_t buflen);
|
||||
extern void nxbg_refresh(NXWINDOW hwnd);
|
||||
extern void nxbg_redrawrect(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect);
|
||||
|
||||
/* Pop-up window interfaces */
|
||||
|
||||
|
@ -392,22 +392,7 @@ int user_start(int argc, char *argv[])
|
||||
* window after two more seconds.
|
||||
*/
|
||||
|
||||
if (popcnt >= 5)
|
||||
{
|
||||
/* Destroy the pop-up window and restart the sequence */
|
||||
|
||||
message("user_start: Close pop-up\n");
|
||||
(void)nxpu_close(hwnd);
|
||||
|
||||
/* NOTE: The following should not be necessary. This is
|
||||
* a temporary workaround for a bug in the TOD list:
|
||||
* "When a window is closed, the display is not updated."
|
||||
*/
|
||||
|
||||
nxbg_refresh(g_bgwnd);
|
||||
popcnt = 0;
|
||||
}
|
||||
else if (popcnt >= 3)
|
||||
if (popcnt == 3)
|
||||
{
|
||||
/* Create a pop-up window */
|
||||
|
||||
@ -425,6 +410,14 @@ int user_start(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (popcnt == 5)
|
||||
{
|
||||
/* Destroy the pop-up window and restart the sequence */
|
||||
|
||||
message("user_start: Close pop-up\n");
|
||||
(void)nxpu_close(hwnd);
|
||||
popcnt = 0;
|
||||
}
|
||||
|
||||
/* Give another line of text to the background window. Force this
|
||||
* text to go the background by calling the kbdin method directly.
|
||||
|
@ -192,11 +192,13 @@ static inline void nxpu_fillwindow(NXWINDOW hwnd,
|
||||
* will actually be redrawn).
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
nxtext_home(st);
|
||||
for (i = 0; i < st->nchars; i++)
|
||||
{
|
||||
nxtext_fillchar(hwnd, rect, &st->bm[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -231,7 +233,10 @@ static void nxpu_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
|
||||
hwnd, size->w, size->h, pos->x, pos->y,
|
||||
bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y);
|
||||
|
||||
/* Save the window size */
|
||||
/* Save the window position and size */
|
||||
|
||||
st->wpos.x = pos->x;
|
||||
st->wpos.y = pos->y;
|
||||
|
||||
st->wsize.w = size->w;
|
||||
st->wsize.h = size->h;
|
||||
@ -390,11 +395,29 @@ errout_with_state:
|
||||
|
||||
int nxpu_close(NXWINDOW hwnd)
|
||||
{
|
||||
int ret = nx_closewindow(hwnd);
|
||||
struct nxgl_rect_s rect;
|
||||
int ret;
|
||||
|
||||
ret = nx_closewindow(hwnd);
|
||||
if (ret < 0)
|
||||
{
|
||||
message("nxpu_close: nx_closewindow failed: %d\n", errno);
|
||||
g_exitcode = NXEXIT_NXCLOSEWINDOW;
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
|
||||
/* NOTE: The following should not be necessary. This is
|
||||
* a temporary workaround for a bug in the TODO list:
|
||||
* "When a window is closed, the display is not updated."
|
||||
*/
|
||||
|
||||
rect.pt1.x = g_pustate.wpos.x;
|
||||
rect.pt1.y = g_pustate.wpos.y;
|
||||
rect.pt2.x = g_pustate.wpos.x + g_pustate.wsize.w - 1;
|
||||
rect.pt2.y = g_pustate.wpos.y + g_pustate.wsize.h - 1;
|
||||
gvdbg("Redraw: pt1(%d,%d) pt2(%d,%d)\n",
|
||||
rect.pt1.x, rect.pt1.y, rect.pt2.x, rect.pt2.y);
|
||||
|
||||
nxbg_redrawrect(g_bgwnd, &rect);
|
||||
return OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user