Browse Source

Add assertions for 0-width ModuleWidgets. Add warning if framebuffer cannot be created in FramebufferWidget.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
7624c46f19
3 changed files with 9 additions and 3 deletions
  1. +1
    -1
      include/widget/Widget.hpp
  2. +2
    -0
      src/app/RackWidget.cpp
  3. +6
    -2
      src/widget/FramebufferWidget.cpp

+ 1
- 1
include/widget/Widget.hpp View File

@@ -136,7 +136,7 @@ struct Widget {
}

/** Override these event callbacks to respond to events.
See events.hpp for a description of each event.
See event.hpp for a description of each event.
*/
virtual void onHover(const event::Hover &e) {recursePositionEvent(&Widget::onHover, e);}
virtual void onButton(const event::Button &e) {recursePositionEvent(&Widget::onButton, e);}


+ 2
- 0
src/app/RackWidget.cpp View File

@@ -358,6 +358,8 @@ static void RackWidget_updateAdjacent(RackWidget *that) {
void RackWidget::addModule(ModuleWidget *m) {
// Add module to ModuleContainer
assert(m);
// Module must be 3U high and at least 1HP wide
assert(m->box.size.x >= RACK_GRID_WIDTH);
assert(m->box.size.y == RACK_GRID_HEIGHT);
moduleContainer->addChild(m);



+ 6
- 2
src/widget/FramebufferWidget.cpp View File

@@ -70,8 +70,10 @@ void FramebufferWidget::step() {
fb = nvgluCreateFramebuffer(vg, fbSize.x * oversample, fbSize.y * oversample, 0);
}

if (!fb)
if (!fb) {
WARN("Framebuffer of size (%f, %f) * %f could not be created for FramebufferWidget", VEC_ARGS(fbSize), oversample);
return;
}

nvgluBindFramebuffer(fb);
drawFramebuffer();
@@ -80,8 +82,10 @@ void FramebufferWidget::step() {
// If oversampling, create another framebuffer and copy it to actual size.
if (oversample != 1.0) {
NVGLUframebuffer *newFb = nvgluCreateFramebuffer(vg, fbSize.x, fbSize.y, 0);
if (!newFb)
if (!newFb) {
WARN("Non-oversampled framebuffer of size (%f, %f) could not be created for FramebufferWidget", VEC_ARGS(fbSize));
return;
}

// Use NanoVG for resizing framebuffers
nvgluBindFramebuffer(newFb);


Loading…
Cancel
Save