Browse Source

Fix SVGKnob getChildrenBoundingBox when forcing it to rescale with

box.size
tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
1461c7290d
4 changed files with 13 additions and 2 deletions
  1. +2
    -1
      include/widgets.hpp
  2. +0
    -1
      src/app/RackWidget.cpp
  3. +1
    -0
      src/app/SVGKnob.cpp
  4. +10
    -0
      src/widgets/TransformWidget.cpp

+ 2
- 1
include/widgets.hpp View File

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


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


Rect getChildrenBoundingBox();
virtual Rect getChildrenBoundingBox();
/** Returns `v` transformed into the coordinate system of `relative` */ /** Returns `v` transformed into the coordinate system of `relative` */
virtual Vec getRelativeOffset(Vec v, Widget *relative); virtual Vec getRelativeOffset(Vec v, Widget *relative);
/** Returns `v` transformed into world coordinates */ /** Returns `v` transformed into world coordinates */
@@ -159,6 +159,7 @@ struct TransformWidget : Widget {
/** The transformation matrix */ /** The transformation matrix */
float transform[6]; float transform[6];
TransformWidget(); TransformWidget();
Rect getChildrenBoundingBox() override;
void identity(); void identity();
void translate(Vec delta); void translate(Vec delta);
void rotate(float angle); void rotate(float angle);


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

@@ -348,7 +348,6 @@ void RackWidget::step() {
Vec cellMargin = Vec(20, 1); Vec cellMargin = Vec(20, 1);
rails->box.pos = bound.pos.div(RACK_GRID_SIZE).floor().minus(cellMargin).mult(RACK_GRID_SIZE); rails->box.pos = bound.pos.div(RACK_GRID_SIZE).floor().minus(cellMargin).mult(RACK_GRID_SIZE);
rails->box.size = bound.size.plus(cellMargin.mult(RACK_GRID_SIZE).mult(2)); rails->box.size = bound.size.plus(cellMargin.mult(RACK_GRID_SIZE).mult(2));
printf("%f %f %f %f\n", rails->box.pos.x, rails->box.pos.y, rails->box.size.x, rails->box.size.y);
rails->dirty = true; rails->dirty = true;


rail->box.size = rails->box.size; rail->box.size = rails->box.size;


+ 1
- 0
src/app/SVGKnob.cpp View File

@@ -22,6 +22,7 @@ void SVGKnob::setSVG(std::shared_ptr<SVG> svg) {
void SVGKnob::step() { void SVGKnob::step() {
// Re-transform TransformWidget if dirty // Re-transform TransformWidget if dirty
if (dirty) { if (dirty) {
tw->box.size = box.size;
float angle = rescalef(value, minValue, maxValue, minAngle, maxAngle); float angle = rescalef(value, minValue, maxValue, minAngle, maxAngle);
tw->identity(); tw->identity();
// Scale SVG to box // Scale SVG to box


+ 10
- 0
src/widgets/TransformWidget.cpp View File

@@ -8,6 +8,16 @@ TransformWidget::TransformWidget() {
identity(); identity();
} }


Rect TransformWidget::getChildrenBoundingBox() {
Rect bound = Widget::getChildrenBoundingBox();
Vec topLeft = bound.pos;
Vec bottomRight = bound.getBottomRight();
nvgTransformPoint(&topLeft.x, &topLeft.y, transform, topLeft.x, topLeft.y);
nvgTransformPoint(&bottomRight.x, &bottomRight.y, transform, bottomRight.x, bottomRight.y);
printf("%f\n", 42.1);
return Rect(topLeft, bottomRight.minus(topLeft));
}

void TransformWidget::identity() { void TransformWidget::identity() {
nvgTransformIdentity(transform); nvgTransformIdentity(transform);
} }


Loading…
Cancel
Save