Module GUI without svg file?

Is it possible to create a module GUI completely with code, without involving an svg file at all?

yes, the svg elements can be created in the module code

1 Like

Yes, just set box.size.x in the ModuleWidget subclass’s constructor.

3 Likes

Captain Clueless here again.

Tried this, how do I draw the panel?

This appears as expected in the module browser, putting it into the rack just shows a shadow.

struct RSSkeletonWidget : ModuleWidget {
    RSSkeleton* module;

    RSSkeletonWidget(RSSkeleton *module) {
        setModule(module);
        this->module = module;

        box.size.x = 100;
        INFO("Racket Science: %f %f", box.size.x, box.size.y);

    }

    void draw(const DrawArgs& args) override {
		nvgStrokeColor(args.vg, COLOR_RS_BRONZE);
		nvgFillColor(args.vg, COLOR_BLACK);
		nvgStrokeWidth(args.vg, 1.5);

		nvgBeginPath(args.vg);
		nvgRoundedRect(args.vg, box.pos.x, box.pos.y, box.size.x, box.size.y, 5);
		nvgStroke(args.vg);
		nvgFill(args.vg);
    }
};

You need to call the superclass draw method in the overridden method.

Like this?

ModuleWidget::draw(args);

Makes no difference.

Did you put it at the end of your draw() method?

Tried at both beginning and end, same (lack of) result.

Seems your module has height of 0 or do I miss something?

Height (as reported by INFO) is 380.

Rack autoadjusts the height based on the width.

You are drawing your rectangle at the wrong position, if you want it to fill your whole module GUI :

nvgRoundedRect(args.vg, 0, 0, box.size.x, box.size.y, 5);
2 Likes

Ah right, ModuleWidget::box.pos is the relative position in the parent widget.

Doh!

Thank you :slight_smile: