Added input-mode to UITextInput and deprecated UITextInputPassword to simplify the implementation.

Added Http::setDefaultUserAgent.
This commit is contained in:
Martín Lucas Golini
2026-04-03 15:53:08 -03:00
parent 461965f73d
commit c039536b26
18 changed files with 211 additions and 230 deletions

View File

@@ -906,7 +906,7 @@ Sets the hint font shadow offset.
* Applicable to: EE::UI::UITextView (TextView) and any element that holds inside text or extends from a
TextView. EE::UI::UICheckBox (CheckBox), EE::UI::UIRadioButton (RadioButton), EE::UI::UITextInput
(TextInput), EE::UI::UIListBoxItem (ListBox::item), EE::UI::UIDropDownList (DropDownList),
EE::UI::UITextInputPassword (TextInputPassword), EE::UI::UIPushButton (PushButton), EE::UI::UIToolti
EE::UI::UIPushButton (PushButton), EE::UI::UIToolti
(Tooltip)
* Data Type: [vector2-length](#vector2-length-data-type)
* Default offset: `1dp 1dp`
@@ -990,6 +990,19 @@ in which these items are displayed/sorted inside the button.
---
### input-mode
Sets the input mode of the element.
* Applicable to: EE::UI::UITextInput (TextInput)
* Data Type: [string-list](#string-list-data-type)
* Value List:
* `normal`: Normal text input.
* `password`: Password text input (bullets).
* Default value: `normal`
---
### layout-gravity
The layout gravity defines how the element gravitates against its parent (when possible). Gravity
@@ -1742,8 +1755,7 @@ Sets the text selection background color on a text element that supports text se
* Applicable to: EE::UI::UITextView (TextView) and any element that holds inside or extends from a
TextView. EE::UI::UICheckBox (CheckBox), EE::UI::UIRadioButton (RadioButton), EE::UI::UITextInput
(TextInput), EE::UI::UIListBoxItem (ListBox::item), EE::UI::UIDropDownList (DropDownList),
EE::UI::UITextInputPassword (TextInputPassword)
(TextInput), EE::UI::UIListBoxItem (ListBox::item), EE::UI::UIDropDownList (DropDownList)
* Data Type: [color](#color-data-type)
* Default color: `#323232`
@@ -1756,7 +1768,7 @@ Sets the text selection color on a text element that supports text selection.
* Applicable to: EE::UI::UITextView (TextView) and any element that holds inside text or extends from a
TextView. EE::UI::UICheckBox (CheckBox), EE::UI::UIRadioButton (RadioButton), EE::UI::UITextInput
(TextInput), EE::UI::UIListBoxItem (ListBox::item), EE::UI::UIDropDownList (DropDownList),
EE::UI::UITextInputPassword (TextInputPassword), EE::UI::UIPushButton (PushButton)
EE::UI::UIPushButton (PushButton)
* Data Type: [color](#color-data-type)
* Default color: `white`
@@ -1918,8 +1930,7 @@ code implementation, but it's available as an option.
* Applicable to: EE::UI::UITextView (TextView) and any element that holds inside or extends from a
TextView. EE::UI::UICheckBox (CheckBox), EE::UI::UIRadioButton (RadioButton), EE::UI::UITextInput
(TextInput), EE::UI::UIListBoxItem (ListBox::item), EE::UI::UIDropDownList (DropDownList),
EE::UI::UITextInputPassword (TextInputPassword), EE::UI::UITooltip (Tooltip), EE::UI::UITab (Tab),
EE::UI::UITextEdit (TextEdit)
EE::UI::UITooltip (Tooltip), EE::UI::UITab (Tab), EE::UI::UITextEdit (TextEdit)
* Data Type: [string](#string-data-type)
* Default value: _No value_
@@ -1954,8 +1965,7 @@ Enables/disables text selection in any element that contains text.
* Applicable to: EE::UI::UITextView (TextView) and any element that holds inside or extends from a
TextView. EE::UI::UICheckBox (CheckBox), EE::UI::UIRadioButton (RadioButton), EE::UI::UITextInput
(TextInput), EE::UI::UIListBoxItem (ListBox::item), EE::UI::UIDropDownList (DropDownList),
EE::UI::UITextInputPassword (TextInputPassword), EE::UI::UITooltip (Tooltip), EE::UI::UITab (Tab),
EE::UI::UITextEdit (TextEdit)
EE::UI::UITooltip (Tooltip), EE::UI::UITab (Tab), EE::UI::UITextEdit (TextEdit)
* Data Type: [boolean](#boolean-data-type)
* Default value: `true` for TextEdit, TextInput. `false` for any other element.
@@ -1968,8 +1978,7 @@ Sets the text shadow color.
* Applicable to: EE::UI::UITextView (TextView) and any element that holds inside text or extends from a
TextView. EE::UI::UICheckBox (CheckBox), EE::UI::UIRadioButton (RadioButton), EE::UI::UITextInput
(TextInput), EE::UI::UIListBoxItem (ListBox::item), EE::UI::UIDropDownList (DropDownList),
EE::UI::UITextInputPassword (TextInputPassword), EE::UI::UIPushButton (PushButton), EE::UI::UIToolti
(Tooltip)
EE::UI::UIPushButton (PushButton), EE::UI::UITooltip (Tooltip)
* Data Type: [color](#color-data-type)
* Default color: `#323232E6`
@@ -1982,8 +1991,7 @@ Sets the text shadow offset.
* Applicable to: EE::UI::UITextView (TextView) and any element that holds inside text or extends from a
TextView. EE::UI::UICheckBox (CheckBox), EE::UI::UIRadioButton (RadioButton), EE::UI::UITextInput
(TextInput), EE::UI::UIListBoxItem (ListBox::item), EE::UI::UIDropDownList (DropDownList),
EE::UI::UITextInputPassword (TextInputPassword), EE::UI::UIPushButton (PushButton), EE::UI::UIToolti
(Tooltip)
EE::UI::UIPushButton (PushButton), EE::UI::UITooltip (Tooltip)
* Data Type: [vector2-length](#vector2-length-data-type)
* Default offset: `1dp 1dp`
@@ -2355,8 +2363,7 @@ Enables/disables word-wrap in the text view element.
* Applicable to: EE::UI::UITextVIew (TextView), EE::UI::UITextInput (TextInput),
EE::UI::UICheckBox (CheckBox), EE::UI::UIRadioButton (RadioButton),
EE::UI::UIListBoxItem (ListBox::item), EE::UI::UITextInputPassword (TextInputPassword),
EE::UI::UIDropDownList (DropDownList).
EE::UI::UIListBoxItem (ListBox::item), EE::UI::UIDropDownList (DropDownList).
* Data Type: [boolean](#boolean-data-type)
* Default value: `false`

View File

@@ -396,6 +396,10 @@ class EE_API Http : NonCopyable {
URI mProxy; ///< Proxy information
};
static void setDefaultUserAgent( const std::string& userAgent );
static std::string getDefaultUserAgent();
/** @brief Default constructor */
Http();

View File

@@ -147,7 +147,6 @@
#include <eepp/ui/uitabwidget.hpp>
#include <eepp/ui/uitextedit.hpp>
#include <eepp/ui/uitextinput.hpp>
#include <eepp/ui/uitextinputpassword.hpp>
#include <eepp/ui/uitextspan.hpp>
#include <eepp/ui/uitextureregion.hpp>
#include <eepp/ui/uitextview.hpp>

View File

@@ -237,6 +237,7 @@ enum class PropertyId : Uint32 {
Type = String::hash( "type" ),
Rows = String::hash( "rows" ),
Cols = String::hash( "cols" ),
InputMode = String::hash( "input-mode" ),
};
enum class PropertyType : Uint32 {

View File

@@ -33,6 +33,8 @@ class EE_API HTMLTextInput : public UITextInput {
void setHtmlSize( Uint32 size );
protected:
HTMLTextInput( const std::string& tag );
Uint32 mHtmlSize{ 20 };
bool mPacking{ false };
};

View File

@@ -15,8 +15,12 @@ class UIMenuItem;
class EE_API UITextInput : public UITextView, public TextDocument::Client {
public:
enum class TextInputMode { Normal, Password };
static UITextInput* New();
static UITextInput* NewPassword();
static UITextInput* NewWithTag( const std::string& tag );
virtual ~UITextInput();
@@ -119,6 +123,14 @@ class EE_API UITextInput : public UITextView, public TextDocument::Client {
void setSelectAllDocOnTabNavigate( bool selectAllDocOnTabNavigate );
UITextInput* setMode( TextInputMode mode );
TextInputMode getMode() const;
const String& getBulletCharacter() const;
void setBulletCharacter( const String& bulletCharacter );
Client::Type getTextDocumentClientType() { return TextDocument::Client::Core; }
protected:
@@ -145,6 +157,9 @@ class EE_API UITextInput : public UITextView, public TextDocument::Client {
Uint64 mLastExecuteEventId{ 0 };
String::HashType mLastCmdHash{ 0 };
HintDisplay mHintDisplay{ HintDisplay::Always };
TextInputMode mMode{ TextInputMode::Normal };
Text* mPassCache{ nullptr };
String mBulletCharacter{ "" };
UITextInput();
@@ -180,6 +195,8 @@ class EE_API UITextInput : public UITextView, public TextDocument::Client {
virtual void onFontChanged();
virtual void onFontStyleChanged();
void onThemeLoaded();
virtual void onCursorPosChange();
@@ -190,6 +207,12 @@ class EE_API UITextInput : public UITextView, public TextDocument::Client {
virtual void updateText();
virtual void updatePass();
virtual void updateFontStyleConfig();
virtual Text& getVisibleTextCache();
virtual void selCurInit( const Int32& init );
virtual void selCurEnd( const Int32& end );

View File

@@ -1,50 +0,0 @@
#ifndef EE_UICUITEXTINPUTPASSWORD_HPP
#define EE_UICUITEXTINPUTPASSWORD_HPP
#include <eepp/ui/uitextinput.hpp>
namespace EE { namespace UI {
class EE_API UITextInputPassword : public UITextInput {
public:
static UITextInputPassword* New();
virtual ~UITextInputPassword();
virtual void draw();
virtual const String& getText() const;
virtual UITextView* setText( const String& text );
const Text& getPassCache() const;
const String& getBulletCharacter() const;
void setBulletCharacter( const String& bulletCharacter );
protected:
UITextInputPassword();
Text mPassCache;
Vector2f mHintAlignOffset;
String mBulletCharacter;
void updateText();
void updatePass( const String& pass );
void updateFontStyleConfig();
virtual void onStateChange();
virtual void onFontChanged();
virtual void onFontStyleChanged();
virtual Text& getVisibleTextCache();
};
}} // namespace EE::UI
#endif

View File

@@ -27,6 +27,17 @@ namespace EE { namespace Network {
#define PACKET_BUFFER_SIZE ( 16384 )
static std::string sDefaultUserAgent = "Mozilla/5.0 (Linux; x86_64) eepp-network/1.0 "
"Chrome/146.0.0.0 AppleWebKit/537.36 Safari/537.36";
void Http::setDefaultUserAgent( const std::string& userAgent ) {
sDefaultUserAgent = userAgent;
}
std::string Http::getDefaultUserAgent() {
return sDefaultUserAgent;
}
std::string Http::Request::statusToString( Http::Request::Status status ) {
switch ( status ) {
case Connected:
@@ -220,7 +231,7 @@ std::string Http::Request::prepareTunnel( const Http& http ) {
setField( "Host", String::format( "%s:%d", http.getHostName().c_str(), http.getPort() ) );
setField( "Proxy-Connection", "Keep-Alive" );
setField( "User-Agent", "eepp-network" );
setField( "User-Agent", sDefaultUserAgent );
for ( FieldTable::const_iterator i = mFields.begin(); i != mFields.end(); ++i )
out << i->first << ": " << i->second << "\r\n";
@@ -1278,7 +1289,7 @@ Http::Request Http::prepareFields( const Http::Request& request ) {
Request toSend( request );
if ( !toSend.hasField( "User-Agent" ) )
toSend.setField( "User-Agent", "eepp-network" );
toSend.setField( "User-Agent", sDefaultUserAgent );
if ( !toSend.hasField( "Accept" ) )
toSend.setField( "Accept", "*/*" );

View File

@@ -418,6 +418,7 @@ void StyleSheetSpecification::registerDefaultProperties() {
registerProperty( "type", "text" ).setType( PropertyType::String );
registerProperty( "rows", "2" ).setType( PropertyType::NumberInt );
registerProperty( "cols", "20" ).setType( PropertyType::NumberInt );
registerProperty( "input-mode", "normal" ).setType( PropertyType::String );
registerProperty( "inner-widget-orientation", "widgeticontextbox" )
.setType( PropertyType::String );

View File

@@ -6,7 +6,6 @@
#include <eepp/ui/uiradiobutton.hpp>
#include <eepp/ui/uispinbox.hpp>
#include <eepp/ui/uistyle.hpp>
#include <eepp/ui/uitextinputpassword.hpp>
namespace EE { namespace UI {
@@ -118,7 +117,7 @@ void HTMLInput::createChildWidget() {
} else if ( mInputType == "number" ) {
mChildWidget = UISpinBox::New();
} else if ( mInputType == "password" ) {
mChildWidget = UITextInputPassword::New();
mChildWidget = HTMLTextInput::New()->setMode( UITextInput::TextInputMode::Password );
} else if ( mInputType == "radio" ) {
mChildWidget = UIRadioButton::New();
} else {

View File

@@ -9,7 +9,9 @@ HTMLTextInput* HTMLTextInput::New() {
return eeNew( HTMLTextInput, () );
}
HTMLTextInput::HTMLTextInput() : UITextInput( "textinput" ) {
HTMLTextInput::HTMLTextInput() : HTMLTextInput( "textinput" ) {}
HTMLTextInput::HTMLTextInput( const std::string& tag ) : UITextInput( tag ) {
mHtmlSize = 20;
mWidthPolicy = SizePolicy::WrapContent;
mHeightPolicy = SizePolicy::WrapContent;
@@ -84,14 +86,9 @@ void HTMLTextInput::onAutoSize() {
setInternalPixelsWidth( width );
}
}
if ( mHeightPolicy == SizePolicy::WrapContent && getFont() ) {
Float height = getFont()->getFontHeight( getFontSize() ) + mPaddingPx.Top +
mPaddingPx.Bottom;
if ( height > 0 ) {
setInternalPixelsHeight( height );
}
}
UITextInput::onAutoSize();
mPacking = false;
}

View File

@@ -39,7 +39,7 @@ UIListBox::UIListBox( const std::string& tag ) :
mVisibleFirst( 0 ),
mVisibleLast( 0 ),
mSmoothScroll( true ) {
setFlags( UI_AUTO_PADDING );
setFlags( UI_AUTO_PADDING | UI_LOADS_ITS_CHILDREN );
auto cb = [this]( const Event* ) { containerResize(); };

View File

@@ -1,5 +1,6 @@
#include <eepp/graphics/font.hpp>
#include <eepp/graphics/fontmanager.hpp>
#include <eepp/graphics/fonttruetype.hpp>
#include <eepp/graphics/primitives.hpp>
#include <eepp/graphics/renderer/renderer.hpp>
#include <eepp/graphics/text.hpp>
@@ -22,6 +23,10 @@ UITextInput* UITextInput::New() {
return eeNew( UITextInput, () );
}
UITextInput* UITextInput::NewPassword() {
return ( eeNew( UITextInput, () ) )->setMode( TextInputMode::Password );
}
UITextInput* UITextInput::NewWithTag( const std::string& tag ) {
return eeNew( UITextInput, ( tag ) );
}
@@ -73,6 +78,7 @@ UITextInput::UITextInput() : UITextInput( "textinput" ) {}
UITextInput::~UITextInput() {
eeSAFE_DELETE( mHintCache );
eeSAFE_DELETE( mPassCache );
}
Uint32 UITextInput::getType() const {
@@ -132,19 +138,41 @@ void UITextInput::draw() {
if ( mVisible && 0.f != mAlpha ) {
UINode::draw();
if ( mTextCache.getTextWidth() ) {
drawSelection( mTextCache );
mTextCache.setAlign( getFlags() );
mTextCache.draw(
Text& textCache = getVisibleTextCache();
if ( textCache.getTextWidth() ) {
drawSelection( textCache );
if ( isClipped() ) {
clipSmartEnable( mScreenPos.x + mPaddingPx.Left, mScreenPos.y + mPaddingPx.Top,
mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right,
mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom );
}
textCache.setAlign( getFlags() );
textCache.draw(
std::trunc( mScreenPos.x ) + (int)mRealAlignOffset.x + (int)mPaddingPx.Left,
std::trunc( mScreenPos.y ) + (int)mRealAlignOffset.y + (int)mPaddingPx.Top,
Vector2f::One, 0.f, getBlendMode() );
if ( isClipped() ) {
clipSmartDisable();
}
} else if ( !mHintCache->getString().empty() &&
( mHintDisplay == HintDisplay::Always || hasFocus() ) ) {
if ( isClipped() ) {
clipSmartEnable( mScreenPos.x + mPaddingPx.Left, mScreenPos.y + mPaddingPx.Top,
mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right,
mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom );
}
mHintCache->draw(
std::trunc( mScreenPos.x ) + (int)mRealAlignOffset.x + (int)mPaddingPx.Left,
std::trunc( mScreenPos.y ) + (int)mRealAlignOffset.y + (int)mPaddingPx.Top,
Vector2f::One, 0.f, getBlendMode() );
if ( isClipped() ) {
clipSmartDisable();
}
}
}
@@ -287,7 +315,90 @@ const String& UITextInput::getText() const {
void UITextInput::wrapText( const Uint32& ) {}
void UITextInput::updateText() {}
UITextInput* UITextInput::setMode( TextInputMode mode ) {
if ( mMode != mode ) {
mMode = mode;
if ( mMode == TextInputMode::Password ) {
if ( !mPassCache ) {
mPassCache = Text::New();
updateFontStyleConfig();
}
updatePass();
}
invalidateDraw();
}
return this;
}
UITextInput::TextInputMode UITextInput::getMode() const {
return mMode;
}
const String& UITextInput::getBulletCharacter() const {
return mBulletCharacter;
}
void UITextInput::setBulletCharacter( const String& bulletCharacter ) {
mBulletCharacter = bulletCharacter;
updatePass();
}
void UITextInput::updateText() {
if ( mMode == TextInputMode::Password )
updatePass();
}
void UITextInput::updatePass() {
if ( !mPassCache )
return;
const String& pass = mTextCache.getString();
if ( mBulletCharacter.size() == 1 && mPassCache->getFont() &&
mPassCache->getFont()->getType() == FontType::TTF &&
!static_cast<FontTrueType*>( mPassCache->getFont() )
->hasGlyph( mBulletCharacter.front() ) ) {
mBulletCharacter = "";
}
String newTxt;
newTxt.reserve( pass.size() );
for ( size_t i = 0; i < pass.size(); i++ )
newTxt += mBulletCharacter;
mPassCache->setString( newTxt );
}
void UITextInput::updateFontStyleConfig() {
if ( mPassCache ) {
mPassCache->setFontSize( mFontStyleConfig.CharacterSize );
mPassCache->setFont( mFontStyleConfig.getFont() );
mPassCache->setFillColor( mFontStyleConfig.getFontColor() );
mPassCache->setShadowColor( mFontStyleConfig.getFontShadowColor() );
mPassCache->setOutlineColor( mFontStyleConfig.getOutlineColor() );
mPassCache->setOutlineThickness( mFontStyleConfig.getOutlineThickness() );
}
}
void UITextInput::onFontChanged() {
UITextView::onFontChanged();
if ( getHintFont() == NULL ) {
setHintFont( getFont() );
}
updateFontStyleConfig();
invalidateDraw();
}
void UITextInput::onFontStyleChanged() {
updateFontStyleConfig();
invalidateDraw();
}
Text& UITextInput::getVisibleTextCache() {
if ( mMode == TextInputMode::Password && mPassCache )
return *mPassCache;
return mTextCache;
}
Uint32 UITextInput::onMouseDown( const Vector2i& position, const Uint32& flags ) {
int endPos = selCurEnd();
@@ -471,6 +582,8 @@ std::string UITextInput::getPropertyString( const PropertyDefinition* propertyDe
return getHintOutlineColor().toHexString();
case PropertyId::HintDisplay:
return mHintDisplay == HintDisplay::Always ? "always" : "focus";
case PropertyId::InputMode:
return mMode == TextInputMode::Password ? "password" : "normal";
default:
return UITextView::getPropertyString( propertyDef, propertyIndex );
}
@@ -492,7 +605,8 @@ std::vector<PropertyId> UITextInput::getPropertiesImplemented() const {
PropertyId::HintFontStyle,
PropertyId::HintStrokeWidth,
PropertyId::HintStrokeColor,
PropertyId::HintDisplay };
PropertyId::HintDisplay,
PropertyId::InputMode };
props.insert( props.end(), local.begin(), local.end() );
return props;
}
@@ -549,6 +663,10 @@ bool UITextInput::applyProperty( const StyleSheetProperty& attribute ) {
? HintDisplay::Focus
: HintDisplay::Always );
break;
case PropertyId::InputMode:
setMode( String::iequals( "password", attribute.asString() ) ? TextInputMode::Password
: TextInputMode::Normal );
break;
default:
return UITextView::applyProperty( attribute );
}
@@ -568,12 +686,6 @@ UIWidget* UITextInput::setPadding( const Rectf& padding ) {
return this;
}
void UITextInput::onFontChanged() {
if ( getHintFont() == NULL ) {
setHintFont( getFont() );
}
}
const String& UITextInput::getHint() const {
return mHintCache->getString();
}

View File

@@ -1,134 +0,0 @@
#include <eepp/graphics/font.hpp>
#include <eepp/graphics/fonttruetype.hpp>
#include <eepp/graphics/text.hpp>
#include <eepp/ui/uitextinputpassword.hpp>
#include <eepp/ui/uithememanager.hpp>
namespace EE { namespace UI {
UITextInputPassword* UITextInputPassword::New() {
return eeNew( UITextInputPassword, () );
}
UITextInputPassword::UITextInputPassword() :
UITextInput( "textinputpassword" ), mBulletCharacter( "" ) {
updateFontStyleConfig();
}
UITextInputPassword::~UITextInputPassword() {}
void UITextInputPassword::draw() {
if ( mVisible && 0.f != mAlpha ) {
UINode::draw();
if ( mPassCache.getTextWidth() ) {
drawSelection( mPassCache );
if ( isClipped() ) {
clipSmartEnable( mScreenPos.x + mPaddingPx.Left, mScreenPos.y + mPaddingPx.Top,
mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right,
mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom );
}
mPassCache.setAlign( getFlags() );
mPassCache.draw(
std::trunc( mScreenPos.x ) + (int)mRealAlignOffset.x + (int)mPaddingPx.Left,
std::trunc( mScreenPos.y ) + (int)mRealAlignOffset.y + (int)mPaddingPx.Top,
Vector2f::One, 0.f, getBlendMode() );
if ( isClipped() ) {
clipSmartDisable();
}
} else if ( !mHintCache->getString().empty() ) {
if ( isClipped() ) {
clipSmartEnable( mScreenPos.x + mPaddingPx.Left, mScreenPos.y + mPaddingPx.Top,
mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right,
mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom );
}
mHintCache->draw(
std::trunc( mScreenPos.x ) + (int)mHintAlignOffset.x + (int)mPaddingPx.Left,
std::trunc( mScreenPos.y ) + (int)mHintAlignOffset.y + (int)mPaddingPx.Top,
Vector2f::One, 0.f, getBlendMode() );
if ( isClipped() ) {
clipSmartDisable();
}
}
}
drawWaitingCursor();
}
Text& UITextInputPassword::getVisibleTextCache() {
return mPassCache;
}
void UITextInputPassword::updateText() {
updatePass( mTextCache.getString() );
}
void UITextInputPassword::updatePass( const String& pass ) {
if ( mBulletCharacter.size() == 1 && mPassCache.getFont()->getType() == FontType::TTF &&
!static_cast<FontTrueType*>( mPassCache.getFont() )
->hasGlyph( mBulletCharacter.front() ) ) {
mBulletCharacter = "";
}
String newTxt;
newTxt.reserve( pass.size() );
for ( size_t i = 0; i < pass.size(); i++ )
newTxt += mBulletCharacter;
mPassCache.setString( newTxt );
}
UITextView* UITextInputPassword::setText( const String& text ) {
UITextInput::setText( text );
updatePass( text );
return this;
}
const Text& UITextInputPassword::getPassCache() const {
return mPassCache;
}
const String& UITextInputPassword::getBulletCharacter() const {
return mBulletCharacter;
}
void UITextInputPassword::setBulletCharacter( const String& bulletCharacter ) {
mBulletCharacter = bulletCharacter;
}
void UITextInputPassword::updateFontStyleConfig() {
mPassCache.setFontSize( mFontStyleConfig.CharacterSize );
mPassCache.setFont( mFontStyleConfig.getFont() );
mPassCache.setFillColor( mFontStyleConfig.getFontColor() );
mPassCache.setShadowColor( mFontStyleConfig.getFontShadowColor() );
mPassCache.setOutlineColor( mFontStyleConfig.getOutlineColor() );
mPassCache.setOutlineThickness( mFontStyleConfig.getOutlineThickness() );
}
void UITextInputPassword::onStateChange() {
updateFontStyleConfig();
UITextInput::onStateChange();
}
void UITextInputPassword::onFontChanged() {
updateFontStyleConfig();
UITextInput::onFontChanged();
}
void UITextInputPassword::onFontStyleChanged() {
updateFontStyleConfig();
UITextInput::onFontStyleChanged();
}
const String& UITextInputPassword::getText() const {
return UITextView::getText();
}
}} // namespace EE::UI

View File

@@ -38,7 +38,6 @@
#include <eepp/ui/uitabwidget.hpp>
#include <eepp/ui/uitextedit.hpp>
#include <eepp/ui/uitextinput.hpp>
#include <eepp/ui/uitextinputpassword.hpp>
#include <eepp/ui/uitextspan.hpp>
#include <eepp/ui/uitextureregion.hpp>
#include <eepp/ui/uitextview.hpp>
@@ -86,7 +85,7 @@ void UIWidgetCreator::createBaseWidgetList() {
registeredWidget["tabwidget"] = UITabWidget::New;
registeredWidget["textedit"] = UITextEdit::New;
registeredWidget["textinput"] = UITextInput::New;
registeredWidget["textinputpassword"] = UITextInputPassword::New;
registeredWidget["textinputpassword"] = UITextInput::NewPassword;
registeredWidget["loader"] = UILoader::New;
registeredWidget["selectbutton"] = UISelectButton::New;
registeredWidget["window"] = UIWindow::New;
@@ -122,7 +121,7 @@ void UIWidgetCreator::createBaseWidgetList() {
// Aliases
registeredWidget["hbox"] = UILinearLayout::NewHorizontal;
registeredWidget["vbox"] = UILinearLayout::NewVertical;
registeredWidget["inputpassword"] = UITextInputPassword::New;
registeredWidget["inputpassword"] = UITextInput::NewPassword;
registeredWidget["viewpagerhorizontal"] = UIViewPager::NewHorizontal;
registeredWidget["viewpagervertical"] = UIViewPager::NewHorizontal;
registeredWidget["vslider"] = UISlider::NewHorizontal;

View File

@@ -7,6 +7,9 @@ EE_MAIN_FUNC int main( int, char** ) {
Log::instance()->setLogToStdOut( true );
Log::instance()->setLiveWrite( true );
Http::setDefaultUserAgent( "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like "
"Gecko) Chrome/146.0.0.0 Safari/537.36" );
auto win = app.getWindow();
auto ui = app.getUI();

View File

@@ -718,7 +718,7 @@ void EETest::createNewUI() {
UITextInput* textInput = UITextInput::New();
textInput->setPosition( 50, 210 )->setSize( 200, 0 )->setParent( container );
UITextInputPassword* textInputPass = UITextInputPassword::New();
UITextInput* textInputPass = UITextInput::NewPassword();
textInputPass->setPosition( 50, 245 )->setSize( 200, 0 )->setParent( container );
UIListBox* listBox = UIListBox::New();

View File

@@ -14,7 +14,6 @@
#include <eepp/ui/uicheckbox.hpp>
#include <eepp/ui/uihtmltable.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/uitextinputpassword.hpp>
#include <eepp/ui/uitextspan.hpp>
#include <eepp/ui/uithememanager.hpp>
#include <eepp/window/engine.hpp>
@@ -241,6 +240,7 @@ UTEST( HTMLInput, sizeAttribute ) {
<input id="i2" size="20" />
<input id="i3" />
<input id="i_pwd" type="password" />
<input id="i_mode_pwd" input-mode="password" />
<input id="i_chk" type="checkbox" />
</vbox>
)html" );
@@ -249,12 +249,14 @@ UTEST( HTMLInput, sizeAttribute ) {
auto c2 = sceneNode->getRoot()->find( "i2" )->asType<HTMLInput>();
auto c3 = sceneNode->getRoot()->find( "i3" )->asType<HTMLInput>();
auto cp = sceneNode->getRoot()->find( "i_pwd" )->asType<HTMLInput>();
auto cm = sceneNode->getRoot()->find( "i_mode_pwd" )->asType<HTMLInput>();
auto cc = sceneNode->getRoot()->find( "i_chk" )->asType<HTMLInput>();
ASSERT_TRUE( c1 != nullptr );
ASSERT_TRUE( c2 != nullptr );
ASSERT_TRUE( c3 != nullptr );
ASSERT_TRUE( cp != nullptr );
ASSERT_TRUE( cm != nullptr );
ASSERT_TRUE( cc != nullptr );
auto i1 = c1->getChildWidget()->asType<HTMLTextInput>();
@@ -273,7 +275,12 @@ UTEST( HTMLInput, sizeAttribute ) {
EXPECT_NEAR( i2->getPixelsSize().getWidth(), i3->getPixelsSize().getWidth(), 1.f );
EXPECT_TRUE( cp->getChildWidget()->isType( UI_TYPE_TEXTINPUT ) );
EXPECT_TRUE( cp->getChildWidget()->getElementTag() == "textinputpassword" );
EXPECT_TRUE( cp->getChildWidget()->asType<UITextInput>()->getMode() ==
UITextInput::TextInputMode::Password );
EXPECT_TRUE( cp->getChildWidget()->asType<UITextInput>()->getMode() ==
UITextInput::TextInputMode::Password );
EXPECT_TRUE( cm->getChildWidget()->asType<UITextInput>()->getMode() ==
UITextInput::TextInputMode::Password );
EXPECT_TRUE( cc->getChildWidget()->isType( UI_TYPE_CHECKBOX ) );
Engine::destroySingleton();