From 663caba66214acdb6170903f6a203740ea1de8b9 Mon Sep 17 00:00:00 2001 From: inmarket Date: Thu, 6 Jun 2013 16:48:30 +1000 Subject: GWIN fixes --- src/gwin/gwidget.c | 4 ++-- src/gwin/gwin.c | 14 ++++++++++++-- src/gwin/slider.c | 19 +++++++++++++++---- 3 files changed, 29 insertions(+), 8 deletions(-) (limited to 'src/gwin') diff --git a/src/gwin/gwidget.c b/src/gwin/gwidget.c index 464210b7..3f23140c 100644 --- a/src/gwin/gwidget.c +++ b/src/gwin/gwidget.c @@ -39,7 +39,7 @@ static void gwidgetCallback(void *param, GEvent *pe) { case GEVENT_TOUCH: // Are we captured? if ((gw->g.flags & GWIN_FLG_MOUSECAPTURE)) { - if (pme->meta == GMETA_MOUSE_UP) { + if ((pme->last_buttons & ~pme->current_buttons & GINPUT_MOUSE_BTN_LEFT)) { gw->g.flags &= ~GWIN_FLG_MOUSECAPTURE; if (wvmt->MouseUp) wvmt->MouseUp(gw, pme->x - gw->g.x, pme->y - gw->g.y); @@ -48,7 +48,7 @@ static void gwidgetCallback(void *param, GEvent *pe) { wvmt->MouseMove(gw, pme->x - gw->g.x, pme->y - gw->g.y); // We are not captured - look for mouse downs over the widget - } else if (pme->meta == GMETA_MOUSE_DOWN + } else if ((~pme->last_buttons & pme->current_buttons & GINPUT_MOUSE_BTN_LEFT) && pme->x >= gw->g.x && pme->x < gw->g.x + gw->g.width && pme->y >= gw->g.y && pme->y < gw->g.y + gw->g.height) { gw->g.flags |= GWIN_FLG_MOUSECAPTURE; diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c index fcbaa397..163e821d 100644 --- a/src/gwin/gwin.c +++ b/src/gwin/gwin.c @@ -18,6 +18,8 @@ static const gwinVMT basegwinVMT = { }; static font_t defaultFont; +static color_t defaultFgColor = White; +static color_t defaultBgColor = Black; // Internal routine for use by GWIN components only // Initialise a window creating it dynamicly if required. @@ -47,8 +49,8 @@ GHandle _gwinInit(GWindowObject *pgw, coord_t x, coord_t y, coord_t width, coord pgw->y = y; pgw->width = width; pgw->height = height; - pgw->color = White; - pgw->bgcolor = Black; + pgw->color = defaultFgColor; + pgw->bgcolor = defaultBgColor; #if GDISP_NEED_TEXT pgw->font = defaultFont; #endif @@ -74,6 +76,14 @@ const char *gwinGetClassName(GHandle gh) { return gh->vmt->classname; } +void gwinSetDefaultColor(color_t clr) { + defaultFgColor = clr; +} + +void gwinSetDefaultBgColor(color_t bgclr) { + defaultBgColor = bgclr; +} + #if GDISP_NEED_TEXT void gwinSetDefaultFont(font_t font) { defaultFont = font; diff --git a/src/gwin/slider.c b/src/gwin/slider.c index f18c665b..a0289d3d 100644 --- a/src/gwin/slider.c +++ b/src/gwin/slider.c @@ -107,10 +107,21 @@ static void MouseUp(GWidgetObject *gw, coord_t x, coord_t y) { #endif // Set the new position - if (gh->width < gh->height) - gsw->pos = (uint16_t)((uint32_t)(gh->height-1-y-GWIN_SLIDER_DEAD_BAND)*(gsw->max-gsw->min)/(gh->height-2*GWIN_SLIDER_DEAD_BAND) + gsw->min); - else - gsw->pos = (uint16_t)((uint32_t)(x-GWIN_SLIDER_DEAD_BAND)*(gsw->max-gsw->min)/(gh->width-2*GWIN_SLIDER_DEAD_BAND) + gsw->min); + if (gh->width < gh->height) { + if (y > gh->height-GWIN_SLIDER_DEAD_BAND) + gsw->pos = gsw->min; + else if (y < GWIN_SLIDER_DEAD_BAND) + gsw->pos = gsw->max; + else + gsw->pos = (uint16_t)((int32_t)(gh->height-1-y-GWIN_SLIDER_DEAD_BAND)*(gsw->max-gsw->min)/(gh->height-2*GWIN_SLIDER_DEAD_BAND) + gsw->min); + } else { + if (x > gh->width-GWIN_SLIDER_DEAD_BAND) + gsw->pos = gsw->max; + else if (x < GWIN_SLIDER_DEAD_BAND) + gsw->pos = gsw->min; + else + gsw->pos = (uint16_t)((int32_t)(x-GWIN_SLIDER_DEAD_BAND)*(gsw->max-gsw->min)/(gh->width-2*GWIN_SLIDER_DEAD_BAND) + gsw->min); + } ResetDisplayPos(gsw); gwinDraw(gh); -- cgit v1.2.3