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

Method registerBaseParsers

src/eepp/ui/css/drawableimageparser.cpp:61–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void DrawableImageParser::registerBaseParsers() {
62 mFuncs["linear-gradient"] = []( const FunctionString& functionType, const Sizef& /*size*/,
63 bool& ownIt, UINode* node ) -> Drawable* {
64 if ( functionType.getParameters().size() < 2 ) {
65 return NULL;
66 }
67
68 RectangleDrawable* drawable = RectangleDrawable::New();
69 RectColors rectColors;
70 const auto& params( functionType.getParameters() );
71
72 if ( Color::isColorString( params.at( 0 ) ) && params.size() >= 2 ) {
73 rectColors.TopLeft = rectColors.TopRight = Color::fromString( params.at( 0 ) );
74 rectColors.BottomLeft = rectColors.BottomRight = Color::fromString( params.at( 1 ) );
75 } else if ( params.size() >= 3 ) {
76 std::string direction = params.at( 0 );
77 String::toLowerInPlace( direction );
78
79 if ( direction == "to bottom" ) {
80 rectColors.TopLeft = rectColors.TopRight = Color::fromString( params.at( 1 ) );
81 rectColors.BottomLeft = rectColors.BottomRight =
82 Color::fromString( params.at( 2 ) );
83 } else if ( direction == "to left" ) {
84 rectColors.TopLeft = rectColors.BottomLeft = Color::fromString( params.at( 2 ) );
85 rectColors.TopRight = rectColors.BottomRight = Color::fromString( params.at( 1 ) );
86 } else if ( direction == "to right" ) {
87 rectColors.TopLeft = rectColors.BottomLeft = Color::fromString( params.at( 1 ) );
88 rectColors.TopRight = rectColors.BottomRight = Color::fromString( params.at( 2 ) );
89 } else if ( direction == "to top" ) {
90 rectColors.TopLeft = rectColors.TopRight = Color::fromString( params.at( 2 ) );
91 rectColors.BottomLeft = rectColors.BottomRight =
92 Color::fromString( params.at( 1 ) );
93 } else {
94 rectColors.TopLeft = rectColors.TopRight = Color::fromString( params.at( 1 ) );
95 rectColors.BottomLeft = rectColors.BottomRight =
96 Color::fromString( params.at( 2 ) );
97 }
98 } else {
99 node->setBackgroundColor( Color::fromString( params.at( 0 ) ) );
100 return NULL;
101 }
102
103 drawable->setRectColors( rectColors );
104 ownIt = true;
105 return drawable;
106 };
107
108 mFuncs["circle"] = []( const FunctionString& functionType, const Sizef& size, bool& ownIt,
109 UINode* node ) -> Drawable* {
110 if ( functionType.getParameters().size() < 1 ) {
111 return NULL;
112 }
113
114 CircleDrawable* drawable = CircleDrawable::New();
115
116 const auto& params( functionType.getParameters() );
117
118 CSS::StyleSheetLength length( params[0] );

Callers 1

SyntaxDefinitionMethod · 0.45

Calls 15

fromStringFunction · 0.85
atMethod · 0.80
setRectColorsMethod · 0.80
convertLengthMethod · 0.80
push_backMethod · 0.80
setCornersMethod · 0.80
parameterWasStringMethod · 0.80
setTriangleColorsMethod · 0.80
setTriangleMethod · 0.80
addPointMethod · 0.80
solveRelativePathMethod · 0.80
findIconDrawableMethod · 0.80

Tested by

no test coverage detected