raygui icon indicating copy to clipboard operation
raygui copied to clipboard

Color selection bar won't move until the big color gradient has been clicked at least once

Open mandar1jn opened this issue 3 years ago • 3 comments

So, I have a variable called portalColor. I have a color selector that takes the portalColor as the argument, and the resulting color is assigned back to portalColor. When I start the program and immediately use the slider instead of the gradient, the slider won't move. You are required to touch the gradient first

mandar1jn avatar Jun 28 '22 15:06 mandar1jn

@mandar1jn Sorry, I can't understand the issue. I just tested GuiColorPicker in controls_test_suite and it works as expected.

Please, could you provide a minimal code sample illustrating the issue?

raysan5 avatar Jun 29 '22 17:06 raysan5

#include <stdio.h>
#include <wchar.h>

#include "raylib.h"

#define RAYGUI_IMPLEMENTATION
#include "raygui.h"

Color portalColor = RAYWHITE;

void DrawPortalControls();

int main()
{
	InitWindow(800, 600, "Skylanders Editor");
	SetTargetFPS(120);
	while (!WindowShouldClose())
	{
		BeginDrawing();

		ClearBackground(RAYWHITE);

		GuiDrawRectangle({ 0, 0, (float)GetScreenWidth(), 30 }, 1, BLACK, RAYWHITE);

		DrawPortalControls();

		EndDrawing();
	}

	CloseWindow();
}

void DrawPortalControls()
{



	portalColor = GuiColorPicker({ (float)GetScreenWidth() - 130, 35, 100, 100}, "Select portal color", portalColor);
}

mandar1jn avatar Jun 30 '22 12:06 mandar1jn

@mandar1jn Issue seems to be located in ConvertRGBtoHSV() specifically for RAYWHITE (or any other initial value with R=G=B). If you init portalColor = RED it works as expected.

It seems there R=G=B is a special case for ConvertRGBtoHSV(), I requires some review...

raysan5 avatar Jun 30 '22 14:06 raysan5