VisibilityTracker needs to inherit from sigc::tracker so that it can be used without...
[ardour.git] / libs / gtkmm2ext / visibility_tracker.cc
index c0aabdfca6d15d2d3e1832dc0af72c108fc30110..7ba282f3f9f251e5ee008f50158cf23e55ee6b24 100644 (file)
 using namespace Gtkmm2ext;
 
 VisibilityTracker::VisibilityTracker (Gtk::Window& win)
-       : window (win)
+       : _window (win)
        , _visibility (GdkVisibilityState (0))
 {
-       window.add_events (Gdk::VISIBILITY_NOTIFY_MASK);
-       window.signal_visibility_notify_event().connect (sigc::mem_fun (*this, &VisibilityTracker::handle_visibility_notify_event));
+       _window.add_events (Gdk::VISIBILITY_NOTIFY_MASK);
+       _window.signal_visibility_notify_event().connect (sigc::mem_fun (*this, &VisibilityTracker::handle_visibility_notify_event));
 }
 
 bool
@@ -41,10 +41,27 @@ VisibilityTracker::handle_visibility_notify_event (GdkEventVisibility* ev)
 void
 VisibilityTracker::cycle_visibility ()
 {
-       if (window.is_mapped() && (_visibility == GDK_VISIBILITY_UNOBSCURED)) {
-               window.hide ();
+       if (fully_visible ()) {
+               _window.hide ();
        } else {
-               window.present ();
+               _window.present ();
        }
 }
 
+bool
+VisibilityTracker::fully_visible () const
+{
+       return _window.is_mapped() && (_visibility == GDK_VISIBILITY_UNOBSCURED);
+}
+
+bool
+VisibilityTracker::not_visible () const
+{
+       return !_window.is_mapped() || (_visibility == GDK_VISIBILITY_FULLY_OBSCURED);
+}
+
+bool
+VisibilityTracker::partially_visible () const
+{
+       return _window.is_mapped() && ((_visibility == GDK_VISIBILITY_PARTIAL) || (_visibility == GDK_VISIBILITY_UNOBSCURED));
+}