diff --git a/panda/src/gui/guiButton.cxx b/panda/src/gui/guiButton.cxx index 532bb512d8..1575ba3d2f 100644 --- a/panda/src/gui/guiButton.cxx +++ b/panda/src/gui/guiButton.cxx @@ -613,15 +613,30 @@ void GuiButton::set_priority(GuiItem* i, const GuiItem::Priority p) { } int GuiButton::set_draw_order(int v) { - int o = _up->set_draw_order(v); - o = _down->set_draw_order(o); - if (_up_rollover != (GuiLabel*)0L) - o = _up_rollover->set_draw_order(o); - if (_down_rollover != (GuiLabel*)0L) - o = _down_rollover->set_draw_order(o); - if (_inactive != (GuiLabel*)0L) - o = _inactive->set_draw_order(o); - return GuiBehavior::set_draw_order(o); + // No two of these labels will ever be drawn simultaneously, so + // there's no need to cascade the draw orders. They can each be + // assigned the same value, and the value we return is the maximum + // of any of the values returned by the labels. + int o = _rgn->set_draw_order(v); + int o1 = _up->set_draw_order(v); + o = max(o, o1); + o1 = _down->set_draw_order(v); + o = max(o, o1); + if (_up_rollover != (GuiLabel*)0L) { + o1 = _up_rollover->set_draw_order(v); + o = max(o, o1); + } + if (_down_rollover != (GuiLabel*)0L) { + o1 = _down_rollover->set_draw_order(v); + o = max(o, o1); + } + if (_inactive != (GuiLabel*)0L) { + o1 = _inactive->set_draw_order(v); + o = max(o, o1); + } + o1 = GuiBehavior::set_draw_order(v); + o = max(o, o1); + return o; } void GuiButton::output(ostream& os) const { diff --git a/panda/src/gui/guiRegion.I b/panda/src/gui/guiRegion.I index 27e13a324a..51edd56ee9 100644 --- a/panda/src/gui/guiRegion.I +++ b/panda/src/gui/guiRegion.I @@ -47,3 +47,8 @@ INLINE LVector4f GuiRegion::get_frame(void) const { _region->test_ref_count_integrity(); return LVector4f(_left, _right, _bottom, _top); } + +INLINE int GuiRegion::set_draw_order(int draw_order) { + _region->set_sort(draw_order); + return draw_order + 1; +} diff --git a/panda/src/gui/guiRegion.h b/panda/src/gui/guiRegion.h index 5859aa8467..08ee10b8aa 100644 --- a/panda/src/gui/guiRegion.h +++ b/panda/src/gui/guiRegion.h @@ -36,6 +36,7 @@ PUBLISHED: INLINE void set_region(float, float, float, float); INLINE LVector4f get_frame(void) const; + INLINE int set_draw_order(int); public: // type interface