diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2023-07-13 14:34:25 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2023-07-13 14:34:25 +0200 |
| commit | 580a531ef511c1b80c30fa61b27e0209ff693f96 (patch) | |
| tree | b478fcd0d7b305757e4c742b4d3a34a3a728cdd5 /src | |
| parent | 03913f32e0010076474d311758c388561eeac01e (diff) | |
Clamp input values of Fl_Color_Chooser (#749)
Note: this may be somewhat confusing if the user enters out-of-range
values manually because they are overwritten immediately with valid
input but the effects seen in issue #749 are IMHO worse.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Color_Chooser.cxx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Fl_Color_Chooser.cxx b/src/Fl_Color_Chooser.cxx index a8b7ac5c5..209f4b45b 100644 --- a/src/Fl_Color_Chooser.cxx +++ b/src/Fl_Color_Chooser.cxx @@ -1,7 +1,7 @@ // // Color chooser for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2019 by Bill Spitzak and others. +// Copyright 1998-2023 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -428,9 +428,14 @@ int Flcc_ValueBox::handle_key(int key) { void Fl_Color_Chooser::rgb_cb(Fl_Widget* o, void*) { Fl_Color_Chooser* c = (Fl_Color_Chooser*)(o->parent()); - double R = c->rvalue.value(); - double G = c->gvalue.value(); - double B = c->bvalue.value(); + // clamp input values to valid ranges (issue #749, part 1) + double R = c->rvalue.clamp(c->rvalue.value()); + double G = c->gvalue.clamp(c->gvalue.value()); + double B = c->bvalue.clamp(c->bvalue.value()); + // update input values if they were clamped (#749, part 2) + c->rvalue.value(R); + c->gvalue.value(G); + c->bvalue.value(B); if (c->mode() == M_HSV) { if (c->hsv(R,G,B)) c->do_callback(FL_REASON_CHANGED); return; |
