diff --git a/libs/escape-from-vstgui/include/efvg/escape_from_vstgui.h b/libs/escape-from-vstgui/include/efvg/escape_from_vstgui.h index 876c586e1e7..65607faa87b 100644 --- a/libs/escape-from-vstgui/include/efvg/escape_from_vstgui.h +++ b/libs/escape-from-vstgui/include/efvg/escape_from_vstgui.h @@ -72,7 +72,7 @@ inline void printStack(const char *where) char **strs = backtrace_symbols(callstack, frames); std::ostringstream oss; oss << "----- " << where << " -----\n"; - for (i = 3; i < frames - 1 && i < 20; ++i) + for (i = 0; i < frames - 1 && i < 20; ++i) { oss << strs[i] << "\n"; } @@ -93,7 +93,7 @@ struct DebugAllocRecord char **strs = backtrace_symbols(callstack, frames); std::ostringstream oss; oss << "----- " << where << " -----\n"; - for (i = 3; i < frames - 1 && i < 20; ++i) + for (i = 0; i < frames - 1 && i < 20; ++i) { oss << strs[i] << "\n"; } @@ -1331,6 +1331,10 @@ struct CControl : public CView } ~CControl() { + if (mGradient) + mGradient->forget(); + if (mGradientHL) + mGradientHL->forget(); /* if (bg) bg->forget(); It seems that is not the semantic of CControl! @@ -1404,8 +1408,25 @@ struct CControl : public CView COLPAIR(TextColorHighlighted); COLPAIR(FrameColorHighlighted); - GSPAIR(Gradient, CGradient *, CGradient *, nullptr); - GSPAIR(GradientHighlighted, CGradient *, CGradient *, nullptr); + CGradient *mGradient = nullptr; + CGradient *getGradient() const { return mGradient; } + virtual void setGradient(CGradient *g) + { + g->remember(); + if (mGradient) + mGradient->forget(); + mGradient = g; + } + + CGradient *mGradientHL = nullptr; + CGradient *getGradientHighlighted() const { return mGradientHL; } + virtual void setGradientHighlighted(CGradient *g) + { + g->remember(); + if (mGradientHL) + mGradientHL->forget(); + mGradientHL = g; + } COLPAIR(FillColor); COLPAIR(TextColor); diff --git a/src/gui/CTextButtonWithHover.cpp b/src/gui/CTextButtonWithHover.cpp index 43245ad16be..afb11133381 100644 --- a/src/gui/CTextButtonWithHover.cpp +++ b/src/gui/CTextButtonWithHover.cpp @@ -19,7 +19,7 @@ template struct HoverGuard { HoverGuard() {} - void activate(std::function getf, std::function isetf, T &overr) + void activate(std::function getf, std::function isetf, T overr) { active = true; setf = isetf; @@ -30,11 +30,42 @@ template struct HoverGuard ~HoverGuard() { if (active) + { setf(orig); + } } bool active = false; - std::function setf; + std::function setf; + T orig; +}; + +template struct HoverGuardRF +{ + HoverGuardRF() {} + + void activate(std::function getf, std::function isetf, T overr) + { + active = true; + setf = isetf; + orig = getf(); + if (orig) + orig->remember(); + setf(overr); + } + + ~HoverGuardRF() + { + if (active) + { + setf(orig); + if (orig) + orig->forget(); + } + } + + bool active = false; + std::function setf; T orig; }; @@ -45,15 +76,22 @@ void CTextButtonWithHover::draw(VSTGUI::CDrawContext *context) HoverGuard hg_##x; \ if (hc_##x.isSet) \ { \ - hg_##x.activate([this]() { return get##x(); }, [this](T &c) { set##x(c); }, hc_##x.item); \ + hg_##x.activate([this]() { return get##x(); }, [this](T c) { set##x(c); }, hc_##x.item); \ + } + +#define DO_HOVERRF(x, T) \ + HoverGuardRF hg_##x; \ + if (hc_##x.isSet) \ + { \ + hg_##x.activate([this]() { return get##x(); }, [this](T c) { set##x(c); }, hc_##x.item); \ } if (isHovered) { - DO_HOVER(Gradient, VSTGUI::CGradient *); + DO_HOVERRF(Gradient, VSTGUI::CGradient *); DO_HOVER(FrameColor, VSTGUI::CColor); DO_HOVER(TextColor, VSTGUI::CColor); - DO_HOVER(GradientHighlighted, VSTGUI::CGradient *); + DO_HOVERRF(GradientHighlighted, VSTGUI::CGradient *); DO_HOVER(FrameColorHighlighted, VSTGUI::CColor); DO_HOVER(TextColorHighlighted, VSTGUI::CColor); CTextButton::draw(context); diff --git a/src/gui/CTextButtonWithHover.h b/src/gui/CTextButtonWithHover.h index fc6672ae8a4..0a6fb8e0ba7 100644 --- a/src/gui/CTextButtonWithHover.h +++ b/src/gui/CTextButtonWithHover.h @@ -35,11 +35,19 @@ class CTextButtonWithHover : public VSTGUI::CTextButton { if (isSet && item) { - // item->forget(); + item->forget(); item = nullptr; } } - T item = T(); + void set(T v) + { + isSet = true; + v->remember(); + if (item) + item->forget(); + item = v; + } + T item = nullptr; bool isSet = false; }; @@ -48,17 +56,7 @@ class CTextButtonWithHover : public VSTGUI::CTextButton : CTextButton(r, l, tag, lab) { } - ~CTextButtonWithHover() - { - if (getGradient()) - { - // getGradient()->forget(); - } - if (getGradientHighlighted()) - { - // getGradientHighlighted()->forget(); - } - } + ~CTextButtonWithHover() {} VSTGUI::CMouseEventResult onMouseEntered(VSTGUI::CPoint &where, const VSTGUI::CButtonState &buttons) override; void draw(VSTGUI::CDrawContext *context) override; @@ -70,11 +68,7 @@ class CTextButtonWithHover : public VSTGUI::CTextButton */ #define ADD_HOVER(m, T) \ OptionalForget hc_##m; \ - void setHover##m(T c) \ - { \ - hc_##m.item = c; \ - hc_##m.isSet = true; \ - } + void setHover##m(T c) { hc_##m.set(c); } #define ADD_HOVER_CR(m, T) \ Optional hc_##m; \ diff --git a/src/gui/MSEGEditor.cpp b/src/gui/MSEGEditor.cpp index a6813da1891..bc3957308d1 100644 --- a/src/gui/MSEGEditor.cpp +++ b/src/gui/MSEGEditor.cpp @@ -1302,7 +1302,12 @@ struct MSEGCanvas : public CControl, dc->setLineStyle( CLineStyle(CLineStyle::kLineCapButt, CLineStyle::kLineJoinMiter, 0, 2, dashes)); #else - std::cout << "FIXME: Dashed Lines" << std::endl; + static bool warned = false; + if (!warned) + { + std::cout << "FIXME: Dashed Lines " << __FILE__ << __LINE__ << std::endl; + warned = true; + } #endif } diff --git a/src/gui/SurgeGUIEditor.cpp b/src/gui/SurgeGUIEditor.cpp index 569c7feaf02..1053903ac81 100644 --- a/src/gui/SurgeGUIEditor.cpp +++ b/src/gui/SurgeGUIEditor.cpp @@ -7249,10 +7249,15 @@ void SurgeGUIEditor::addEditorOverlay(VSTGUI::CView *c, std::string editorTitle, b->setHoverFrameColor(hovbtnborder); b->setHoverTextColor(hovbtntext); b->setGradientHighlighted(presscg); + b->setHoverGradientHighlighted(presscg); b->setFrameColorHighlighted(pressbtnborder); b->setTextColorHighlighted(pressbtntext); b->setRoundRadius(CCoord(3.f)); + presscg->forget(); + hovcg->forget(); + cg->forget(); + innerc->addView(b); } @@ -7279,6 +7284,7 @@ void SurgeGUIEditor::addEditorOverlay(VSTGUI::CView *c, std::string editorTitle, editorOverlay.push_back(std::make_pair(editorTag, editorOverlayC)); editorOverlayOnClose[editorOverlayC] = onClose; editorOverlayContentsWeakReference[editorOverlayC] = c; + editorOverlayContentsWeakReference[editorOverlayC] = c; } std::string SurgeGUIEditor::getDisplayForTag(long tag) @@ -7451,6 +7457,10 @@ void SurgeGUIEditor::promptForMiniEdit(const std::string &value, const std::stri kb->setTextColorHighlighted(pressbtntext); kb->setRoundRadius(CCoord(3.f)); bg->addView(kb); + + presscg->forget(); + hovcg->forget(); + cg->forget(); } void SurgeGUIEditor::swapControllers(int t1, int t2) @@ -7633,6 +7643,10 @@ void SurgeGUIEditor::makeStorePatchDialog() kb->setTextColorHighlighted(pressbtntext); kb->setRoundRadius(CCoord(3.f)); + cg->forget(); + presscg->forget(); + hovcg->forget(); + saveDialog->addView(pnamelbl); saveDialog->addView(pcatlbl); saveDialog->addView(pauthlbl);