@@ -173,16 +173,17 @@ void Sidebar::addPanel(SidePanel panel)
173173 rebuildPanelTable ();
174174 updateSelectorButtonStates ();
175175
176- // If this is the first panel on this sidebar, make it active.
177176 if (!hasCurrentPanel && panel != InspectorPanel) {
178177 currentPanel = panel;
179178 hasCurrentPanel = true ;
180179 if (auto * btn = getSelectorButton (panel))
181180 btn->setToggleState (true , dontSendNotification);
182- if (auto * p = getPanelComponent (panel))
183- p->setVisible (!sidebarHidden);
184181 }
185182
183+ for (auto & entry : panelTable)
184+ entry.panel ->setVisible (entry.id == currentPanel && !sidebarHidden);
185+
186+ updateCommandInputVisibility ();
186187 updateExtraSettingsButton ();
187188 resized ();
188189 repaint ();
@@ -233,6 +234,7 @@ void Sidebar::removePanel(SidePanel panel)
233234 rebuildPanelTable ();
234235 updateSelectorButtonStates ();
235236 updateExtraSettingsButton ();
237+ updateCommandInputVisibility ();
236238 resized ();
237239 repaint ();
238240}
@@ -328,6 +330,12 @@ void Sidebar::paintOverChildren(Graphics& g)
328330 g.drawLine (getWidth () - 0 .5f , 30 , getWidth () - 0 .5f , getHeight () + 0 .5f );
329331 }
330332 g.drawLine (0 , 30 , getWidth (), 30 );
333+
334+ if (currentPanel == InspectorPanel && !inspectorPtr->isVisible ())
335+ {
336+ g.setColour (PlugDataColours::sidebarTextColour.withAlpha (0 .55f ));
337+ g.drawText (" (no object selected)" , getLocalBounds ().withTrimmedTop (40 ), Justification::centredTop);
338+ }
331339}
332340
333341int Sidebar::getCommandInputHeight ()
@@ -371,11 +379,13 @@ void Sidebar::resized()
371379
372380 if (commandInputPtr && commandInputPtr->isVisible ()
373381 && commandInputPtr->getParentComponent () == this ) {
382+ auto commandInputHeight = getCommandInputHeight ();
374383 commandInputPtr->setBounds (getLocalBounds ()
375- .removeFromBottom (getCommandInputHeight () )
384+ .removeFromBottom (commandInputHeight )
376385 .reduced (8 )
377386 .withTrimmedLeft (side == Side::Left ? 30 : 0 )
378387 .withTrimmedRight (side == Side::Right ? 30 : 0 ));
388+ bounds.removeFromBottom (commandInputHeight);
379389 }
380390
381391 bounds.removeFromTop (30 );
@@ -515,6 +525,24 @@ bool Sidebar::refreshInspectorVisibility(bool const allowManualShow)
515525 return shouldShow;
516526}
517527
528+ void Sidebar::updateCommandInputVisibility ()
529+ {
530+ auto const wantsCmd = (currentPanel == ConsolePanel) || (hasPanel (ConsolePanel) && inspectorAutoShow && currentPanel == InspectorPanel);
531+ if (commandInputPtr) {
532+ if (wantsCmd && hasPanel (currentPanel)) {
533+ if (commandInputPtr->getParentComponent () != this ) {
534+ if (commandInputPtr->getParentComponent ())
535+ commandInputPtr->getParentComponent ()->removeChildComponent (commandInputPtr);
536+ addAndMakeVisible (commandInputPtr);
537+ } else {
538+ commandInputPtr->setVisible (true );
539+ }
540+ } else if (commandInputPtr->getParentComponent () == this ) {
541+ commandInputPtr->setVisible (false );
542+ }
543+ }
544+ }
545+
518546void Sidebar::showPanel (SidePanel const panelToShow)
519547{
520548 // Toggle off if clicking the already-active panel
@@ -542,6 +570,7 @@ void Sidebar::showPanel(SidePanel const panelToShow)
542570 refreshInspectorVisibility (true );
543571 }
544572
573+ updateCommandInputVisibility ();
545574 updateExtraSettingsButton ();
546575 resized ();
547576 repaint ();
@@ -571,22 +600,6 @@ void Sidebar::showPanel(SidePanel const panelToShow)
571600 updateSelectorButtonStates ();
572601 };
573602
574- // CommandInput belongs to the Console panel.
575- auto const wantsCmd = (panelToShow == ConsolePanel);
576- if (commandInputPtr) {
577- if (wantsCmd && hasPanel (panelToShow)) {
578- if (commandInputPtr->getParentComponent () != this ) {
579- if (commandInputPtr->getParentComponent ())
580- commandInputPtr->getParentComponent ()->removeChildComponent (commandInputPtr);
581- addAndMakeVisible (commandInputPtr);
582- } else {
583- commandInputPtr->setVisible (true );
584- }
585- } else if (commandInputPtr->getParentComponent () == this ) {
586- commandInputPtr->setVisible (false );
587- }
588- }
589-
590603 switch (panelToShow) {
591604 case ConsolePanel:
592605 if (hasPanel (ConsolePanel))
@@ -624,6 +637,7 @@ void Sidebar::showPanel(SidePanel const panelToShow)
624637 break ;
625638 }
626639
640+ updateCommandInputVisibility ();
627641 updateExtraSettingsButton ();
628642 resized ();
629643 repaint ();
@@ -773,6 +787,7 @@ void Sidebar::showParameters(SmallArray<Component*>& objects, SmallArray<ObjectP
773787 if (!shouldShowInspector && !inspectorAutoShow)
774788 inspectorManuallyShown = false ;
775789
790+ updateCommandInputVisibility ();
776791 updateSelectorButtonStates ();
777792 updateExtraSettingsButton ();
778793 resized ();
@@ -789,6 +804,7 @@ void Sidebar::hideParameters()
789804 if (consolePanelPtr && hasPanel (ConsolePanel))
790805 consolePanelPtr->deselect ();
791806
807+ updateCommandInputVisibility ();
792808 updateSelectorButtonStates ();
793809 updateExtraSettingsButton ();
794810 resized ();
0 commit comments