Fix progressbar bounds checking and decrementing
This commit is contained in:
parent
379878a013
commit
59917dbe1a
@ -16,6 +16,7 @@ FIX: Fixed an issue with color formats in Linux-Framebuffer board files
|
|||||||
FIX: Fixing and improving arc rendering functions
|
FIX: Fixing and improving arc rendering functions
|
||||||
FIX: Preventing possible crash when no valid GWIN default font has been set
|
FIX: Preventing possible crash when no valid GWIN default font has been set
|
||||||
FIX: Updating Windows binaries of the font encoder to improve compatibility
|
FIX: Updating Windows binaries of the font encoder to improve compatibility
|
||||||
|
FIX: Fix Progressbar bounds checking and decrementing
|
||||||
|
|
||||||
|
|
||||||
*** Release 2.6 ***
|
*** Release 2.6 ***
|
||||||
|
@ -102,9 +102,17 @@ void gwinProgressbarSetRange(GHandle gh, int min, int max) {
|
|||||||
|
|
||||||
if (min == max) // prevent divide by 0 errors.
|
if (min == max) // prevent divide by 0 errors.
|
||||||
max++;
|
max++;
|
||||||
gsw->min = min;
|
if (min <= max) {
|
||||||
gsw->max = max;
|
gsw->min = min;
|
||||||
gsw->pos = min;
|
gsw->max = max;
|
||||||
|
gsw->pos = min;
|
||||||
|
gsw->res = 1;
|
||||||
|
} else {
|
||||||
|
gsw->min = max;
|
||||||
|
gsw->max = min;
|
||||||
|
gsw->pos = min;
|
||||||
|
gsw->res = -1;
|
||||||
|
}
|
||||||
|
|
||||||
PBResetDisplayPos(gsw);
|
PBResetDisplayPos(gsw);
|
||||||
|
|
||||||
@ -117,15 +125,9 @@ void gwinProgressbarSetPosition(GHandle gh, int pos) {
|
|||||||
if (gh->vmt != (gwinVMT *)&progressbarVMT)
|
if (gh->vmt != (gwinVMT *)&progressbarVMT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (gsw->min <= gsw->max) {
|
if (pos < gsw->min) gsw->pos = gsw->min;
|
||||||
if (pos < gsw->min) gsw->pos = gsw->min;
|
else if (pos > gsw->max) gsw->pos = gsw->max;
|
||||||
else if (pos > gsw->max) gsw->pos = gsw->max;
|
else gsw->pos = pos;
|
||||||
else gsw->pos = pos;
|
|
||||||
} else {
|
|
||||||
if (pos > gsw->min) gsw->pos = gsw->min;
|
|
||||||
else if (pos < gsw->max) gsw->pos = gsw->max;
|
|
||||||
else gsw->pos = pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
PBResetDisplayPos(gsw);
|
PBResetDisplayPos(gsw);
|
||||||
_gwinUpdate(gh);
|
_gwinUpdate(gh);
|
||||||
@ -139,9 +141,6 @@ void gwinProgressbarSetResolution(GHandle gh, int resolution) {
|
|||||||
if (gh->vmt != (gwinVMT *)&progressbarVMT)
|
if (gh->vmt != (gwinVMT *)&progressbarVMT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (resolution <= 0)
|
|
||||||
resolution = 1;
|
|
||||||
|
|
||||||
gsw->res = resolution;
|
gsw->res = resolution;
|
||||||
|
|
||||||
#undef gsw
|
#undef gsw
|
||||||
@ -153,10 +152,9 @@ void gwinProgressbarIncrement(GHandle gh) {
|
|||||||
if (gh->vmt != (gwinVMT *)&progressbarVMT)
|
if (gh->vmt != (gwinVMT *)&progressbarVMT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (gsw->max - gsw->pos > gsw->res)
|
gsw->pos += gsw->res;
|
||||||
gsw->pos += gsw->res;
|
if (gsw->pos < gsw->min) gsw->pos = gsw->min;
|
||||||
else
|
else if (gsw->pos > gsw->max) gsw->pos = gsw->max;
|
||||||
gsw->pos = gsw->max;
|
|
||||||
|
|
||||||
PBResetDisplayPos(gsw);
|
PBResetDisplayPos(gsw);
|
||||||
_gwinUpdate(gh);
|
_gwinUpdate(gh);
|
||||||
@ -170,12 +168,9 @@ void gwinProgressbarDecrement(GHandle gh) {
|
|||||||
if (gh->vmt != (gwinVMT *)&progressbarVMT)
|
if (gh->vmt != (gwinVMT *)&progressbarVMT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (gsw->pos > gsw->res)
|
|
||||||
gsw->pos -= gsw->min;
|
|
||||||
else
|
|
||||||
gsw->pos = gsw->min;
|
|
||||||
|
|
||||||
gsw->pos -= gsw->res;
|
gsw->pos -= gsw->res;
|
||||||
|
if (gsw->pos < gsw->min) gsw->pos = gsw->min;
|
||||||
|
else if (gsw->pos > gsw->max) gsw->pos = gsw->max;
|
||||||
|
|
||||||
PBResetDisplayPos(gsw);
|
PBResetDisplayPos(gsw);
|
||||||
_gwinUpdate(gh);
|
_gwinUpdate(gh);
|
||||||
|
Loading…
Reference in New Issue
Block a user