From 67ae847970aee780fb28580bd17233df5f5bb3b2 Mon Sep 17 00:00:00 2001 From: Andrew Hannam Date: Mon, 12 Nov 2012 18:49:47 +1000 Subject: [PATCH] Win32 orientation & gwin console line clear fixes Fixes to Win32 orientation for scrolling Improve the way line clearing is handled in gwin consoles. --- drivers/gdisp/Win32/gdisp_lld.c | 56 ++++++++++-------- .../MCU/.touchscreen_lld_config.h.swp | Bin 12288 -> 0 bytes src/gwin.c | 17 +++--- 3 files changed, 40 insertions(+), 33 deletions(-) delete mode 100644 drivers/touchscreen/MCU/.touchscreen_lld_config.h.swp diff --git a/drivers/gdisp/Win32/gdisp_lld.c b/drivers/gdisp/Win32/gdisp_lld.c index 560a5f20..8aff8efc 100644 --- a/drivers/gdisp/Win32/gdisp_lld.c +++ b/drivers/gdisp/Win32/gdisp_lld.c @@ -709,7 +709,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { * @notapi */ 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; #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.left = rect.right-cx; vertical_scroll: - if (cy >= lines && cy >= -lines) - ScrollDC(dcBuffer, 0, lines, &rect, 0, 0, 0); - frect.left = rect.left; - frect.right = rect.right; + srect.left = frect.left = rect.left; + srect.right = frect.right = rect.right; if (lines > 0) { - frect.top = rect.top; - frect.bottom = frect.top+lines; + srect.top = frect.top = rect.top; + frect.bottom = rect.top+lines; + srect.bottom = rect.bottom-lines; } else { - frect.bottom = rect.bottom; - frect.top = frect.bottom+lines; + srect.bottom = frect.bottom = rect.bottom; + frect.top = rect.bottom+lines; + srect.top = rect.top-lines; } + if (cy >= lines && cy >= -lines) + ScrollDC(dcBuffer, 0, lines, &srect, 0, 0, 0); break; case GDISP_ROTATE_270: 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; lines = -lines; horizontal_scroll: - if (cy >= lines && cy >= -lines) - ScrollDC(dcBuffer, lines, 0, &rect, 0, 0, 0); - frect.top = rect.top; - frect.bottom = rect.bottom; + srect.top = frect.top = rect.top; + srect.bottom = frect.bottom = rect.bottom; if (lines > 0) { - frect.left = rect.left; - frect.right = frect.left+lines; + srect.left = frect.left = rect.left; + frect.right = rect.left+lines; + srect.right = rect.right-lines; } else { - frect.right = rect.right; - frect.left = frect.right+lines; + srect.right = frect.right = rect.right; + frect.left = rect.right+lines; + srect.left = rect.left-lines; } + if (cy >= lines && cy >= -lines) + ScrollDC(dcBuffer, lines, 0, &srect, 0, 0, 0); break; } #else @@ -786,17 +790,19 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { rect.left = x; rect.right = rect.left+cx; lines = -lines; - if (cy >= lines && cy >= -lines) - ScrollDC(dcBuffer, 0, lines, &rect, 0, 0, 0); - frect.left = rect.left; - frect.right = rect.right; + srect.left = frect.left = rect.left; + srect.right = frect.right = rect.right; if (lines > 0) { - frect.top = rect.top; - frect.bottom = frect.top+lines; + srect.top = frect.top = rect.top; + frect.bottom = rect.top+lines; + srect.bottom = rect.bottom-lines; } else { - frect.bottom = rect.bottom; - frect.top = frect.bottom+lines; + srect.bottom = frect.bottom = rect.bottom; + frect.top = rect.bottom+lines; + srect.top = rect.top-lines; } + if (cy >= lines && cy >= -lines) + ScrollDC(dcBuffer, 0, lines, &srect, 0, 0, 0); #endif if (hbr) diff --git a/drivers/touchscreen/MCU/.touchscreen_lld_config.h.swp b/drivers/touchscreen/MCU/.touchscreen_lld_config.h.swp deleted file mode 100644 index 595c456fd2b9057efb453648640ac2b272e3f26f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&u<$=6vrnVpau#EIB|M391=Hp)8qhZ+N!Q&$1aX-`3G%ItM%@zciQ#NYG*c% zNeWl^7x*POap1<0e*umh5S%~)i9`PcB)+>&8V8bA6}=#4q;D+yy*KmTXWk~V@`kJL zHn!=l(mKO>iLqC$FFNVD*Vr3RGp4z#)9mv{tUh<^a?Bs$#n}7#hE|-&JJ?xS30E>r zT&^rP5JMrA#rL!|^7kw+5xYE5mX@g-C^z9evbHOO`S*4hdbTSgUyMq@Bab!?hJYc! z&a?HkORE`(#S5>~D=!ZW6GOldFa!(%L%UJL<4zz{G53;{#H5HJJ`0YktLFa!(%L*PG1!0{Mson!1~0m075d#ll`*S$^~o*V7q0U#-M~q_iIZ?rX`EG7qQ_qOeorpF zt9d^OpHAx}t9WogGrZoCZEv=3?`)wT?d3e^6z=n#$`*wm!RN%qoN!=Ss}g#DKmX}? zo|dCTrty3TOu2QK2<%1kJ#a)-r9(AUnvW@z6AJk*4{0_CT*^az5%R)gPX^!86+q zXN=X6=RrUDc;oSs&?pJk>FGuy}tBG-w~4aZC}0#4*v`E}y2!gN-DKkL7& zqceiBljtm=Ik2Uf8_lnq5>Lbp>G5dnL=ic69m43nPU*@WSgxm$OvX-__3O2NB>N^+ V(3goA1)7#B%e1z7X$`;8*k7DITF(Fg diff --git a/src/gwin.c b/src/gwin.c index 0b3078b4..344252f9 100644 --- a/src/gwin.c +++ b/src/gwin.c @@ -36,7 +36,8 @@ #include -#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_FIRST_CONTROL_FLAG 0x0002 @@ -635,19 +636,14 @@ void gwinPutChar(GHandle gh, char c) { #endif 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->cy += gcw->fy; + // We use lazy scrolling here and only scroll when the next char arrives } else if (c == '\r') { // gcw->cx = 0; } else { width = gdispGetCharWidth(c, gh->font) + gcw->fp; 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->cy += gcw->fy; } @@ -668,7 +664,12 @@ void gwinPutChar(GHandle gh, char c) { #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); #else gdispDrawChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color);