| 135 | RenderCommandConfig<CustomElementData> |
| 136 | { |
| 137 | pub(crate) fn from_engine_render_command(value: &engine::InternalRenderCommand<CustomElementData>) -> Self { |
| 138 | match value.command_type { |
| 139 | engine::RenderCommandType::None => Self::None(), |
| 140 | engine::RenderCommandType::Rectangle => { |
| 141 | if let engine::InternalRenderData::Rectangle { background_color, corner_radius } = &value.render_data { |
| 142 | Self::Rectangle(Rectangle { |
| 143 | color: *background_color, |
| 144 | corner_radii: (*corner_radius).into(), |
| 145 | }) |
| 146 | } else { |
| 147 | Self::None() |
| 148 | } |
| 149 | } |
| 150 | engine::RenderCommandType::Text => { |
| 151 | if let engine::InternalRenderData::Text { text, text_color, font_size, letter_spacing, line_height, font_asset } = &value.render_data { |
| 152 | Self::Text(Text { |
| 153 | text: text.clone(), |
| 154 | color: *text_color, |
| 155 | font_size: *font_size, |
| 156 | letter_spacing: *letter_spacing, |
| 157 | line_height: *line_height, |
| 158 | font_asset: *font_asset, |
| 159 | }) |
| 160 | } else { |
| 161 | Self::None() |
| 162 | } |
| 163 | } |
| 164 | engine::RenderCommandType::Border => { |
| 165 | if let engine::InternalRenderData::Border { color, corner_radius, width, position } = &value.render_data { |
| 166 | Self::Border(Border { |
| 167 | color: *color, |
| 168 | corner_radii: (*corner_radius).into(), |
| 169 | width: BorderWidth { |
| 170 | left: width.left, |
| 171 | right: width.right, |
| 172 | top: width.top, |
| 173 | bottom: width.bottom, |
| 174 | between_children: width.between_children, |
| 175 | }, |
| 176 | position: *position, |
| 177 | }) |
| 178 | } else { |
| 179 | Self::None() |
| 180 | } |
| 181 | } |
| 182 | engine::RenderCommandType::Image => { |
| 183 | if let engine::InternalRenderData::Image { background_color, corner_radius, image_data } = &value.render_data { |
| 184 | Self::Image(Image { |
| 185 | data: image_data.clone(), |
| 186 | corner_radii: (*corner_radius).into(), |
| 187 | background_color: *background_color, |
| 188 | }) |
| 189 | } else { |
| 190 | Self::None() |
| 191 | } |
| 192 | } |
| 193 | engine::RenderCommandType::ScissorStart => Self::ScissorStart(), |
| 194 | engine::RenderCommandType::ScissorEnd => Self::ScissorEnd(), |