Make number boxes easier to use, plus limit deco editor numbers to 255
This commit is contained in:
parent
bb08de4544
commit
a4f12d367b
@ -33,12 +33,22 @@ ColourPickerActivity::ColourPickerActivity(ui::Colour initialColour, ColourPicke
|
||||
|
||||
void TextChangedCallback(ui::Textbox * sender)
|
||||
{
|
||||
int r, g, b;
|
||||
int r, g, b, alpha;
|
||||
r = format::StringToNumber<int>(a->rValue->GetText());
|
||||
g = format::StringToNumber<int>(a->gValue->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);
|
||||
|
||||
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
|
||||
while(backingText[0] == '0' && backingText.length()>1)
|
||||
backingText.erase(backingText.begin());
|
||||
|
||||
//If there is no content, replace with 0
|
||||
if(!backingText.length())
|
||||
backingText = "0";
|
||||
}
|
||||
if(cursor > backingText.length())
|
||||
cursor = backingText.length();
|
||||
|
Reference in New Issue
Block a user