Browse Source

Make RackRails positioned correctly to prevent blank frames.

tags/v1.0.0
Andrew Belt 6 years ago
parent
commit
51c37936a9
6 changed files with 23 additions and 23 deletions
  1. +1
    -1
      include/event.hpp
  2. +1
    -1
      include/widget/Widget.hpp
  3. +5
    -5
      src/app/RackRail.cpp
  4. +10
    -12
      src/app/RackWidget.cpp
  5. +5
    -3
      src/widget/FramebufferWidget.cpp
  6. +1
    -1
      src/widget/Widget.cpp

+ 1
- 1
include/event.hpp View File

@@ -291,7 +291,7 @@ struct Zoom : Base {
}; };




/** Occurs after a Widget's position is set by Widget::setPos().
/** Occurs after a Widget's position is set by Widget::setPosition().
*/ */
struct Reposition : Base { struct Reposition : Base {
}; };


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

@@ -32,7 +32,7 @@ struct Widget {


virtual ~Widget(); virtual ~Widget();


void setPos(math::Vec pos);
void setPosition(math::Vec pos);
void setSize(math::Vec size); void setSize(math::Vec size);
void show(); void show();
void hide(); void hide();


+ 5
- 5
src/app/RackRail.cpp View File

@@ -5,19 +5,19 @@ namespace rack {
namespace app { namespace app {


void RackRail::draw(const DrawArgs &args) { void RackRail::draw(const DrawArgs &args) {
const float railHeight = RACK_GRID_WIDTH;
const float railHeight = 15;


// Background color // Background color
nvgBeginPath(args.vg); nvgBeginPath(args.vg);
nvgRect(args.vg, 0.0, 0.0, box.size.x, box.size.y); nvgRect(args.vg, 0.0, 0.0, box.size.x, box.size.y);
nvgFillColor(args.vg, nvgRGBf(0.2, 0.2, 0.2));
nvgFillColor(args.vg, nvgRGB(0x30, 0x30, 0x30));
nvgFill(args.vg); nvgFill(args.vg);


// Rails // Rails
nvgFillColor(args.vg, nvgRGBf(0.85, 0.85, 0.85));
nvgFillColor(args.vg, nvgRGB(0xc9, 0xc9, 0xc9));
nvgStrokeWidth(args.vg, 1.0); nvgStrokeWidth(args.vg, 1.0);
nvgStrokeColor(args.vg, nvgRGBf(0.7, 0.7, 0.7));
float holeRadius = 3.5;
nvgStrokeColor(args.vg, nvgRGB(0x9d, 0x9f, 0xa2));
float holeRadius = 4.0;
for (float railY = 0; railY < box.size.y; railY += RACK_GRID_HEIGHT) { for (float railY = 0; railY < box.size.y; railY += RACK_GRID_HEIGHT) {
// Top rail // Top rail
nvgBeginPath(args.vg); nvgBeginPath(args.vg);


+ 10
- 12
src/app/RackWidget.cpp View File

@@ -97,22 +97,19 @@ RackWidget::~RackWidget() {
} }


void RackWidget::step() { void RackWidget::step() {
// Adjust size and position of railFb
math::Rect bound = getViewport(math::Rect(math::Vec(), box.size));
if (!railFb->box.isContaining(bound)) {
math::Vec margin = math::Vec(200, 200);
railFb->box.pos = bound.pos.minus(margin).div(RACK_GRID_SIZE).floor().mult(RACK_GRID_SIZE);
railFb->box.size = bound.size.plus(margin.mult(2));
railFb->dirty = true;

RackRail *rail = railFb->getFirstDescendantOfType<RackRail>();
rail->box.size = railFb->box.size;
}

Widget::step(); Widget::step();
} }


void RackWidget::draw(const DrawArgs &args) { void RackWidget::draw(const DrawArgs &args) {
// Resize and reposition the RackRail to align on the grid.
math::Rect railBox;
railBox.pos = args.clipBox.pos.div(RACK_GRID_SIZE).floor().mult(RACK_GRID_SIZE);
railBox.size = args.clipBox.size.div(RACK_GRID_SIZE).floor().plus(math::Vec(25, 2)).mult(RACK_GRID_SIZE);
railFb->box = railBox;

RackRail *rail = railFb->getFirstDescendantOfType<RackRail>();
rail->box.size = railFb->box.size;

Widget::draw(args); Widget::draw(args);
} }


@@ -140,6 +137,7 @@ void RackWidget::onHoverKey(const event::HoverKey &e) {
} }


void RackWidget::onDragHover(const event::DragHover &e) { void RackWidget::onDragHover(const event::DragHover &e) {
// Set before calling children's onDragHover()
mousePos = e.pos; mousePos = e.pos;
OpaqueWidget::onDragHover(e); OpaqueWidget::onDragHover(e);
} }


+ 5
- 3
src/widget/FramebufferWidget.cpp View File

@@ -71,7 +71,7 @@ void FramebufferWidget::step() {
} }


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


@@ -83,7 +83,7 @@ void FramebufferWidget::step() {
if (oversample != 1.0) { if (oversample != 1.0) {
NVGLUframebuffer *newFb = nvgluCreateFramebuffer(vg, fbSize.x, fbSize.y, 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));
WARN("Non-oversampled framebuffer of size (%f, %f) could not be created for FramebufferWidget.", VEC_ARGS(fbSize));
return; return;
} }


@@ -125,8 +125,10 @@ void FramebufferWidget::draw(const DrawArgs &args) {
float xform[6]; float xform[6];
nvgCurrentTransform(args.vg, xform); nvgCurrentTransform(args.vg, xform);
// Skew and rotate is not supported // Skew and rotate is not supported
if (!math::isNear(xform[1], 0.f) || !math::isNear(xform[2], 0.f))
if (!math::isNear(xform[1], 0.f) || !math::isNear(xform[2], 0.f)) {
WARN("Skew and rotation detected but not supported in FramebufferWidget.");
return; return;
}
// Extract scale and offset from world transform // Extract scale and offset from world transform
scale = math::Vec(xform[0], xform[3]); scale = math::Vec(xform[0], xform[3]);
offset = math::Vec(xform[4], xform[5]); offset = math::Vec(xform[4], xform[5]);


+ 1
- 1
src/widget/Widget.cpp View File

@@ -13,7 +13,7 @@ Widget::~Widget() {
clearChildren(); clearChildren();
} }


void Widget::setPos(math::Vec pos) {
void Widget::setPosition(math::Vec pos) {
box.pos = pos; box.pos = pos;
// event::Reposition // event::Reposition
event::Reposition eReposition; event::Reposition eReposition;


Loading…
Cancel
Save