From b9022a9c7cd225434823eb098b6bbc268ab2719f Mon Sep 17 00:00:00 2001 From: Timothy Schoen Date: Fri, 10 Jan 2025 13:49:17 +0100 Subject: [PATCH] Hide graph area resize handles when locked --- Source/Components/GraphArea.h | 60 ++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/Source/Components/GraphArea.h b/Source/Components/GraphArea.h index aa0f155ac..4b1eeaabc 100644 --- a/Source/Components/GraphArea.h +++ b/Source/Components/GraphArea.h @@ -58,36 +58,38 @@ class GraphArea final : public Component nvgDrawRoundedRect(nvg, lineBounds.getX(), lineBounds.getY(), lineBounds.getWidth(), lineBounds.getHeight(), nvgRGBA(0, 0, 0, 0), canvas->graphAreaCol, Corners::objectCornerRadius); - auto& resizeHandleImage = canvas->resizeHandleImage; - int angle = 360; - - auto getVert = [lineBounds](int const index) -> Point { - switch (index) { - case 0: - return lineBounds.getTopLeft(); - case 1: - return lineBounds.getBottomLeft(); - case 2: - return lineBounds.getBottomRight(); - case 3: - return lineBounds.getTopRight(); - default: - return {}; + if(!getValue(canvas->locked)) { + auto& resizeHandleImage = canvas->resizeHandleImage; + int angle = 360; + + auto getVert = [lineBounds](int const index) -> Point { + switch (index) { + case 0: + return lineBounds.getTopLeft(); + case 1: + return lineBounds.getBottomLeft(); + case 2: + return lineBounds.getBottomRight(); + case 3: + return lineBounds.getTopRight(); + default: + return {}; + } + }; + + for (int i = 0; i < 4; i++) { + NVGScopedState scopedState(nvg); + // Rotate around centre + nvgTranslate(nvg, getVert(i).x, getVert(i).y); + nvgRotate(nvg, degreesToRadians(angle)); + nvgTranslate(nvg, -3.0f, -3.0f); + + nvgBeginPath(nvg); + nvgRect(nvg, 0, 0, 9, 9); + nvgFillPaint(nvg, nvgImageAlphaPattern(nvg, 0, 0, 9, 9, 0, resizeHandleImage.getImageId(), canvas->graphAreaCol)); + nvgFill(nvg); + angle -= 90; } - }; - - for (int i = 0; i < 4; i++) { - NVGScopedState scopedState(nvg); - // Rotate around centre - nvgTranslate(nvg, getVert(i).x, getVert(i).y); - nvgRotate(nvg, degreesToRadians(angle)); - nvgTranslate(nvg, -3.0f, -3.0f); - - nvgBeginPath(nvg); - nvgRect(nvg, 0, 0, 9, 9); - nvgFillPaint(nvg, nvgImageAlphaPattern(nvg, 0, 0, 9, 9, 0, resizeHandleImage.getImageId(), canvas->graphAreaCol)); - nvgFill(nvg); - angle -= 90; } }