I got bored and put in the math functions from Imprudence.

We need something to show the list - Preferably a bit better than the popup that they use, I'm thinking maybe an expanding sidebar on the build menu?

Oh, minor changes - Texture repeats go up to 1000 now because it has numbers, and I tweaked the primitive params section so it doesn't fall off the window.

Signed-off-by: Beeks <HgDelirium@gmail.com>
This commit is contained in:
Beeks
2010-09-16 22:08:33 -04:00
parent 7f0af74e00
commit d49c92b6fe
9 changed files with 350 additions and 218 deletions

View File

@@ -42,6 +42,7 @@
#include "llgl.h"
#include "lltimer.h"
#include "llcalc.h"
//#include "llclipboard.h"
#include "llcontrol.h"
#include "llbutton.h"
@@ -130,6 +131,7 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect,
mDrawAsterixes( FALSE ),
mHandleEditKeysDirectly( FALSE ),
mSelectAllonFocusReceived( FALSE ),
mSelectAllonCommit( TRUE ),
mPassDelete(FALSE),
mReadOnly(FALSE),
mHaveHistory(FALSE),
@@ -223,7 +225,10 @@ void LLLineEditor::onCommit()
updateHistory();
LLUICtrl::onCommit();
selectAll();
// Selection on commit needs to be turned off when evaluating maths
// expressions, to allow indication of the error position
if (mSelectAllonCommit) selectAll();
}
@@ -2164,6 +2169,40 @@ BOOL LLLineEditor::prevalidateASCII(const LLWString &str)
return rv;
}
BOOL LLLineEditor::evaluateFloat()
{
bool success = false;
std::string expr = getText();
// user deleted the contents, nothing to evaluate -- MC
if (expr.empty())
{
return success;
}
else
{
F32 result = 0.f;
success = LLCalc::getInstance()->evalString(expr, result);
if (!success)
{
// Move the cursor to near the error on failure
setCursor(LLCalc::getInstance()->getLastErrorPos());
// *TODO: Translated error message indicating the type of error? Select error text?
}
else
{
// Replace the expression with the result
std::ostringstream result_str;
result_str << result;
setText(result_str.str());
selectAll();
}
return success;
}
}
void LLLineEditor::onMouseCaptureLost()
{
endSelection();