Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. diff --git a/vstgui/lib/platform/common/genericoptionmenu.cpp b/vstgui/lib/platform/common/genericoptionmenu.cpp
  2. index 58fe6a89..d4408813 100644
  3. --- a/vstgui/lib/platform/common/genericoptionmenu.cpp
  4. +++ b/vstgui/lib/platform/common/genericoptionmenu.cpp
  5. @@ -16,6 +16,15 @@
  6. #include "../../controls/coptionmenu.h"
  7. #include "../../controls/cscrollbar.h"
  8.  
  9. +/// Surge ///
  10. +#ifndef VSTGUI_OPTION_MENU_NEVER_ANIMATE
  11. +# if LINUX // serious lag with animation on the Linux platform
  12. +# define VSTGUI_OPTION_MENU_NEVER_ANIMATE 1
  13. +# else
  14. +# define VSTGUI_OPTION_MENU_NEVER_ANIMATE 0
  15. +# endif
  16. +#endif
  17. +
  18. //------------------------------------------------------------------------
  19. namespace VSTGUI {
  20. namespace GenericOptionMenuDetail {
  21. @@ -264,6 +273,11 @@ private:
  22. }
  23. else
  24. {
  25. +#if VSTGUI_OPTION_MENU_NEVER_ANIMATE
  26. + /// Surge ///
  27. + subMenuView->getParentView ()->asViewContainer ()->removeView (subMenuView);
  28. + subMenuView = nullptr;
  29. +#else
  30. auto view = shared (subMenuView);
  31. subMenuView = nullptr;
  32. view->addAnimation (
  33. @@ -279,6 +293,7 @@ private:
  34. if (auto frame = db->getFrame ())
  35. frame->setFocusView (db);
  36. }
  37. +#endif
  38. }
  39. }
  40. }
  41. @@ -517,7 +532,6 @@ CView* setupGenericOptionMenu (Proc clickCallback, CViewContainer* container,
  42. viewRect.inset (-1, -1);
  43. viewRect.offset (1, 1);
  44. auto decorView = new CViewContainer (viewRect);
  45. - decorView->setAlphaValue (0.f);
  46. decorView->setBackgroundColor (
  47. GenericOptionMenuDetail::makeDarkerColor (theme.backgroundColor));
  48. decorView->setBackgroundColorDrawStyle (kDrawStroked);
  49. @@ -538,10 +552,13 @@ CView* setupGenericOptionMenu (Proc clickCallback, CViewContainer* container,
  50. decorView->addView (browser);
  51.  
  52. container->addView (decorView);
  53. +#if !VSTGUI_OPTION_MENU_NEVER_ANIMATE /// Surge ///
  54. using namespace Animation;
  55. + decorView->setAlphaValue (0.f);
  56. decorView->addAnimation ("AlphaAnimation", new AlphaValueAnimation (1.f, true),
  57. new CubicBezierTimingFunction (
  58. CubicBezierTimingFunction::easyIn (theme.menuAnimationTime)));
  59. +#endif
  60. frame->setFocusView (browser);
  61. if (!parentDataSource && optionMenu->isCheckStyle ())
  62. {
  63. @@ -605,21 +622,29 @@ void GenericOptionMenu::removeModalView (PlatformOptionMenuResult result)
  64. if (impl->listener)
  65. impl->listener->optionMenuPopupStopped ();
  66.  
  67. + /// Surge ///
  68. + auto onCompletion = [result](GenericOptionMenu *self) {
  69. + if (!self->impl->container)
  70. + return;
  71. + auto callback = std::move (self->impl->callback);
  72. + self->impl->callback = nullptr;
  73. + self->impl->container->unregisterViewMouseListener (self);
  74. + self->impl->frame->endModalViewSession (self->impl->modalViewSession);
  75. + callback (self->impl->menu, result);
  76. + self->impl->container = nullptr;
  77. + };
  78. +#if VSTGUI_OPTION_MENU_NEVER_ANIMATE
  79. + onCompletion(this);
  80. +#else
  81. auto self = shared (this);
  82. impl->container->addAnimation (
  83. "OptionMenuDone", new AlphaValueAnimation (0.f, true),
  84. new CubicBezierTimingFunction (
  85. CubicBezierTimingFunction::easyIn (impl->theme.menuAnimationTime)),
  86. - [self, result] (CView*, const IdStringPtr, IAnimationTarget*) {
  87. - if (!self->impl->container)
  88. - return;
  89. - auto callback = std::move (self->impl->callback);
  90. - self->impl->callback = nullptr;
  91. - self->impl->container->unregisterViewMouseListener (self);
  92. - self->impl->frame->endModalViewSession (self->impl->modalViewSession);
  93. - callback (self->impl->menu, result);
  94. - self->impl->container = nullptr;
  95. + [self, onCompletion] (CView*, const IdStringPtr, IAnimationTarget*) {
  96. + onCompletion(self.get());
  97. });
  98. +#endif
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement