13
0

VisibilityTracker needs to inherit from sigc::tracker so that it can be used without combination with other sigc::trackable parents; fix partially_visible() logic

This commit is contained in:
Paul Davis 2013-05-04 22:01:32 -04:00
parent 9267648e5d
commit 69a3310037
2 changed files with 12 additions and 10 deletions

View File

@ -28,7 +28,7 @@ namespace GTK {
namespace Gtkmm2ext {
class VisibilityTracker {
class VisibilityTracker : public virtual sigc::trackable {
public:
VisibilityTracker (Gtk::Window&);
virtual ~VisibilityTracker() {}
@ -39,8 +39,10 @@ class VisibilityTracker {
bool not_visible() const;
bool partially_visible() const;
Gtk::Window& window () const { return _window; }
private:
Gtk::Window& window;
Gtk::Window& _window;
GdkVisibilityState _visibility;
bool handle_visibility_notify_event (GdkEventVisibility*);
};

View File

@ -24,11 +24,11 @@
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
@ -42,26 +42,26 @@ void
VisibilityTracker::cycle_visibility ()
{
if (fully_visible ()) {
window.hide ();
_window.hide ();
} else {
window.present ();
_window.present ();
}
}
bool
VisibilityTracker::fully_visible () const
{
return window.is_mapped() && (_visibility == GDK_VISIBILITY_UNOBSCURED);
return _window.is_mapped() && (_visibility == GDK_VISIBILITY_UNOBSCURED);
}
bool
VisibilityTracker::not_visible () const
{
return !window.is_mapped() || (_visibility == GDK_VISIBILITY_FULLY_OBSCURED);
return !_window.is_mapped() || (_visibility == GDK_VISIBILITY_FULLY_OBSCURED);
}
bool
VisibilityTracker::partially_visible () const
{
return window.is_mapped() && (_visibility == GDK_VISIBILITY_PARTIAL);
return _window.is_mapped() && ((_visibility == GDK_VISIBILITY_PARTIAL) || (_visibility == GDK_VISIBILITY_UNOBSCURED));
}