Skip to content

Commit

Permalink
Fixed object browser bugs, made object reference panel slightly better
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyschoen committed Oct 3, 2023
1 parent 528d6a9 commit 99ee10b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Source/Dialogs/Deken.h
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ class Deken : public Component
listBox.setBounds(getLocalBounds().withHeight(listBox.getHeight()));
listBox.getViewport()->setBounds(bounds);

refreshButton.setBounds(getLocalBounds().removeFromTop(40).removeFromLeft(40));
refreshButton.setBounds(getLocalBounds().removeFromTop(40).removeFromLeft(40).translated(2, 0));
}

// Show error message in statusbar
Expand Down
4 changes: 2 additions & 2 deletions Source/Dialogs/Dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void Dialogs::showHeavyExportDialog(std::unique_ptr<Dialog>* target, Component*
void Dialogs::showObjectBrowserDialog(std::unique_ptr<Dialog>* target, Component* parent)
{

auto* dialog = new Dialog(target, parent, 750, 450, true);
auto* dialog = new Dialog(target, parent, 750, 480, true);
auto* dialogContent = new ObjectBrowserDialog(parent, dialog);

dialog->setViewedComponent(dialogContent);
Expand All @@ -227,7 +227,7 @@ void Dialogs::showObjectBrowserDialog(std::unique_ptr<Dialog>* target, Component

void Dialogs::showObjectReferenceDialog(std::unique_ptr<Dialog>* target, Component* parent, String const& objectName)
{
auto* dialog = new Dialog(target, parent, 750, 450, true);
auto* dialog = new Dialog(target, parent, 750, 480, true);
auto* dialogContent = new ObjectReferenceDialog(dynamic_cast<PluginEditor*>(parent), false);

dialogContent->showObject(objectName);
Expand Down
24 changes: 20 additions & 4 deletions Source/Dialogs/ObjectBrowserDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,10 @@ class ObjectViewer : public Component {
buttonBounds.removeFromTop(5);
openHelp.setBounds(buttonBounds.removeFromTop(25));

objectDragArea.setBounds(getLocalBounds().withTrimmedTop(48).withTrimmedBottom(130).withTrimmedLeft(12).withTrimmedRight(6));
objectDragArea.setBounds(getLocalBounds().withTrimmedTop(48).withTrimmedBottom(120).withTrimmedLeft(12).withTrimmedRight(6));
}


void paintOverChildren(Graphics& g) override
{
g.setColour(findColour(PlugDataColour::outlineColourId));
Expand All @@ -268,7 +269,7 @@ class ObjectViewer : public Component {
auto objectDisplayBounds = infoBounds.removeFromTop(100).reduced(60);

auto colour = findColour(PlugDataColour::panelTextColourId);
Fonts::drawStyledText(g, objectName, getLocalBounds().removeFromTop(35).translated(0, 4), colour, Bold, 16.0f, Justification::centred);
Fonts::drawStyledText(g, objectName, getLocalBounds().removeFromTop(24).translated(0, 4), colour, Bold, 16.0f, Justification::centred);

auto numInlets = unknownInletLayout ? "Unknown" : String(inlets.size());
auto numOutlets = unknownOutletLayout ? "Unknown" : String(outlets.size());
Expand Down Expand Up @@ -688,7 +689,7 @@ class ObjectSearchComponent : public Component

input.setBounds(inputBounds);

clearButton.setBounds(inputBounds.removeFromRight(32));
clearButton.setBounds(inputBounds.removeFromRight(30).translated(4, 0));

listBox.setBounds(tableBounds);
}
Expand Down Expand Up @@ -812,7 +813,7 @@ class ObjectBrowserDialog : public Component {

void resized() override
{
auto b = getLocalBounds().reduced(1);
auto b = getLocalBounds().withTrimmedTop(40).reduced(1);
objectViewer.setBounds(b.removeFromRight(260));
objectSearch.setBounds(b);
b.removeFromTop(35);
Expand All @@ -827,6 +828,21 @@ class ObjectBrowserDialog : public Component {
{
g.setColour(findColour(PlugDataColour::panelBackgroundColourId));
g.fillRoundedRectangle(getLocalBounds().reduced(1).toFloat(), Corners::windowCornerRadius);

g.setColour(findColour(PlugDataColour::panelBackgroundColourId));
g.fillRoundedRectangle(getLocalBounds().reduced(1).toFloat(), Corners::windowCornerRadius);

g.setColour(findColour(PlugDataColour::toolbarBackgroundColourId));

auto toolbarBounds = Rectangle<float>(1, 1, getWidth() - 2, 40);
g.fillRoundedRectangle(toolbarBounds, Corners::windowCornerRadius);
g.fillRect(toolbarBounds.withTrimmedTop(15.0f));

g.setColour(findColour(PlugDataColour::toolbarOutlineColourId));
g.drawHorizontalLine(40, 0.0f, getWidth());
g.drawHorizontalLine(70, 0.0f, getWidth());

Fonts::drawStyledText(g, "Object Browser", Rectangle<float>(0.0f, 4.0f, getWidth(), 32.0f), findColour(PlugDataColour::panelTextColourId), Semibold, 15, Justification::centred);
}

private:
Expand Down
62 changes: 46 additions & 16 deletions Source/Dialogs/ObjectReferenceDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@ class ObjectInfoPanel : public Component {
g.setColour(findColour(PlugDataColour::outlineColourId));
g.drawLine(0, 1, getWidth(), 0);

Fonts::drawStyledText(g, categoryName, getLocalBounds().toFloat().removeFromTop(24), findColour(PlugDataColour::panelTextColourId), FontStyle::Bold, 14.0f);
Fonts::drawStyledText(g, categoryName, getLocalBounds().toFloat().removeFromTop(24).translated(2, 0), findColour(PlugDataColour::panelTextColourId), FontStyle::Bold, 14.0f);

float totalHeight = 24;
for (int i = 0; i < panelContent.size(); i++) {
auto textHeight = layouts[i].getHeight();
auto bounds = Rectangle<float>(24.0f, totalHeight + 6.0f, getWidth() - 48.0f, textHeight);

Fonts::drawStyledText(g, panelContent[i].first, bounds.removeFromLeft(128), findColour(PlugDataColour::panelTextColourId), FontStyle::Semibold, 13.5f);

auto bounds = Rectangle<float>(36.0f, totalHeight + 6.0f, getWidth() - 48.0f, textHeight);
auto nameWidth = std::max(Fonts::getSemiBoldFont().getStringWidth(panelContent[i].first), 64);

Fonts::drawStyledText(g, panelContent[i].first, bounds.removeFromLeft(nameWidth), findColour(PlugDataColour::panelTextColourId), FontStyle::Semibold, 13.5f);

layouts[i].draw(g, bounds);

g.setColour(findColour(PlugDataColour::outlineColourId));
g.drawLine(24.0f, totalHeight, getWidth() - 24.0f, totalHeight);
g.drawLine(36.0f, totalHeight, getWidth() - 24.0f, totalHeight);

totalHeight += textHeight + 12;
}
Expand All @@ -47,10 +49,27 @@ class ObjectInfoPanel : public Component {

int totalHeight = 24;
for (auto const& [name, description] : panelContent) {
auto nameWidth = std::max(Fonts::getSemiBoldFont().getStringWidth(name), 64);

AttributedString str;
str.append(description, Font(13.5f), findColour(PlugDataColour::panelTextColourId));

auto lines = StringArray::fromLines(description);

// Draw anything between () as bold
for (auto const& line : lines) {
if (line.contains("(") && line.contains(")")) {
auto type = line.fromFirstOccurrenceOf("(", false, false).upToFirstOccurrenceOf(")", false, false);
auto description = line.fromFirstOccurrenceOf(")", false, false);
str.append(type + ":", Fonts::getSemiBoldFont().withHeight(13.5f), findColour(PlugDataColour::panelTextColourId));

str.append(description + "\n", Font(13.5f), findColour(PlugDataColour::panelTextColourId));
} else {
str.append(line, Font(13.5f), findColour(PlugDataColour::panelTextColourId));
}
}

TextLayout layout;
layout.createLayout(str, width - 192.0f);
layout.createLayout(str, width - (nameWidth + 64.0f));
layouts.add(layout);
totalHeight += layout.getHeight() + 12;
}
Expand Down Expand Up @@ -162,7 +181,7 @@ class ObjectInfoPanel : public Component {
{
categoriesViewport.setBounds(getLocalBounds());

int totalHeight = 0;
int totalHeight = 24;
for (auto* category : categories) {
category->recalculateLayout(getWidth());
category->setTopLeftPosition(0, totalHeight);
Expand Down Expand Up @@ -203,12 +222,9 @@ class ObjectReferenceDialog : public Component {

void resized() override
{
backButton.setBounds(8, 6, 40, 40);

auto buttonBounds = getLocalBounds().removeFromBottom(80).reduced(30, 0).translated(0, -30);
buttonBounds.removeFromTop(10);
backButton.setBounds(2, 0, 40, 40);

auto rightPanelBounds = getLocalBounds().removeFromRight(getLocalBounds().proportionOfWidth(0.7f)).reduced(20, 40);
auto rightPanelBounds = getLocalBounds().withTrimmedTop(40).removeFromRight(getLocalBounds().proportionOfWidth(0.65f)).reduced(20, 0);

objectInfoPanel.setBounds(rightPanelBounds);
}
Expand All @@ -217,16 +233,30 @@ class ObjectReferenceDialog : public Component {
{
g.setColour(findColour(PlugDataColour::panelBackgroundColourId));
g.fillRoundedRectangle(getLocalBounds().reduced(1).toFloat(), Corners::windowCornerRadius);

g.setColour(findColour(PlugDataColour::panelBackgroundColourId));
g.fillRoundedRectangle(getLocalBounds().reduced(1).toFloat(), Corners::windowCornerRadius);

g.setColour(findColour(PlugDataColour::toolbarBackgroundColourId));

auto toolbarBounds = Rectangle<float>(1, 1, getWidth() - 2, 40);
g.fillRoundedRectangle(toolbarBounds, Corners::windowCornerRadius);
g.fillRect(toolbarBounds.withTrimmedTop(15.0f));

g.setColour(findColour(PlugDataColour::toolbarOutlineColourId));
g.drawHorizontalLine(40, 0.0f, getWidth());

if (objectName.isEmpty())
return;

auto leftPanelBounds = getLocalBounds().withTrimmedRight(getLocalBounds().proportionOfWidth(0.7f));
auto leftPanelBounds = getLocalBounds().withTrimmedRight(getLocalBounds().proportionOfWidth(0.65f));

auto infoBounds = leftPanelBounds.withTrimmedBottom(100).withTrimmedTop(100).withTrimmedLeft(5).reduced(10);
g.drawVerticalLine(leftPanelBounds.getRight(), 40.0f, getHeight() - 40.0f);

auto infoBounds = leftPanelBounds.withTrimmedBottom(100).withTrimmedTop(140).withTrimmedLeft(5).reduced(10);
auto objectDisplayBounds = leftPanelBounds.removeFromTop(140);

Fonts::drawStyledText(g, "Reference: " + objectName, getLocalBounds().removeFromTop(35).translated(0, 4), findColour(PlugDataColour::panelTextColourId), Bold, 16, Justification::centred);
Fonts::drawStyledText(g, "Object Reference: " + objectName, getLocalBounds().removeFromTop(35).translated(0, 4), findColour(PlugDataColour::panelTextColourId), Bold, 16, Justification::centred);

auto colour = findColour(PlugDataColour::panelTextColourId);

Expand Down

0 comments on commit 99ee10b

Please sign in to comment.