Signed-off-by: falkTX <falktx@falktx.com>tags/22.02
| @@ -180,6 +180,7 @@ GLFWAPI const char* glfwGetKeyName(const int key, int) | |||||
| namespace rack { | namespace rack { | ||||
| namespace app { | namespace app { | ||||
| widget::Widget* createMenuBar(bool isStandalone); | widget::Widget* createMenuBar(bool isStandalone); | ||||
| void hideResizeHandle(Scene* scene); | |||||
| } | } | ||||
| namespace window { | namespace window { | ||||
| void WindowSetPluginUI(Window* window, DISTRHO_NAMESPACE::UI* ui); | void WindowSetPluginUI(Window* window, DISTRHO_NAMESPACE::UI* ui); | ||||
| @@ -269,12 +270,19 @@ public: | |||||
| context->nativeWindowId = window.getNativeWindowHandle(); | context->nativeWindowId = window.getNativeWindowHandle(); | ||||
| if (isResizable()) | if (isResizable()) | ||||
| fResizeHandle.hide(); | |||||
| hideResizeHandle(context->scene); | |||||
| const double scaleFactor = getScaleFactor(); | const double scaleFactor = getScaleFactor(); | ||||
| if (scaleFactor != 1) | if (scaleFactor != 1) | ||||
| { | |||||
| setGeometryConstraints(640 * scaleFactor, 480 * scaleFactor); | |||||
| setSize(1228 * scaleFactor, 666 * scaleFactor); | setSize(1228 * scaleFactor, 666 * scaleFactor); | ||||
| } | |||||
| else | |||||
| { | |||||
| setGeometryConstraints(640, 480); | |||||
| } | |||||
| rack::contextSet(context); | rack::contextSet(context); | ||||
| @@ -53,29 +53,8 @@ public: | |||||
| protected: | protected: | ||||
| void onDisplay() override | void onDisplay() override | ||||
| { | { | ||||
| const GraphicsContext& context(getGraphicsContext()); | |||||
| const double lineWidth = 1.0 * getScaleFactor(); | |||||
| #ifdef DGL_OPENGL | |||||
| // glUseProgram(0); | |||||
| glMatrixMode(GL_MODELVIEW); | |||||
| #endif | |||||
| // draw white lines, 1px wide | |||||
| Color(1.0f, 1.0f, 1.0f).setFor(context); | |||||
| l1.draw(context, lineWidth); | |||||
| l2.draw(context, lineWidth); | |||||
| l3.draw(context, lineWidth); | |||||
| // draw black lines, offset by 1px and 1px wide | |||||
| Color(0.0f, 0.0f, 0.0f).setFor(context); | |||||
| Line<double> l1b(l1), l2b(l2), l3b(l3); | |||||
| l1b.moveBy(lineWidth, lineWidth); | |||||
| l2b.moveBy(lineWidth, lineWidth); | |||||
| l3b.moveBy(lineWidth, lineWidth); | |||||
| l1b.draw(context, lineWidth); | |||||
| l2b.draw(context, lineWidth); | |||||
| l3b.draw(context, lineWidth); | |||||
| /* Nothing here, we purposefully avoid drawing anything. | |||||
| * The resize handle is on the plugin UI directly. */ | |||||
| } | } | ||||
| bool onMouse(const MouseEvent& ev) override | bool onMouse(const MouseEvent& ev) override | ||||
| @@ -46,11 +46,58 @@ namespace rack { | |||||
| namespace app { | namespace app { | ||||
| struct ResizeHandle : widget::OpaqueWidget { | |||||
| void draw(const DrawArgs& args) override { | |||||
| nvgStrokeColor(args.vg, nvgRGBf(1, 1, 1)); | |||||
| nvgStrokeWidth(args.vg, 1); | |||||
| nvgBeginPath(args.vg); | |||||
| nvgMoveTo(args.vg, box.size.x, 0); | |||||
| nvgLineTo(args.vg, 0, box.size.y); | |||||
| nvgStroke(args.vg); | |||||
| nvgBeginPath(args.vg); | |||||
| nvgMoveTo(args.vg, box.size.x + 5, 0); | |||||
| nvgLineTo(args.vg, 0, box.size.y + 5); | |||||
| nvgStroke(args.vg); | |||||
| nvgBeginPath(args.vg); | |||||
| nvgMoveTo(args.vg, box.size.x + 10, 0); | |||||
| nvgLineTo(args.vg, 0, box.size.y + 10); | |||||
| nvgStroke(args.vg); | |||||
| nvgStrokeColor(args.vg, nvgRGBf(0, 0, 0)); | |||||
| nvgBeginPath(args.vg); | |||||
| nvgMoveTo(args.vg, box.size.x+1, 0); | |||||
| nvgLineTo(args.vg, 0, box.size.y+1); | |||||
| nvgStroke(args.vg); | |||||
| nvgBeginPath(args.vg); | |||||
| nvgMoveTo(args.vg, box.size.x + 6, 0); | |||||
| nvgLineTo(args.vg, 0, box.size.y + 6); | |||||
| nvgStroke(args.vg); | |||||
| nvgBeginPath(args.vg); | |||||
| nvgMoveTo(args.vg, box.size.x + 11, 0); | |||||
| nvgLineTo(args.vg, 0, box.size.y + 11); | |||||
| nvgStroke(args.vg); | |||||
| } | |||||
| }; | |||||
| struct Scene::Internal { | struct Scene::Internal { | ||||
| ResizeHandle* resizeHandle; | |||||
| bool heldArrowKeys[4] = {}; | bool heldArrowKeys[4] = {}; | ||||
| }; | }; | ||||
| void hideResizeHandle(Scene* scene) { | |||||
| scene->internal->resizeHandle->hide(); | |||||
| } | |||||
| Scene::Scene() { | Scene::Scene() { | ||||
| internal = new Internal; | internal = new Internal; | ||||
| @@ -65,6 +112,10 @@ Scene::Scene() { | |||||
| browser = browserCreate(); | browser = browserCreate(); | ||||
| browser->hide(); | browser->hide(); | ||||
| addChild(browser); | addChild(browser); | ||||
| internal->resizeHandle = new ResizeHandle; | |||||
| internal->resizeHandle->box.size = math::Vec(16, 16); | |||||
| addChild(internal->resizeHandle); | |||||
| } | } | ||||
| @@ -79,6 +130,8 @@ math::Vec Scene::getMousePos() { | |||||
| void Scene::step() { | void Scene::step() { | ||||
| internal->resizeHandle->box.pos = box.size.minus(internal->resizeHandle->box.size); | |||||
| // Resize owned descendants | // Resize owned descendants | ||||
| menuBar->box.size.x = box.size.x; | menuBar->box.size.x = box.size.x; | ||||
| rackScroll->box.pos.y = menuBar->box.size.y; | rackScroll->box.pos.y = menuBar->box.size.y; | ||||
| @@ -325,6 +325,9 @@ math::Vec Window::getSize() { | |||||
| void Window::setSize(math::Vec size) { | void Window::setSize(math::Vec size) { | ||||
| internal->size = size.max(minWindowSize); | internal->size = size.max(minWindowSize); | ||||
| if (DISTRHO_NAMESPACE::UI* const ui = internal->ui) | |||||
| ui->setSize(internal->size.x, internal->size.y); | |||||
| } | } | ||||