Custom splash screen: underneath controllers are reacting on mouse

Because the standard view “Animation Splash Screen” is just one bitmap, and we want it to contain a link button and text I can easily change like the version number, we implemented our own view to switch to.
However the controls underneath react on mouse input even when the about screen is open and overlays the controls. How can I disable the controls if another view is above them? A drop down menu even shows on top of the view when clicked.

You should use a modal view session for this. Here is an example of how I implemented it in Jamba. It is a bit more complicated because I am accounting for multiple scenarios:
a) the modal view is provided as a template name in the xml file and is created dynamically when required so it is very convenient to create one
b) the ui can be closed and reopened and I want to reopen the modal dialog if there was one when closed

2 Likes

Thanks for pointing us there!

If I would just want to create a blank view to block the underlying controls in a view switch container – Could I do it like this?

#include "aboutViewBackground.h++"

namespace VSTGUI {
AboutViewBackground::AboutViewBackground (const CRect& size) : CControl (size) {}
void AboutViewBackground::draw (CDrawContext* pContext)
{
    auto id = this->getFrame()->beginModalViewSession(this);
    setDirty (false);
}
} // namespace VSTGUI

This creates a view, but unfortunately doesn’t change the behaviour regarding the controls.

Hello there! Unfortuntately I still wasn’t able to find a solution. Any help would be greatly appreciated!

1 Like

First, you should only draw when you get a draw call. Second, a modal view should always be a child of the frame and not a child of another view container.
If you just want to disable controls in a view switch container, you should just simply call view->setMouseEnabled (false) on the view which contains the controls.

1 Like

Thanks Arne, this helped finding a solution! For me it seemed more straight forward to deactivate the controls then using the modal view dialog.

I’m not sure if this is the way to go, but this is what I did in my EditController class:

To be able to parse the views from the .uidesc json file, I’m keeping a pointer to the editor in my private member variables.

private:
   VSTGUI::VST3Editor* view_;

When creating the Editor from the .uidesc file, I’m saving the pointer:

Steinberg::IPlugView* Controller::createView(const char* name) {
  if (name && strcmp(name, Steinberg::Vst::ViewType::kEditor) == 0) {
    view_ = new VSTGUI::VST3Editor(this, "main_view", "MyPlugin.uidesc");
    return view_;
  }
  return nullptr;
}

I’m not sure if I should rather use a shared or unique pointer type here – or if this is a good idea at all – but I’m not aware of other possibilities to parse the view data from the .uidesc file.

Steinberg::tresult endEdit (Steinberg::Vst::ParamID tag) override
 {
   if(tag == static_cast<int32_t>(ParameterId::ViewSwitch))
      {
           if(getParameterObject(tag)->getNormalized()==1)
           {
               // disable controls on the main view
               auto ui_sliders = std::vector<CSlider*>();
               view_->getFrame()->getView(0)->asViewContainer()->getChildViewsOfType<CSlider>(ui_sliders, true);
               for(auto ui_element : ui_sliders) {
                   ui_element->setMouseEnabled(false);
               }
           }
           else
           {
               // enable controls on the main view
               auto ui_sliders   = std::vector<CSlider*>();
               view_->getFrame()->getView(0)->asViewContainer()->getChildViewsOfType<CSlider>(ui_sliders, true);
               for(auto ui_element : ui_sliders)  {
                   ui_element->setMouseEnabled(true);
               }
           }
}

This works for me! Thanks!

BTW: I was struggling with that approach until I finally found the asViewContainer() method. Without it, the top view returns only one child which was confusing me quite a bit.