display correct values

Few fixes to display float values if the inspector field asks for floats
Split Hsb out from colorI now linearColorF can return HSB from its own color without having to go through the colorI conversion, hopefully gets rid of rounding errors etc since we are only doing the calc once.
This commit is contained in:
marauder2k7 2025-01-23 19:06:35 +00:00
parent 48ca98ca84
commit 704e304eef
4 changed files with 170 additions and 55 deletions

View file

@ -109,7 +109,7 @@ $guiContent = new GuiColorPickerCtrl(ColorPickerDlg,EditorGuiGroup) {
position = "213 3";
extent = "50 25";
profile = "GuiDefaultProfile";
command = "%selHue = ColorNewSelected.getSelectedHue();\n%selSat = ColorNewSelected.getSelectedSaturation();\n%selBright = ColorNewSelected.getSelectedBrightness();\n\nHueTextEditor.setText(%selHue);\nSatTextEditor.setText(%selSat);\nBrightTextEditor.setText(%selBright);\n\n%color = ColorNewSelected.getSelectedColorI();\nRedTextEdit.setText(getWord(%color, 0));\nGreenTextEdit.setText(getWord(%color, 1));\nBlueTextEdit.setText(getWord(%color, 2));\nAlphaTextEdit.setText(getWord(%color, 3));\n\n%hex = ColorRGBToHEX(%color);\nHexTextEditor.setText(%hex);";
command = "%selHue = ColorNewSelected.getSelectedHue();\n%selSat = ColorNewSelected.getSelectedSaturation();\n%selBright = ColorNewSelected.getSelectedBrightness();\n\nHueTextEditor.setText(%selHue);\nSatTextEditor.setText(%selSat);\nBrightTextEditor.setText(%selBright);\n\n%color = $ColorCallbackType == 1 ? ColorNewSelected.getSelectedColorI() : ColorNewSelected.getSelectedLinearColor();\nRedTextEdit.setText(getWord(%color, 0));\nGreenTextEdit.setText(getWord(%color, 1));\nBlueTextEdit.setText(getWord(%color, 2));\nAlphaTextEdit.setText(getWord(%color, 3));\n\n%hex = ColorRGBToHEX(ColorNewSelected.getSelectedColorI());\nHexTextEditor.setText(%hex);";
tooltipProfile = "GuiToolTipProfile";
};
new GuiColorPickerCtrl(ColorOld) {
@ -437,8 +437,12 @@ function ColorPickerRGBClass::onValidate(%this)
%alpha = AlphaTextEdit.getValue();
//Update all the other color fields
%hsb = ColorRGBToHSB(%red SPC %green SPC %blue);
if( $ColorCallbackType == 1)
%hsb = ColorRGBToHSB(%red SPC %green SPC %blue);
else
{
%hsb = ColorLinearRGBToHSB(%red SPC %green SPC %blue);
}
// these automatically update our ColorNewSelected which
// updates all text fields including these.
ColorHueRange.setSelectedHue(getWord(%hsb, 0));
@ -448,7 +452,7 @@ function ColorPickerRGBClass::onValidate(%this)
ColorBlendRange.setSelectedBrightness(getWord(%hsb, 2));
ColorBlendRange.executeUpdate();
ColorAlphaRange.setSelectedAlpha(%alpha);
ColorAlphaRange.setSelectedAlpha(%alpha * 255.0);
ColorAlphaRange.executeUpdate();
}