mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 19:29:52 +02:00
Make number boxes easier to use, plus limit deco editor numbers to 255
This commit is contained in:
@@ -33,12 +33,22 @@ ColourPickerActivity::ColourPickerActivity(ui::Colour initialColour, ColourPicke
|
|||||||
|
|
||||||
void TextChangedCallback(ui::Textbox * sender)
|
void TextChangedCallback(ui::Textbox * sender)
|
||||||
{
|
{
|
||||||
int r, g, b;
|
int r, g, b, alpha;
|
||||||
r = format::StringToNumber<int>(a->rValue->GetText());
|
r = format::StringToNumber<int>(a->rValue->GetText());
|
||||||
g = format::StringToNumber<int>(a->gValue->GetText());
|
g = format::StringToNumber<int>(a->gValue->GetText());
|
||||||
b = format::StringToNumber<int>(a->bValue->GetText());
|
b = format::StringToNumber<int>(a->bValue->GetText());
|
||||||
a->currentAlpha = format::StringToNumber<int>(a->aValue->GetText());
|
|
||||||
RGB_to_HSV(r, g, b, &a->currentHue, &a->currentSaturation, &a->currentValue);
|
RGB_to_HSV(r, g, b, &a->currentHue, &a->currentSaturation, &a->currentValue);
|
||||||
|
|
||||||
|
if (r > 255)
|
||||||
|
a->rValue->SetText("255");
|
||||||
|
if (g > 255)
|
||||||
|
a->gValue->SetText("255");
|
||||||
|
if (b > 255)
|
||||||
|
a->bValue->SetText("255");
|
||||||
|
alpha = format::StringToNumber<int>(a->aValue->GetText());
|
||||||
|
if (alpha > 255)
|
||||||
|
a->aValue->SetText("255");
|
||||||
|
a->currentAlpha = format::StringToNumber<int>(a->aValue->GetText());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -412,10 +412,6 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
//Remove extra preceding 0's
|
//Remove extra preceding 0's
|
||||||
while(backingText[0] == '0' && backingText.length()>1)
|
while(backingText[0] == '0' && backingText.length()>1)
|
||||||
backingText.erase(backingText.begin());
|
backingText.erase(backingText.begin());
|
||||||
|
|
||||||
//If there is no content, replace with 0
|
|
||||||
if(!backingText.length())
|
|
||||||
backingText = "0";
|
|
||||||
}
|
}
|
||||||
if(cursor > backingText.length())
|
if(cursor > backingText.length())
|
||||||
cursor = backingText.length();
|
cursor = backingText.length();
|
||||||
|
Reference in New Issue
Block a user