Skip to content

Commit

Permalink
Merge pull request #794 from Spartan322/4.3-fixes/colorpicker-jank
Browse files Browse the repository at this point in the history
[4.3] Fix RGB/RAW `ColorMode` jank sliders and spinbox
  • Loading branch information
Spartan322 authored Oct 25, 2024
2 parents d8eab9a + 7a16a43 commit abe786d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions scene/gui/color_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ String ColorModeRGB::get_slider_label(int idx) const {

float ColorModeRGB::get_slider_max(int idx) const {
ERR_FAIL_INDEX_V_MSG(idx, 4, 0, "Couldn't get slider max value.");
Color color = color_picker->get_pick_color();
return next_power_of_2(MAX(255, color.components[idx] * 255.0)) - 1;
return slider_max[idx];
}

float ColorModeRGB::get_slider_value(int idx) const {
Expand Down
6 changes: 3 additions & 3 deletions scene/gui/color_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class ColorModeHSV : public ColorMode {
class ColorModeRGB : public ColorMode {
public:
String labels[3] = { "R", "G", "B" };
float slider_max[4] = { 255, 255, 255, 255 };

virtual String get_name() const override { return "RGB"; }

Expand All @@ -108,12 +109,11 @@ class ColorModeRGB : public ColorMode {
class ColorModeRAW : public ColorMode {
public:
String labels[3] = { "R", "G", "B" };
float slider_max[4] = { 100, 100, 100, 1 };
float slider_max[4] = { 1, 1, 1, 1 };

virtual String get_name() const override { return "RAW"; }

virtual float get_slider_step() const override { return 0.001; }
virtual float get_spinbox_arrow_step() const override { return 0.01; }
virtual float get_slider_step() const override { return 1.0 / 255.0; }
virtual String get_slider_label(int idx) const override;
virtual float get_slider_max(int idx) const override;
virtual float get_slider_value(int idx) const override;
Expand Down

0 comments on commit abe786d

Please sign in to comment.