Added shorthand: min-size and max-size.

SyntaxDefinitionManager: Improved JSON.
breeze theme improvements.
ecode: Added mime-type icons (using nonicons).
This commit is contained in:
Martín Lucas Golini
2022-06-01 01:21:21 -03:00
parent 344ce7ddb0
commit 835dc3a55a
11 changed files with 155 additions and 24 deletions
Binary file not shown.
+11
View File
@@ -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,
+12
View File
@@ -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.
@@ -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" ),
+3 -1
View File
@@ -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<std::vector<StyleSheetProperty>( const ShorthandDefinition* shorthand,
+2
View File
@@ -10,6 +10,8 @@ class UIThemeManager;
class EE_API UIIconThemeManager {
public:
static std::string getIconNameFromFileName( const std::string& fileName );
static UIIconThemeManager* New();
~UIIconThemeManager();
+18 -16
View File
@@ -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,
+5 -2
View File
@@ -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",
+2 -1
View File
@@ -3,6 +3,7 @@
#include <eepp/system/sys.hpp>
#include <eepp/ui/abstract/uiabstractview.hpp>
#include <eepp/ui/models/filesystemmodel.hpp>
#include <eepp/ui/uiiconthememanager.hpp>
#include <eepp/ui/uiscenenode.hpp>
#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";
}
+10
View File
@@ -1,9 +1,19 @@
#include <algorithm>
#include <eepp/system/filesystem.hpp>
#include <eepp/ui/uiiconthememanager.hpp>
#include <eepp/ui/uithememanager.hpp>
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, () );
}
+90 -4
View File
@@ -2037,6 +2037,24 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) {
updateEditorTabTitle( editor );
} );
auto docChanged = [&]( const Event* event ) {
const DocEvent* synEvent = static_cast<const DocEvent*>( event );
UICodeEditor* editor = event->getNode()->asType<UICodeEditor>();
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&
</RelativeLayout>
)html";
UIIconTheme* iconTheme = UIIconTheme::New( "remixicon" );
UIIconTheme* iconTheme = UIIconTheme::New( "ecode" );
mMenuIconSize = mConfig.ui.fontSize.asPixels( 0, Sizef(), mDisplayDPI );
std::unordered_map<std::string, Uint32> 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<std::string, Uint32> 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 );