instead of box.pos.tags/v0.3.0
@@ -165,7 +165,10 @@ void renderGui() { | |||||
nvgBeginFrame(vg, width, height, 1.0); | nvgBeginFrame(vg, width, height, 1.0); | ||||
nvgSave(vg); | |||||
gScene->draw(vg); | gScene->draw(vg); | ||||
nvgRestore(vg); | |||||
nvgEndFrame(vg); | nvgEndFrame(vg); | ||||
glfwSwapBuffers(window); | glfwSwapBuffers(window); | ||||
} | } | ||||
@@ -4,7 +4,7 @@ | |||||
namespace rack { | namespace rack { | ||||
void Button::draw(NVGcontext *vg) { | void Button::draw(NVGcontext *vg) { | ||||
bndToolButton(vg, box.pos.x, box.pos.y, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, text.c_str()); | |||||
bndToolButton(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, text.c_str()); | |||||
} | } | ||||
void Button::onMouseEnter() { | void Button::onMouseEnter() { | ||||
@@ -4,7 +4,7 @@ | |||||
namespace rack { | namespace rack { | ||||
void ChoiceButton::draw(NVGcontext *vg) { | void ChoiceButton::draw(NVGcontext *vg) { | ||||
bndChoiceButton(vg, box.pos.x, box.pos.y, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, text.c_str()); | |||||
bndChoiceButton(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, text.c_str()); | |||||
} | } | ||||
@@ -4,7 +4,7 @@ | |||||
namespace rack { | namespace rack { | ||||
void Label::draw(NVGcontext *vg) { | void Label::draw(NVGcontext *vg) { | ||||
bndLabel(vg, box.pos.x, box.pos.y, box.size.x, box.size.y, -1, text.c_str()); | |||||
bndLabel(vg, 0.0, 0.0, box.size.x, box.size.y, -1, text.c_str()); | |||||
} | } | ||||
@@ -6,11 +6,10 @@ namespace rack { | |||||
void Light::draw(NVGcontext *vg) { | void Light::draw(NVGcontext *vg) { | ||||
NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5); | NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5); | ||||
Vec c = box.getCenter(); | |||||
Vec r = box.size.div(2.0); | Vec r = box.size.div(2.0); | ||||
nvgBeginPath(vg); | nvgBeginPath(vg); | ||||
nvgEllipse(vg, c.x, c.y, r.x - 1.0, r.y - 1.0); | |||||
nvgEllipse(vg, r.x, r.y, r.x - 1.0, r.y - 1.0); | |||||
nvgFillColor(vg, color); | nvgFillColor(vg, color); | ||||
nvgFill(vg); | nvgFill(vg); | ||||
@@ -23,7 +23,7 @@ void Menu::draw(NVGcontext *vg) { | |||||
child->box.size.x = box.size.x; | child->box.size.x = box.size.x; | ||||
} | } | ||||
bndMenuBackground(vg, box.pos.x, box.pos.y, box.size.x, box.size.y, BND_CORNER_NONE); | |||||
bndMenuBackground(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE); | |||||
Widget::draw(vg); | Widget::draw(vg); | ||||
} | } | ||||
@@ -4,7 +4,7 @@ | |||||
namespace rack { | namespace rack { | ||||
void MenuItem::draw(NVGcontext *vg) { | void MenuItem::draw(NVGcontext *vg) { | ||||
bndMenuItem(vg, box.pos.x, box.pos.y, box.size.x, box.size.y, state, -1, text.c_str()); | |||||
bndMenuItem(vg, 0.0, 0.0, box.size.x, box.size.y, state, -1, text.c_str()); | |||||
} | } | ||||
void MenuItem::onMouseEnter() { | void MenuItem::onMouseEnter() { | ||||
@@ -4,7 +4,7 @@ | |||||
namespace rack { | namespace rack { | ||||
void MenuLabel::draw(NVGcontext *vg) { | void MenuLabel::draw(NVGcontext *vg) { | ||||
bndMenuLabel(vg, box.pos.x, box.pos.y, box.size.x, box.size.y, -1, text.c_str()); | |||||
bndMenuLabel(vg, 0.0, 0.0, box.size.x, box.size.y, -1, text.c_str()); | |||||
} | } | ||||
@@ -99,7 +99,7 @@ void ModuleWidget::cloneParams(ModuleWidget *source) { | |||||
void ModuleWidget::draw(NVGcontext *vg) { | void ModuleWidget::draw(NVGcontext *vg) { | ||||
Widget::draw(vg); | Widget::draw(vg); | ||||
bndBevel(vg, box.pos.x, box.pos.y, box.size.x, box.size.y); | |||||
bndBevel(vg, 0.0, 0.0, box.size.x, box.size.y); | |||||
// CPU usage text | // CPU usage text | ||||
if (dynamic_cast<RackScene*>(gScene)->toolbar->cpuUsageButton->value != 0.0) { | if (dynamic_cast<RackScene*>(gScene)->toolbar->cpuUsageButton->value != 0.0) { | ||||
@@ -108,17 +108,17 @@ void ModuleWidget::draw(NVGcontext *vg) { | |||||
nvgSave(vg); | nvgSave(vg); | ||||
nvgBeginPath(vg); | nvgBeginPath(vg); | ||||
nvgRect(vg, box.pos.x, box.pos.y, box.size.x, BND_WIDGET_HEIGHT); | |||||
nvgRect(vg, 0.0, 0.0, box.size.x, BND_WIDGET_HEIGHT); | |||||
nvgFillColor(vg, nvgRGBf(0.0, 0.0, 0.0)); | nvgFillColor(vg, nvgRGBf(0.0, 0.0, 0.0)); | ||||
nvgFill(vg); | nvgFill(vg); | ||||
nvgBeginPath(vg); | nvgBeginPath(vg); | ||||
cpuTime = clampf(cpuTime, 0.0, 1.0); | cpuTime = clampf(cpuTime, 0.0, 1.0); | ||||
nvgRect(vg, box.pos.x, box.pos.y, box.size.x * cpuTime, BND_WIDGET_HEIGHT); | |||||
nvgRect(vg, 0.0, 0.0, box.size.x * cpuTime, BND_WIDGET_HEIGHT); | |||||
nvgFillColor(vg, nvgHSL(0.33 * cubic(1.0 - cpuTime), 1.0, 0.4)); | nvgFillColor(vg, nvgHSL(0.33 * cubic(1.0 - cpuTime), 1.0, 0.4)); | ||||
nvgFill(vg); | nvgFill(vg); | ||||
bndMenuItem(vg, box.pos.x, box.pos.y, box.size.x, BND_WIDGET_HEIGHT, BND_DEFAULT, -1, text.c_str()); | |||||
bndMenuItem(vg, 0.0, 0.0, box.size.x, BND_WIDGET_HEIGHT, BND_DEFAULT, -1, text.c_str()); | |||||
nvgRestore(vg); | nvgRestore(vg); | ||||
} | } | ||||
} | } | ||||
@@ -5,7 +5,7 @@ namespace rack { | |||||
void Panel::draw(NVGcontext *vg) { | void Panel::draw(NVGcontext *vg) { | ||||
nvgBeginPath(vg); | nvgBeginPath(vg); | ||||
nvgRect(vg, box.pos.x, box.pos.y, box.size.x, box.size.y); | |||||
nvgRect(vg, 0.0, 0.0, box.size.x, box.size.y); | |||||
// Background color | // Background color | ||||
nvgFillColor(vg, backgroundColor); | nvgFillColor(vg, backgroundColor); | ||||
@@ -15,7 +15,7 @@ void Panel::draw(NVGcontext *vg) { | |||||
if (backgroundImage) { | if (backgroundImage) { | ||||
int width, height; | int width, height; | ||||
nvgImageSize(vg, backgroundImage->handle, &width, &height); | nvgImageSize(vg, backgroundImage->handle, &width, &height); | ||||
NVGpaint paint = nvgImagePattern(vg, box.pos.x, box.pos.y, width, height, 0.0, backgroundImage->handle, 1.0); | |||||
NVGpaint paint = nvgImagePattern(vg, 0.0, 0.0, width, height, 0.0, backgroundImage->handle, 1.0); | |||||
nvgFillPaint(vg, paint); | nvgFillPaint(vg, paint); | ||||
nvgFill(vg); | nvgFill(vg); | ||||
} | } | ||||
@@ -27,19 +27,6 @@ void RackScene::step() { | |||||
void RackScene::draw(NVGcontext *vg) { | void RackScene::draw(NVGcontext *vg) { | ||||
Scene::draw(vg); | Scene::draw(vg); | ||||
// // Draw custom stuff here | |||||
// static std::shared_ptr<SVG> svg; | |||||
// if (!svg) | |||||
// svg = SVG::load("res/ComponentLibrary/CL1362.svg"); | |||||
// for (float y = 0.0; y < 1000.0; y += 200.0) | |||||
// for (float x = 0.0; x < 1000.0; x += 200.0) { | |||||
// nvgSave(vg); | |||||
// nvgTranslate(vg, x, y); | |||||
// drawSVG(vg, svg->handle); | |||||
// nvgRestore(vg); | |||||
// } | |||||
} | } | ||||
@@ -289,7 +289,7 @@ void RackWidget::step() { | |||||
void RackWidget::draw(NVGcontext *vg) { | void RackWidget::draw(NVGcontext *vg) { | ||||
nvgBeginPath(vg); | nvgBeginPath(vg); | ||||
nvgRect(vg, box.pos.x, box.pos.y, box.size.x, box.size.y); | |||||
nvgRect(vg, 0.0, 0.0, box.size.x, box.size.y); | |||||
// Background color | // Background color | ||||
nvgFillColor(vg, nvgRGBf(0.2, 0.2, 0.2)); | nvgFillColor(vg, nvgRGBf(0.2, 0.2, 0.2)); | ||||
@@ -299,7 +299,7 @@ void RackWidget::draw(NVGcontext *vg) { | |||||
{ | { | ||||
int imageWidth, imageHeight; | int imageWidth, imageHeight; | ||||
nvgImageSize(vg, railsImage->handle, &imageWidth, &imageHeight); | nvgImageSize(vg, railsImage->handle, &imageWidth, &imageHeight); | ||||
NVGpaint paint = nvgImagePattern(vg, box.pos.x, box.pos.y, imageWidth, imageHeight, 0.0, railsImage->handle, 1.0); | |||||
NVGpaint paint = nvgImagePattern(vg, 0.0, 0.0, imageWidth, imageHeight, 0.0, railsImage->handle, 1.0); | |||||
nvgFillPaint(vg, paint); | nvgFillPaint(vg, paint); | ||||
nvgFill(vg); | nvgFill(vg); | ||||
} | } | ||||
@@ -4,7 +4,7 @@ | |||||
namespace rack { | namespace rack { | ||||
void RadioButton::draw(NVGcontext *vg) { | void RadioButton::draw(NVGcontext *vg) { | ||||
bndRadioButton(vg, box.pos.x, box.pos.y, box.size.x, box.size.y, BND_CORNER_NONE, value == 0.0 ? state : BND_ACTIVE, -1, label.c_str()); | |||||
bndRadioButton(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, value == 0.0 ? state : BND_ACTIVE, -1, label.c_str()); | |||||
} | } | ||||
void RadioButton::onMouseEnter() { | void RadioButton::onMouseEnter() { | ||||
@@ -10,7 +10,7 @@ void ScrollBar::draw(NVGcontext *vg) { | |||||
float offset = containerOffset / maxOffset; | float offset = containerOffset / maxOffset; | ||||
float size = boxSize / containerSize; | float size = boxSize / containerSize; | ||||
size = clampf(size, 0.0, 1.0); | size = clampf(size, 0.0, 1.0); | ||||
bndScrollBar(vg, box.pos.x, box.pos.y, box.size.x, box.size.y, state, offset, size); | |||||
bndScrollBar(vg, 0.0, 0.0, box.size.x, box.size.y, state, offset, size); | |||||
} | } | ||||
void ScrollBar::move(float delta) { | void ScrollBar::move(float delta) { | ||||
@@ -8,7 +8,7 @@ namespace rack { | |||||
void Slider::draw(NVGcontext *vg) { | void Slider::draw(NVGcontext *vg) { | ||||
float progress = mapf(value, minValue, maxValue, 0.0, 1.0); | float progress = mapf(value, minValue, maxValue, 0.0, 1.0); | ||||
bndSlider(vg, box.pos.x, box.pos.y, box.size.x, box.size.y, BND_CORNER_NONE, state, progress, getText().c_str(), NULL); | |||||
bndSlider(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, progress, getText().c_str(), NULL); | |||||
} | } | ||||
void Slider::onDragStart() { | void Slider::onDragStart() { | ||||
@@ -4,8 +4,6 @@ | |||||
namespace rack { | namespace rack { | ||||
void SpriteWidget::draw(NVGcontext *vg) { | void SpriteWidget::draw(NVGcontext *vg) { | ||||
Vec pos = box.pos.plus(spriteOffset); | |||||
int width, height; | int width, height; | ||||
nvgImageSize(vg, spriteImage->handle, &width, &height); | nvgImageSize(vg, spriteImage->handle, &width, &height); | ||||
int stride = width / spriteSize.x; | int stride = width / spriteSize.x; | ||||
@@ -14,10 +12,10 @@ void SpriteWidget::draw(NVGcontext *vg) { | |||||
return; | return; | ||||
} | } | ||||
Vec offset = Vec((index % stride) * spriteSize.x, (index / stride) * spriteSize.y); | Vec offset = Vec((index % stride) * spriteSize.x, (index / stride) * spriteSize.y); | ||||
NVGpaint paint = nvgImagePattern(vg, pos.x - offset.x, pos.y - offset.y, width, height, 0.0, spriteImage->handle, 1.0); | |||||
NVGpaint paint = nvgImagePattern(vg, spriteOffset.x - offset.x, spriteOffset.y - offset.y, width, height, 0.0, spriteImage->handle, 1.0); | |||||
nvgFillPaint(vg, paint); | nvgFillPaint(vg, paint); | ||||
nvgBeginPath(vg); | nvgBeginPath(vg); | ||||
nvgRect(vg, pos.x, pos.y, spriteSize.x, spriteSize.y); | |||||
nvgRect(vg, spriteOffset.x, spriteOffset.y, spriteSize.x, spriteSize.y); | |||||
nvgFill(vg); | nvgFill(vg); | ||||
} | } | ||||
@@ -165,8 +165,8 @@ Toolbar::Toolbar() { | |||||
} | } | ||||
void Toolbar::draw(NVGcontext *vg) { | void Toolbar::draw(NVGcontext *vg) { | ||||
bndBackground(vg, box.pos.x, box.pos.y, box.size.x, box.size.y); | |||||
bndBevel(vg, box.pos.x, box.pos.y, box.size.x, box.size.y); | |||||
bndBackground(vg, 0.0, 0.0, box.size.x, box.size.y); | |||||
bndBevel(vg, 0.0, 0.0, box.size.x, box.size.y); | |||||
Widget::draw(vg); | Widget::draw(vg); | ||||
} | } | ||||
@@ -69,12 +69,12 @@ void Widget::step() { | |||||
} | } | ||||
void Widget::draw(NVGcontext *vg) { | void Widget::draw(NVGcontext *vg) { | ||||
nvgTranslate(vg, box.pos.x, box.pos.y); | |||||
for (Widget *child : children) { | for (Widget *child : children) { | ||||
nvgSave(vg); | nvgSave(vg); | ||||
nvgTranslate(vg, child->box.pos.x, child->box.pos.y); | |||||
child->draw(vg); | child->draw(vg); | ||||
nvgRestore(vg); | |||||
} | } | ||||
nvgRestore(vg); | |||||
} | } | ||||
Widget *Widget::onMouseDown(Vec pos, int button) { | Widget *Widget::onMouseDown(Vec pos, int button) { | ||||
@@ -120,7 +120,7 @@ void WireWidget::updateWire() { | |||||
} | } | ||||
void WireWidget::draw(NVGcontext *vg) { | void WireWidget::draw(NVGcontext *vg) { | ||||
Vec absolutePos = getAbsolutePos(); | |||||
Vec absolutePos = getAbsolutePos().minus(box.pos); | |||||
float opacity = dynamic_cast<RackScene*>(gScene)->toolbar->wireOpacitySlider->value / 100.0; | float opacity = dynamic_cast<RackScene*>(gScene)->toolbar->wireOpacitySlider->value / 100.0; | ||||
float tension = dynamic_cast<RackScene*>(gScene)->toolbar->wireTensionSlider->value; | float tension = dynamic_cast<RackScene*>(gScene)->toolbar->wireTensionSlider->value; | ||||