|
|
@ -57,7 +57,7 @@ namespace fx
|
|
|
|
virtual void toDefault() = 0;
|
|
|
|
virtual void toDefault() = 0;
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
std::weak_ptr<fx::Types::UniformBase> mUniform;
|
|
|
|
std::shared_ptr<fx::Types::UniformBase> mUniform;
|
|
|
|
Index mIndex;
|
|
|
|
Index mIndex;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -95,22 +95,19 @@ namespace fx
|
|
|
|
float range = 0.f;
|
|
|
|
float range = 0.f;
|
|
|
|
float min = 0.f;
|
|
|
|
float min = 0.f;
|
|
|
|
|
|
|
|
|
|
|
|
if (auto uniform = mUniform.lock())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if constexpr (std::is_fundamental_v<UType>)
|
|
|
|
if constexpr (std::is_fundamental_v<UType>)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uniform->template setValue<UType>(mValue);
|
|
|
|
mUniform->template setValue<UType>(mValue);
|
|
|
|
range = uniform->template getMax<UType>() - uniform->template getMin<UType>();
|
|
|
|
range = mUniform->template getMax<UType>() - mUniform->template getMin<UType>();
|
|
|
|
min = uniform->template getMin<UType>();
|
|
|
|
min = mUniform->template getMin<UType>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
UType uvalue = uniform->template getValue<UType>();
|
|
|
|
UType uvalue = mUniform->template getValue<UType>();
|
|
|
|
uvalue[mIndex] = mValue;
|
|
|
|
uvalue[mIndex] = mValue;
|
|
|
|
uniform->template setValue<UType>(uvalue);
|
|
|
|
mUniform->template setValue<UType>(uvalue);
|
|
|
|
range = uniform->template getMax<UType>()[mIndex] - uniform->template getMin<UType>()[mIndex];
|
|
|
|
range = mUniform->template getMax<UType>()[mIndex] - mUniform->template getMin<UType>()[mIndex];
|
|
|
|
min = uniform->template getMin<UType>()[mIndex];
|
|
|
|
min = mUniform->template getMin<UType>()[mIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float fill = (range == 0.f) ? 1.f : (mValue - min) / range;
|
|
|
|
float fill = (range == 0.f) ? 1.f : (mValue - min) / range;
|
|
|
@ -118,29 +115,23 @@ namespace fx
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void setValueFromUniform() override
|
|
|
|
void setValueFromUniform() override
|
|
|
|
{
|
|
|
|
|
|
|
|
if (auto uniform = mUniform.lock())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
T value;
|
|
|
|
T value;
|
|
|
|
|
|
|
|
|
|
|
|
if constexpr (std::is_fundamental_v<UType>)
|
|
|
|
if constexpr (std::is_fundamental_v<UType>)
|
|
|
|
value = uniform->template getValue<UType>();
|
|
|
|
value = mUniform->template getValue<UType>();
|
|
|
|
else
|
|
|
|
else
|
|
|
|
value = uniform->template getValue<UType>()[mIndex];
|
|
|
|
value = mUniform->template getValue<UType>()[mIndex];
|
|
|
|
|
|
|
|
|
|
|
|
setValue(value);
|
|
|
|
setValue(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void toDefault() override
|
|
|
|
void toDefault() override
|
|
|
|
{
|
|
|
|
|
|
|
|
if (auto uniform = mUniform.lock())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if constexpr (std::is_fundamental_v<UType>)
|
|
|
|
if constexpr (std::is_fundamental_v<UType>)
|
|
|
|
setValue(uniform->template getDefault<UType>());
|
|
|
|
setValue(mUniform->template getDefault<UType>());
|
|
|
|
else
|
|
|
|
else
|
|
|
|
setValue(uniform->template getDefault<UType>()[mIndex]);
|
|
|
|
setValue(mUniform->template getDefault<UType>()[mIndex]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
@ -164,15 +155,10 @@ namespace fx
|
|
|
|
|
|
|
|
|
|
|
|
void notifyMouseWheel(MyGUI::Widget* sender, int rel)
|
|
|
|
void notifyMouseWheel(MyGUI::Widget* sender, int rel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto uniform = mUniform.lock();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!uniform)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rel > 0)
|
|
|
|
if (rel > 0)
|
|
|
|
increment(uniform->mStep);
|
|
|
|
increment(mUniform->mStep);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
increment(-uniform->mStep);
|
|
|
|
increment(-mUniform->mStep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void notifyMouseButtonDragged(MyGUI::Widget* sender, int left, int top, MyGUI::MouseButton id)
|
|
|
|
void notifyMouseButtonDragged(MyGUI::Widget* sender, int left, int top, MyGUI::MouseButton id)
|
|
|
@ -180,24 +166,19 @@ namespace fx
|
|
|
|
if (id != MyGUI::MouseButton::Left)
|
|
|
|
if (id != MyGUI::MouseButton::Left)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
auto uniform = mUniform.lock();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!uniform)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int delta = left - mLastPointerX;
|
|
|
|
int delta = left - mLastPointerX;
|
|
|
|
|
|
|
|
|
|
|
|
// allow finer tuning when shift is pressed
|
|
|
|
// allow finer tuning when shift is pressed
|
|
|
|
constexpr double scaling = 20.0;
|
|
|
|
constexpr double scaling = 20.0;
|
|
|
|
T step
|
|
|
|
T step
|
|
|
|
= MyGUI::InputManager::getInstance().isShiftPressed() ? uniform->mStep / scaling : uniform->mStep;
|
|
|
|
= MyGUI::InputManager::getInstance().isShiftPressed() ? mUniform->mStep / scaling : mUniform->mStep;
|
|
|
|
|
|
|
|
|
|
|
|
if (step == 0)
|
|
|
|
if (step == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if constexpr (std::is_integral_v<T>)
|
|
|
|
if constexpr (std::is_integral_v<T>)
|
|
|
|
step = 1;
|
|
|
|
step = 1;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
step = uniform->mStep;
|
|
|
|
step = mUniform->mStep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (delta > 0)
|
|
|
|
if (delta > 0)
|
|
|
@ -218,30 +199,20 @@ namespace fx
|
|
|
|
|
|
|
|
|
|
|
|
void increment(T step)
|
|
|
|
void increment(T step)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto uniform = mUniform.lock();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!uniform)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if constexpr (std::is_fundamental_v<UType>)
|
|
|
|
if constexpr (std::is_fundamental_v<UType>)
|
|
|
|
setValue(std::clamp<T>(uniform->template getValue<UType>() + step,
|
|
|
|
setValue(std::clamp<T>(mUniform->template getValue<UType>() + step,
|
|
|
|
uniform->template getMin<UType>(), uniform->template getMax<T>()));
|
|
|
|
mUniform->template getMin<UType>(), mUniform->template getMax<T>()));
|
|
|
|
else
|
|
|
|
else
|
|
|
|
setValue(std::clamp<T>(uniform->template getValue<UType>()[mIndex] + step,
|
|
|
|
setValue(std::clamp<T>(mUniform->template getValue<UType>()[mIndex] + step,
|
|
|
|
uniform->template getMin<UType>()[mIndex], uniform->template getMax<UType>()[mIndex]));
|
|
|
|
mUniform->template getMin<UType>()[mIndex], mUniform->template getMax<UType>()[mIndex]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void notifyButtonClicked(MyGUI::Widget* sender)
|
|
|
|
void notifyButtonClicked(MyGUI::Widget* sender)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto uniform = mUniform.lock();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!uniform)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sender == mButtonDecrease)
|
|
|
|
if (sender == mButtonDecrease)
|
|
|
|
increment(-uniform->mStep);
|
|
|
|
increment(-mUniform->mStep);
|
|
|
|
else if (sender == mButtonIncrease)
|
|
|
|
else if (sender == mButtonIncrease)
|
|
|
|
increment(uniform->mStep);
|
|
|
|
increment(mUniform->mStep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MyGUI::Button* mButtonDecrease{ nullptr };
|
|
|
|
MyGUI::Button* mButtonDecrease{ nullptr };
|
|
|
@ -275,6 +246,23 @@ namespace fx
|
|
|
|
MYGUI_RTTI_DERIVED(EditNumberInt)
|
|
|
|
MYGUI_RTTI_DERIVED(EditNumberInt)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EditChoice : public EditBase, public MyGUI::Widget
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MYGUI_RTTI_DERIVED(EditChoice)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
|
|
|
|
void setValue(const T& value);
|
|
|
|
|
|
|
|
void setValueFromUniform() override;
|
|
|
|
|
|
|
|
void toDefault() override;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void initialiseOverride() override;
|
|
|
|
|
|
|
|
void notifyComboBoxChanged(MyGUI::ComboBox* sender, size_t pos);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MyGUI::ComboBox* mChoices{ nullptr };
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class UniformBase final : public MyGUI::Widget
|
|
|
|
class UniformBase final : public MyGUI::Widget
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MYGUI_RTTI_DERIVED(UniformBase)
|
|
|
|
MYGUI_RTTI_DERIVED(UniformBase)
|
|
|
|