Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Libraries/nanovg
Submodule nanovg updated 2 files
+4 −4 src/nanovg.cpp
+3 −3 src/nanovg_gl.h
2 changes: 1 addition & 1 deletion Source/Iolet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void Iolet::render(NVGcontext* nvg)
nvgSave(nvg);

if (isLocked || !(overObject || isHovering) || (getValue<bool>(patchDownwardsOnly) && isInlet)) {
auto clipBounds = getLocalArea(object, object->getLocalBounds().toFloat().reduced(Object::margin + 0.55f));
auto clipBounds = getLocalArea(object, object->getLocalBounds().toFloat().reduced(Object::margin));
nvgIntersectRoundedScissor(nvg, clipBounds.getX(), clipBounds.getY(), clipBounds.getWidth(), clipBounds.getHeight(), Corners::objectCornerRadius);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ void Object::performRender(NVGcontext* nvg)
auto backgroundColour = convertColour(getLookAndFeel().findColour(PlugDataColour::textObjectBackgroundColourId));
auto outlineColour = convertColour(getLookAndFeel().findColour(PlugDataColour::objectOutlineColourId));

nvgDrawRoundedRect(nvg, b.getX() + 0.5f, b.getY() + 0.5f, b.getWidth() - 1.0f, b.getHeight() - 1.0f, backgroundColour, isSelected() ? selectedOutlineColour : outlineColour, Corners::objectCornerRadius);
nvgDrawRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), backgroundColour, isSelected() ? selectedOutlineColour : outlineColour, Corners::objectCornerRadius);

nvgTranslate(nvg, margin, margin);
textEditorRenderer.renderJUCEComponent(nvg, *newObjectEditor, getValue<float>(cnv->zoomScale) * cnv->getRenderScale());
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/ArrayObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ class ArrayObject final : public ObjectBase {

void render(NVGcontext* nvg) override
{
auto b = getLocalBounds().toFloat().reduced(0.5f);
auto b = getLocalBounds().toFloat();
auto backgroundColour = nvgRGBA(0, 0, 0, 0);
auto selectedOutlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectSelectedOutlineColourId));
auto outlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectOutlineColourId));
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/BangObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class BangObject final : public ObjectBase {

void render(NVGcontext* nvg) override
{
auto b = getLocalBounds().toFloat().reduced(0.5f);
auto b = getLocalBounds().toFloat();

auto foregroundColour = convertColour(getValue<Colour>(iemHelper.primaryColour)); // TODO: this is some bad threading practice!

Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/BicoeffObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class BicoeffGraph : public Component

void render(NVGcontext* nvg) override
{
auto b = getLocalBounds().reduced(0.5f);
auto b = getLocalBounds();
auto backgroundColour = convertColour(object->cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectBackgroundColourId));
auto selectedOutlineColour = convertColour(object->cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectSelectedOutlineColourId));
auto outlineColour = convertColour(object->cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectOutlineColourId));
Expand Down
43 changes: 25 additions & 18 deletions Source/Objects/FloatAtomObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class FloatAtomObject final : public ObjectBase {

float value = 0.0f;

NVGcolor backgroundColour;
NVGcolor selectedOutlineColour;
NVGcolor outlineColour;
NVGcolor flagColour;

public:
FloatAtomObject(pd::WeakReference obj, Object* parent)
: ObjectBase(obj, parent)
Expand Down Expand Up @@ -133,6 +138,12 @@ class FloatAtomObject final : public ObjectBase {
input.setColour(Label::textWhenEditingColourId, cnv->editor->getLookAndFeel().findColour(PlugDataColour::canvasTextColourId));
input.setColour(Label::textColourId, cnv->editor->getLookAndFeel().findColour(PlugDataColour::canvasTextColourId));
input.setColour(TextEditor::textColourId, cnv->editor->getLookAndFeel().findColour(PlugDataColour::canvasTextColourId));

backgroundColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectBackgroundColourId));
selectedOutlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectSelectedOutlineColourId));
outlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectOutlineColourId));
flagColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectInternalOutlineColour));

repaint();
}

Expand Down Expand Up @@ -168,18 +179,23 @@ class FloatAtomObject final : public ObjectBase {

void render(NVGcontext* nvg) override
{
auto b = getLocalBounds().toFloat().reduced(0.5f);
auto backgroundColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectBackgroundColourId));
auto selectedOutlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectSelectedOutlineColourId));
auto outlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectOutlineColourId));
bool highlighed = hasKeyboardFocus(true) && ::getValue<bool>(object->locked);
auto b = getLocalBounds().toFloat();
auto sb = b.reduced(0.5f);

nvgDrawRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), backgroundColour, (object->isSelected() || highlighed) ? selectedOutlineColour : outlineColour, Corners::objectCornerRadius);
bool active = hasKeyboardFocus(true) && ::getValue<bool>(object->locked);

nvgSave(nvg);
nvgIntersectRoundedScissor(nvg, b.getX() + 0.25f, b.getY() + 0.25f, b.getWidth() - 0.5f, b.getHeight() - 0.5f, Corners::objectCornerRadius);
nvgIntersectRoundedScissor(nvg, sb.getX(), sb.getY(), sb.getWidth(), sb.getHeight(), Corners::objectCornerRadius);

nvgBeginPath(nvg);
nvgFillColor(nvg, backgroundColour);
nvgRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight());
nvgFill(nvg);

input.render(nvg);

nvgFillColor(nvg, convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectInternalOutlineColour)));
// draw flag
nvgFillColor(nvg, active ? selectedOutlineColour : flagColour);
nvgBeginPath(nvg);
nvgMoveTo(nvg, b.getRight() - 8, b.getY());
nvgLineTo(nvg, b.getRight(), b.getY());
Expand All @@ -189,16 +205,7 @@ class FloatAtomObject final : public ObjectBase {

nvgRestore(nvg);

if (object->isSelected()) // If object is selected, draw outline over top too, so the flag doesn't poke into the selected outline
{
nvgBeginPath(nvg);
nvgRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), Corners::objectCornerRadius);
nvgStrokeColor(nvg, selectedOutlineColour);
nvgStrokeWidth(nvg, 1.0f);
nvgStroke(nvg);
}

input.render(nvg);
nvgDrawRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), nvgRGBAf(0, 0, 0, 0), (active || object->isSelected()) ? selectedOutlineColour : outlineColour, Corners::objectCornerRadius);
}

void updateLabel() override
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/FunctionObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class FunctionObject final : public ObjectBase {
bool selected = object->isSelected() && !cnv->isGraph;
bool editing = cnv->locked == var(true) || cnv->presentationMode == var(true) || ModifierKeys::getCurrentModifiers().isCtrlDown();

auto b = getLocalBounds().toFloat().reduced(0.5f);
auto b = getLocalBounds().toFloat();
auto backgroundColour = convertColour(Colour::fromString(secondaryColour.toString()));
auto foregroundColour = convertColour(Colour::fromString(primaryColour.toString()));
auto selectedOutlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectSelectedOutlineColourId));
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/KnobObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ class KnobObject : public ObjectBase {

void render(NVGcontext* nvg) override
{
auto b = getLocalBounds().toFloat().reduced(0.5f);
auto b = getLocalBounds().toFloat();
auto bgColour = Colour::fromString(secondaryColour.toString());

if (getProperties()["hover"])
Expand Down
59 changes: 33 additions & 26 deletions Source/Objects/ListObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ class ListObject final : public ObjectBase {
Value max = SynchronousValue(0.0f);
Value sizeProperty = SynchronousValue();

NVGcolor backgroundColour;
NVGcolor selectedOutlineColour;
NVGcolor outlineColour;
NVGcolor flagColour;

bool editorActive = false;


public:
ListObject(pd::WeakReference obj, Object* parent)
: ObjectBase(obj, parent)
Expand All @@ -27,6 +35,7 @@ class ListObject final : public ObjectBase {

listLabel.onEditorHide = [this]() {
stopEdition();
editorActive = false;
};

listLabel.onTextChange = [this]() {
Expand All @@ -41,16 +50,19 @@ class ListObject final : public ObjectBase {
auto* editor = listLabel.getCurrentTextEditor();
editor->setColour(TextEditor::focusedOutlineColourId, Colours::transparentBlack);
editor->setBorder({ 0, 1, 3, 0 });
editorActive = true;
};

listLabel.dragStart = [this]() {
startEdition();
editorActive = true;
};

listLabel.onValueChange = [this](float) { updateFromGui(); };

listLabel.dragEnd = [this]() {
stopEdition();
editorActive = false;
};

listLabel.addMouseListener(this, false);
Expand Down Expand Up @@ -162,19 +174,25 @@ class ListObject final : public ObjectBase {

void render(NVGcontext* nvg) override
{
auto b = getLocalBounds().toFloat().reduced(0.5f);
auto backgroundColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectBackgroundColourId));
auto selectedOutlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectSelectedOutlineColourId));
auto outlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectOutlineColourId));
auto b = getLocalBounds().toFloat();
auto sb = b.reduced(0.5f);

bool highlighed = editorActive && getValue<bool>(object->locked);

nvgDrawRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), backgroundColour, object->isSelected() ? selectedOutlineColour : outlineColour, Corners::objectCornerRadius);
nvgSave(nvg);
nvgIntersectRoundedScissor(nvg, sb.getX(), sb.getY(), sb.getWidth(), sb.getHeight(), Corners::objectCornerRadius);

nvgBeginPath(nvg);
nvgFillColor(nvg, backgroundColour);
nvgRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight());
nvgFill(nvg);

imageRenderer.renderJUCEComponent(nvg, listLabel, getImageScale());

nvgSave(nvg);
nvgIntersectRoundedScissor(nvg, b.getX() + 0.25f, b.getY() + 0.25f, b.getWidth() - 0.5f, b.getHeight() - 0.5f, Corners::objectCornerRadius);
nvgIntersectRoundedScissor(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), Corners::objectCornerRadius);

nvgFillColor(nvg, convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectInternalOutlineColour)));
// draw flag
nvgFillColor(nvg, highlighed ? selectedOutlineColour : flagColour);
nvgBeginPath(nvg);
nvgMoveTo(nvg, b.getRight() - 8, b.getY());
nvgLineTo(nvg, b.getRight(), b.getY());
Expand All @@ -191,31 +209,20 @@ class ListObject final : public ObjectBase {

nvgRestore(nvg);

if (object->isSelected()) // If object is selected, draw outline over top too, so the flag doesn't poke into the selected outline
{
nvgBeginPath(nvg);
nvgRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), Corners::objectCornerRadius);
nvgStrokeColor(nvg, selectedOutlineColour);
nvgStrokeWidth(nvg, 1.0f);
nvgStroke(nvg);
}

bool highlighed = hasKeyboardFocus(true) && getValue<bool>(object->locked);

if (highlighed) {
nvgStrokeColor(nvg, convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectSelectedOutlineColourId)));
nvgStrokeWidth(nvg, 2.0f);
nvgBeginPath(nvg);
nvgRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), Corners::objectCornerRadius);
nvgStroke(nvg);
}
nvgDrawRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), nvgRGBAf(0, 0, 0, 0), (object->isSelected() || highlighed) ? selectedOutlineColour : outlineColour, Corners::objectCornerRadius);
}

void lookAndFeelChanged() override
{
listLabel.setColour(Label::textWhenEditingColourId, cnv->editor->getLookAndFeel().findColour(PlugDataColour::canvasTextColourId));
listLabel.setColour(Label::textColourId, cnv->editor->getLookAndFeel().findColour(PlugDataColour::canvasTextColourId));
listLabel.setColour(TextEditor::textColourId, cnv->editor->getLookAndFeel().findColour(PlugDataColour::canvasTextColourId));

backgroundColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectBackgroundColourId));
selectedOutlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectSelectedOutlineColourId));
outlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectOutlineColourId));
flagColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectInternalOutlineColour));

repaint();
}

Expand Down
55 changes: 29 additions & 26 deletions Source/Objects/MessageObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ class MessageObject final : public ObjectBase
bool isDown = false;
bool isLocked = false;

NVGcolor backgroundColour;
NVGcolor selectedOutlineColour;
NVGcolor outlineColour;
NVGcolor guiOutlinetColour;
NVGcolor flagColour;

public:
MessageObject(pd::WeakReference obj, Object* parent)
: ObjectBase(obj, parent)
{
objectParameters.addParamInt("Width (chars)", cDimensions, &sizeProperty);

lookAndFeelChanged();
}

void update() override
Expand Down Expand Up @@ -140,17 +148,17 @@ class MessageObject final : public ObjectBase

void render(NVGcontext* nvg) override
{
auto b = getLocalBounds().toFloat().reduced(0.5f);

auto backgroundColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectBackgroundColourId));
auto selectedOutlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectSelectedOutlineColourId));
auto outlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectOutlineColourId));
auto flagColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectInternalOutlineColour));

nvgDrawRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), backgroundColour, object->isSelected() ? selectedOutlineColour : outlineColour, Corners::objectCornerRadius);
auto b = getLocalBounds().toFloat();
auto sb = b.reduced(0.5f); // reduce size of background to stop AA edges from showing through

nvgSave(nvg);
nvgIntersectRoundedScissor(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), Corners::objectCornerRadius);
nvgRoundedScissor(nvg, sb.getX(), sb.getY(), sb.getWidth(), sb.getHeight(), Corners::objectCornerRadius);

// Background
nvgBeginPath(nvg);
nvgRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight());
nvgFillColor(nvg, backgroundColour);
nvgFill(nvg);

float bRight = b.getRight(); // offset to make it go completely under outline
float bY = b.getY();
Expand All @@ -163,31 +171,25 @@ class MessageObject final : public ObjectBase
nvgRect(nvg, b.getRight() - d, b.getY(), d, b.getHeight());
nvgRect(nvg, b.getX(), b.getBottom() - d, b.getWidth(), d);
nvgRect(nvg, b.getX(), b.getY(), d, b.getHeight());
nvgFillColor(nvg, convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::outlineColourId)));
nvgFillColor(nvg, guiOutlinetColour);
nvgFill(nvg);
}

// Create flag path
auto isObjectHighlighted = (object->isSelected() || (isDown && getValue<bool>(object->locked)));

// draw flag
nvgBeginPath(nvg);
nvgMoveTo(nvg, bRight, bY);
nvgLineTo(nvg, bRight - d, bY + d);
nvgLineTo(nvg, bRight - d, bBottom - d);
nvgLineTo(nvg, bRight, bBottom);
nvgClosePath(nvg);

nvgFillColor(nvg, flagColour);
nvgFillColor(nvg, isDown && ::getValue<bool>(object->locked) ? selectedOutlineColour : flagColour);
nvgFill(nvg);

nvgRestore(nvg);

if (object->isSelected()) // If object is selected, draw outline over top too, so the flag doesn't poke into the selected outline
{
nvgBeginPath(nvg);
nvgRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), Corners::objectCornerRadius);
nvgStrokeColor(nvg, selectedOutlineColour);
nvgStrokeWidth(nvg, 1.0f);
nvgStroke(nvg);
}
nvgDrawRoundedRect(nvg, b.getX(), b.getY(), b.getWidth(), b.getHeight(), nvgRGBAf(0, 0, 0, 0), isObjectHighlighted ? selectedOutlineColour : outlineColour, Corners::objectCornerRadius);

if (editor) {
imageRenderer.renderJUCEComponent(nvg, *editor, getImageScale());
Expand Down Expand Up @@ -221,6 +223,12 @@ class MessageObject final : public ObjectBase

void lookAndFeelChanged() override
{
backgroundColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectBackgroundColourId));
selectedOutlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectSelectedOutlineColourId));
outlineColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectOutlineColourId));
flagColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::guiObjectInternalOutlineColour));
guiOutlinetColour = convertColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::outlineColourId));

updateTextLayout();
}

Expand Down Expand Up @@ -395,11 +403,6 @@ class MessageObject final : public ObjectBase
return false;
}

bool hideInGraph() override
{
return true;
}

std::unique_ptr<ComponentBoundsConstrainer> createConstrainer() override
{
return TextObjectHelper::createConstrainer(object);
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/MousePadObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class MousePadObject final : public ObjectBase {

void render(NVGcontext* nvg) override
{
auto b = getLocalBounds().toFloat().reduced(0.5f);
auto b = getLocalBounds().toFloat();
Colour fillColour, outlineColour;
if(auto x = ptr.get<t_fake_pad>()) {
fillColour = Colour(x->x_color[0], x->x_color[1], x->x_color[2]);
Expand Down
2 changes: 1 addition & 1 deletion Source/Objects/NumberObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class NumberObject final : public ObjectBase {

void render(NVGcontext* nvg) override
{
auto b = getLocalBounds().toFloat().reduced(0.5f);
auto b = getLocalBounds().toFloat();

bool selected = object->isSelected() && !cnv->isGraph;
auto backgroundColour = convertColour(iemHelper.getBackgroundColour());
Expand Down
Loading