GuiColorPickerHSV hue bar blinks while changing/dragging the color panel value

Open Beginner friendly
#587 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
frontend

Research direction

Read the GuiColorPickerHSV implementation shown in the issue and check how GuiColorPanelHSV and GuiColorBarHue report changes and render. Make sure the hue bar is called every frame while preserving the changed result, then exercise the color picker by dragging over the panel and confirm the hue bar no longer blinks. The unused text parameter is a separate question raised in the issue.

Written by the indexing model from the issue text.

Description

int GuiColorPickerHSV(Rectangle bounds, const char *text, Vector3 *colorHsv)
{
    int result = RESULT_NONE;

    Vector3 tempHsv = { 0 };

    if (colorHsv == NULL)
    {
        const Vector3 tempColor = { 200.0f/255.0f, 0.0f, 0.0f };
        tempHsv = ConvertRGBtoHSV(tempColor);
        colorHsv = &tempHsv;
    }

    result = GuiColorPanelHSV(bounds, NULL, colorHsv);

    Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };

    if (result == RESULT_NONE) result = GuiColorBarHue(boundsHue, NULL, &colorHsv->x);

    return result;
}

When GuiColorPanelHSV returns RESULT_CHANGED the later call to GuiColorBarHue never happens, this causes the hue bar to not be rendered for that frame and thus causing blinking while dragging the mouse over the color panel.

In my zig code I ported the function and implemented this change:

const second_result = ray.GuiColorBarHue(bounds_hue, null, &color_hsv.x);
if (result == ray.RESULT_NONE) result = second_result;

Which would be equivalent to:

int secondResult = GuiColorBarHue(boundsHue, NULL, &colorHsv->x);
if (result == RESULT_NONE) result = secondResult;

I am not sure whether there is another better solution, but at least this allows both functions to return changed without a previous changed being overwritten with none and always call the GuiColorBarHue function to make sure it is rendered.


I also noticed the text parameter is unused, why is it there and should it be used?

Dominant language
C
Stars
5.3k
Forks
410
Avg merge
1d 22h
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from raysan5/raygui

All issues in raysan5/raygui

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.