diff --git a/bin/assets/fonts/nonicons.ttf b/bin/assets/fonts/nonicons.ttf new file mode 100644 index 000000000..c14aa53e9 Binary files /dev/null and b/bin/assets/fonts/nonicons.ttf differ diff --git a/bin/assets/ui/breeze.css b/bin/assets/ui/breeze.css index d67c8d206..5eab97eab 100644 --- a/bin/assets/ui/breeze.css +++ b/bin/assets/ui/breeze.css @@ -240,6 +240,7 @@ ListView::row { ListView::cell { padding-left: 4dp; + min-icon-size: 16dp 16dp; } ListBox:hover, @@ -527,6 +528,11 @@ Tab:selectedhover { background-color: var(--tab-active); } +tab::icon { + margin-left: 2dp; + margin-right: 2dp; +} + Tab::close { width: 10dp; height: 10dp; @@ -860,6 +866,11 @@ tableview::cell, treeview::cell { padding-left: 6dp; padding-right: 6dp; + min-icon-size: 16dp 16dp; +} + +treeview::cell::expander { + min-size: 16dp 16dp; } TreeView, diff --git a/docs/articles/cssspecification.md b/docs/articles/cssspecification.md index b2915b7fc..d3d626ea5 100644 --- a/docs/articles/cssspecification.md +++ b/docs/articles/cssspecification.md @@ -2076,6 +2076,18 @@ Read [margin](https://developer.mozilla.org/en-US/docs/Web/CSS/margin) documenta --- +### min-size + +Shorthand for [min-width](#min-width) and [min-height](#min-height) + +--- + +### min-size + +Shorthand for [max-width](#max-width) and [max-height](#max-height) + +--- + ### padding Read [padding](https://developer.mozilla.org/en-US/docs/Web/CSS/padding) documentation. diff --git a/include/eepp/ui/css/propertydefinition.hpp b/include/eepp/ui/css/propertydefinition.hpp index 3adf4a7d0..86c6cab33 100644 --- a/include/eepp/ui/css/propertydefinition.hpp +++ b/include/eepp/ui/css/propertydefinition.hpp @@ -76,6 +76,8 @@ enum class PropertyId : Uint32 { TextAlign = String::hash( "text-align" ), Icon = String::hash( "icon" ), MinIconSize = String::hash( "min-icon-size" ), + MinSize = String::hash( "min-size" ), + MaxSize = String::hash( "max-size" ), Src = String::hash( "src" ), ScaleType = String::hash( "scale-type" ), Tint = String::hash( "tint" ), diff --git a/include/eepp/ui/css/shorthanddefinition.hpp b/include/eepp/ui/css/shorthanddefinition.hpp index 2246b02ea..4a283d587 100644 --- a/include/eepp/ui/css/shorthanddefinition.hpp +++ b/include/eepp/ui/css/shorthanddefinition.hpp @@ -22,7 +22,9 @@ enum class ShorthandId : Uint32 { ScaleOriginPoint = String::hash( "scale-origin-point" ), BorderColor = String::hash( "border-color" ), BorderWidth = String::hash( "border-width" ), - BorderRadius = String::hash( "border-radius" ) + BorderRadius = String::hash( "border-radius" ), + MinSize = String::hash( "min-size" ), + MaxSize = String::hash( "max-size" ) }; typedef std::function( const ShorthandDefinition* shorthand, diff --git a/include/eepp/ui/uiiconthememanager.hpp b/include/eepp/ui/uiiconthememanager.hpp index 9019249ca..904facb7b 100644 --- a/include/eepp/ui/uiiconthememanager.hpp +++ b/include/eepp/ui/uiiconthememanager.hpp @@ -10,6 +10,8 @@ class UIThemeManager; class EE_API UIIconThemeManager { public: + static std::string getIconNameFromFileName( const std::string& fileName ); + static UIIconThemeManager* New(); ~UIIconThemeManager(); diff --git a/src/eepp/ui/css/stylesheetspecification.cpp b/src/eepp/ui/css/stylesheetspecification.cpp index 6b2e7edfa..56cbc3501 100644 --- a/src/eepp/ui/css/stylesheetspecification.cpp +++ b/src/eepp/ui/css/stylesheetspecification.cpp @@ -370,43 +370,45 @@ void StyleSheetSpecification::registerDefaultProperties() { registerProperty( "splitter-always-show", "true" ).setType( PropertyType::Bool ); // Shorthands - registerShorthand( "margin", {"margin-top", "margin-right", "margin-bottom", "margin-left"}, + registerShorthand( "margin", { "margin-top", "margin-right", "margin-bottom", "margin-left" }, "box" ); registerShorthand( "layout-margin", - {"margin-top", "margin-right", "margin-bottom", "margin-left"}, "box" ); + { "margin-top", "margin-right", "margin-bottom", "margin-left" }, "box" ); registerShorthand( "layout_margin", - {"margin-top", "margin-right", "margin-bottom", "margin-left"}, "box" ); - registerShorthand( "padding", - {"padding-top", "padding-right", "padding-bottom", "padding-left"}, "box" ); + { "margin-top", "margin-right", "margin-bottom", "margin-left" }, "box" ); + registerShorthand( + "padding", { "padding-top", "padding-right", "padding-bottom", "padding-left" }, "box" ); registerShorthand( "background", - {"background-color", "background-image", "background-repeat", "background-position"}, + { "background-color", "background-image", "background-repeat", "background-position" }, "background" ); registerShorthand( "foreground", - {"foreground-color", "foreground-image", "foreground-repeat", "foreground-position"}, + { "foreground-color", "foreground-image", "foreground-repeat", "foreground-position" }, "background" ); - registerShorthand( "box-margin", {"column-margin", "row-margin"}, "single-value-vector" ); - registerShorthand( "background-position", {"background-position-x", "background-position-y"}, + registerShorthand( "box-margin", { "column-margin", "row-margin" }, "single-value-vector" ); + registerShorthand( "background-position", { "background-position-x", "background-position-y" }, "background-position" ); - registerShorthand( "foreground-position", {"foreground-position-x", "foreground-position-y"}, + registerShorthand( "foreground-position", { "foreground-position-x", "foreground-position-y" }, "background-position" ); registerShorthand( "border-color", - {"border-top-color", "border-right-color", "border-bottom-color", "border-left-color"}, + { "border-top-color", "border-right-color", "border-bottom-color", "border-left-color" }, "border-box" ); registerShorthand( "border-width", - {"border-top-width", "border-right-width", "border-bottom-width", "border-left-width"}, + { "border-top-width", "border-right-width", "border-bottom-width", "border-left-width" }, "border-box" ); registerShorthand( "border-radius", - {"border-top-left-radius", "border-top-right-radius", - "border-bottom-right-radius", "border-bottom-left-radius"}, + { "border-top-left-radius", "border-top-right-radius", + "border-bottom-right-radius", "border-bottom-left-radius" }, "radius" ); registerShorthand( "rotation-origin-point", - {"rotation-origin-point-x", "rotation-origin-point-y"}, "vector2" ); - registerShorthand( "scale-origin-point", {"scale-origin-point-x", "scale-origin-point-y"}, + { "rotation-origin-point-x", "rotation-origin-point-y" }, "vector2" ); + registerShorthand( "scale-origin-point", { "scale-origin-point-x", "scale-origin-point-y" }, "vector2" ); + registerShorthand( "min-size", { "min-width", "min-height" }, "vector2" ); + registerShorthand( "max-size", { "max-width", "max-height" }, "vector2" ); } void StyleSheetSpecification::registerNodeSelector( const std::string& name, diff --git a/src/eepp/ui/doc/syntaxdefinitionmanager.cpp b/src/eepp/ui/doc/syntaxdefinitionmanager.cpp index f9422dc45..c4a751801 100644 --- a/src/eepp/ui/doc/syntaxdefinitionmanager.cpp +++ b/src/eepp/ui/doc/syntaxdefinitionmanager.cpp @@ -266,14 +266,17 @@ SyntaxDefinitionManager::SyntaxDefinitionManager() { add( { "JSON", { "%.json$", "%.cson$" }, { + { { "(\".-\")(:)" }, { "normal", "keyword", "operator" } }, { { "\"", "\"", "\\" }, "string" }, { { "'", "'", "\\" }, "string" }, { { "`", "`", "\\" }, "string" }, { { "0x[%da-fA-F]+" }, "number" }, { { "-?%d+[%d%.eE]*" }, "number" }, { { "-?%.?%d+" }, "number" }, + { { "[%[%]%{%}]" }, "operator" }, + { { "[%a_][%w_]*" }, "symbol" }, }, - {}, + { { "true", "literal" }, { "false", "literal" } }, "//" } ); // TypeScript @@ -1032,7 +1035,7 @@ SyntaxDefinitionManager::SyntaxDefinitionManager() { { { "[a-z]+" }, "symbol" } }, { { "true", "literal" }, { "false", "literal" } }, "#", - { "^%[.-%]" } } ); + { "^%[.-%]%f[^\n]" } } ); // Makefile add( { "Makefile", diff --git a/src/eepp/ui/models/filesystemmodel.cpp b/src/eepp/ui/models/filesystemmodel.cpp index 6fad20d14..dcf83e755 100644 --- a/src/eepp/ui/models/filesystemmodel.cpp +++ b/src/eepp/ui/models/filesystemmodel.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #ifndef INDEX_ALREADY_EXISTS @@ -26,7 +27,7 @@ FileSystemModel::Node::Node( FileInfo&& info, FileSystemModel::Node* parent ) : mInfoDirty = false; mName = FileSystem::fileNameFromPath( mInfo.getFilepath() ); if ( !mInfo.isDirectory() ) { - mMimeType = "filetype-" + FileSystem::fileExtension( mName ); + mMimeType = UIIconThemeManager::getIconNameFromFileName( mName ); } else { mMimeType = "folder"; } diff --git a/src/eepp/ui/uiiconthememanager.cpp b/src/eepp/ui/uiiconthememanager.cpp index 54169839d..db9391e1d 100644 --- a/src/eepp/ui/uiiconthememanager.cpp +++ b/src/eepp/ui/uiiconthememanager.cpp @@ -1,9 +1,19 @@ #include +#include #include #include namespace EE { namespace UI { +std::string UIIconThemeManager::getIconNameFromFileName( const std::string& fileName ) { + std::string ext( FileSystem::fileExtension( fileName ) ); + if ( !ext.empty() ) { + return "filetype-" + ext; + } else { + return "filetype-" + String::toLower( fileName ); + } +} + UIIconThemeManager* UIIconThemeManager::New() { return eeNew( UIIconThemeManager, () ); } diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index c01710b25..15708e664 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -2037,6 +2037,24 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) { updateEditorTabTitle( editor ); } ); + auto docChanged = [&]( const Event* event ) { + const DocEvent* synEvent = static_cast( event ); + UICodeEditor* editor = event->getNode()->asType(); + UIIcon* icon = mUISceneNode->findIcon( + UIIconThemeManager::getIconNameFromFileName( synEvent->getDoc()->getFilename() ) ); + if ( !icon ) + icon = mUISceneNode->findIcon( "file" ); + if ( !icon ) + return; + if ( editor->getData() ) { + UITab* tab = (UITab*)editor->getData(); + tab->setIcon( icon->getSize( mMenuIconSize ) ); + } + }; + + editor->addEventListener( Event::OnDocumentLoaded, docChanged ); + editor->addEventListener( Event::OnDocumentChanged, docChanged ); + editor->showMinimap( config.minimap ); if ( config.autoComplete && !mAutoCompletePlugin ) @@ -2800,6 +2818,9 @@ void App::init( std::string file, const Float& pidelDensity, const std::string& return; } + FontTrueType* mimeIconFont = + FontTrueType::New( "nonicons", mResPath + "fonts/nonicons.ttf" ); + SceneManager::instance()->add( mUISceneNode ); UITheme* theme = @@ -3011,7 +3032,7 @@ void App::init( std::string file, const Float& pidelDensity, const std::string& )html"; - UIIconTheme* iconTheme = UIIconTheme::New( "remixicon" ); + UIIconTheme* iconTheme = UIIconTheme::New( "ecode" ); mMenuIconSize = mConfig.ui.fontSize.asPixels( 0, Sizef(), mDisplayDPI ); std::unordered_map icons = { { "document-new", 0xecc3 }, @@ -3029,10 +3050,10 @@ void App::init( std::string file, const Float& pidelDensity, const std::string& { "split-horizontal", 0xf17a }, { "split-vertical", 0xf17b }, { "find-replace", 0xed2b }, - { "folder", 0xed54 }, - { "folder-open", 0xed70 }, + // { "folder", 0xed54 }, + // { "folder-open", 0xed70 }, { "folder-add", 0xed5a }, - { "file", 0xecc3 }, + // { "file", 0xecc3 }, { "file-add", 0xecc9 }, { "file-copy", 0xecd3 }, { "file-code", 0xecd1 }, @@ -3068,6 +3089,71 @@ void App::init( std::string file, const Float& pidelDensity, const std::string& for ( const auto& icon : icons ) iconTheme->add( UIGlyphIcon::New( icon.first, iconFont, icon.second ) ); + if ( mimeIconFont && mimeIconFont->loaded() ) { + std::unordered_map mimeIcons = { + { "filetype-lua", 61826 }, + { "filetype-c", 61718 }, + { "filetype-h", 61792 }, + { "filetype-cs", 61720 }, + { "filetype-cpp", 61719 }, + { "filetype-css", 61743 }, + { "filetype-conf", 61781 }, + { "filetype-cfg", 61781 }, + { "filetype-desktop", 61781 }, + { "filetype-service", 61781 }, + { "filetype-env", 61781 }, + { "filetype-properties", 61781 }, + { "filetype-ini", 61781 }, + { "filetype-dart", 61744 }, + { "filetype-diff", 61752 }, + { "filetype-zip", 61775 }, + { "filetype-go", 61789 }, + { "filetype-htm", 61799 }, + { "filetype-html", 61799 }, + { "filetype-java", 61809 }, + { "filetype-js", 61810 }, + { "filetype-json", 61811 }, + { "filetype-kt", 61814 }, + { "filetype-md", 61829 }, + { "filetype-perl", 61853 }, + { "filetype-php", 61855 }, + { "filetype-py", 61863 }, + { "filetype-pyc", 61863 }, + { "filetype-pyd", 61863 }, + { "filetype-swift", 61906 }, + { "filetype-rb", 61880 }, + { "filetype-rs", 61881 }, + { "filetype-ts", 61923 }, + { "filetype-yaml", 61945 }, + { "filetype-yml", 61945 }, + { "filetype-jpg", 61801 }, + { "filetype-png", 61801 }, + { "filetype-jpeg", 61801 }, + { "filetype-bmp", 61801 }, + { "filetype-tga", 61801 }, + { "filetype-sh", 61911 }, + { "filetype-bash", 61911 }, + { "filetype-fish", 61911 }, + { "filetype-scala", 61882 }, + { "filetype-r", 61866 }, + { "filetype-rake", 61880 }, + { "filetype-rss", 61879 }, + { "filetype-sql", 61746 }, + { "filetype-elm", 61763 }, + { "filetype-ex", 61971 }, + { "filetype-exs", 61971 }, + { "filetype-awk", 61971 }, + { "filetype-nim", 61734 }, + { "filetype-xml", 61769 }, + { "filetype-dockerfile", 61758 }, + { "file", 61766 }, + { "folder", 0xF23B }, + { "folder-open", 0xF23C }, + }; + for ( const auto& icon : mimeIcons ) + iconTheme->add( UIGlyphIcon::New( icon.first, mimeIconFont, icon.second ) ); + } + mUISceneNode->getUIIconThemeManager()->setCurrentTheme( iconTheme ); UIWidgetCreator::registerWidget( "searchbar", UISearchBar::New );