1
0

Merging r6426 through r6466 from trunk to ogl-es branch

Note: Updated IShaderConstantSetCallBack not yet supported by ogl-es drivers


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6467 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2023-04-22 21:50:32 +00:00
parent e184e4aedb
commit 621bad3111
118 changed files with 12767 additions and 444 deletions

View File

@@ -23,7 +23,8 @@ CGUISpinBox::CGUISpinBox(const wchar_t* text, bool border,IGUIEnvironment* envir
: IGUISpinBox(environment, parent, id, rectangle),
EditBox(0), ButtonSpinUp(0), ButtonSpinDown(0), StepSize(1.f),
RangeMin(-FLT_MAX), RangeMax(FLT_MAX), FormatString(L"%f"),
DecimalPlaces(-1), ValidateOn(EGUI_SBV_ENTER|EGUI_SBV_LOSE_FOCUS)
DecimalPlaces(-1), ValidateOn(EGUI_SBV_ENTER|EGUI_SBV_LOSE_FOCUS),
OldValue(0.f)
{
#ifdef _DEBUG
setDebugName("CGUISpinBox");
@@ -104,23 +105,25 @@ IGUIEditBox* CGUISpinBox::getEditBox() const
void CGUISpinBox::setValue(f32 val)
{
wchar_t str[100];
swprintf_irr(str, 99, FormatString.c_str(), val);
EditBox->setText(str);
verifyValueRange();
verifyValueRange(getValue());
}
f32 CGUISpinBox::getValue() const
{
const wchar_t* val = EditBox->getText();
return getValueFor(EditBox->getText());
}
f32 CGUISpinBox::getValueFor(const wchar_t* val) const
{
if ( !val )
return 0.f;
core::stringc tmp(val);
return core::fast_atof(tmp.c_str());
}
void CGUISpinBox::setRange(f32 min, f32 max)
{
if (max<min)
@@ -135,7 +138,7 @@ void CGUISpinBox::setRange(f32 min, f32 max)
swprintf_irr(str, 99, FormatString.c_str(), RangeMax);
RangeMax = core::fast_atof(core::stringc(str).c_str());
verifyValueRange();
verifyValueRange(getValue());
}
@@ -203,7 +206,8 @@ bool CGUISpinBox::OnEvent(const SEvent& event)
{
case EMIE_MOUSE_WHEEL:
{
f32 val = getValue() + (StepSize * (event.MouseInput.Wheel < 0 ? -1.f : 1.f));
OldValue = getValue();
f32 val = OldValue + (StepSize * (event.MouseInput.Wheel < 0 ? -1.f : 1.f));
setValue(val);
changeEvent = true;
eatEvent = true;
@@ -220,15 +224,15 @@ bool CGUISpinBox::OnEvent(const SEvent& event)
{
if (event.GUIEvent.Caller == ButtonSpinUp)
{
f32 val = getValue();
val += StepSize;
OldValue = getValue();
f32 val = OldValue + StepSize;
setValue(val);
changeEvent = true;
}
else if ( event.GUIEvent.Caller == ButtonSpinDown)
{
f32 val = getValue();
val -= StepSize;
OldValue = getValue();
f32 val = OldValue - StepSize;
setValue(val);
changeEvent = true;
}
@@ -240,7 +244,8 @@ bool CGUISpinBox::OnEvent(const SEvent& event)
|| (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST && ValidateOn & EGUI_SBV_LOSE_FOCUS)
)
{
verifyValueRange();
OldValue = getValue(); // no call to setValue when text was changed without setText call
verifyValueRange(OldValue);
changeEvent = true;
}
}
@@ -251,14 +256,16 @@ bool CGUISpinBox::OnEvent(const SEvent& event)
if ( changeEvent )
{
SEvent e;
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0;
e.GUIEvent.EventType = EGET_SPINBOX_CHANGED;
if ( Parent )
{
SEvent e;
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0;
e.GUIEvent.EventType = EGET_SPINBOX_CHANGED;
Parent->OnEvent(e);
}
if ( eatEvent )
return true;
}
@@ -286,17 +293,12 @@ void CGUISpinBox::draw()
IGUISpinBox::draw();
}
void CGUISpinBox::verifyValueRange()
void CGUISpinBox::verifyValueRange(f32 val)
{
f32 val = getValue();
if ( val+core::ROUNDING_ERROR_f32 < RangeMin )
val = RangeMin;
setValue(RangeMin);
else if ( val-core::ROUNDING_ERROR_f32 > RangeMax )
val = RangeMax;
else
return;
setValue(val);
setValue(RangeMax);
}
@@ -305,7 +307,6 @@ void CGUISpinBox::setText(const wchar_t* text)
{
EditBox->setText(text);
setValue(getValue());
verifyValueRange();
}