/*! This function initializes CX functionality. It should probably only be called once, at program start. \param config The intial CX configuration. \return `true` if intialization was successful, `false` if there was an error. If there was an error, it should be logged. */ bool initializeCX(CX_InitConfiguation config) { if (config.clockPrecisionTestIterations < 10000) { config.clockPrecisionTestIterations = 10000; } #if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR == 9 && OF_VERSION_PATCH >= 0 ofInit(); #else //Older versions... ofSetWorkingDirectoryToDefault(); #endif ofSetEscapeQuitsApp(false); CX::Instances::Log.captureOFLogMessages(config.captureOFLogMessages); CX::Instances::Log.levelForAllModules(CX_Logger::Level::LOG_ALL); CX::Instances::Log.levelForModule(CX_Logger::Level::LOG_NOTICE, "ofShader"); //Try to eliminate some of the verbose shader gobbeldygook. CX::Private::learnOpenGLVersion(); //Should come before reopenWindow. bool openedSucessfully = CX::reopenWindow(config.windowConfig); //or for the first time. if (!openedSucessfully) { CX::Instances::Log.error("CX_EntryPoint") << "The window was not opened successfully."; } else { // Set up the clock CX::Instances::Clock.setup(nullptr, true, config.clockPrecisionTestIterations); CX::Instances::Input.pollEvents(); //Do this so that the window is at least minimally responding and doesn't get killed by the OS. //This must happen after the window is configured because it relies on GLFW. if (config.framePeriodEstimationInterval != CX_Millis(0)) { CX::Instances::Disp.estimateFramePeriod(config.framePeriodEstimationInterval); CX::Instances::Log.notice("CX_EntryPoint") << "Estimated frame period for display: " << CX::Instances::Disp.getFramePeriod().millis() << " ms."; } setupKeyboardShortcuts(); // Set up sound CX::Instances::SoundPlayer.setup(&CX::Instances::SoundStream); CX::Instances::SoundRecorder.setup(&CX::Instances::SoundStream); //This is temporary: I think there's an oF bug about it #if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR == 8 glfwSetWindowPos(CX::Private::glfwContext, 200, 200); #endif } CX::Instances::Log.verbose() << endl << endl << "### End of startup logging data ###" << endl << endl; CX::Instances::Log.flush(); //Flush logs after setup, so user can see if any errors happened during setup. CX::Instances::Log.levelForAllModules(CX_Logger::Level::LOG_NOTICE); CX::Instances::Log.levelForModule(CX_Logger::Level::LOG_WARNING, "ofFbo"); //It isn't clear that this should be here, but the fbos //are really verbose when allocated and it is a lot of gibberish. return openedSucessfully; }
MainWindow2::MainWindow2( QWidget *parent ) : QMainWindow( parent ) { ui = new Ui::MainWindow2; ui->setupUi( this ); mBackground = new BackgroundWidget( this ); mScribbleArea = new ScribbleArea( mBackground ); mScribbleArea->setFocusPolicy( Qt::StrongFocus ); // Show the UI over the background // QVBoxLayout* layout = new QVBoxLayout(); layout->setSpacing(0); layout->setMargin(0); layout->setContentsMargins(0,0,0,0); layout->addWidget(mScribbleArea); mBackground->setLayout(layout); // Central widget setCentralWidget(mBackground); Object* object = new Object(); object->init(); mEditor = new Editor( this ); mEditor->setScribbleArea(mScribbleArea); mEditor->init(); mEditor->setObject( object ); mScribbleArea->setCore( mEditor ); mScribbleArea->init(); mEditor->setScribbleArea( mScribbleArea ); makeConnections( mEditor, mScribbleArea ); mCommands = new CommandCenter( this ); mCommands->setCore( mEditor ); createDockWidgets(); createMenus(); setupKeyboardShortcuts(); readSettings(); connect( mEditor, &Editor::needSave, this, &MainWindow2::saveDocument ); connect( mToolBox, &ToolBoxWidget::clearButtonClicked, mEditor, &Editor::clearCurrentFrame ); //connect( mScribbleArea, &ScribbleArea::refreshPreview, mPreview, &PreviewWidget::updateImage ); mEditor->setCurrentLayer( mEditor->object()->getLayerCount() - 1 ); mEditor->tools()->setDefaultTool(); mBackground->init(mEditor->preference()); mEditor->updateObject(); mEditor->color()->setColorNumber(0); }
void MainWindow2::preferences() { PreferencesDialog* prefDialog = new PreferencesDialog( this ); prefDialog->setAttribute( Qt::WA_DeleteOnClose ); prefDialog->init( mEditor->preference() ); connect( prefDialog, &PreferencesDialog::windowOpacityChange, this, &MainWindow2::setOpacity ); connect( prefDialog, &PreferencesDialog::finished, [ &] { qDebug() << "Preference dialog closed!"; clearKeyboardShortcuts(); setupKeyboardShortcuts(); } ); prefDialog->show(); }