MCPcopy Create free account
hub / github.com/SpartanJ/eepp / applyProperty

Method applyProperty

src/eepp/ui/uiwidget.cpp:1815–2260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1813}
1814
1815bool UIWidget::applyProperty( const StyleSheetProperty& attribute ) {
1816 if ( !checkPropertyDefinition( attribute ) )
1817 return false;
1818 bool attributeSet = true;
1819
1820 switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
1821 case PropertyId::Id:
1822 setId( attribute.value() );
1823 break;
1824 case PropertyId::Class:
1825 addClasses( String::split( attribute.getValue(), ' ' ) );
1826 break;
1827 case PropertyId::X:
1828 setLayoutWidthPolicy( SizePolicy::Fixed );
1829 setInternalPosition(
1830 Vector2f( eefloor( lengthFromValueAsDp( attribute ) ), mDpPos.y ) );
1831 notifyLayoutAttrChange();
1832 break;
1833 case PropertyId::Y:
1834 setLayoutWidthPolicy( SizePolicy::Fixed );
1835 setInternalPosition(
1836 Vector2f( mDpPos.x, eefloor( lengthFromValueAsDp( attribute ) ) ) );
1837 notifyLayoutAttrChange();
1838 break;
1839 case PropertyId::Width:
1840 if ( mStyle ) {
1841 mStyle->setStyleSheetProperty(
1842 StyleSheetProperty( "layout-width", attribute.value(), true,
1843 StyleSheetSelectorRule::SpecificityImportant ) );
1844 }
1845 setLayoutWidthPolicy( SizePolicy::Fixed );
1846 setSize( eefloor( lengthFromValueAsDp( attribute ) ), getSize().getHeight() );
1847 notifyLayoutAttrChange();
1848 break;
1849 case PropertyId::Height:
1850 if ( mStyle ) {
1851 mStyle->setStyleSheetProperty(
1852 StyleSheetProperty( "layout-height", attribute.value(), true,
1853 StyleSheetSelectorRule::SpecificityImportant ) );
1854 }
1855 setLayoutHeightPolicy( SizePolicy::Fixed );
1856 setSize( getSize().getWidth(), eefloor( lengthFromValueAsDp( attribute ) ) );
1857 notifyLayoutAttrChange();
1858 break;
1859 case PropertyId::BackgroundColor:
1860 setBackgroundColor( attribute.asColor() );
1861 break;
1862 case PropertyId::BackgroundTint:
1863 setBackgroundTint( attribute.asColor(), attribute.getIndex() );
1864 break;
1865 case PropertyId::BackgroundImage:
1866 setBackgroundDrawable( attribute.getValue(), attribute.getIndex() );
1867 break;
1868 case PropertyId::BackgroundRepeat:
1869 setBackgroundRepeat( attribute.value(), attribute.getIndex() );
1870 break;
1871 case PropertyId::BackgroundSize:
1872 setBackgroundSize( attribute.value(), attribute.getIndex() );

Callers 1

Calls 15

setIdFunction · 0.85
setSizeFunction · 0.85
getParentFunction · 0.85
fromStringFunction · 0.85
setBlendModeFunction · 0.85
eeminFunction · 0.85
getPropertyIdMethod · 0.80
setStyleSheetPropertyMethod · 0.80
asColorMethod · 0.80
getIndexMethod · 0.80
setBorderTypeMethod · 0.80
asBoolMethod · 0.80

Tested by

no test coverage detected