aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin/slider.c
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-06-06 16:48:30 +1000
committerinmarket <andrewh@inmarket.com.au>2013-06-06 16:48:30 +1000
commit663caba66214acdb6170903f6a203740ea1de8b9 (patch)
treec6e69819bda8766d4d19ec2c9bc449a66b7ac11b /src/gwin/slider.c
parent1db77bda85aabd64eb78edf34e9b4b77e1e7324d (diff)
downloaduGFX-663caba66214acdb6170903f6a203740ea1de8b9.tar.gz
uGFX-663caba66214acdb6170903f6a203740ea1de8b9.tar.bz2
uGFX-663caba66214acdb6170903f6a203740ea1de8b9.zip
GWIN fixes
Diffstat (limited to 'src/gwin/slider.c')
-rw-r--r--src/gwin/slider.c19
1 files changed, 15 insertions, 4 deletions
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);