|
|
@@ -19,44 +19,19 @@ namespace BansheeEditor
|
|
|
{
|
|
|
const float GUIFloatField::DRAG_SPEED = 0.05f;
|
|
|
|
|
|
- GUIFloatField::GUIFloatField(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent,
|
|
|
- GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions)
|
|
|
- :GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mInputBox(nullptr), mIsDragging(false),
|
|
|
- mLastDragPos(0), mIsDragCursorSet(false), mLabelWidth(100)
|
|
|
+ GUIFloatField::GUIFloatField(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent, CM::UINT32 labelWidth,
|
|
|
+ GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
|
|
|
+ :TGUIField(dummy, parent, labelContent, labelWidth, labelStyle, layoutOptions, withLabel), mInputBox(nullptr), mIsDragging(false),
|
|
|
+ mLastDragPos(0), mIsDragCursorSet(false)
|
|
|
{
|
|
|
- const GUIElementStyle* curLabelStyle = labelStyle;
|
|
|
const GUIElementStyle* curInputBoxStyle = inputBoxStyle;
|
|
|
-
|
|
|
- if(curLabelStyle == nullptr)
|
|
|
- curLabelStyle = parent.getSkin().getStyle("Label");
|
|
|
-
|
|
|
- if(curInputBoxStyle == nullptr)
|
|
|
- curInputBoxStyle = parent.getSkin().getStyle("InputBox");
|
|
|
-
|
|
|
- mLabel = GUILabel::create(parent, labelContent, curLabelStyle);
|
|
|
- mInputBox = GUIInputBox::create(parent, false, inputBoxStyle);
|
|
|
- mInputBox->setFilter(&GUIFloatField::floatFilter);
|
|
|
-
|
|
|
- _registerChildElement(mLabel);
|
|
|
- _registerChildElement(mInputBox);
|
|
|
-
|
|
|
- setValue(0);
|
|
|
- }
|
|
|
-
|
|
|
- GUIFloatField::GUIFloatField(const PrivatelyConstruct& dummy, GUIWidget& parent,
|
|
|
- GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions)
|
|
|
- :GUIElementContainer(parent, layoutOptions), mLabel(nullptr), mInputBox(nullptr), mIsDragging(false),
|
|
|
- mLastDragPos(0), mLabelWidth(100)
|
|
|
- {
|
|
|
- const GUIElementStyle* curInputBoxStyle = inputBoxStyle;
|
|
|
-
|
|
|
if(curInputBoxStyle == nullptr)
|
|
|
curInputBoxStyle = parent.getSkin().getStyle("InputBox");
|
|
|
|
|
|
- mInputBox = GUIInputBox::create(parent, false, inputBoxStyle);
|
|
|
+ mInputBox = GUIInputBox::create(parent, false, GUIOptions(GUIOption::flexibleWidth()), inputBoxStyle);
|
|
|
mInputBox->setFilter(&GUIFloatField::floatFilter);
|
|
|
|
|
|
- _registerChildElement(mInputBox);
|
|
|
+ mLayout->addElement(mInputBox);
|
|
|
|
|
|
setValue(0);
|
|
|
}
|
|
|
@@ -66,47 +41,6 @@ namespace BansheeEditor
|
|
|
|
|
|
}
|
|
|
|
|
|
- GUIFloatField* GUIFloatField::create(GUIWidget& parent, const GUIContent& labelContent, const GUIOptions& layoutOptions,
|
|
|
- GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle)
|
|
|
- {
|
|
|
- return cm_new<GUIFloatField>(PrivatelyConstruct(), parent, labelContent, labelStyle, inputBoxStyle,
|
|
|
- GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
|
|
|
- }
|
|
|
-
|
|
|
- GUIFloatField* GUIFloatField::create(GUIWidget& parent, const GUIContent& labelContent, GUIElementStyle* labelStyle,
|
|
|
- GUIElementStyle* inputBoxStyle)
|
|
|
- {
|
|
|
- return cm_new<GUIFloatField>(PrivatelyConstruct(), parent, labelContent, labelStyle, inputBoxStyle,
|
|
|
- GUILayoutOptions::create(&GUISkin::DefaultStyle));
|
|
|
- }
|
|
|
-
|
|
|
- GUIFloatField* GUIFloatField::create(GUIWidget& parent, const HString& labelContent, const GUIOptions& layoutOptions,
|
|
|
- GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle)
|
|
|
- {
|
|
|
- return cm_new<GUIFloatField>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle,
|
|
|
- inputBoxStyle, GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
|
|
|
- }
|
|
|
-
|
|
|
- GUIFloatField* GUIFloatField::create(GUIWidget& parent, const HString& labelContent, GUIElementStyle* labelStyle,
|
|
|
- GUIElementStyle* inputBoxStyle)
|
|
|
- {
|
|
|
- return cm_new<GUIFloatField>(PrivatelyConstruct(), parent, GUIContent(labelContent), labelStyle, inputBoxStyle,
|
|
|
- GUILayoutOptions::create(&GUISkin::DefaultStyle));
|
|
|
- }
|
|
|
-
|
|
|
- GUIFloatField* GUIFloatField::create(GUIWidget& parent, const GUIOptions& layoutOptions, GUIElementStyle* labelStyle,
|
|
|
- GUIElementStyle* inputBoxStyle)
|
|
|
- {
|
|
|
- return cm_new<GUIFloatField>(PrivatelyConstruct(), parent, labelStyle, inputBoxStyle,
|
|
|
- GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle));
|
|
|
- }
|
|
|
-
|
|
|
- GUIFloatField* GUIFloatField::create(GUIWidget& parent,
|
|
|
- GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle)
|
|
|
- {
|
|
|
- return cm_new<GUIFloatField>(PrivatelyConstruct(), parent, labelStyle, inputBoxStyle, GUILayoutOptions::create(&GUISkin::DefaultStyle));
|
|
|
- }
|
|
|
-
|
|
|
bool GUIFloatField::mouseEvent(const GUIMouseEvent& event)
|
|
|
{
|
|
|
GUIElementContainer::mouseEvent(event);
|
|
|
@@ -220,77 +154,12 @@ namespace BansheeEditor
|
|
|
mInputBox->setText(toWString(value));
|
|
|
}
|
|
|
|
|
|
- void GUIFloatField::setLabelWidth(UINT32 width)
|
|
|
- {
|
|
|
- mLabelWidth = width;
|
|
|
-
|
|
|
- markContentAsDirty();
|
|
|
- }
|
|
|
-
|
|
|
void GUIFloatField::updateClippedBounds()
|
|
|
{
|
|
|
Vector2I offset = _getOffset();
|
|
|
mClippedBounds = RectI(offset.x, offset.y, _getWidth(), _getHeight());
|
|
|
}
|
|
|
|
|
|
- void GUIFloatField::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
|
|
|
- RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
|
|
|
- {
|
|
|
- UINT32 inputBoxOffset = 0;
|
|
|
- UINT32 inputBoxWidth = width;
|
|
|
-
|
|
|
- if(mLabel != nullptr)
|
|
|
- {
|
|
|
- UINT32 labelWidth = mLabelWidth;
|
|
|
-
|
|
|
- Vector2I optimalSize = mLabel->_getOptimalSize();
|
|
|
- INT32 yOffset = Math::roundToInt((height - optimalSize.y) * 0.5f);
|
|
|
-
|
|
|
- Vector2I offset(x, y + yOffset);
|
|
|
- mLabel->_setOffset(offset);
|
|
|
- mLabel->_setWidth(labelWidth);
|
|
|
- mLabel->_setHeight(optimalSize.y);
|
|
|
- mLabel->_setAreaDepth(areaDepth);
|
|
|
- mLabel->_setWidgetDepth(widgetDepth);
|
|
|
-
|
|
|
- RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
|
|
|
- mLabel->_setClipRect(elemClipRect);
|
|
|
-
|
|
|
- inputBoxOffset = labelWidth;
|
|
|
- inputBoxWidth = width - labelWidth;
|
|
|
- }
|
|
|
-
|
|
|
- Vector2I inputBoxSize = mInputBox->_getOptimalSize();
|
|
|
-
|
|
|
- {
|
|
|
- Vector2I optimalSize = mInputBox->_getOptimalSize();
|
|
|
- INT32 yOffset = Math::roundToInt((height - optimalSize.y) * 0.5f);
|
|
|
-
|
|
|
- Vector2I offset(x + inputBoxOffset, y + yOffset);
|
|
|
- mInputBox->_setOffset(offset);
|
|
|
- mInputBox->_setWidth(inputBoxWidth);
|
|
|
- mInputBox->_setHeight(optimalSize.y);
|
|
|
- mInputBox->_setAreaDepth(areaDepth);
|
|
|
- mInputBox->_setWidgetDepth(widgetDepth);
|
|
|
-
|
|
|
- RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
|
|
|
- mInputBox->_setClipRect(elemClipRect);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Vector2I GUIFloatField::_getOptimalSize() const
|
|
|
- {
|
|
|
- Vector2I optimalsize = mInputBox->_getOptimalSize();
|
|
|
-
|
|
|
- if(mLabel != nullptr)
|
|
|
- {
|
|
|
- optimalsize.x += mLabel->_getOptimalSize().x;
|
|
|
- optimalsize.y = std::max(optimalsize.y, mLabel->_getOptimalSize().y);
|
|
|
- }
|
|
|
-
|
|
|
- return optimalsize;
|
|
|
- }
|
|
|
-
|
|
|
const String& GUIFloatField::getGUITypeName()
|
|
|
{
|
|
|
static String typeName = "GUIFloatField";
|