Win32 orientation & gwin console line clear fixes
Fixes to Win32 orientation for scrolling Improve the way line clearing is handled in gwin consoles.
This commit is contained in:
parent
1c5ca344e8
commit
67ae847970
3 changed files with 40 additions and 33 deletions
|
@ -709,7 +709,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
|
void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
|
||||||
RECT rect, frect;
|
RECT rect, frect, srect;
|
||||||
HBRUSH hbr;
|
HBRUSH hbr;
|
||||||
|
|
||||||
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
|
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
|
||||||
|
@ -748,17 +748,19 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
|
||||||
rect.right = GDISP.Width - x;
|
rect.right = GDISP.Width - x;
|
||||||
rect.left = rect.right-cx;
|
rect.left = rect.right-cx;
|
||||||
vertical_scroll:
|
vertical_scroll:
|
||||||
if (cy >= lines && cy >= -lines)
|
srect.left = frect.left = rect.left;
|
||||||
ScrollDC(dcBuffer, 0, lines, &rect, 0, 0, 0);
|
srect.right = frect.right = rect.right;
|
||||||
frect.left = rect.left;
|
|
||||||
frect.right = rect.right;
|
|
||||||
if (lines > 0) {
|
if (lines > 0) {
|
||||||
frect.top = rect.top;
|
srect.top = frect.top = rect.top;
|
||||||
frect.bottom = frect.top+lines;
|
frect.bottom = rect.top+lines;
|
||||||
|
srect.bottom = rect.bottom-lines;
|
||||||
} else {
|
} else {
|
||||||
frect.bottom = rect.bottom;
|
srect.bottom = frect.bottom = rect.bottom;
|
||||||
frect.top = frect.bottom+lines;
|
frect.top = rect.bottom+lines;
|
||||||
|
srect.top = rect.top-lines;
|
||||||
}
|
}
|
||||||
|
if (cy >= lines && cy >= -lines)
|
||||||
|
ScrollDC(dcBuffer, 0, lines, &srect, 0, 0, 0);
|
||||||
break;
|
break;
|
||||||
case GDISP_ROTATE_270:
|
case GDISP_ROTATE_270:
|
||||||
rect.bottom = GDISP.Width - x;
|
rect.bottom = GDISP.Width - x;
|
||||||
|
@ -767,17 +769,19 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
|
||||||
rect.right = rect.left+cy;
|
rect.right = rect.left+cy;
|
||||||
lines = -lines;
|
lines = -lines;
|
||||||
horizontal_scroll:
|
horizontal_scroll:
|
||||||
if (cy >= lines && cy >= -lines)
|
srect.top = frect.top = rect.top;
|
||||||
ScrollDC(dcBuffer, lines, 0, &rect, 0, 0, 0);
|
srect.bottom = frect.bottom = rect.bottom;
|
||||||
frect.top = rect.top;
|
|
||||||
frect.bottom = rect.bottom;
|
|
||||||
if (lines > 0) {
|
if (lines > 0) {
|
||||||
frect.left = rect.left;
|
srect.left = frect.left = rect.left;
|
||||||
frect.right = frect.left+lines;
|
frect.right = rect.left+lines;
|
||||||
|
srect.right = rect.right-lines;
|
||||||
} else {
|
} else {
|
||||||
frect.right = rect.right;
|
srect.right = frect.right = rect.right;
|
||||||
frect.left = frect.right+lines;
|
frect.left = rect.right+lines;
|
||||||
|
srect.left = rect.left-lines;
|
||||||
}
|
}
|
||||||
|
if (cy >= lines && cy >= -lines)
|
||||||
|
ScrollDC(dcBuffer, lines, 0, &srect, 0, 0, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -786,17 +790,19 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
|
||||||
rect.left = x;
|
rect.left = x;
|
||||||
rect.right = rect.left+cx;
|
rect.right = rect.left+cx;
|
||||||
lines = -lines;
|
lines = -lines;
|
||||||
if (cy >= lines && cy >= -lines)
|
srect.left = frect.left = rect.left;
|
||||||
ScrollDC(dcBuffer, 0, lines, &rect, 0, 0, 0);
|
srect.right = frect.right = rect.right;
|
||||||
frect.left = rect.left;
|
|
||||||
frect.right = rect.right;
|
|
||||||
if (lines > 0) {
|
if (lines > 0) {
|
||||||
frect.top = rect.top;
|
srect.top = frect.top = rect.top;
|
||||||
frect.bottom = frect.top+lines;
|
frect.bottom = rect.top+lines;
|
||||||
|
srect.bottom = rect.bottom-lines;
|
||||||
} else {
|
} else {
|
||||||
frect.bottom = rect.bottom;
|
srect.bottom = frect.bottom = rect.bottom;
|
||||||
frect.top = frect.bottom+lines;
|
frect.top = rect.bottom+lines;
|
||||||
|
srect.top = rect.top-lines;
|
||||||
}
|
}
|
||||||
|
if (cy >= lines && cy >= -lines)
|
||||||
|
ScrollDC(dcBuffer, 0, lines, &srect, 0, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (hbr)
|
if (hbr)
|
||||||
|
|
Binary file not shown.
17
src/gwin.c
17
src/gwin.c
|
@ -36,7 +36,8 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define GWIN_USE_FILLED_CHARS FALSE
|
#define GWIN_CONSOLE_USE_CLEAR_LINES TRUE
|
||||||
|
#define GWIN_CONSOLE_USE_FILLED_CHARS FALSE
|
||||||
|
|
||||||
#define GWIN_FLG_DYNAMIC 0x0001
|
#define GWIN_FLG_DYNAMIC 0x0001
|
||||||
#define GWIN_FIRST_CONTROL_FLAG 0x0002
|
#define GWIN_FIRST_CONTROL_FLAG 0x0002
|
||||||
|
@ -635,19 +636,14 @@ void gwinPutChar(GHandle gh, char c) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
/* clear the text at the end of the line */
|
|
||||||
if (gcw->cx < gh->width)
|
|
||||||
gdispFillArea(gh->x + gcw->cx, gh->y + gcw->cy, gh->width - gcw->cx, gcw->fy, gh->bgcolor);
|
|
||||||
gcw->cx = 0;
|
gcw->cx = 0;
|
||||||
gcw->cy += gcw->fy;
|
gcw->cy += gcw->fy;
|
||||||
|
// We use lazy scrolling here and only scroll when the next char arrives
|
||||||
} else if (c == '\r') {
|
} else if (c == '\r') {
|
||||||
// gcw->cx = 0;
|
// gcw->cx = 0;
|
||||||
} else {
|
} else {
|
||||||
width = gdispGetCharWidth(c, gh->font) + gcw->fp;
|
width = gdispGetCharWidth(c, gh->font) + gcw->fp;
|
||||||
if (gcw->cx + width >= gh->width) {
|
if (gcw->cx + width >= gh->width) {
|
||||||
/* clear the text at the end of the line */
|
|
||||||
if (gcw->cy + gcw->fy <= gh->height)
|
|
||||||
gdispFillArea(gh->x + gcw->cx, gh->y + gcw->cy, gh->width - (gcw->cx + width), gcw->fy, gh->bgcolor);
|
|
||||||
gcw->cx = 0;
|
gcw->cx = 0;
|
||||||
gcw->cy += gcw->fy;
|
gcw->cy += gcw->fy;
|
||||||
}
|
}
|
||||||
|
@ -668,7 +664,12 @@ void gwinPutChar(GHandle gh, char c) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GWIN_USE_FILLED_CHARS
|
#if GWIN_CONSOLE_USE_CLEAR_LINES
|
||||||
|
/* clear to the end of the line */
|
||||||
|
if (gcw->cx == 0)
|
||||||
|
gdispFillArea(gh->x, gh->y + gcw->cy, gh->width, gcw->fy, gh->bgcolor);
|
||||||
|
#endif
|
||||||
|
#if GWIN_CONSOLE_USE_FILLED_CHARS
|
||||||
gdispFillChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color, gh->bgcolor);
|
gdispFillChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color, gh->bgcolor);
|
||||||
#else
|
#else
|
||||||
gdispDrawChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color);
|
gdispDrawChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color);
|
||||||
|
|
Loading…
Add table
Reference in a new issue