MCPcopy Create free account
hub / github.com/VitalAudio/visage / ShaderEditor

Method ShaderEditor

visage_widgets/shader_editor.cpp:194–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 15

setDefaultTextMethod · 0.80
toUtf8Method · 0.80
textMethod · 0.80
redrawMethod · 0.80
compileMethod · 0.80
svgMethod · 0.80
FontClass · 0.50
setMultiLineMethod · 0.45
setMarginMethod · 0.45
setFontMethod · 0.45
setJustificationMethod · 0.45
setTextMethod · 0.45

Tested by

no test coverage detected