1
0
Fork 0

Prevent PUI menubar obscuring startup tips

Add an additional visibility flag to the menubar implementations, 
conditional on whether or not the menubar overlaps the window content.
(I.e for PUI but not Cocoa). This flag is linked to a new property
/sim/menubar/overlap-hide, which the renderer drives off the splash-
screen visibility.
This commit is contained in:
James Turner 2017-05-11 08:39:48 +01:00
parent 4dc2e4fc09
commit 00845b17b9
8 changed files with 91 additions and 5 deletions

View file

@ -55,6 +55,14 @@ public:
* Test whether the menu bar is visible. * Test whether the menu bar is visible.
*/ */
virtual bool isVisible () const; virtual bool isVisible () const;
/**
* This is a no-op on Cocoa - the menubar doesn't overlap the window
* when its drawn.
*/
void setHideIfOverlapsWindow(bool hide) override;
bool getHideIfOverlapsWindow() const override;
class CocoaMenuBarPrivate; class CocoaMenuBarPrivate;
private: private:

View file

@ -9,6 +9,7 @@
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/structure/SGBinding.hxx> #include <simgear/structure/SGBinding.hxx>
#include <simgear/misc/strutils.hxx> #include <simgear/misc/strutils.hxx>
#include <simgear/sg_inlines.h>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <GUI/CocoaHelpers_private.h> #include <GUI/CocoaHelpers_private.h>
@ -325,3 +326,14 @@ void FGCocoaMenuBar::hide()
// no-op // no-op
} }
void FGCocoaMenuBar::setHideIfOverlapsWindow(bool hide)
{
SG_UNUSED(hide);
// no-op
}
bool FGCocoaMenuBar::getHideIfOverlapsWindow() const
{
return false;
}

View file

@ -111,17 +111,15 @@ FGPUIMenuBar::init ()
void void
FGPUIMenuBar::show () FGPUIMenuBar::show ()
{ {
if (_menuBar != 0)
_menuBar->reveal();
_visible = true; _visible = true;
recomputeVisibility();
} }
void void
FGPUIMenuBar::hide () FGPUIMenuBar::hide ()
{ {
if (_menuBar != 0)
_menuBar->hide();
_visible = false; _visible = false;
recomputeVisibility();
} }
bool bool
@ -130,6 +128,32 @@ FGPUIMenuBar::isVisible () const
return _visible; return _visible;
} }
void
FGPUIMenuBar::setHideIfOverlapsWindow(bool hide)
{
_hideOverlapping = hide;
recomputeVisibility();
}
bool
FGPUIMenuBar::getHideIfOverlapsWindow() const
{
return _hideOverlapping;
}
void
FGPUIMenuBar::recomputeVisibility()
{
if (_menuBar) {
const bool actualVis = _visible && (!_hideOverlapping);
if (actualVis) {
_menuBar->reveal();
} else {
_menuBar->hide();
}
}
}
void void
FGPUIMenuBar::fireItem (puObject * item) FGPUIMenuBar::fireItem (puObject * item)
{ {

View file

@ -69,7 +69,10 @@ public:
*/ */
virtual bool isVisible () const; virtual bool isVisible () const;
void setHideIfOverlapsWindow(bool hide) override;
bool getHideIfOverlapsWindow() const override;
/** /**
* IGNORE THIS METHOD!!! * IGNORE THIS METHOD!!!
* *
@ -113,9 +116,12 @@ private:
// Add <enabled> listener that enables/disables menu entries. // Add <enabled> listener that enables/disables menu entries.
void add_enabled_listener(SGPropertyNode * node); void add_enabled_listener(SGPropertyNode * node);
void recomputeVisibility();
// Is the menu visible? // Is the menu visible?
bool _visible; bool _visible;
bool _hideOverlapping = false;
// The top-level menubar itself. // The top-level menubar itself.
puMenuBar * _menuBar; puMenuBar * _menuBar;

View file

@ -48,6 +48,19 @@ public:
*/ */
virtual bool isVisible () const = 0; virtual bool isVisible () const = 0;
/**
* Request the menubar to be hidden if its display overlays the main window content.
* (Which essentially means the PUI menubar at the moment). This is used to prevent
* the menubar overlapping the splash-screen during startup.
*
* The state of this flag is independant of the normal menubar visibility, i.e this
* flag and the normal visibility and AND-ed together inside the code.
*/
virtual void setHideIfOverlapsWindow(bool hide) = 0;
// corresponding getter to valye able.
virtual bool getHideIfOverlapsWindow() const = 0;
/** /**
* Read a menu label from the menu's property tree. * Read a menu label from the menu's property tree.
* Take care of mapping it to the appropriate translation, if available. * Take care of mapping it to the appropriate translation, if available.

View file

@ -71,6 +71,9 @@ NewGUI::init ()
fgTie("/sim/menubar/visibility", this, fgTie("/sim/menubar/visibility", this,
&NewGUI::getMenuBarVisible, &NewGUI::setMenuBarVisible); &NewGUI::getMenuBarVisible, &NewGUI::setMenuBarVisible);
fgTie("/sim/menubar/overlap-hide", this,
&NewGUI::getMenuBarOverlapHide, &NewGUI::setMenuBarOverlapHide);
setStyle(); setStyle();
SGPath p(globals->get_fg_root(), "gui/dialogs"); SGPath p(globals->get_fg_root(), "gui/dialogs");
readDir(p); readDir(p);
@ -305,6 +308,18 @@ NewGUI::setMenuBarVisible (bool visible)
_menubar->hide(); _menubar->hide();
} }
bool
NewGUI::getMenuBarOverlapHide() const
{
return _menubar->getHideIfOverlapsWindow();
}
void
NewGUI::setMenuBarOverlapHide(bool hide)
{
_menubar->setHideIfOverlapsWindow(hide);
}
void void
NewGUI::newDialog (SGPropertyNode* props) NewGUI::newDialog (SGPropertyNode* props)
{ {

View file

@ -201,6 +201,8 @@ protected:
*/ */
virtual void reset (bool reload); virtual void reset (bool reload);
bool getMenuBarOverlapHide() const;
void setMenuBarOverlapHide(bool hide);
private: private:
void createMenuBarImplementation(); void createMenuBarImplementation();

View file

@ -468,6 +468,11 @@ FGRenderer::preinit( void )
_updateVisitor->setFrameStamp(_frameStamp.get()); _updateVisitor->setFrameStamp(_frameStamp.get());
viewer->setUpdateVisitor(_updateVisitor.get()); viewer->setUpdateVisitor(_updateVisitor.get());
fgSetDouble("/sim/startup/splash-alpha", 1.0); fgSetDouble("/sim/startup/splash-alpha", 1.0);
// hide the menubar if it overlaps the window, so the splash screen
// is completely visible. We reset this value when the splash screen
// is fading out.
fgSetBool("/sim/menubar/overlap-hide", true);
} }
class ShadowMapSizeListener : public SGPropertyChangeListener { class ShadowMapSizeListener : public SGPropertyChangeListener {
@ -1594,6 +1599,7 @@ FGRenderer::update( ) {
_splash_alpha->setDoubleValue((sAlpha < 0) ? 0.0 : sAlpha); _splash_alpha->setDoubleValue((sAlpha < 0) ? 0.0 : sAlpha);
syncPausePopupState(); syncPausePopupState();
fgSetBool("/sim/menubar/overlap-hide", false);
} }
FGLight *l = static_cast<FGLight*>(globals->get_subsystem("lighting")); FGLight *l = static_cast<FGLight*>(globals->get_subsystem("lighting"));