Exemplo n.º 1
0
//=================================================================================================
MainWindow::MainWindow()
    : DocumentWindow (JUCEApplication::getInstance()->getApplicationName(),
                      Colours::lightgrey,
                      DocumentWindow::allButtons)
{   
    // 创建基础组件和读写文档的对象
    baseComponent = new BaseComponent();
    appDoc = LoadAndSaveDoc::getInstance();
    appDoc->addChangeListener(this);  // FileBasedDocument 对象绑定可变捕获器
    
    // 获取全局性的撤销管理器、命令管理器和程序属性
    undoManager     = AppSingleton::getInstance()->getUndoManager(); 
    commandManager  = AppSingleton::getInstance()->getCommandManager();
    appProperties   = AppSingleton::getInstance()->getAppProperties();
    
    // 注册命令目标
    commandManager->registerAllCommandsForTarget (JUCEApplication::getInstance());
    commandManager->registerAllCommandsForTarget (this); 

    // 获取所有命令默认的快捷键
    commandManager->getKeyMappings()->resetToDefaultMappings();

    // 获取用户自定义的快捷键
    ScopedPointer<XmlElement> keys(appProperties->getUserSettings()->getXmlValue("keyMappings")); 

    if (keys != nullptr)        
        commandManager->getKeyMappings()->restoreFromXml(*keys);

    // 本类绑定按键捕获器
    addKeyListener (commandManager->getKeyMappings());

    // 设置本类的默认属性
    centreWithSize (1280, 800);
    setResizable(true, false);
    setResizeLimits(800, 600, 4096, 4096);
    setVisible (true);
    setUsingNativeTitleBar(true);

    // 主菜单随时关注命令的变化
    setApplicationCommandManagerToWatch(commandManager);

    // 设置主菜单  
#ifdef JUCE_MAC
    setMacMainMenu(this);
#else
    setMenuBar(this);   
#endif

    // 恢复上次退出时的窗口状态
    restoreWindowStateFromString(appProperties->getUserSettings()->getValue("mainWindowState"));
    setName(AppString::appNameOnTitleBar + TRANS("Untitled"));      // 设置标题栏默认显示的文本

    // 设置并添加基础组件
    baseComponent->setSize(getWidth(), getHeight());
    setContentOwned(baseComponent, false);  

    // 设置当前进程为高优先级
    Process::setPriority (Process::HighPriority);
}
Exemplo n.º 2
0
//==============================================================================
MainWindow::MainWindow()
    : DocumentWindow ("The Jucer",
                      Colours::azure,
                      DocumentWindow::allButtons)
{
    if (oldLook == 0)
        oldLook = new OldSchoolLookAndFeel();

    setContentOwned (multiDocHolder = new MultiDocHolder(), false);

    setApplicationCommandManagerToWatch (commandManager);

   #if JUCE_MAC
    setMacMainMenu (this);
   #else
    setMenuBar (this);
   #endif

    setResizable (true, false);

    centreWithSize (700, 600);

    // restore the last size and position from our settings file..
    restoreWindowStateFromString (StoredSettings::getInstance()->getProps()
                                    .getValue ("lastMainWindowPos"));

    // Register all the app commands..
    {
        commandManager->registerAllCommandsForTarget (JUCEApplication::getInstance());
        commandManager->registerAllCommandsForTarget (this);

        // use a temporary one of these to harvest its commands..
        JucerDocumentHolder tempDesignHolder (ObjectTypes::createNewDocument (0));
        commandManager->registerAllCommandsForTarget (&tempDesignHolder);
    }

    commandManager->getKeyMappings()->resetToDefaultMappings();

    XmlElement* const keys = StoredSettings::getInstance()->getProps().getXmlValue ("keyMappings");

    if (keys != 0)
    {
        commandManager->getKeyMappings()->restoreFromXml (*keys);
        delete keys;
    }

    addKeyListener (commandManager->getKeyMappings());

    // don't want the window to take focus when the title-bar is clicked..
    setWantsKeyboardFocus (false);

   #ifndef JUCE_DEBUG
    // scan for fonts before the app gets started rather than glitching later
    FontPropertyComponent::preloadAllFonts();
   #endif
}
Exemplo n.º 3
0
void MainWindow::restoreWindowPosition()
{
    String windowState;

    if (currentProject != nullptr)
        windowState = currentProject->getStoredProperties().getValue (getProjectWindowPosName());

    if (windowState.isEmpty())
        windowState = getGlobalProperties().getValue ("lastMainWindowPos");

    restoreWindowStateFromString (windowState);
}
Exemplo n.º 4
0
void MainWindow::restoreWindowPosition()
{
    String windowState;

    if (currentProject != nullptr)
        windowState = StoredSettings::getInstance()->getProps().getValue (getProjectWindowPosName());

    if (windowState.isEmpty())
        windowState = StoredSettings::getInstance()->getProps().getValue ("lastMainWindowPos");

    restoreWindowStateFromString (windowState);
}
Exemplo n.º 5
0
PrefsPanel::PrefsPanel()
    : DialogWindow ("Jucer Preferences", Colour::greyLevel (0.92f), true)
{
    PrefsTabComp* const p = new PrefsTabComp();
    p->setSize (456, 510);

    setContentOwned (p, true);

    if (! restoreWindowStateFromString (prefsWindowPos))
        centreAroundComponent (0, getWidth(), getHeight());

    setResizable (true, true);
    setResizeLimits (400, 400, 1000, 800);
}
Exemplo n.º 6
0
//==============================================================================
MainHostWindow::MainHostWindow()
    : DocumentWindow (JUCEApplication::getInstance()->getApplicationName(), Colours::lightgrey,
                      DocumentWindow::allButtons)
{
    XmlElement* const savedAudioState = ApplicationProperties::getInstance()->getUserSettings()
                                            ->getXmlValue (T("audioDeviceState"));

    deviceManager.initialise (256, 256, savedAudioState, true);

    delete savedAudioState;

    setResizable (true, false);
    setResizeLimits (500, 400, 10000, 10000);
    centreWithSize (800, 600);

    setContentComponent (new GraphDocumentComponent (&deviceManager));

    restoreWindowStateFromString (ApplicationProperties::getInstance()->getUserSettings()->getValue ("mainWindowPos"));

    setVisible (true);

    InternalPluginFormat internalFormat;
    internalFormat.getAllTypes (internalTypes);

    XmlElement* const savedPluginList = ApplicationProperties::getInstance()
                                          ->getUserSettings()
                                          ->getXmlValue (T("pluginList"));

    if (savedPluginList != 0)
    {
        knownPluginList.recreateFromXml (*savedPluginList);
        delete savedPluginList;
    }

    pluginSortMethod = (KnownPluginList::SortMethod) ApplicationProperties::getInstance()->getUserSettings()
                            ->getIntValue (T("pluginSortMethod"), KnownPluginList::sortByManufacturer);

    knownPluginList.addChangeListener (this);

    addKeyListener (commandManager->getKeyMappings());

    Process::setPriority (Process::HighPriority);

#if JUCE_MAC
    setMacMainMenu (this);
#else
    setMenuBar (this);
#endif
}
Exemplo n.º 7
0
//==============================================================================
MainHostWindow::MainHostWindow()
    : DocumentWindow (JUCEApplication::getInstance()->getApplicationName(), Colours::lightgrey,
                      DocumentWindow::allButtons)
{
    formatManager.addDefaultFormats();
    formatManager.addFormat (new InternalPluginFormat());

    ScopedPointer<XmlElement> savedAudioState (appProperties->getUserSettings()
                                                   ->getXmlValue ("audioDeviceState"));

    deviceManager.initialise (256, 256, savedAudioState, true);

    setResizable (true, false);
    setResizeLimits (500, 400, 10000, 10000);
    centreWithSize (800, 600);

    setContentOwned (new GraphDocumentComponent (formatManager, &deviceManager), false);

    restoreWindowStateFromString (appProperties->getUserSettings()->getValue ("mainWindowPos"));

    setVisible (true);

    InternalPluginFormat internalFormat;
    internalFormat.getAllTypes (internalTypes);

    ScopedPointer<XmlElement> savedPluginList (appProperties->getUserSettings()->getXmlValue ("pluginList"));

    if (savedPluginList != nullptr)
        knownPluginList.recreateFromXml (*savedPluginList);

    pluginSortMethod = (KnownPluginList::SortMethod) appProperties->getUserSettings()
                            ->getIntValue ("pluginSortMethod", KnownPluginList::sortByManufacturer);

    knownPluginList.addChangeListener (this);

    addKeyListener (commandManager->getKeyMappings());

    Process::setPriority (Process::HighPriority);

   #if JUCE_MAC
    setMacMainMenu (this);
   #else
    setMenuBar (this);
   #endif

    commandManager->setFirstCommandTarget (this);
}
Exemplo n.º 8
0
    PluginListWindow (MainHostWindow& owner_, AudioPluginFormatManager& formatManager)
        : DocumentWindow ("Available Plugins", Colours::white,
                          DocumentWindow::minimiseButton | DocumentWindow::closeButton),
          owner (owner_)
    {
        const File deadMansPedalFile (getAppProperties().getUserSettings()
                                        ->getFile().getSiblingFile ("RecentlyCrashedPluginsList"));

        setContentOwned (new PluginListComponent (formatManager,
                                                  owner.knownPluginList,
                                                  deadMansPedalFile,
                                                  getAppProperties().getUserSettings()), true);

        setResizable (true, false);
        setResizeLimits (300, 400, 800, 1500);
        setTopLeftPosition (60, 60);

        restoreWindowStateFromString (getAppProperties().getUserSettings()->getValue ("listWindowPos"));
        setVisible (true);
    }
Exemplo n.º 9
0
        MainWindow (String name, const PropertiesFile::Options & options) :
			DocumentWindow (name, Colours::lightgrey, DocumentWindow::allButtons),
			main_content_(options)
        {
            setUsingNativeTitleBar (true);
            setContentOwned (&main_content_, true);

            centreWithSize (getWidth(), getHeight());

			ApplicationProperties props;

			props.setStorageParameters(options);

			const auto user_settings = props.getUserSettings();

			restoreWindowStateFromString(user_settings->getValue("window state"));

            setVisible (true);
			setResizable(true, true);
        }
Exemplo n.º 10
0
    PluginListWindow (KnownPluginList& knownPluginList)
        : DocumentWindow ("Available Plugins", Colours::white,
                          DocumentWindow::minimiseButton | DocumentWindow::closeButton)
    {
        currentPluginListWindow = this;

        const File deadMansPedalFile (ApplicationProperties::getInstance()->getUserSettings()
                                        ->getFile().getSiblingFile ("RecentlyCrashedPluginsList"));

        setContentComponent (new PluginListComponent (knownPluginList,
                                                      deadMansPedalFile,
                                                      ApplicationProperties::getInstance()->getUserSettings()), true, true);

        setResizable (true, false);
        setResizeLimits (300, 400, 800, 1500);
        setTopLeftPosition (60, 60);

        restoreWindowStateFromString (ApplicationProperties::getInstance()->getUserSettings()->getValue ("listWindowPos"));
        setVisible (true);
    }
Exemplo n.º 11
0
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
StupidWindow::StupidWindow(const String& commandLine, bool startHidden):
DocumentWindow(L"Pedalboard 2", Colours::black, DocumentWindow::allButtons)
{
	//Make sure we've loaded all the available plugin formats before we create
	//the main panel.
	{
		InternalPluginFormat *internalFormat = new InternalPluginFormat;
		//LADSPAPluginFormat *ladspaFormat = new LADSPAPluginFormat;
		//VSTPluginFormat *vstFormat = new VSTPluginFormat;
		//NiallsAudioPluginFormat *napFormat = new NiallsAudioPluginFormat;

		AudioPluginFormatManagerSingleton::getInstance().addFormat(internalFormat);
		//AudioPluginFormatManager::getInstance()->addFormat(napFormat);
		//AudioPluginFormatManager::getInstance()->addFormat(vstFormat);
		//AudioPluginFormatManager::getInstance()->addFormat(ladspaFormat);
	}

	//Load correct colour scheme.
	{
		String scheme = PropertiesSingleton::getInstance().getUserSettings()->getValue(L"colourScheme");

		if(scheme != String::empty)
			ColourScheme::getInstance().loadPreset(scheme);
	}

	LookAndFeel::setDefaultLookAndFeel(laf = new BranchesLAF());
	setResizable(true, false);
	setContentOwned(mainPanel = new MainPanel(&commandManager), true);
	//mainPanel->setCommandManager(&commandManager);
	centreWithSize(1024, 580);
	setUsingNativeTitleBar(true);
	//setDropShadowEnabled(false);
	if(!startHidden)
		setVisible(true);
#ifndef __APPLE__
	setMenuBar(mainPanel);
#endif

	//Attempts to associate our icon with the window's titlebar.
	getPeer()->setIcon(ImageCache::getFromMemory(Images::icon512_png,
												 Images::icon512_pngSize));

	commandManager.registerAllCommandsForTarget(mainPanel);
    commandManager.registerAllCommandsForTarget(JUCEApplication::getInstance());

	commandManager.getKeyMappings()->resetToDefaultMappings();

	loadKeyMappings();

	addKeyListener(commandManager.getKeyMappings());

	restoreWindowStateFromString(PropertiesSingleton::getInstance().getUserSettings()->getValue("WindowState"));

	//See if we can load a .pdl file from the commandline.
	File initialFile(commandLine);

	if(initialFile.existsAsFile())
	{
		if(initialFile.getFileExtension() == L".pdl")
		{
			mainPanel->loadDocument(initialFile);
			mainPanel->setLastDocumentOpened(initialFile);
			mainPanel->setFile(initialFile);
			mainPanel->setChangedFlag(false);
		}
	}
}
Exemplo n.º 12
0
//==============================================================================
CodeWindow::CodeWindow(String name):DocumentWindow (name, Colours::black,
							  DocumentWindow::allButtons),
							  fontSize(15),
							  showOutput(true),
							  csoundOutputText(""),
							  debugMessage(""),
							  firstTime(true),
							  font(String("Courier New"), 15, 1),
							  showingHelp(false)
{  
	setApplicationCommandManagerToWatch(&commandManager);
	commandManager.registerAllCommandsForTarget(this);
	addKeyListener(commandManager.getKeyMappings());
	
	textEditor = new CsoundCodeEditor("csound", csoundDoc, &csoundToker);

	restoreWindowStateFromString (appProperties->getUserSettings()->getValue ("mainWindowPos"));


	textEditor->addActionListener(this);

	
	this->setTitleBarHeight(20);
	this->setColour(DocumentWindow::backgroundColourId, CabbageUtils::getBackgroundSkin());
	

	setMenuBar(this, 25);	
	
	setVisible(true);

	this->setWantsKeyboardFocus(false);


	if(!appProperties->getUserSettings()->getValue("EditorColourScheme", var(0)).getIntValue())
		setEditorColourScheme("white");
	else if(appProperties->getUserSettings()->getValue("EditorColourScheme", var(0)).getIntValue())
		setEditorColourScheme("dark");

	RecentlyOpenedFilesList recentFiles;
	recentFiles.restoreFromString (appProperties->getUserSettings()
										->getValue ("recentlyOpenedFiles"));

	csdFile = recentFiles.getFile (0);
	csoundDoc.replaceAllContent(csdFile.loadFileAsString());
	
	//cabbageTimer->addActionListener(this);
	//cabbageTimer->startTimedEvent(10, "splash");
	setResizable(true, false);

	String opcodeFile = File(File::getSpecialLocation(File::currentExecutableFile)).getParentDirectory().getFullPathName(); 
	opcodeFile += "/opcodes.txt";
	Logger::writeToLog(opcodeFile);

	if(File(opcodeFile).existsAsFile())
		textEditor->setOpcodeStrings(File(opcodeFile).loadFileAsString());
	//else csound->Message("Could not open opcodes.txt file, parameter display disabled..");

	//set up popup for displaying info regarding opcodes..
	popupDisplay = new PopupDisplay("Poppy");
	popupDisplay->addActionListener(this);
	popupDisplay->setTitleBarHeight(0);
	popupDisplay->addToDesktop(0);
	popupDisplay->setVisible(false);
	
	
htmlHelp = new WebBrowserComponent(false);

setContentNonOwned(textEditor, false);
}
Exemplo n.º 13
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
}