diff --git a/panda/src/gui/guiManager.cxx b/panda/src/gui/guiManager.cxx index 9021277455..2d53c42e7d 100644 --- a/panda/src/gui/guiManager.cxx +++ b/panda/src/gui/guiManager.cxx @@ -201,3 +201,35 @@ void GuiManager::recompute_priorities(void) { } _next_draw_order = p; } + +INLINE bool in_range(float x, float a, float b) { + return ((x >= a) && (x <= b)); +} + +INLINE bool overlap(GuiRegion* a, GuiRegion* b) { + LVector4f av = a->get_frame(); + LVector4f bv = b->get_frame(); + + if (in_range(av[0], bv[0], bv[1]) || + in_range(av[1], bv[0], bv[1]) || + in_range(av[2], bv[2], bv[3]) || + in_range(av[3], bv[2], bv[3])) + return true; + return false; +} + +void GuiManager::sanity_check(void) const { + for (RegionSet::const_iterator i=_regions.begin(); i!=_regions.end(); ++i) + for (RegionSet::const_iterator j=_regions.begin(); j!=_regions.end(); ++j) { + if ((*i) == (*j)) + continue; + if (overlap((*i), (*j))) + gui_cat->warning() << "GuiManager::sanity_check: overlapping regions '" + << (*i)->get_name() << "' and '" << (*j)->get_name() + << "'" << endl; + if ((*i)->get_name() == (*j)->get_name()) + gui_cat->warning() << "GuiManager::sanity_check: regions with same " + << "name '" << (*i)->get_name() << " 0x" + << (void*)(*i) << " and 0x" << (void*)(*j) << endl; + } +} diff --git a/panda/src/gui/guiManager.h b/panda/src/gui/guiManager.h index 47d9d9bbf7..2e5b3d94cb 100644 --- a/panda/src/gui/guiManager.h +++ b/panda/src/gui/guiManager.h @@ -57,6 +57,8 @@ PUBLISHED: INLINE void set_next_draw_order(int); INLINE int get_start_draw_order(void) const; INLINE void set_start_draw_order(int); + + void sanity_check(void) const; }; #include "guiManager.I"