//================================================================================================= 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); }
//============================================================================== 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 }
//============================================================================== 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 }
//================================================================================================= MainWindow::~MainWindow() { #if JUCE_MAC setMacMainMenu (nullptr); #else setMenuBar(nullptr); #endif removeKeyListener (commandManager->getKeyMappings()); appDoc->removeChangeListener(this); // 保存窗口状态 setSize(getWidth(), getHeight()); // 不加此句,每次保存的窗口高度均莫名其妙的增加22,断定是JUCE的BUG appProperties->getUserSettings()->setValue("mainWindowState", getWindowStateAsString()); }
MainHostWindow::~MainHostWindow() { pluginListWindow = nullptr; #if JUCE_MAC setMacMainMenu (nullptr); #else setMenuBar (nullptr); #endif knownPluginList.removeChangeListener (this); appProperties->getUserSettings()->setValue ("mainWindowPos", getWindowStateAsString()); clearContentComponent(); }
MainHostWindow::~MainHostWindow() { delete PluginListWindow::currentPluginListWindow; #if JUCE_MAC setMacMainMenu (0); #else setMenuBar (0); #endif knownPluginList.removeChangeListener (this); ApplicationProperties::getInstance()->getUserSettings()->setValue ("mainWindowPos", getWindowStateAsString()); setContentComponent (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); }
MainWindow::~MainWindow() { #if JUCE_MAC setMacMainMenu (0); #else setMenuBar (0); #endif removeKeyListener (commandManager->getKeyMappings()); // save the current size and position to our settings file.. StoredSettings::getInstance()->getProps() .setValue ("lastMainWindowPos", getWindowStateAsString()); clearContentComponent(); deleteAndZero (oldLook); }
MainContentComponent::~MainContentComponent() { previewWindow = nullptr; stepToCopy.clear(); sequenceToCopy = Sequence(); #if JUCE_MAC setMacMainMenu( nullptr ); #endif chaseManager = nullptr; sliceManager = nullptr; xmlManager = nullptr; achievementManager = nullptr; setLookAndFeel( nullptr ); }
//============================================================================== MainContentComponent::MainContentComponent() { laf = new ColourLookAndFeel(); setLookAndFeel( laf ); version = ProjectInfo::versionString; xmlManager = new ChaserXmlManager(); //try to get the last used chaser file //this will create and return a deafult filename if nothing is found File lastChaser = FileLess::getLastUsedFileName( FileLess::Chaser ); xmlManager->setSaveFile( lastChaser ); //save the version XmlElement* versionXml = new XmlElement( "version" ); versionXml->setAttribute( "nr", version ); xmlManager->saveXmlElement( versionXml ); achievementManager = new AchievementManager(); sliceManager = new SliceManager( xmlManager ); chaseManager = new ChaseManager( xmlManager, sliceManager, achievementManager ); previewWindow = new Preview( chaseManager, sliceManager, achievementManager ); addAndMakeVisible( previewWindow ); sequencer = new Sequencer( chaseManager ); addAndMakeVisible( sequencer ); SliceList* sliceList = new SliceList( chaseManager, sliceManager ); //SequenceList* sequenceList = new SequenceList( chaseManager ); listBrowser = new ListBrowser(); listBrowser->addComponentAsTab( sliceList, "Slices" ); //listBrowser->addComponentAsTab( sequenceList, "Sequences" ); addAndMakeVisible( listBrowser ); //chaseManager->addUpdateable( sequenceList ); chaseManager->addUpdateable( sequencer ); chaseManager->addUpdateable( previewWindow ); sliceManager->addUpdateable( sliceList ); sliceManager->addUpdateable( previewWindow ); copier = new Copier( chaseManager ); addAndMakeVisible( copier ); creator = new ChaserCreator( sliceManager, chaseManager, previewWindow, sliceList ); //start checking for ass file updates once per second autoUpdate = new AutoUpdateTimer( creator ); autoUpdate->start(); //add a menu bar menuBar = new MenuBarComponent( this ); #if JUCE_WINDOWS addAndMakeVisible( menuBar ); #elif JUCE_MAC setMacMainMenu( this ); #endif addKeyListener( this ); setSize( 1280, 720 ); //start a timer to update the window name startTimer( 1000 ); }