diff --git a/include/plugin/Plugin.hpp b/include/plugin/Plugin.hpp index b4d9c80a..c0702f5c 100644 --- a/include/plugin/Plugin.hpp +++ b/include/plugin/Plugin.hpp @@ -30,7 +30,8 @@ struct Plugin { To guarantee uniqueness, it is a good idea to prefix the slug by your "company name" if available, e.g. "MyCompany-MyPlugin" */ std::string slug; - /** Your plugin's latest version, using the guidelines at https://github.com/VCVRack/Rack/issues/266. Do not include the "v" prefix. + /** Your plugin's latest version. + Do not include the "v" prefix. */ std::string version; /** The license type of your plugin. Use "proprietary" if all rights are reserved. If your license is in the [SPDX license list](https://spdx.org/licenses/), use its abbreviation in the "Identifier" column. diff --git a/include/widget/Widget.hpp b/include/widget/Widget.hpp index 38d0b59c..f7dfd564 100644 --- a/include/widget/Widget.hpp +++ b/include/widget/Widget.hpp @@ -19,14 +19,18 @@ The bounding box of a Widget is a rectangle specified by `box` relative to their The appearance is defined by overriding `draw()`, and the behavior is defined by overriding `step()` and `on*()` event handlers. */ struct Widget : WeakBase { - /** Stores position and size */ + /** Position relative to parent and size of widget. */ math::Rect box = math::Rect(math::Vec(), math::Vec(INFINITY, INFINITY)); /** Automatically set when Widget is added as a child to another Widget */ Widget* parent = NULL; std::list children; - /** Disables rendering but allow stepping */ + /** Disables rendering but allow stepping. + Use isVisible(), setVisible(), show(), or hide() instead of using this variable directly. + */ bool visible = true; - /** If set to true, parent will delete Widget in the next step() */ + /** If set to true, parent will delete Widget in the next step(). + Use requestDelete() instead of using this variable directly. + */ bool requestedDelete = false; virtual ~Widget(); diff --git a/include/widget/ZoomWidget.hpp b/include/widget/ZoomWidget.hpp index 2719b408..0043d7f2 100644 --- a/include/widget/ZoomWidget.hpp +++ b/include/widget/ZoomWidget.hpp @@ -8,15 +8,14 @@ namespace widget { /** A Widget with a dynamic zoom level. */ struct ZoomWidget : Widget { + /** Use setZoom() and getZoom() instead of using this variable directly. */ float zoom = 1.f; math::Vec getRelativeOffset(math::Vec v, Widget* ancestor) override; float getRelativeZoom(Widget* ancestor) override; math::Rect getViewport(math::Rect r) override; + float getZoom(); void setZoom(float zoom); - float getZoom() { - return zoom; - } void draw(const DrawArgs& args) override; void drawLayer(const DrawArgs& args, int layer) override; diff --git a/include/window/Window.hpp b/include/window/Window.hpp index fbcccb03..f22d9dc1 100644 --- a/include/window/Window.hpp +++ b/include/window/Window.hpp @@ -29,9 +29,10 @@ namespace window { struct Font { NVGcontext* vg; int handle = -1; + + ~Font(); /** Don't call this directly but instead use `APP->window->loadFont()` */ void loadFile(const std::string& filename, NVGcontext* vg); - ~Font(); /** Use `APP->window->loadFont()` instead. */ DEPRECATED static std::shared_ptr load(const std::string& filename); }; @@ -41,9 +42,10 @@ struct Font { struct Image { NVGcontext* vg; int handle = -1; + + ~Image(); /** Don't call this directly but instead use `APP->window->loadImage()` */ void loadFile(const std::string& filename, NVGcontext* vg); - ~Image(); /** Use `APP->window->loadImage()` instead. */ DEPRECATED static std::shared_ptr load(const std::string& filename); }; @@ -57,10 +59,10 @@ struct Window { GLFWwindow* win = NULL; NVGcontext* vg = NULL; NVGcontext* fbVg = NULL; - /** The scaling ratio */ + /** UI scaling ratio */ float pixelRatio = 1.f; - /* The ratio between the framebuffer size and the window size reported by the OS. - This is not equal to gPixelRatio in general. + /** Ratio between the framebuffer size and the window size reported by the OS. + This is not equal to pixelRatio in general. */ float windowRatio = 1.f; std::shared_ptr uiFont; diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index 223c99d8..be7679eb 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -1414,9 +1414,9 @@ NVGcolor RackWidget::getNextCableColor() { return color::WHITE; int id = internal->nextCableColorId++; - if (id >= settings::cableColors.size()) + if (id >= (int) settings::cableColors.size()) id = 0; - if (internal->nextCableColorId >= settings::cableColors.size()) + if (internal->nextCableColorId >= (int) settings::cableColors.size()) internal->nextCableColorId = 0; return settings::cableColors[id]; } diff --git a/src/widget/ZoomWidget.cpp b/src/widget/ZoomWidget.cpp index 5049d58e..a169043e 100644 --- a/src/widget/ZoomWidget.cpp +++ b/src/widget/ZoomWidget.cpp @@ -27,6 +27,11 @@ math::Rect ZoomWidget::getViewport(math::Rect r) { } +float ZoomWidget::getZoom() { + return zoom; +} + + void ZoomWidget::setZoom(float zoom) { if (zoom == this->zoom) return; diff --git a/src/window/Window.cpp b/src/window/Window.cpp index 389411b1..895a6214 100644 --- a/src/window/Window.cpp +++ b/src/window/Window.cpp @@ -30,6 +30,11 @@ namespace window { static const math::Vec WINDOW_SIZE_MIN = math::Vec(480, 320); +Font::~Font() { + // There is no NanoVG deleteFont() function yet, so do nothing +} + + void Font::loadFile(const std::string& filename, NVGcontext* vg) { this->vg = vg; handle = nvgCreateFont(vg, filename.c_str(), filename.c_str()); @@ -39,13 +44,15 @@ void Font::loadFile(const std::string& filename, NVGcontext* vg) { } -Font::~Font() { - // There is no NanoVG deleteFont() function yet, so do nothing +std::shared_ptr Font::load(const std::string& filename) { + return APP->window->loadFont(filename); } -std::shared_ptr Font::load(const std::string& filename) { - return APP->window->loadFont(filename); +Image::~Image() { + // TODO What if handle is invalid? + if (handle >= 0) + nvgDeleteImage(vg, handle); } @@ -58,13 +65,6 @@ void Image::loadFile(const std::string& filename, NVGcontext* vg) { } -Image::~Image() { - // TODO What if handle is invalid? - if (handle >= 0) - nvgDeleteImage(vg, handle); -} - - std::shared_ptr Image::load(const std::string& filename) { return APP->window->loadImage(filename); }