Ndk/TextAreaWidget: Add possibility to write only one specific character category (#174)
* Ndk/TextAreaWidget: Add possibility to write only one specific character category * Add support for multiple categories * Use a predicate instead of an enum * Log change * String::FindLast/FindWord: Fix bug where index wouldn't be used (#177) * String::FindLast/FindWord: Fix bug where index wouldn't be used * Log change * Update Physics2D Component and Body (#178) * Update * Add: [Get/Set]AngularDaming for standardization * Fix: Name error * Add: [Get/Set][AngularDamping/MomentOfInertia] in PhysicsComponent2D * Forgot in last commit * Add: param coordSys in [PhysicsComponent2D/RigidBody2D]::SetMassCenter * Add: Some forgotten inline * Fix little error * Fix: Indentation before case * Move and Change GetCenterOfGravity * Physics2D: Add Arbiter2D * Fix deprecation warning * Fix units tests :derp: * Fixies
This commit is contained in:
parent
46e3de90ed
commit
05f277deeb
|
|
@ -177,11 +177,12 @@ Nazara Development Kit:
|
||||||
- ⚠️ TextAreaWidget::GetHoveredGlyph now returns a two-dimensional position instead of a single glyph position
|
- ⚠️ TextAreaWidget::GetHoveredGlyph now returns a two-dimensional position instead of a single glyph position
|
||||||
- Fixed Entity::OnEntityDestruction signal not being properly moved and thus not being called.
|
- Fixed Entity::OnEntityDestruction signal not being properly moved and thus not being called.
|
||||||
- Fixed EntityOwner move assignment which was losing entity ownership
|
- Fixed EntityOwner move assignment which was losing entity ownership
|
||||||
- Add GraphicsComponent:ForEachRenderable method
|
- Added GraphicsComponent:ForEachRenderable method
|
||||||
- Fixed GraphicsComponent reflective material count which was not initialized
|
- Fixed GraphicsComponent reflective material count which was not initialized
|
||||||
- Added PhysicsComponent2D::ClosestPointQuery
|
- Added PhysicsComponent2D::ClosestPointQuery
|
||||||
- Fix GraphicsComponent copy constructor not copying scissor rect
|
- Fixed GraphicsComponent copy constructor not copying scissor rect
|
||||||
- Force parent parameter to be present in widgets constructor
|
- Force parent parameter to be present in widgets constructor
|
||||||
|
- Added the possibility to write only specific characters with a predicate in TextAreaWidget
|
||||||
|
|
||||||
# 0.4:
|
# 0.4:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,15 @@
|
||||||
#include <NDK/BaseWidget.hpp>
|
#include <NDK/BaseWidget.hpp>
|
||||||
#include <NDK/Widgets/Enums.hpp>
|
#include <NDK/Widgets/Enums.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
class NDK_API TextAreaWidget : public BaseWidget
|
class NDK_API TextAreaWidget : public BaseWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using CharacterFilter = std::function<bool(char32_t)>;
|
||||||
|
|
||||||
TextAreaWidget(BaseWidget* parent);
|
TextAreaWidget(BaseWidget* parent);
|
||||||
TextAreaWidget(const TextAreaWidget&) = delete;
|
TextAreaWidget(const TextAreaWidget&) = delete;
|
||||||
TextAreaWidget(TextAreaWidget&&) = default;
|
TextAreaWidget(TextAreaWidget&&) = default;
|
||||||
|
|
@ -33,6 +36,7 @@ namespace Ndk
|
||||||
|
|
||||||
void EraseSelection();
|
void EraseSelection();
|
||||||
|
|
||||||
|
inline CharacterFilter GetCharacterFilter() const;
|
||||||
inline unsigned int GetCharacterSize() const;
|
inline unsigned int GetCharacterSize() const;
|
||||||
inline const Nz::Vector2ui& GetCursorPosition() const;
|
inline const Nz::Vector2ui& GetCursorPosition() const;
|
||||||
inline Nz::Vector2ui GetCursorPosition(std::size_t glyphIndex) const;
|
inline Nz::Vector2ui GetCursorPosition(std::size_t glyphIndex) const;
|
||||||
|
|
@ -54,6 +58,7 @@ namespace Ndk
|
||||||
|
|
||||||
void ResizeToContent() override;
|
void ResizeToContent() override;
|
||||||
|
|
||||||
|
inline void SetCharacterFilter(CharacterFilter filter);
|
||||||
inline void SetCharacterSize(unsigned int characterSize);
|
inline void SetCharacterSize(unsigned int characterSize);
|
||||||
inline void SetCursorPosition(std::size_t glyphIndex);
|
inline void SetCursorPosition(std::size_t glyphIndex);
|
||||||
inline void SetCursorPosition(Nz::Vector2ui cursorPosition);
|
inline void SetCursorPosition(Nz::Vector2ui cursorPosition);
|
||||||
|
|
@ -96,6 +101,7 @@ namespace Ndk
|
||||||
void RefreshCursor();
|
void RefreshCursor();
|
||||||
void UpdateDisplayText();
|
void UpdateDisplayText();
|
||||||
|
|
||||||
|
std::function<bool(char32_t)> m_characterFilter;
|
||||||
EchoMode m_echoMode;
|
EchoMode m_echoMode;
|
||||||
EntityHandle m_cursorEntity;
|
EntityHandle m_cursorEntity;
|
||||||
EntityHandle m_textEntity;
|
EntityHandle m_textEntity;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,11 @@ namespace Ndk
|
||||||
m_multiLineEnabled = enable;
|
m_multiLineEnabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline TextAreaWidget::CharacterFilter TextAreaWidget::GetCharacterFilter() const
|
||||||
|
{
|
||||||
|
return m_characterFilter;
|
||||||
|
}
|
||||||
|
|
||||||
inline unsigned int TextAreaWidget::GetCharacterSize() const
|
inline unsigned int TextAreaWidget::GetCharacterSize() const
|
||||||
{
|
{
|
||||||
return m_drawer.GetCharacterSize();
|
return m_drawer.GetCharacterSize();
|
||||||
|
|
@ -140,6 +145,11 @@ namespace Ndk
|
||||||
SetCursorPosition(cursorPosition);
|
SetCursorPosition(cursorPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void TextAreaWidget::SetCharacterFilter(CharacterFilter filter)
|
||||||
|
{
|
||||||
|
m_characterFilter = filter;
|
||||||
|
}
|
||||||
|
|
||||||
inline void TextAreaWidget::SetCharacterSize(unsigned int characterSize)
|
inline void TextAreaWidget::SetCharacterSize(unsigned int characterSize)
|
||||||
{
|
{
|
||||||
m_drawer.SetCharacterSize(characterSize);
|
m_drawer.SetCharacterSize(characterSize);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
TextAreaWidget::TextAreaWidget(BaseWidget* parent) :
|
TextAreaWidget::TextAreaWidget(BaseWidget* parent) :
|
||||||
BaseWidget(parent),
|
BaseWidget(parent),
|
||||||
|
m_characterFilter(),
|
||||||
m_echoMode(EchoMode_Normal),
|
m_echoMode(EchoMode_Normal),
|
||||||
m_cursorPositionBegin(0U, 0U),
|
m_cursorPositionBegin(0U, 0U),
|
||||||
m_cursorPositionEnd(0U, 0U),
|
m_cursorPositionEnd(0U, 0U),
|
||||||
|
|
@ -394,7 +395,7 @@ namespace Ndk
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (Nz::Unicode::GetCategory(character) == Nz::Unicode::Category_Other_Control)
|
if (Nz::Unicode::GetCategory(character) == Nz::Unicode::Category_Other_Control || (m_characterFilter && !m_characterFilter(character)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (HasSelection())
|
if (HasSelection())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue