Browse Source

Forgot to add new .cpp files

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
da7d6c06a9
2 changed files with 59 additions and 0 deletions
  1. +36
    -0
      src/ui/MenuOverlay.cpp
  2. +23
    -0
      src/ui/Tooltip.cpp

+ 36
- 0
src/ui/MenuOverlay.cpp View File

@@ -0,0 +1,36 @@
#include "ui/MenuOverlay.hpp"


namespace rack {


void MenuOverlay::step() {
// Adopt parent's size
box.size = parent->box.size;

// Fit all children in the box
for (Widget *child : children) {
child->box = child->box.nudge(box.zeroPos());
}

Widget::step();
}

void MenuOverlay::onButton(const event::Button &e) {
OpaqueWidget::onButton(e);

if (e.getConsumed() == this && e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) {
requestedDelete = true;
}
}

void MenuOverlay::onHoverKey(const event::HoverKey &e) {
OpaqueWidget::onHoverKey(e);

if (e.getConsumed() == this && e.action == GLFW_PRESS && e.key == GLFW_KEY_ESCAPE) {
requestedDelete = true;
}
}


} // namespace rack

+ 23
- 0
src/ui/Tooltip.cpp View File

@@ -0,0 +1,23 @@
#include "ui/Tooltip.hpp"
#include "context.hpp"
#include "window.hpp"


namespace rack {


void Tooltip::step() {
// Wrap size to contents
box.size.x = bndLabelWidth(context()->window->vg, -1, text.c_str()) + 10.0;
box.size.y = bndLabelHeight(context()->window->vg, -1, text.c_str(), INFINITY);
Widget::step();
}

void Tooltip::draw(NVGcontext *vg) {
bndTooltipBackground(vg, 0.0, 0.0, box.size.x, box.size.y);
bndMenuLabel(vg, 0.0, 0.0, box.size.x, box.size.y, -1, text.c_str());
Widget::draw(vg);
}


} // namespace rack

Loading…
Cancel
Save