Skip to content

Commit

Permalink
Merge pull request #1190 from plugdata-team/main
Browse files Browse the repository at this point in the history
Merge main
  • Loading branch information
timothyschoen authored Sep 20, 2023
2 parents c59c2bb + 400ce81 commit 6f51902
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Source/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ StringArray Connection::getMessageFormated()
formatedMessage.add("symbol:");
formatedMessage.add(String(args[0].getSymbol()));
} else if (name == "list") {
formatedMessage.add("list:");
formatedMessage.add("list (" + String(args.size()) + "):");
for (auto& arg : args) {
if (arg.isFloat()) {
formatedMessage.add(String(arg.getFloat()));
Expand Down
10 changes: 5 additions & 5 deletions Source/Dialogs/ConnectionMessageDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ConnectionMessageDisplay

auto halfEditorWidth = getParentComponent()->getWidth() / 2;
auto fontStyle = haveMessage ? FontStyle::Semibold : FontStyle::Regular;
auto textFont = Font(haveMessage ? Fonts::getSemiBoldFont() : Fonts::getCurrentFont());
auto textFont = Font(haveMessage ? Fonts::getSemiBoldFont() : Fonts::getDefaultFont());
textFont.setSizeAndStyle(14, FontStyle::Regular, 1.0f, 0.0f);

int stringWidth;
Expand All @@ -103,10 +103,10 @@ class ConnectionMessageDisplay

messageItemsWithFormat.add(TextStringWithMetrics(stringItem, fontStyle, stringWidth));

if (fontStyle != FontStyle::Monospace) {
// set up font for next item/s - use monospace for values / lists etc
fontStyle = FontStyle::Monospace;
textFont = Font(Fonts::getMonospaceFont());
if (fontStyle != FontStyle::Regular) {
// set up font for next item/s -regular font to support extended character
fontStyle = FontStyle::Regular;
textFont = Font(Fonts::getDefaultFont());
}
}

Expand Down
14 changes: 12 additions & 2 deletions Source/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ void Object::applyBounds()
}
void Object::updateBounds()
{
if (gui) {
// only update if we have a gui and the object isn't been moved by the user
// otherwise PD hasn't been informed of the new position 'while' we are dragging
// so we don't need to update the bounds when an object is being interacted with
if (gui && !isObjectMouseActive) {
// Get the bounds of the object in Pd
auto newBounds = gui->getPdBounds();

Expand Down Expand Up @@ -863,6 +866,10 @@ void Object::mouseUp(MouseEvent const& e)
openHelpPatch();
}

auto objects = cnv->getSelectionOfType<Object>();
for (auto* obj : objects)
obj->isObjectMouseActive = false;

if (ds.wasResized) {

cnv->objectGrid.clearAll();
Expand Down Expand Up @@ -969,6 +976,8 @@ void Object::mouseDrag(MouseEvent const& e)
if (!obj->gui)
continue;

obj->isObjectMouseActive = true;

// Create undo step when we start resizing
if (!ds.wasResized) {
auto* objPtr = static_cast<t_gobj*>(obj->getPointer());
Expand Down Expand Up @@ -1050,6 +1059,7 @@ void Object::mouseDrag(MouseEvent const& e)
int i = 0;
for (auto* selected : selection) {
selected->originalBounds = selected->getBounds().withPosition(mouseDownObjectPositions[i]);
selected->isObjectMouseActive = true;
i++;
}

Expand All @@ -1061,7 +1071,7 @@ void Object::mouseDrag(MouseEvent const& e)
// FIXME: stop the mousedrag event from blocking the objects from redrawing, we shouldn't need to do this? JUCE bug?
if (ds.componentBeingDragged) {
for (auto* object : selection) {

object->isObjectMouseActive = true;
auto newPosition = object->originalBounds.getPosition() + dragDistance;

object->setBufferedToImage(true);
Expand Down
2 changes: 2 additions & 0 deletions Source/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class Object : public Component
bool showActiveState = false;
float activeStateAlpha = 0.0f;

bool isObjectMouseActive = false;

Image activityOverlayImage;

ObjectDragState& ds;
Expand Down
13 changes: 7 additions & 6 deletions Source/Objects/IEMHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,27 +279,28 @@ class IEMHelper {

void updateLabel(std::unique_ptr<ObjectLabel>& label)
{
int fontHeight = getFontHeight();

const String text = getExpandedLabelText();
const String text = ::getValue<String>(labelText);

if (text.isNotEmpty()) {
if (!label) {
label = std::make_unique<ObjectLabel>(object);
object->cnv->addChildComponent(label.get());
}

auto bounds = getLabelBounds();

bounds.translate(0, fontHeight / -2.0f);
bounds.translate(0, bounds.getHeight() / -2.0f);

label->setFont(Font(fontHeight));
label->setFont(Font(bounds.getHeight()));
label->setBounds(bounds);
label->setText(text, dontSendNotification);

label->setColour(Label::textColourId, getLabelColour());

object->cnv->addAndMakeVisible(label.get());
label->setVisible(true);
} else {
if (label)
label->setVisible(false);
label.reset(nullptr);
}
}
Expand Down

0 comments on commit 6f51902

Please sign in to comment.