void CtrlrManager::restoreEditorState() { Rectangle<int> r; if (getProperty(Ids::ctrlrEditorBounds).toString() == String::empty) { if (getInstanceMode() == InstanceSingle || getInstanceMode() == InstanceSingleRestriced) { if (getActivePanel() && getActivePanel()->getEditor()) { Rectangle<int> r1 = VAR2RECT(getActivePanel()->getEditor()->getProperty (Ids::uiPanelCanvasRectangle)); r = r1.withHeight (r1.getHeight()); } } } else { r = VAR2RECT(getProperty(Ids::ctrlrEditorBounds, "0 0 720 480")); } ctrlrEditor->setSize (r.getWidth(), r.getHeight()); }
CtrlrEditor::CtrlrEditor (CtrlrProcessor *_ownerFilter, CtrlrManager &_owner) : AudioProcessorEditor (_ownerFilter), ownerFilter(_ownerFilter), owner(_owner), resizer(this, 0), tempResult(Result::ok()), menuHandlerCalled(false), lastCommandInvocationMillis(0) { Rectangle<int> editorRect; // http://www.juce.com/forum/topic/applicationcommandmanager-menus-not-active-annoyance#new owner.getCommandManager().setFirstCommandTarget (this); addAndMakeVisible (menuBar = new MenuBarComponent (this)); menuBarLookAndFeel = new CtrlrMenuBarLookAndFeel (*this); setApplicationCommandManagerToWatch (&owner.getCommandManager()); owner.getCommandManager().registerAllCommandsForTarget (this); owner.getCommandManager().registerAllCommandsForTarget (JUCEApplication::getInstance()); ScopedPointer <XmlElement> xml(XmlDocument::parse(owner.getProperty(Ids::ctrlrKeyboardMapping))); if (xml) { owner.getCommandManager().getKeyMappings()->restoreFromXml (*xml); } owner.setEditor (this); addAndMakeVisible (&owner.getCtrlrDocumentPanel()); if (!JUCEApplication::isStandaloneApp()) { if (owner.getInstanceMode() != InstanceSingleRestriced) { /* Restricted instances don't get to be resizable */ addAndMakeVisible (&resizer); resizer.setAlwaysOnTop (false); resizer.grabKeyboardFocus(); resizer.toFront (true); } } if (owner.getProperty (Ids::ctrlrEditorBounds).toString() != String::empty) { if (owner.getInstanceMode() != InstanceSingle && owner.getInstanceMode() != InstanceSingleRestriced) { editorRect = VAR2RECT(owner.getProperty (Ids::ctrlrEditorBounds)); } else if (owner.getActivePanel()) { editorRect = VAR2RECT(owner.getActivePanel()->getEditor()->getProperty(Ids::uiPanelCanvasRectangle)); if ((bool)owner.getActivePanel()->getEditor()->getProperty(Ids::uiPanelMenuBarVisible)) editorRect.setHeight (editorRect.getHeight() + CTRLR_MENUBAR_HEIGHT); else editorRect.setHeight (editorRect.getHeight()); } } else editorRect.setSize(640,480); setBounds (editorRect); lookAndFeelChanged(); activeCtrlrChanged(); }
CtrlrStandaloneWindow::CtrlrStandaloneWindow (const String& title, const Colour& backgroundColour) : DocumentWindow (title, backgroundColour, DocumentWindow::allButtons, true), ctrlrProcessor(nullptr), filter(nullptr), appProperties(nullptr), restoreState(true) { setTitleBarButtonsRequired (DocumentWindow::allButtons, false); setUsingNativeTitleBar (true); JUCE_TRY { filter = createPluginFilter(); if (filter != 0) { ctrlrProcessor = dynamic_cast<CtrlrProcessor*>(filter); if (ctrlrProcessor == nullptr) { AlertWindow::showMessageBox (AlertWindow::WarningIcon, "CTRLR", "The filter object is not a valid Ctrlr Processor"); return; } /* set some default audio stuff so the filter works without the audio card */ ctrlrProcessor->setPlayConfigDetails (2, 2, SAMPLERATE, 512); addKeyListener (ctrlrProcessor->getManager().getCommandManager().getKeyMappings()); /* we want to listen too manager actions */ ctrlrProcessor->getManager().addActionListener (this); /* get the properties pointer from the manager */ appProperties = ctrlrProcessor->getManager().getApplicationProperties(); setResizable (true, false); if (appProperties != nullptr) { ScopedPointer <XmlElement> xml(appProperties->getUserSettings()->getXmlValue(CTRLR_PROPERTIES_FILTER_STATE)); if (xml != nullptr) { ctrlrProcessor->setStateInformation (xml); } AudioProcessorEditor *editor = ctrlrProcessor->createEditorIfNeeded(); setName (ctrlrProcessor->getManager().getInstanceName()); if (appProperties->getUserSettings()->getValue(CTRLR_PROPERTIES_WINDOW_STATE,String::empty) != String::empty) { restoreWindowStateFromString (appProperties->getUserSettings()->getValue(CTRLR_PROPERTIES_WINDOW_STATE)); } else { Rectangle<int> r = VAR2RECT(ctrlrProcessor->getManager().getInstanceTree().getChildWithName(Ids::uiPanelEditor).getProperty(Ids::uiPanelCanvasRectangle, "0 0 800 600")); centreWithSize (r.getWidth(), r.getHeight()+CTRLR_MENUBAR_HEIGHT/*Menubar*/); } setContentOwned (editor, false); } else { AlertWindow::showMessageBox (AlertWindow::WarningIcon, "CTRLR", "Can't find any application properties"); } } restoreState = false; setVisible (true); } JUCE_CATCH_ALL }