Skip to content

Commit

Permalink
Hide graph area resize handles when locked
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyschoen committed Jan 10, 2025
1 parent eb19226 commit b9022a9
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions Source/Components/GraphArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> {
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<bool>(canvas->locked)) {
auto& resizeHandleImage = canvas->resizeHandleImage;
int angle = 360;

auto getVert = [lineBounds](int const index) -> Point<float> {
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<float>(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<float>(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;
}
}

Expand Down

0 comments on commit b9022a9

Please sign in to comment.