StandaloneFilterWindow::StandaloneFilterWindow ()
    : DocumentWindow ("Cabbage", Colours::black, DocumentWindow::minimiseButton | DocumentWindow::closeButton),
      lookAndFeel(new CabbageLookAndFeel()),
      editorShowing(true),
      globalScale(1.f),
      firstRun(true)
{
    setOpenGLRenderingEngine();
    //Desktop::getInstance().setKioskModeComponent(this);
    setTitleBarButtonsRequired(0, false);
    Component::setLookAndFeel(lookAndFeel);
    pluginHolder = new StandalonePluginHolder ();
    desktopRect = Desktop::getInstance().getDisplays().getMainDisplay().userArea.toDouble();
    loadFile(filename);
    setVisible (true);
    //setFullScreen(true);
}
//==============================================================================
StandaloneFilterWindow::StandaloneFilterWindow (const String& title,
                                                const Colour& backgroundColour)
    : DocumentWindow (title, backgroundColour,
                      DocumentWindow::minimiseButton
                       | DocumentWindow::closeButton),
      filter (0),
      deviceManager (0),
      optionsButton (0)
{
    setTitleBarButtonsRequired (DocumentWindow::minimiseButton | DocumentWindow::closeButton, false);

    PropertySet* const globalSettings = getGlobalSettings();

    optionsButton = new TextButton (T("options"));
    Component::addAndMakeVisible (optionsButton);
    optionsButton->addButtonListener (this);
    optionsButton->setTriggeredOnMouseDown (true);

    JUCE_TRY
    {
        filter = createPluginFilter();

        if (filter != 0)
        {
            deviceManager = new AudioFilterStreamingDeviceManager();
            deviceManager->setFilter (filter);

            XmlElement* savedState = 0;

            if (globalSettings != 0)
                savedState = globalSettings->getXmlValue (T("audioSetup"));

            deviceManager->initialise (filter->getNumInputChannels(),
                                       filter->getNumOutputChannels(),
                                       savedState,
                                       true);

            delete savedState;

            if (globalSettings != 0)
            {
                JUCE_NAMESPACE::MemoryBlock data;

                if (data.fromBase64Encoding (globalSettings->getValue (T("filterState")))
                     && data.getSize() > 0)
                {
                    filter->setStateInformation (data.getData(), data.getSize());
                }
            }

            setContentComponent (filter->createEditorIfNeeded(), true, true);

            const int x = globalSettings->getIntValue (T("windowX"), -100);
            const int y = globalSettings->getIntValue (T("windowY"), -100);

            if (x != -100 && y != -100)
                setBoundsConstrained (x, y, getWidth(), getHeight());
            else
                centreWithSize (getWidth(), getHeight());
        }
    }
    JUCE_CATCH_ALL

    if (deviceManager == 0)
    {
        jassertfalse    // Your filter didn't create correctly! In a standalone app that's not too great.
        JUCEApplication::quit();
    }
}
Esempio n. 3
0
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
}