| 192 | } |
| 193 | |
| 194 | ShaderEditor::ShaderEditor() { |
| 195 | addChild(&editor_); |
| 196 | addChild(&error_); |
| 197 | addChild(&status_); |
| 198 | editor_.setMultiLine(true); |
| 199 | editor_.setMargin(15, 10); |
| 200 | editor_.setFont(Font(16, fonts::DroidSansMono_ttf)); |
| 201 | editor_.setJustification(Font::kTopLeft); |
| 202 | editor_.setDefaultText("No shader set"); |
| 203 | |
| 204 | editor_.onTextChange() += [this] { |
| 205 | if (shader_.data) { |
| 206 | std::string text = editor_.text().toUtf8(); |
| 207 | auto callback = [this](const std::string& error) { |
| 208 | error_.setText(error); |
| 209 | status_.redraw(); |
| 210 | redraw(); |
| 211 | }; |
| 212 | compiler_.compile(shader_, text, callback); |
| 213 | } |
| 214 | }; |
| 215 | |
| 216 | error_.setMultiLine(true); |
| 217 | error_.setMargin(15, 10); |
| 218 | error_.setFont(Font(16, fonts::DroidSansMono_ttf)); |
| 219 | error_.setJustification(Font::kTopLeft); |
| 220 | error_.setActive(false); |
| 221 | |
| 222 | status_.onDraw() = [this](Canvas& canvas) { |
| 223 | if (error_.text().isEmpty()) { |
| 224 | canvas.setColor(0xff66ff66); |
| 225 | canvas.svg(icons::check_circle_svg, 0.0f, 0.0f, status_.width(), status_.height()); |
| 226 | } |
| 227 | else { |
| 228 | canvas.setColor(0xffff6666); |
| 229 | canvas.svg(icons::x_circle_svg, 0, 0, status_.width(), status_.height()); |
| 230 | } |
| 231 | }; |
| 232 | } |
| 233 | |
| 234 | void ShaderEditor::draw(Canvas& canvas) { |
| 235 | canvas.setColor(0xff222222); |
nothing calls this directly
no test coverage detected