Skip to content

Commit

Permalink
Expanded tooltip api (#1209)
Browse files Browse the repository at this point in the history
* Expanded tooltip api

1. expand the tooltip class in jucegui to have a structured row
2. use it in the mod depth window

* Ooops - retain a proir behavior
  • Loading branch information
baconpaul authored Aug 28, 2024
1 parent 6dcf770 commit 64ee008
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src-ui/app/SCXTEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ struct SCXTEditor : sst::jucegui::components::WindowPanel, juce::DragAndDropCont

void showTooltip(const juce::Component &relativeTo);
void hideTooltip();
void setTooltipContents(const std::string &title,
const std::vector<sst::jucegui::components::ToolTip::Row> &rows);
void setTooltipContents(const std::string &title, const std::vector<std::string> &display);
void setTooltipContents(const std::string &title, const std::string &display)
{
Expand Down
29 changes: 23 additions & 6 deletions src-ui/app/edit-screen/components/ModPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@ template <typename GZTrait> struct ModRow : juce::Component, HasEditor
}
sl += vl;

std::vector<jcmp::ToolTip::Row> rows;
auto lineOne = sl + " " + u8"\U00002192" + " " + tl;
rows.push_back(jcmp::ToolTip::Row(lineOne));

auto &epo = parent->routingTable.routes[index].extraPayload;
if (!epo.has_value())
Expand All @@ -340,18 +342,33 @@ template <typename GZTrait> struct ModRow : juce::Component, HasEditor
auto ep = *epo;
datamodel::pmd &md = ep.targetMetadata;

bool isSourceBipolar{false}; // fixme - we shoudl determine this one day
auto v = md.modulationNaturalToString(ep.targetBaseValue,
at.value * (md.maxVal - md.minVal), false);
at.value * (md.maxVal - md.minVal), isSourceBipolar);

std::string modLineOne{}, modLineTwo{};
auto rMove = jcmp::ToolTip::Row();
auto rDelta = jcmp::ToolTip::Row();

if (v.has_value())
{
modLineOne = v->singleLineModulationSummary;
modLineTwo =
fmt::format("depth={:.2f}%, {}={}", at.value * 100, u8"\U00000394", v->changeUp);
if (isSourceBipolar)
{
rMove.rowLeadingGlyph = jcmp::GlyphPainter::GlyphType::LINK;
rMove.centerAlignText = v->baseValue;
rMove.leftAlignText = v->valDown;
rMove.rightAlignText = v->valUp;
}
else
{
rMove.rowLeadingGlyph = jcmp::GlyphPainter::GlyphType::LINK;
rMove.centerAlignText = v->baseValue;
rMove.rightAlignText = v->valUp;
}
rDelta.rowLeadingGlyph = jcmp::GlyphPainter::GlyphType::SPEAKER;
rDelta.leftAlignText = fmt::format("{:.2f}%", at.value * 100);
rDelta.rightAlignText = fmt::format("{}", v->changeUp);
}
editor->setTooltipContents(lineOne, {modLineOne, modLineTwo});
editor->setTooltipContents(lineOne, {rMove, rDelta});
}

void pushRowUpdate(bool forceUpdate = false)
Expand Down
12 changes: 12 additions & 0 deletions src-ui/app/editor-impl/SCXTEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,18 @@ void SCXTEditor::showTooltip(const juce::Component &relativeTo)
void SCXTEditor::hideTooltip() { toolTip->setVisible(false); }

void SCXTEditor::setTooltipContents(const std::string &title, const std::vector<std::string> &data)
{
std::vector<sst::jucegui::components::ToolTip::Row> d;
std::transform(data.begin(), data.end(), std::back_inserter(d), [](auto &a) {
auto r = sst::jucegui::components::ToolTip::Row(a);
r.leftIsMonospace = true;
return r;
});
toolTip->setTooltipTitleAndData(title, d);
}

void SCXTEditor::setTooltipContents(const std::string &title,
const std::vector<sst::jucegui::components::ToolTip::Row> &data)
{
toolTip->setTooltipTitleAndData(title, data);
}
Expand Down

0 comments on commit 64ee008

Please sign in to comment.