mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Fix auto-size for HTML images.
Added visibility property support. Fix display: none. Added figure and figcaption HTML tags.
This commit is contained in:
@@ -35,6 +35,7 @@ enum class PropertyId : Uint32 {
|
||||
ForegroundBottomLeftRadius = String::hash( "foreground-bottom-left-radius" ),
|
||||
ForegroundBottomRightRadius = String::hash( "foreground-bottom-right-radius" ),
|
||||
Visible = String::hash( "visible" ),
|
||||
Visibility = String::hash( "visibility" ),
|
||||
Enabled = String::hash( "enabled" ),
|
||||
Theme = String::hash( "theme" ),
|
||||
Skin = String::hash( "skin" ),
|
||||
|
||||
@@ -8,17 +8,17 @@ SINGLETON_DECLARE_IMPLEMENTATION( PropertySpecification )
|
||||
|
||||
PropertySpecification::~PropertySpecification() {}
|
||||
|
||||
PropertyDefinition& PropertySpecification::registerProperty( const std::string& propertyVame,
|
||||
PropertyDefinition& PropertySpecification::registerProperty( const std::string& propertyName,
|
||||
const std::string& defaultValue,
|
||||
bool inherited ) {
|
||||
PropertyDefinition* property = const_cast<PropertyDefinition*>( getProperty( propertyVame ) );
|
||||
PropertyDefinition* property = const_cast<PropertyDefinition*>( getProperty( propertyName ) );
|
||||
|
||||
if ( nullptr != property ) {
|
||||
Log::warning( "Property \"%s\" already registered.", propertyVame.c_str() );
|
||||
if ( nullptr != property && !String::startsWith( propertyName, "-" ) ) {
|
||||
Log::warning( "Property \"%s\" already registered.", propertyName.c_str() );
|
||||
return *property;
|
||||
}
|
||||
|
||||
PropertyDefinition* propDef = new PropertyDefinition( propertyVame, defaultValue, inherited );
|
||||
PropertyDefinition* propDef = new PropertyDefinition( propertyName, defaultValue, inherited );
|
||||
|
||||
mProperties[propDef->getId()] = std::shared_ptr<PropertyDefinition>( propDef );
|
||||
|
||||
|
||||
@@ -123,7 +123,8 @@ bool StyleSheetParser::parse( std::string& css, std::vector<std::string>& import
|
||||
mediaParse( css, rs, pos, buffer, importedList );
|
||||
} else if ( String::startsWith( buffer, "@import" ) ) {
|
||||
importParse( css, pos, buffer, importedList );
|
||||
} else if ( String::startsWith( buffer, "@keyframes" ) ) {
|
||||
} else if ( String::startsWith( buffer, "@keyframes" ) ||
|
||||
String::startsWith( buffer, "@-webkit-keyframes" ) ) {
|
||||
keyframesParse( css, rs, pos, buffer );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ StyleSheetProperty::StyleSheetProperty( const PropertyDefinition* definition,
|
||||
createIndexed();
|
||||
checkVars();
|
||||
|
||||
if ( NULL == mShorthandDefinition && NULL == mPropertyDefinition ) {
|
||||
if ( NULL == mShorthandDefinition && NULL == mPropertyDefinition &&
|
||||
!String::startsWith( mName, "-" ) ) {
|
||||
Log::warning( "Property \"%s\" is not defined!", mName );
|
||||
}
|
||||
}
|
||||
@@ -60,7 +61,8 @@ StyleSheetProperty::StyleSheetProperty( bool isVolatile, const PropertyDefinitio
|
||||
checkImportant();
|
||||
checkVars();
|
||||
|
||||
if ( NULL == mShorthandDefinition && NULL == mPropertyDefinition ) {
|
||||
if ( NULL == mShorthandDefinition && NULL == mPropertyDefinition &&
|
||||
!String::startsWith( mName, "-" ) ) {
|
||||
Log::warning( "Property \"%s\" is not defined!", mName );
|
||||
}
|
||||
}
|
||||
@@ -86,7 +88,8 @@ StyleSheetProperty::StyleSheetProperty( const std::string& name, const std::stri
|
||||
createIndexed();
|
||||
checkVars();
|
||||
|
||||
if ( NULL == mShorthandDefinition && NULL == mPropertyDefinition ) {
|
||||
if ( NULL == mShorthandDefinition && NULL == mPropertyDefinition &&
|
||||
!String::startsWith( mName, "-" ) ) {
|
||||
Log::warning( "Property \"%s\" is not defined!", mName );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ void StyleSheetSpecification::registerDefaultProperties() {
|
||||
.setType( PropertyType::ForegroundSize )
|
||||
.setIndexed();
|
||||
registerProperty( "visible", "true" ).setType( PropertyType::Bool );
|
||||
registerProperty( "visibility", "visible" ).setType( PropertyType::String );
|
||||
registerProperty( "enabled", "true" ).setType( PropertyType::Bool );
|
||||
registerProperty( "theme", "" );
|
||||
registerProperty( "skin", "" );
|
||||
|
||||
@@ -22,9 +22,8 @@ UIHTMLWidget::~UIHTMLWidget() {
|
||||
}
|
||||
|
||||
UILayouter* UIHTMLWidget::getLayouter() {
|
||||
if ( !mLayouter ) {
|
||||
if ( nullptr == mLayouter )
|
||||
mLayouter = UILayouterManager::create( mDisplay, this );
|
||||
}
|
||||
return mLayouter;
|
||||
}
|
||||
|
||||
@@ -52,6 +51,8 @@ void UIHTMLWidget::onDisplayChange() {
|
||||
void UIHTMLWidget::setDisplay( CSSDisplay display ) {
|
||||
if ( mDisplay != display ) {
|
||||
mDisplay = display;
|
||||
mNodeFlags |= NODE_FLAG_OVER_FIND_ALLOWED;
|
||||
|
||||
if ( mDisplay == CSSDisplay::InlineBlock || mDisplay == CSSDisplay::Inline ) {
|
||||
if ( getLayoutWidthPolicy() == SizePolicy::MatchParent )
|
||||
setLayoutWidthPolicy( SizePolicy::WrapContent );
|
||||
@@ -59,7 +60,10 @@ void UIHTMLWidget::setDisplay( CSSDisplay display ) {
|
||||
if ( getLayoutWidthPolicy() == SizePolicy::WrapContent &&
|
||||
mPosition != CSSPosition::Absolute && mPosition != CSSPosition::Fixed )
|
||||
setLayoutWidthPolicy( SizePolicy::MatchParent );
|
||||
} else if ( mDisplay == CSSDisplay::None ) {
|
||||
mNodeFlags &= ~NODE_FLAG_OVER_FIND_ALLOWED;
|
||||
}
|
||||
|
||||
onDisplayChange();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,9 @@ void UIImage::onAutoSize() {
|
||||
if ( nullptr == mDrawable )
|
||||
return;
|
||||
|
||||
Sizef drawableSize = mDrawable->getPixelsSize();
|
||||
Sizef drawableSize = mFlags & UI_HTML_ELEMENT
|
||||
? mDrawable->getPixelsSize() * PixelDensity::getPixelDensity()
|
||||
: mDrawable->getPixelsSize();
|
||||
if ( drawableSize.getWidth() <= 0 || drawableSize.getHeight() <= 0 )
|
||||
return;
|
||||
|
||||
|
||||
@@ -2029,6 +2029,9 @@ bool UIWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
case PropertyId::Visible:
|
||||
setVisible( attribute.asBool() );
|
||||
break;
|
||||
case PropertyId::Visibility:
|
||||
setVisible( attribute.value() == "hidden" ? false : true );
|
||||
break;
|
||||
case PropertyId::Enabled:
|
||||
setEnabled( attribute.asBool() );
|
||||
break;
|
||||
|
||||
@@ -195,6 +195,8 @@ void UIWidgetCreator::createBaseWidgetList() {
|
||||
registeredWidget["input"] = [] { return UIHTMLInput::New(); };
|
||||
registeredWidget["header"] = [] { return UIRichText::NewWithTag( "header" ); };
|
||||
registeredWidget["article"] = [] { return UIRichText::NewWithTag( "article" ); };
|
||||
registeredWidget["figure"] = [] { return UIRichText::NewWithTag( "figure" ); };
|
||||
registeredWidget["figcaption"] = [] { return UIRichText::NewWithTag( "figcaption" ); };
|
||||
registeredWidget["footer"] = [] { return UIRichText::NewWithTag( "footer" ); };
|
||||
registeredWidget["main"] = [] { return UIRichText::NewWithTag( "main" ); };
|
||||
registeredWidget["section"] = [] { return UIRichText::NewWithTag( "section" ); };
|
||||
|
||||
Reference in New Issue
Block a user