fix [#36008] Can't set values higher than 1.0 in HSV colour picker (But can in RGB) - also some strange behavior
This commit is contained in:
@@ -2167,6 +2167,15 @@ static void ui_set_but_soft_range(uiBut *but)
|
||||
but->softmin = softmin;
|
||||
but->softmax = softmax;
|
||||
}
|
||||
else if (but->poin && (but->pointype & UI_BUT_POIN_TYPES)) {
|
||||
float value = ui_get_but_val(but);
|
||||
CLAMP(value, but->hardmin, but->hardmax);
|
||||
but->softmin = min_ff(but->softmin, value);
|
||||
but->softmax = max_ff(but->softmax, value);
|
||||
}
|
||||
else {
|
||||
BLI_assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* ******************* Free ********************/
|
||||
@@ -2368,8 +2377,12 @@ void ui_check_but(uiBut *but)
|
||||
ui_check_but_select(but, &value);
|
||||
|
||||
/* only update soft range while not editing */
|
||||
if (but->rnaprop && !(but->editval || but->editstr || but->editvec)) {
|
||||
ui_set_but_soft_range(but);
|
||||
if (!(but->editval || but->editstr || but->editvec)) {
|
||||
if ((but->rnaprop != NULL) ||
|
||||
(but->poin && (but->pointype & UI_BUT_POIN_TYPES)))
|
||||
{
|
||||
ui_set_but_soft_range(but);
|
||||
}
|
||||
}
|
||||
|
||||
/* test for min and max, icon sliders, etc */
|
||||
@@ -2757,13 +2770,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
|
||||
uiBut *but;
|
||||
int slen;
|
||||
|
||||
BLI_assert(width >= 0);
|
||||
BLI_assert(height >= 0);
|
||||
BLI_assert(width >= 0 && height >= 0);
|
||||
|
||||
/* we could do some more error checks here */
|
||||
if ((type & BUTTYPE) == LABEL) {
|
||||
if ((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)))
|
||||
printf("blah\n");
|
||||
BLI_assert((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)) == FALSE);
|
||||
}
|
||||
|
||||
|
||||
@@ -2116,7 +2116,7 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
|
||||
static char tip[50];
|
||||
static char hexcol[128];
|
||||
float rgb_gamma[3];
|
||||
float min, max, step, precision;
|
||||
float softmin, softmax, hardmin, hardmax, step, precision;
|
||||
float *hsv = ui_block_hsv_get(block);
|
||||
int yco;
|
||||
|
||||
@@ -2142,7 +2142,8 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
|
||||
/* sneaky way to check for alpha */
|
||||
rgba[3] = FLT_MAX;
|
||||
|
||||
RNA_property_float_ui_range(ptr, prop, &min, &max, &step, &precision);
|
||||
RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
|
||||
RNA_property_float_range(ptr, prop, &hardmin, &hardmax);
|
||||
RNA_property_float_get_array(ptr, prop, rgba);
|
||||
|
||||
switch (U.color_picker_type) {
|
||||
@@ -2196,7 +2197,8 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
|
||||
uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
|
||||
bt = uiDefButF(block, NUMSLI, 0, IFACE_("S "), 0, yco -= UI_UNIT_Y, butwidth, UI_UNIT_Y, hsv + 1, 0.0, 1.0, 10, 3, TIP_("Saturation"));
|
||||
uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
|
||||
bt = uiDefButF(block, NUMSLI, 0, IFACE_("V "), 0, yco -= UI_UNIT_Y, butwidth, UI_UNIT_Y, hsv + 2, 0.0, max, 10, 3, TIP_("Value"));
|
||||
bt = uiDefButF(block, NUMSLI, 0, IFACE_("V "), 0, yco -= UI_UNIT_Y, butwidth, UI_UNIT_Y, hsv + 2, 0.0, softmax, 10, 3, TIP_("Value"));
|
||||
bt->hardmax = hardmax; /* not common but rgb may be over 1.0 */
|
||||
uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user