mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-04 20:46:29 +03:00
Add hint-display property to UITextInput.
Minor refactor in ProjectDirectoryTree.
This commit is contained in:
@@ -752,6 +752,19 @@ Sets the hint font color.
|
||||
|
||||
---
|
||||
|
||||
### hint-display
|
||||
|
||||
Sets the hint display mode.
|
||||
|
||||
* Applicable to: EE::UI::UITextInput (TextInput)
|
||||
* Data Type: [string-list](#string-list-data-type)
|
||||
* Value List:
|
||||
* `always`: Always visible
|
||||
* `focus`: Visible on focus
|
||||
* Default value: `always`
|
||||
|
||||
---
|
||||
|
||||
### hint-font-family
|
||||
|
||||
Sets the hint font family.
|
||||
|
||||
@@ -165,6 +165,7 @@ enum class PropertyId : Uint32 {
|
||||
HintFontStyle = String::hash( "hint-font-style" ),
|
||||
HintStrokeWidth = String::hash( "hint-stroke-width" ),
|
||||
HintStrokeColor = String::hash( "hint-stroke-color" ),
|
||||
HintDisplay = String::hash( "hint-display" ),
|
||||
Transition = String::hash( "transition" ),
|
||||
TransitionDelay = String::hash( "transition-delay" ),
|
||||
TransitionDuration = String::hash( "transition-duration" ),
|
||||
|
||||
@@ -26,11 +26,6 @@ class UIFontStyleConfig : public FontStyleConfig {
|
||||
UIFontStyleConfig( const FontStyleConfig& fontStyleConfig ) :
|
||||
FontStyleConfig( fontStyleConfig ) {}
|
||||
|
||||
// UIFontStyleConfig( const UIFontStyleConfig& fontStyleConfig ) :
|
||||
// FontStyleConfig( fontStyleConfig ),
|
||||
// FontSelectedColor( fontStyleConfig.FontSelectedColor ),
|
||||
// FontSelectionBackColor( fontStyleConfig.FontSelectionBackColor ) {}
|
||||
|
||||
virtual void updateStyleConfig( const UIFontStyleConfig& fontStyleConfig ) {
|
||||
FontStyleConfig::updateFontStyleConfig( fontStyleConfig );
|
||||
FontSelectedColor = fontStyleConfig.FontSelectedColor;
|
||||
|
||||
@@ -132,6 +132,11 @@ static const Uint32 UI_NODE_DEFAULT_FLAGS =
|
||||
static const Uint32 UI_NODE_DEFAULT_FLAGS_CENTERED =
|
||||
UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_HALIGN_CENTER | UI_VALIGN_CENTER;
|
||||
|
||||
enum class HintDisplay {
|
||||
Always,
|
||||
Focus
|
||||
};
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
#endif
|
||||
|
||||
@@ -115,6 +115,10 @@ class EE_API UITextInput : public UITextView, public TextDocument::Client {
|
||||
|
||||
void setEscapePastedText( bool escapePastedText );
|
||||
|
||||
void setHintDisplay( HintDisplay );
|
||||
|
||||
HintDisplay getHintDisplay() const;
|
||||
|
||||
protected:
|
||||
TextDocument mDoc;
|
||||
Float mWaitCursorTime;
|
||||
@@ -136,6 +140,7 @@ class EE_API UITextInput : public UITextView, public TextDocument::Client {
|
||||
size_t mMenuIconSize{ 16 };
|
||||
UIPopUpMenu* mCurrentMenu{ nullptr };
|
||||
Uint64 mLastExecuteEventId{ 0 };
|
||||
HintDisplay mHintDisplay{ HintDisplay::Always };
|
||||
|
||||
void resetWaitCursor();
|
||||
|
||||
|
||||
@@ -323,6 +323,7 @@ void StyleSheetSpecification::registerDefaultProperties() {
|
||||
.addAlias( "hintoutlinethickness" );
|
||||
registerProperty( "hint-stroke-color", "" ).setType( PropertyType::Color );
|
||||
registerProperty( "hint-font-family", "" ).addAlias( "hint-font-name" );
|
||||
registerProperty( "hint-display", "" ).setType( PropertyType::String );
|
||||
|
||||
registerProperty( "transition", "" ).setIndexed();
|
||||
registerProperty( "transition-duration", "" );
|
||||
|
||||
@@ -171,6 +171,7 @@ bool UIComboBox::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
case PropertyId::HintFontStyle:
|
||||
case PropertyId::HintStrokeWidth:
|
||||
case PropertyId::HintStrokeColor:
|
||||
case PropertyId::HintDisplay:
|
||||
case PropertyId::PopUpToRoot:
|
||||
case PropertyId::MaxVisibleItems:
|
||||
case PropertyId::SelectedIndex:
|
||||
@@ -220,6 +221,7 @@ std::string UIComboBox::getPropertyString( const PropertyDefinition* propertyDef
|
||||
case PropertyId::HintFontStyle:
|
||||
case PropertyId::HintStrokeWidth:
|
||||
case PropertyId::HintStrokeColor:
|
||||
case PropertyId::HintDisplay:
|
||||
case PropertyId::PopUpToRoot:
|
||||
case PropertyId::MaxVisibleItems:
|
||||
case PropertyId::SelectedIndex:
|
||||
@@ -264,6 +266,7 @@ std::vector<PropertyId> UIComboBox::getPropertiesImplemented() const {
|
||||
PropertyId::HintFontStyle,
|
||||
PropertyId::HintStrokeWidth,
|
||||
PropertyId::HintStrokeColor,
|
||||
PropertyId::HintDisplay,
|
||||
PropertyId::PopUpToRoot,
|
||||
PropertyId::MaxVisibleItems,
|
||||
PropertyId::SelectedIndex,
|
||||
|
||||
@@ -306,6 +306,7 @@ std::string UISpinBox::getPropertyString( const PropertyDefinition* propertyDef,
|
||||
case PropertyId::HintFontStyle:
|
||||
case PropertyId::HintStrokeWidth:
|
||||
case PropertyId::HintStrokeColor:
|
||||
case PropertyId::HintDisplay:
|
||||
case PropertyId::Color:
|
||||
case PropertyId::TextShadowColor:
|
||||
case PropertyId::TextShadowOffset:
|
||||
@@ -343,6 +344,7 @@ std::vector<PropertyId> UISpinBox::getPropertiesImplemented() const {
|
||||
PropertyId::HintFontStyle,
|
||||
PropertyId::HintStrokeWidth,
|
||||
PropertyId::HintStrokeColor,
|
||||
PropertyId::HintDisplay,
|
||||
PropertyId::Color,
|
||||
PropertyId::TextShadowColor,
|
||||
PropertyId::TextShadowOffset,
|
||||
@@ -394,6 +396,7 @@ bool UISpinBox::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
case PropertyId::HintFontStyle:
|
||||
case PropertyId::HintStrokeWidth:
|
||||
case PropertyId::HintStrokeColor:
|
||||
case PropertyId::HintDisplay:
|
||||
case PropertyId::Color:
|
||||
case PropertyId::TextShadowColor:
|
||||
case PropertyId::TextShadowOffset:
|
||||
|
||||
@@ -139,7 +139,8 @@ void UITextInput::draw() {
|
||||
mFontLineCenter + (Float)mScreenPosi.y + (int)mRealAlignOffset.y +
|
||||
(int)mPaddingPx.Top,
|
||||
Vector2f::One, 0.f, getBlendMode() );
|
||||
} else if ( !mHintCache->getString().empty() ) {
|
||||
} else if ( !mHintCache->getString().empty() &&
|
||||
( mHintDisplay == HintDisplay::Always || hasFocus() ) ) {
|
||||
mHintCache->draw( (Float)mScreenPosi.x + (int)mRealAlignOffset.x + (int)mPaddingPx.Left,
|
||||
mFontLineCenter + (Float)mScreenPosi.y + (int)mRealAlignOffset.y +
|
||||
(int)mPaddingPx.Top,
|
||||
@@ -480,6 +481,8 @@ std::string UITextInput::getPropertyString( const PropertyDefinition* propertyDe
|
||||
return String::fromFloat( PixelDensity::dpToPx( getHintOutlineThickness() ), "px" );
|
||||
case PropertyId::HintStrokeColor:
|
||||
return getHintOutlineColor().toHexString();
|
||||
case PropertyId::HintDisplay:
|
||||
return mHintDisplay == HintDisplay::Always ? "always" : "focus";
|
||||
default:
|
||||
return UITextView::getPropertyString( propertyDef, propertyIndex );
|
||||
}
|
||||
@@ -500,7 +503,8 @@ std::vector<PropertyId> UITextInput::getPropertiesImplemented() const {
|
||||
PropertyId::HintFontFamily,
|
||||
PropertyId::HintFontStyle,
|
||||
PropertyId::HintStrokeWidth,
|
||||
PropertyId::HintStrokeColor };
|
||||
PropertyId::HintStrokeColor,
|
||||
PropertyId::HintDisplay };
|
||||
props.insert( props.end(), local.begin(), local.end() );
|
||||
return props;
|
||||
}
|
||||
@@ -552,6 +556,11 @@ bool UITextInput::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
case PropertyId::HintStrokeColor:
|
||||
setHintOutlineColor( attribute.asColor() );
|
||||
break;
|
||||
case PropertyId::HintDisplay:
|
||||
setHintDisplay( String::toLower( attribute.asString() ) == "focus"
|
||||
? HintDisplay::Focus
|
||||
: HintDisplay::Always );
|
||||
break;
|
||||
default:
|
||||
return UITextView::applyProperty( attribute );
|
||||
}
|
||||
@@ -943,4 +952,12 @@ bool UITextInput::onCreateContextMenu( const Vector2i& position, const Uint32& f
|
||||
return true;
|
||||
}
|
||||
|
||||
void UITextInput::setHintDisplay( HintDisplay display ) {
|
||||
mHintDisplay = display;
|
||||
}
|
||||
|
||||
HintDisplay UITextInput::getHintDisplay() const {
|
||||
return mHintDisplay;
|
||||
}
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -2735,7 +2735,9 @@ void App::removeFolderWatches() {
|
||||
void App::loadDirTree( const std::string& path ) {
|
||||
Clock* clock = eeNew( Clock, () );
|
||||
mDirTreeReady = false;
|
||||
mDirTree = std::make_shared<ProjectDirectoryTree>( path, mThreadPool, this );
|
||||
mDirTree = std::make_shared<ProjectDirectoryTree>(
|
||||
path, mThreadPool, mPluginManager.get(),
|
||||
[this]( auto path ) { loadFileFromPathOrFocus( path ); } );
|
||||
Log::info( "Loading DirTree: %s", path );
|
||||
mDirTree->scan(
|
||||
[this, clock]( ProjectDirectoryTree& dirTree ) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "projectdirectorytree.hpp"
|
||||
#include "ecode.hpp"
|
||||
#include <algorithm>
|
||||
#include <eepp/system/filesystem.hpp>
|
||||
#include <limits>
|
||||
@@ -8,8 +7,9 @@ namespace ecode {
|
||||
|
||||
#define PRJ_ALLOWED_PATH ".ecode/.prjallowed"
|
||||
|
||||
ProjectDirectoryTree::ProjectDirectoryTree( const std::string& path,
|
||||
std::shared_ptr<ThreadPool> threadPool, App* app ) :
|
||||
ProjectDirectoryTree::ProjectDirectoryTree(
|
||||
const std::string& path, std::shared_ptr<ThreadPool> threadPool, PluginManager* pluginManager,
|
||||
std::function<void( const std::string& )> loadFileFromPathOrFocusFn ) :
|
||||
mPath( path ),
|
||||
mPool( threadPool ),
|
||||
mRunning( false ),
|
||||
@@ -17,14 +17,15 @@ ProjectDirectoryTree::ProjectDirectoryTree( const std::string& path,
|
||||
mIgnoreHidden( true ),
|
||||
mClosing( false ),
|
||||
mIgnoreMatcher( path ),
|
||||
mApp( app ) {
|
||||
mPluginManager( pluginManager ),
|
||||
mLoadFileFromPathOrFocusFn( std::move( loadFileFromPathOrFocusFn ) ) {
|
||||
FileSystem::dirAddSlashAtEnd( mPath );
|
||||
}
|
||||
|
||||
ProjectDirectoryTree::~ProjectDirectoryTree() {
|
||||
mClosing = true;
|
||||
if ( mApp->getPluginManager() )
|
||||
mApp->getPluginManager()->unsubscribeMessages( "ProjectDirectoryTree" );
|
||||
if ( mPluginManager )
|
||||
mPluginManager->unsubscribeMessages( "ProjectDirectoryTree" );
|
||||
Lock rl( mMatchingMutex );
|
||||
if ( mRunning ) {
|
||||
mRunning = false;
|
||||
@@ -79,10 +80,13 @@ void ProjectDirectoryTree::scan( const ProjectDirectoryTree::ScanCompleteEvent&
|
||||
mAllowedMatcher.get() );
|
||||
}
|
||||
mIsReady = true;
|
||||
mApp->getPluginManager()->subscribeMessages(
|
||||
"ProjectDirectoryTree", [this]( const PluginMessage& msg ) -> PluginRequestHandle {
|
||||
return processMessage( msg );
|
||||
} );
|
||||
if ( mPluginManager ) {
|
||||
mPluginManager->subscribeMessages(
|
||||
"ProjectDirectoryTree",
|
||||
[this]( const PluginMessage& msg ) -> PluginRequestHandle {
|
||||
return processMessage( msg );
|
||||
} );
|
||||
}
|
||||
#if EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN && !defined( __EMSCRIPTEN_PTHREADS__ )
|
||||
if ( scanComplete )
|
||||
scanComplete( *this );
|
||||
@@ -530,9 +534,11 @@ PluginRequestHandle ProjectDirectoryTree::processMessage( const PluginMessage& m
|
||||
}
|
||||
|
||||
if ( !matchesMap.empty() ) {
|
||||
std::string filePath( matchesMap.begin()->second );
|
||||
mApp->getUISceneNode()->runOnMainThread(
|
||||
[this, filePath]() { mApp->loadFileFromPathOrFocus( filePath ); } );
|
||||
if ( mPluginManager && mLoadFileFromPathOrFocusFn ) {
|
||||
std::string filePath( matchesMap.begin()->second );
|
||||
mPluginManager->getUISceneNode()->runOnMainThread(
|
||||
[this, filePath]() { mLoadFileFromPathOrFocusFn( filePath ); } );
|
||||
}
|
||||
}
|
||||
|
||||
return PluginRequestHandle::broadcast();
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <eepp/ui/uiiconthememanager.hpp>
|
||||
#include <eepp/ui/uiscenenode.hpp>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
@@ -23,8 +22,6 @@ using namespace EE::UI::Models;
|
||||
|
||||
namespace ecode {
|
||||
|
||||
class App;
|
||||
|
||||
class FileListModel : public Model {
|
||||
public:
|
||||
FileListModel( const std::vector<std::string>& files, const std::vector<std::string>& names ) :
|
||||
@@ -97,8 +94,10 @@ class ProjectDirectoryTree {
|
||||
typedef std::function<void( ProjectDirectoryTree& dirTree )> ScanCompleteEvent;
|
||||
typedef std::function<void( std::shared_ptr<FileListModel> )> MatchResultCb;
|
||||
|
||||
ProjectDirectoryTree( const std::string& path, std::shared_ptr<ThreadPool> threadPool,
|
||||
App* app );
|
||||
ProjectDirectoryTree(
|
||||
const std::string& path, std::shared_ptr<ThreadPool> threadPool,
|
||||
PluginManager* pluginManager = nullptr,
|
||||
std::function<void( const std::string& )> loadFileFromPathOrFocusFn = {} );
|
||||
|
||||
~ProjectDirectoryTree();
|
||||
|
||||
@@ -161,7 +160,8 @@ class ProjectDirectoryTree {
|
||||
mutable Mutex mMatchingMutex;
|
||||
Mutex mDoneMutex;
|
||||
IgnoreMatcherManager mIgnoreMatcher;
|
||||
App* mApp{ nullptr };
|
||||
PluginManager* mPluginManager{ nullptr };
|
||||
std::function<void( const std::string& )> mLoadFileFromPathOrFocusFn;
|
||||
|
||||
void getDirectoryFiles( std::vector<std::string>& files, std::vector<std::string>& names,
|
||||
std::string directory, std::set<std::string> currentDirs,
|
||||
|
||||
Reference in New Issue
Block a user