Hi Robert,

many thanks for integrating the feature! I'll have a look at the code asap  and 
do some testing.

cheers,

Stephan

Am 22.10.2013 um 21:12 schrieb Robert Osfield <[email protected]>:

> Hi Stephan,
> 
> I have just checked in your changes to DisplaySettings (with the OSX prefix 
> to methods) and also my proposed changes to WindowSystemInterface that 
> introduce a virtual s/getDisplaySettings() method, and calling of this to 
> assign the DisplaySettings objects within the 
> Viewer/CompositeViewer::realize() just before the windows are realized.  I 
> think this approach should work OK for implementing the window behaviour 
> under OSX.  Let me know if things are step in the right direction.
> 
> Cheers,
> Robert.
> 
> ~/OpenSceneGraph$ svn diff
> Index: include/osg/DisplaySettings
> ===================================================================
> --- include/osg/DisplaySettings (revision 13850)
> +++ include/osg/DisplaySettings (working copy)
> @@ -283,22 +283,30 @@
>  
>          /** Get the hint of the profile mask to use in when creating graphic 
> contexts.*/
>          unsigned int getGLContextProfileMask() const { return 
> _glContextProfileMask; }
> -        
> -        
> +
> +
>          void setKeystoneHint(bool enabled) { _keystoneHint = enabled; }
>          bool getKeystoneHint() const { return _keystoneHint; }
> -        
> +
>          typedef std::vector<std::string> FileNames;
>          void setKeystoneFileNames(const FileNames& filenames) { 
> _keystoneFileNames = filenames; }
>          FileNames& getKeystoneFileNames() { return _keystoneFileNames; }
>          const FileNames& getKeystoneFileNames() const { return 
> _keystoneFileNames; }
> -        
> +
>          typedef std::vector< osg::ref_ptr<osg::Object> > Objects;
>          void setKeystones(const Objects& objects) { _keystones = objects; }
>          Objects& getKeystones() { return _keystones; }
>          const Objects& getKeystones() const { return _keystones; }
>  
> +        enum OSXMenubarBehavior {
> +            MENUBAR_AUTO_HIDE,
> +            MENUBAR_FORCE_HIDE,
> +            MENUBAR_FORCE_SHOW
> +        };
>  
> +        OSXMenubarBehavior getOSXMenubarBehavior() const { return 
> _OSXMenubarBehavior; }
> +        void setOSXMenubarBehavior(OSXMenubarBehavior hint) { 
> _OSXMenubarBehavior = hint; }
> +
>          /** helper function for computing the left eye projection matrix.*/
>          virtual osg::Matrixd computeLeftEyeProjectionImplementation(const 
> osg::Matrixd& projection) const;
>  
> @@ -365,11 +373,13 @@
>  
>          SwapMethod                      _swapMethod;
>  
> -    
> +
>          bool                            _keystoneHint;
>          FileNames                       _keystoneFileNames;
> -        Objects                         _keystones; 
> -        
> +        Objects                         _keystones;
> +
> +        OSXMenubarBehavior              _OSXMenubarBehavior;
> +
>  };
>  
>  }
> Index: include/osg/GraphicsContext
> ===================================================================
> --- include/osg/GraphicsContext (revision 13850)
> +++ include/osg/GraphicsContext (working copy)
> @@ -176,6 +176,10 @@
>  
>              virtual void enumerateScreenSettings(const ScreenIdentifier& 
> screenIdentifier, ScreenSettingsList & resolutionList) = 0;
>  
> +            virtual void setDisplaySettings(DisplaySettings*) {}
> +
> +            virtual osg::DisplaySettings* getDisplaySettings() const { 
> return 0; }
> +
>              virtual GraphicsContext* createGraphicsContext(Traits* traits) = 
> 0;
>  
>              virtual ~WindowingSystemInterface() {}
> @@ -206,6 +210,7 @@
>                  settings.refreshRate = refreshRate;
>                  return setScreenSettings(screenIdentifier, settings);
>              }
> +
>          };
>  
>  
> Index: src/osg/DisplaySettings.cpp
> ===================================================================
> --- src/osg/DisplaySettings.cpp (revision 13850)
> +++ src/osg/DisplaySettings.cpp (working copy)
> @@ -100,6 +100,8 @@
>      _keystoneHint = vs._keystoneHint;
>      _keystoneFileNames = vs._keystoneFileNames;
>      _keystones = vs._keystones;
> +
> +    _OSXMenubarBehavior = vs._OSXMenubarBehavior;
>  }
>  
>  void DisplaySettings::merge(const DisplaySettings& vs)
> @@ -157,6 +159,9 @@
>          Objects::iterator found_itr = std::find(_keystones.begin(), 
> _keystones.end(), object);
>          if (found_itr == _keystones.end()) 
> _keystones.push_back(const_cast<osg::Object*>(object));
>      }
> +
> +    if (vs._OSXMenubarBehavior > _OSXMenubarBehavior)
> +        _OSXMenubarBehavior = vs._OSXMenubarBehavior;
>  }
>  
>  void DisplaySettings::setDefaults()
> @@ -215,6 +220,8 @@
>      _swapMethod = SWAP_DEFAULT;
>  
>      _keystoneHint = false;
> +
> +    _OSXMenubarBehavior = MENUBAR_AUTO_HIDE;
>  }
>  
>  void DisplaySettings::setMaxNumberOfGraphicsContexts(unsigned int num)
> @@ -327,6 +334,9 @@
>          "OSG_KEYSTONE_FILES <filename>[:filename]..",
>          "Specify filenames of keystone parameter files. Under Windows use ; 
> to deliminate files, otherwise use :");
>  
> +static ApplicationUsageProxy 
> DisplaySetting_e30(ApplicationUsage::ENVIRONMENTAL_VARIABLE,
> +        "OSG_MENUBAR_BEHAVIOR <behavior>",
> +        "OSX Only : Specify the behavior of the menubar (AUTO_HIDE, 
> FORCE_HIDE, FORCE_SHOW)");
>  
>  void DisplaySettings::readEnvironmentalVariables()
>  {
> @@ -658,6 +668,24 @@
>                  _keystoneFileNames.push_back(lastPath);
>          }
>      }
> +
> +    if( (ptr = getenv("OSG_MENUBAR_BEHAVIOR")) != 0)
> +    {
> +        if (strcmp(ptr,"AUTO_HIDE")==0)
> +        {
> +            _OSXMenubarBehavior = MENUBAR_AUTO_HIDE;
> +        }
> +        else
> +        if (strcmp(ptr,"FORCE_HIDE")==0)
> +        {
> +            _OSXMenubarBehavior = MENUBAR_FORCE_HIDE;
> +        }
> +        else
> +        if (strcmp(ptr,"FORCE_SHOW")==0)
> +        {
> +            _OSXMenubarBehavior = MENUBAR_FORCE_SHOW;
> +        }
> +    }
>  }
>  
>  void DisplaySettings::readCommandLine(ArgumentParser& arguments)
> @@ -686,6 +714,7 @@
>          arguments.getApplicationUsage()->addCommandLineOption("--keystone 
> <filename>","Specify a keystone file to be used by the viewer for keystone 
> correction.");
>          
> arguments.getApplicationUsage()->addCommandLineOption("--keystone-on","Set 
> the keystone hint to true to tell the viewer to do keystone correction.");
>          
> arguments.getApplicationUsage()->addCommandLineOption("--keystone-off","Set 
> the keystone hint to false.");
> +        
> arguments.getApplicationUsage()->addCommandLineOption("--menubar-behavior 
> <behavior>","Set the menubar behavior (AUTO_HIDE | FORCE_HIDE | FORCE_SHOW)");
>      }
>  
>      std::string str;
> @@ -824,6 +853,12 @@
>          else if (str=="UNDEFINED") _swapMethod = SWAP_UNDEFINED;
>      }
>  
> +    while(arguments.read("--menubar-behavior",str))
> +    {
> +        if (str=="AUTO_HIDE") _OSXMenubarBehavior = MENUBAR_AUTO_HIDE;
> +        else if (str=="FORCE_HIDE") _OSXMenubarBehavior = MENUBAR_FORCE_HIDE;
> +        else if (str=="FORCE_SHOW") _OSXMenubarBehavior = MENUBAR_FORCE_SHOW;
> +    }
>  
>  }
>  
> Index: src/osgViewer/CompositeViewer.cpp
> ===================================================================
> --- src/osgViewer/CompositeViewer.cpp   (revision 13850)
> +++ src/osgViewer/CompositeViewer.cpp   (working copy)
> @@ -585,9 +585,16 @@
>          return;
>      }
>  
> -    unsigned int maxTexturePoolSize = 
> osg::DisplaySettings::instance()->getMaxTexturePoolSize();
> -    unsigned int maxBufferObjectPoolSize = 
> osg::DisplaySettings::instance()->getMaxBufferObjectPoolSize();
> +    // get the display settings that will be active for this viewer
> +    osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
> +    osg::GraphicsContext::WindowingSystemInterface* wsi = 
> osg::GraphicsContext::getWindowingSystemInterface();
>  
> +    // pass on the display settings to the WindowSystemInterface.
> +    if (wsi && wsi->getDisplaySettings()==0) wsi->setDisplaySettings(ds);
> +
> +    unsigned int maxTexturePoolSize = ds->getMaxTexturePoolSize();
> +    unsigned int maxBufferObjectPoolSize = ds->getMaxBufferObjectPoolSize();
> +
>      for(Contexts::iterator citr = contexts.begin();
>          citr != contexts.end();
>          ++citr)
> Index: src/osgViewer/Viewer.cpp
> ===================================================================
> --- src/osgViewer/Viewer.cpp    (revision 13850)
> +++ src/osgViewer/Viewer.cpp    (working copy)
> @@ -520,14 +520,16 @@
>          return;
>      }
>  
> -    unsigned int maxTexturePoolSize = 
> osg::DisplaySettings::instance()->getMaxTexturePoolSize();
> -    if (_camera->getDisplaySettings()) maxTexturePoolSize = 
> std::max(maxTexturePoolSize, 
> _camera->getDisplaySettings()->getMaxTexturePoolSize());
> -    if (_displaySettings.valid()) maxTexturePoolSize = 
> std::max(maxTexturePoolSize, _displaySettings->getMaxTexturePoolSize());
> +    // get the display settings that will be active for this viewer
> +    osg::DisplaySettings* ds = _displaySettings.valid() ? 
> _displaySettings.get() : osg::DisplaySettings::instance().get();
> +    osg::GraphicsContext::WindowingSystemInterface* wsi = 
> osg::GraphicsContext::getWindowingSystemInterface();
>  
> -    unsigned int maxBufferObjectPoolSize = 
> osg::DisplaySettings::instance()->getMaxBufferObjectPoolSize();
> -    if (_displaySettings.valid()) maxBufferObjectPoolSize = 
> std::max(maxBufferObjectPoolSize, 
> _displaySettings->getMaxBufferObjectPoolSize());
> -    if (_camera->getDisplaySettings()) maxBufferObjectPoolSize = 
> std::max(maxBufferObjectPoolSize, 
> _camera->getDisplaySettings()->getMaxBufferObjectPoolSize());
> +    // pass on the display settings to the WindowSystemInterface.
> +    if (wsi && wsi->getDisplaySettings()==0) wsi->setDisplaySettings(ds);
>  
> +    unsigned int maxTexturePoolSize = ds->getMaxTexturePoolSize();
> +    unsigned int maxBufferObjectPoolSize = ds->getMaxBufferObjectPoolSize();
> +
>      for(Contexts::iterator citr = contexts.begin();
>          citr != contexts.end();
>          ++citr)
> 
> _______________________________________________
> osg-submissions mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to