Showing the changes to interface/src/Application.cpp (1 of 55 files). Show all
Unified · Split
| @@ -58,6 +58,8 @@ · 57 unmodified lines | ||
| 58 | 58 | #include <AutoUpdater.h> |
| 59 | 59 | #include <DeferredLightingEffect.h> |
| 60 | 60 | #include <DependencyManager.h> |
| 61 | +#include <plugins/PluginContainer.h> | |
| 62 | +#include <plugins/PluginManager.h> | |
| 61 | 63 | #include <display-plugins/DisplayPlugin.h> |
| 62 | 64 | |
| 63 | 65 | #include <EntityScriptingInterface.h> |
| @@ -148,6 +150,8 @@ · 84 unmodified lines | ||
| 148 | 150 | |
| 149 | 151 | #include "ui/overlays/Cube3DOverlay.h" |
| 150 | 152 | |
| 153 | +#include "PluginContainerProxy.h" | |
| 154 | + | |
| 151 | 155 | // ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU |
| 152 | 156 | // FIXME seems to be broken. |
| 153 | 157 | #if defined(Q_OS_WIN) |
| @@ -301,7 +305,7 @@ bool setupEssentials(int& argc, char** argv) { · 147 unmodified lines | ||
| 301 | 305 | // continuing to overburden Application.cpp |
| 302 | 306 | Cube3DOverlay* _keyboardFocusHighlight{ nullptr }; |
| 303 | 307 | int _keyboardFocusHighlightID{ -1 }; |
| 304 | − | |
| 308 | +PluginContainer* _pluginContainer; | |
| 305 | 309 | |
| 306 | 310 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : |
| 307 | 311 | QApplication(argc, argv), |
| @@ -351,7 +355,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 43 unmodified lines | ||
| 351 | 355 | _applicationOverlay() |
| 352 | 356 | { |
| 353 | 357 | setInstance(this); |
| 354 | − Plugin::setContainer(this); | |
| 358 | + | |
| 359 | + _pluginContainer = new PluginContainerProxy(); | |
| 360 | + Plugin::setContainer(_pluginContainer); | |
| 355 | 361 | #ifdef Q_OS_WIN |
| 356 | 362 | installNativeEventFilter(&MyNativeEventFilter::getInstance()); |
| 357 | 363 | #endif |
| @@ -1263,6 +1269,7 @@ void Application::resizeGL() { · 905 unmodified lines | ||
| 1263 | 1269 | // Possible change in aspect ratio |
| 1264 | 1270 | loadViewFrustum(_myCamera, _viewFrustum); |
| 1265 | 1271 | float fov = glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES); |
| 1272 | + // FIXME the aspect ratio for stereo displays is incorrect based on this. | |
| 1266 | 1273 | float aspectRatio = aspect(_renderResolution); |
| 1267 | 1274 | _myCamera.setProjection(glm::perspective(fov, aspectRatio, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP)); |
| 1268 | 1275 | } |
| @@ -1422,7 +1429,15 @@ void Application::keyPressEvent(QKeyEvent* event) { · 153 unmodified lines | ||
| 1422 | 1429 | break; |
| 1423 | 1430 | case Qt::Key_Enter: |
| 1424 | 1431 | case Qt::Key_Return: |
| 1425 | − Menu::getInstance()->triggerOption(MenuOption::AddressBar); | |
| 1432 | + if (isOption) { | |
| 1433 | + if (_window->isFullScreen()) { | |
| 1434 | + _pluginContainer->unsetFullscreen(); | |
| 1435 | + } else { | |
| 1436 | + _pluginContainer->setFullscreen(nullptr); | |
| 1437 | + } | |
| 1438 | + } else { | |
| 1439 | + Menu::getInstance()->triggerOption(MenuOption::AddressBar); | |
| 1440 | + } | |
| 1426 | 1441 | break; |
| 1427 | 1442 | |
| 1428 | 1443 | case Qt::Key_B: |
| @@ -3327,7 +3342,7 @@ namespace render { · 1898 unmodified lines | ||
| 3327 | 3342 | template <> const ItemKey payloadGetKey(const WorldBoxRenderData::Pointer& stuff) { return ItemKey::Builder::opaqueShape(); } |
| 3328 | 3343 | template <> const Item::Bound payloadGetBound(const WorldBoxRenderData::Pointer& stuff) { return Item::Bound(); } |
| 3329 | 3344 | template <> void payloadRender(const WorldBoxRenderData::Pointer& stuff, RenderArgs* args) { |
| 3330 | − if (args->_renderMode != RenderArgs::MIRROR_RENDER_MODE && Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { | |
| 3345 | + if (args->_renderMode != RenderArgs::MIRROR_RENDER_MODE && Menu::getInstance()->isOptionChecked(MenuOption::WorldAxes)) { | |
| 3331 | 3346 | PerformanceTimer perfTimer("worldBox"); |
| 3332 | 3347 | |
| 3333 | 3348 | auto& batch = *args->_batch; |
| @@ -4625,10 +4640,6 @@ void Application::checkSkeleton() { · 1291 unmodified lines | ||
| 4625 | 4640 | } |
| 4626 | 4641 | } |
| 4627 | 4642 | |
| 4628 | −bool Application::isForeground() { | |
| 4629 | − return _isForeground && !getWindow()->isMinimized(); | |
| 4630 | −} | |
| 4631 | − | |
| 4632 | 4643 | void Application::activeChanged(Qt::ApplicationState state) { |
| 4633 | 4644 | switch (state) { |
| 4634 | 4645 | case Qt::ApplicationActive: |
| @@ -4734,6 +4745,10 @@ const DisplayPlugin * Application::getActiveDisplayPlugin() const { · 99 unmodified lines | ||
| 4734 | 4745 | return ((Application*)this)->getActiveDisplayPlugin(); |
| 4735 | 4746 | } |
| 4736 | 4747 | |
| 4748 | +bool _activatingDisplayPlugin{ false }; | |
| 4749 | +QVector<QPair<QString, QString>> _currentDisplayPluginActions; | |
| 4750 | +QVector<QPair<QString, QString>> _currentInputPluginActions; | |
| 4751 | + | |
| 4737 | 4752 | |
| 4738 | 4753 | static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool active = false) { |
| 4739 | 4754 | auto menu = Menu::getInstance(); |
| @@ -4755,9 +4770,6 @@ static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool acti · 15 unmodified lines | ||
| 4755 | 4770 | Q_ASSERT(menu->menuItemExists(MenuOption::OutputMenu, name)); |
| 4756 | 4771 | } |
| 4757 | 4772 | |
| 4758 | −static QVector<QPair<QString, QString>> _currentDisplayPluginActions; | |
| 4759 | −static bool _activatingDisplayPlugin{false}; | |
| 4760 | − | |
| 4761 | 4773 | void Application::updateDisplayMode() { |
| 4762 | 4774 | auto menu = Menu::getInstance(); |
| 4763 | 4775 | auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins(); |
| @@ -4824,7 +4836,7 @@ void Application::updateDisplayMode() { · 60 unmodified lines | ||
| 4824 | 4836 | // Only show the hmd tools after the correct plugin has |
| 4825 | 4837 | // been activated so that it's UI is setup correctly |
| 4826 | 4838 | if (newPluginWantsHMDTools) { |
| 4827 | − showDisplayPluginsTools(); | |
| 4839 | + _pluginContainer->showDisplayPluginsTools(); | |
| 4828 | 4840 | } |
| 4829 | 4841 | |
| 4830 | 4842 | if (oldDisplayPlugin) { |
| @@ -4842,9 +4854,6 @@ void Application::updateDisplayMode() { · 11 unmodified lines | ||
| 4842 | 4854 | Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin"); |
| 4843 | 4855 | } |
| 4844 | 4856 | |
| 4845 | −static QVector<QPair<QString, QString>> _currentInputPluginActions; | |
| 4846 | − | |
| 4847 | − | |
| 4848 | 4857 | static void addInputPluginToMenu(InputPluginPointer inputPlugin, bool active = false) { |
| 4849 | 4858 | auto menu = Menu::getInstance(); |
| 4850 | 4859 | QString name = inputPlugin->getName(); |
| @@ -4918,42 +4927,6 @@ void Application::updateInputModes() { · 67 unmodified lines | ||
| 4918 | 4927 | //} |
| 4919 | 4928 | } |
| 4920 | 4929 | |
| 4921 | −void Application::addMenu(const QString& menuName) { | |
| 4922 | − Menu::getInstance()->addMenu(menuName); | |
| 4923 | −} | |
| 4924 | − | |
| 4925 | −void Application::removeMenu(const QString& menuName) { | |
| 4926 | − Menu::getInstance()->removeMenu(menuName); | |
| 4927 | −} | |
| 4928 | − | |
| 4929 | −void Application::addMenuItem(const QString& path, const QString& name, std::function<void(bool)> onClicked, bool checkable, bool checked, const QString& groupName) { | |
| 4930 | − auto menu = Menu::getInstance(); | |
| 4931 | − MenuWrapper* parentItem = menu->getMenu(path); | |
| 4932 | − QAction* action = menu->addActionToQMenuAndActionHash(parentItem, name); | |
| 4933 | − connect(action, &QAction::triggered, [=] { | |
| 4934 | − onClicked(action->isChecked()); | |
| 4935 | − }); | |
| 4936 | − action->setCheckable(checkable); | |
| 4937 | − action->setChecked(checked); | |
| 4938 | − if (_activatingDisplayPlugin) { | |
| 4939 | − _currentDisplayPluginActions.push_back({ path, name }); | |
| 4940 | − } else { | |
| 4941 | − _currentInputPluginActions.push_back({ path, name }); | |
| 4942 | − } | |
| 4943 | −} | |
| 4944 | − | |
| 4945 | −void Application::removeMenuItem(const QString& menuName, const QString& menuItem) { | |
| 4946 | − Menu::getInstance()->removeMenuItem(menuName, menuItem); | |
| 4947 | −} | |
| 4948 | − | |
| 4949 | −bool Application::isOptionChecked(const QString& name) { | |
| 4950 | − return Menu::getInstance()->isOptionChecked(name); | |
| 4951 | −} | |
| 4952 | − | |
| 4953 | −void Application::setIsOptionChecked(const QString& path, bool checked) { | |
| 4954 | − Menu::getInstance()->setIsOptionChecked(path, checked); | |
| 4955 | −} | |
| 4956 | − | |
| 4957 | 4930 | mat4 Application::getEyeProjection(int eye) const { |
| 4958 | 4931 | if (isHMDMode()) { |
| 4959 | 4932 | return getActiveDisplayPlugin()->getProjection((Eye)eye, _viewFrustum.getProjection()); |
| @@ -4986,89 +4959,6 @@ mat4 Application::getHMDSensorPose() const { · 26 unmodified lines | ||
| 4986 | 4959 | return mat4(); |
| 4987 | 4960 | } |
| 4988 | 4961 | |
| 4989 | −// FIXME there is a bug in the fullscreen setting, where leaving | |
| 4990 | −// fullscreen does not restore the window frame, making it difficult | |
| 4991 | −// or impossible to move or size the window. | |
| 4992 | −// Additionally, setting fullscreen isn't hiding the menu on windows | |
| 4993 | −// make it useless for stereoscopic modes. | |
| 4994 | −void Application::setFullscreen(const QScreen* target) { | |
| 4995 | − if (!_window->isFullScreen()) { | |
| 4996 | − _savedGeometry = _window->geometry(); | |
| 4997 | − } | |
| 4998 | −#ifdef Q_OS_MAC | |
| 4999 | − _window->setGeometry(target->availableGeometry()); | |
| 5000 | −#endif | |
| 5001 | − _window->windowHandle()->setScreen((QScreen*)target); | |
| 5002 | − _window->showFullScreen(); | |
| 5003 | − | |
| 5004 | −#ifndef Q_OS_MAC | |
| 5005 | − // also hide the QMainWindow's menuBar | |
| 5006 | − QMenuBar* menuBar = _window->menuBar(); | |
| 5007 | − if (menuBar) { | |
| 5008 | − menuBar->setVisible(false); | |
| 5009 | − } | |
| 5010 | −#endif | |
| 5011 | −} | |
| 5012 | − | |
| 5013 | −void Application::unsetFullscreen(const QScreen* avoid) { | |
| 5014 | − _window->showNormal(); | |
| 5015 | − | |
| 5016 | − QRect targetGeometry = _savedGeometry; | |
| 5017 | − if (avoid != nullptr) { | |
| 5018 | − QRect avoidGeometry = avoid->geometry(); | |
| 5019 | − if (avoidGeometry.contains(targetGeometry.topLeft())) { | |
| 5020 | − QScreen* newTarget = primaryScreen(); | |
| 5021 | − if (newTarget == avoid) { | |
| 5022 | − foreach(auto screen, screens()) { | |
| 5023 | − if (screen != avoid) { | |
| 5024 | − newTarget = screen; | |
| 5025 | − break; | |
| 5026 | − } | |
| 5027 | − } | |
| 5028 | − } | |
| 5029 | − targetGeometry = newTarget->availableGeometry(); | |
| 5030 | − } | |
| 5031 | − } | |
| 5032 | −#ifdef Q_OS_MAC | |
| 5033 | − QTimer* timer = new QTimer(); | |
| 5034 | − timer->singleShot(2000, [=] { | |
| 5035 | − _window->setGeometry(targetGeometry); | |
| 5036 | − timer->deleteLater(); | |
| 5037 | − }); | |
| 5038 | −#else | |
| 5039 | − _window->setGeometry(targetGeometry); | |
| 5040 | −#endif | |
| 5041 | − | |
| 5042 | −#ifndef Q_OS_MAC | |
| 5043 | − // also show the QMainWindow's menuBar | |
| 5044 | − QMenuBar* menuBar = _window->menuBar(); | |
| 5045 | − if (menuBar) { | |
| 5046 | − menuBar->setVisible(true); | |
| 5047 | − } | |
| 5048 | −#endif | |
| 5049 | −} | |
| 5050 | − | |
| 5051 | − | |
| 5052 | −void Application::showDisplayPluginsTools() { | |
| 5053 | − DependencyManager::get<DialogsManager>()->hmdTools(true); | |
| 5054 | −} | |
| 5055 | − | |
| 5056 | −QGLWidget* Application::getPrimarySurface() { | |
| 5057 | − return _glWidget; | |
| 5058 | −} | |
| 5059 | − | |
| 5060 | −void Application::setActiveDisplayPlugin(const QString& pluginName) { | |
| 5061 | − auto menu = Menu::getInstance(); | |
| 5062 | − foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) { | |
| 5063 | − QString name = displayPlugin->getName(); | |
| 5064 | − QAction* action = menu->getActionForOption(name); | |
| 5065 | − if (pluginName == name) { | |
| 5066 | − action->setChecked(true); | |
| 5067 | − } | |
| 5068 | − } | |
| 5069 | − updateDisplayMode(); | |
| 5070 | −} | |
| 5071 | − | |
| 5072 | 4962 | void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, float deltaTime, int index) { |
| 5073 | 4963 | PalmData* palm; |
| 5074 | 4964 | bool foundHand = false; |