Skip to content

fixed RGB octets showing as characters #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

sfinktah
Copy link
Contributor

void HSVColorPicker::UpdateControls(Gwk::Color color)
{
    // What in the FUCK
    TextBoxNumeric* redBox = gwk_cast<TextBoxNumeric>(FindChildByName("RedBox", false));

    // if you need to deal with pesky __int8 or char displaying as character instead of value, see:
    // https://stackoverflow.com/questions/19562103/uint8-t-cant-be-printed-with-cout/#21389821

    if (redBox)
        redBox->SetText(Gwk::Utility::ToString(+color.r), false);

    TextBoxNumeric* greenBox = gwk_cast<TextBoxNumeric>(FindChildByName("GreenBox", false));

    if (greenBox)
        greenBox->SetText(Gwk::Utility::ToString(+color.g), false);

    TextBoxNumeric* blueBox = gwk_cast<TextBoxNumeric>(FindChildByName("BlueBox", false));

    if (blueBox)
        blueBox->SetText(Gwk::Utility::ToString(+color.b), false);

    m_after->SetColor(color);
}```

Just inserted a `+` before `color.x` to make colors show as "65" instead of "A"

Copy link
Owner

@billyquith billyquith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I intend to refactor the colour picker at some point.

@billyquith billyquith merged commit 379272f into billyquith:gwork Jan 12, 2018
@billyquith
Copy link
Owner

Thanks. 👍

@sfinktah
Copy link
Contributor Author

sfinktah commented Jan 13, 2018

Literally "too easy." I've had the same problem with stream << char before, I recognised it from the symptoms.

I should be able to whip you up an actual "HSV" color picker too, I've already had to replicate imgui's conversion routines for HSV and RGB conversion. But hell if I know what I'd call the class. Also, my implementation used integers, not floats, so the range for a HSV value would be [360, 100, 100, 255] (yeah, it doesn't really make a lot of sense, i know) :p

@billyquith
Copy link
Owner

Thanks for the feedback. If you add comments to #71 for any features/changes you think need adding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants