| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "BsEditorPrerequisites.h"
- #include "GUI/BsGUIFieldBase.h"
- #include "Math/BsVector4.h"
- namespace bs
- {
- /** @addtogroup GUI-Editor
- * @{
- */
- /**
- * A composite GUI object representing an editor field. Editor fields are a combination of a label and an input field.
- * Label is optional. This specific implementation displays a Vector4 input field.
- */
- class BS_ED_EXPORT BS_SCRIPT_EXPORT(m:GUIEditor,api:bed)
- GUIVector4Field final : public TGUIField<GUIVector4Field>
- {
- public:
- /** Returns type name of the GUI element used for finding GUI element styles. */
- static const String& getGUITypeName();
- /** Style type name for the internal X input box. */
- static constexpr const char* X_FIELD_STYLE_TYPE = "XFloatField";
- /** Style type name for the internal Y input box. */
- static constexpr const char* Y_FIELD_STYLE_TYPE = "YFloatField";
- /** Style type name for the internal Z input box. */
- static constexpr const char* Z_FIELD_STYLE_TYPE = "ZFloatField";
- /** Style type name for the internal W input box. */
- static constexpr const char* W_FIELD_STYLE_TYPE = "WFloatField";
- GUIVector4Field(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
- const String& style, const GUIDimensions& dimensions, bool withLabel);
- /** Returns the value of the input field. */
- BS_SCRIPT_EXPORT(pr:getter,n:Value)
- Vector4 getValue() const;
- /** Sets a new value in the input field. */
- BS_SCRIPT_EXPORT(pr:setter,n:Value)
- void setValue(const Vector4& value);
- /** Checks is the input field currently active. */
- BS_SCRIPT_EXPORT(pr:getter,n:HasInputFocus)
- bool hasInputFocus() const;
- /** Sets input focus to a specific component's input box. */
- BS_SCRIPT_EXPORT()
- void setInputFocus(VectorComponent component, bool focus);
- /** @copydoc GUIElement::setTint */
- void setTint(const Color& color) override;
- /** Reports the new value of the vector when the user changes the value of any of the vector components. */
- BS_SCRIPT_EXPORT()
- Event<void(const Vector4&)> onValueChanged;
- /** Reports the new value of an individual vector component when the user changes it. */
- BS_SCRIPT_EXPORT()
- Event<void(float, VectorComponent)> onComponentChanged;
- /** Triggered when an individual component loses or gains focus. */
- BS_SCRIPT_EXPORT()
- Event<void(bool, VectorComponent)> onComponentFocusChanged;
- /** Triggered when the user hits the Enter key with any of the component input boxes in focus. */
- BS_SCRIPT_EXPORT()
- Event<void(VectorComponent)> onConfirm;
- protected:
- /** @copydoc GUIElement::setTint */
- void styleUpdated() override;
- /** Triggered when the values in any of the input boxes change. */
- void valueChanged(float newValue, VectorComponent component);
- /** Triggered when the users confirms input in the input box. */
- void inputConfirmed(VectorComponent component);
- static const UINT32 ELEMENT_LABEL_WIDTH;
- GUIFloatField* mFieldX = nullptr;
- GUIFloatField* mFieldY = nullptr;
- GUIFloatField* mFieldZ = nullptr;
- GUIFloatField* mFieldW = nullptr;
- };
- /** @} */
- }
|