fix sticky rollover buttons
This commit is contained in:
parent
ab3fe7e180
commit
dc6b1cbe79
|
|
@ -102,6 +102,9 @@ remove_region(MouseWatcherRegion *region) {
|
|||
|
||||
remove_region_from(_current_regions, region);
|
||||
if (region == _preferred_region) {
|
||||
if (_preferred_region != (MouseWatcherRegion *)NULL) {
|
||||
exit_region(_preferred_region, MouseWatcherParameter());
|
||||
}
|
||||
_preferred_region = (MouseWatcherRegion *)NULL;
|
||||
}
|
||||
if (region == _preferred_button_down_region) {
|
||||
|
|
@ -160,7 +163,8 @@ add_group(MouseWatcherGroup *group) {
|
|||
|
||||
#ifndef NDEBUG
|
||||
if (!_show_regions_render2d.is_empty()) {
|
||||
group->show_regions(_show_regions_render2d);
|
||||
group->show_regions(_show_regions_render2d, _show_regions_bin_name,
|
||||
_show_regions_draw_order);
|
||||
}
|
||||
#endif // NDEBUG
|
||||
|
||||
|
|
@ -188,6 +192,9 @@ remove_group(MouseWatcherGroup *group) {
|
|||
_current_regions.swap(only_a);
|
||||
|
||||
if (has_region_in(both, _preferred_region)) {
|
||||
if (_preferred_region != (MouseWatcherRegion *)NULL) {
|
||||
exit_region(_preferred_region, MouseWatcherParameter());
|
||||
}
|
||||
_preferred_region = (MouseWatcherRegion *)NULL;
|
||||
}
|
||||
if (has_region_in(both, _preferred_button_down_region)) {
|
||||
|
|
@ -241,7 +248,8 @@ replace_group(MouseWatcherGroup *old_group, MouseWatcherGroup *new_group) {
|
|||
#ifndef NDEBUG
|
||||
if (!_show_regions_render2d.is_empty()) {
|
||||
old_group->do_hide_regions();
|
||||
new_group->do_show_regions(_show_regions_render2d);
|
||||
new_group->do_show_regions(_show_regions_render2d, _show_regions_bin_name,
|
||||
_show_regions_draw_order);
|
||||
}
|
||||
#endif // NDEBUG
|
||||
|
||||
|
|
@ -258,6 +266,9 @@ replace_group(MouseWatcherGroup *old_group, MouseWatcherGroup *new_group) {
|
|||
_current_regions.swap(only_a);
|
||||
|
||||
if (has_region_in(both, _preferred_region)) {
|
||||
if (_preferred_region != (MouseWatcherRegion *)NULL) {
|
||||
exit_region(_preferred_region, MouseWatcherParameter());
|
||||
}
|
||||
_preferred_region = (MouseWatcherRegion *)NULL;
|
||||
}
|
||||
if (has_region_in(both, _preferred_button_down_region)) {
|
||||
|
|
@ -598,14 +609,17 @@ clear_current_regions() {
|
|||
// assumes the lock is already held.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MouseWatcher::
|
||||
do_show_regions(const NodePath &render2d) {
|
||||
MouseWatcherGroup::do_show_regions(render2d);
|
||||
do_show_regions(const NodePath &render2d, const string &bin_name,
|
||||
int draw_order) {
|
||||
MouseWatcherGroup::do_show_regions(render2d, bin_name, draw_order);
|
||||
_show_regions_render2d = render2d;
|
||||
_show_regions_bin_name = bin_name;
|
||||
_show_regions_draw_order = draw_order;
|
||||
|
||||
Groups::const_iterator gi;
|
||||
for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
|
||||
MouseWatcherGroup *group = (*gi);
|
||||
group->show_regions(render2d);
|
||||
group->show_regions(render2d, bin_name, draw_order);
|
||||
}
|
||||
}
|
||||
#endif // NDEBUG
|
||||
|
|
@ -621,6 +635,8 @@ void MouseWatcher::
|
|||
do_hide_regions() {
|
||||
MouseWatcherGroup::do_hide_regions();
|
||||
_show_regions_render2d = NodePath();
|
||||
_show_regions_bin_name = string();
|
||||
_show_regions_draw_order = 0;
|
||||
|
||||
Groups::const_iterator gi;
|
||||
for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
|
||||
|
|
|
|||
|
|
@ -127,7 +127,8 @@ protected:
|
|||
void clear_current_regions();
|
||||
|
||||
#ifndef NDEBUG
|
||||
virtual void do_show_regions(const NodePath &render2d);
|
||||
virtual void do_show_regions(const NodePath &render2d,
|
||||
const string &bin_name, int draw_order);
|
||||
virtual void do_hide_regions();
|
||||
#endif // NDEBUG
|
||||
|
||||
|
|
@ -201,6 +202,8 @@ private:
|
|||
|
||||
#ifndef NDEBUG
|
||||
NodePath _show_regions_render2d;
|
||||
string _show_regions_bin_name;
|
||||
int _show_regions_draw_order;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -220,9 +220,9 @@ write(ostream &out, int indent_level) const {
|
|||
// for the window.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MouseWatcherGroup::
|
||||
show_regions(const NodePath &render2d) {
|
||||
show_regions(const NodePath &render2d, const string &bin_name, int draw_order) {
|
||||
MutexHolder holder(_lock);
|
||||
do_show_regions(render2d);
|
||||
do_show_regions(render2d, bin_name, draw_order);
|
||||
}
|
||||
#endif // NDEBUG
|
||||
|
||||
|
|
@ -313,11 +313,12 @@ do_remove_region(MouseWatcherRegion *region) {
|
|||
// assumes the lock is already held.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MouseWatcherGroup::
|
||||
do_show_regions(const NodePath &render2d) {
|
||||
do_show_regions(const NodePath &render2d, const string &bin_name,
|
||||
int draw_order) {
|
||||
do_hide_regions();
|
||||
_show_regions = true;
|
||||
_show_regions_root = render2d.attach_new_node("show_regions");
|
||||
_show_regions_root.set_bin("unsorted", 0);
|
||||
_show_regions_root.set_bin(bin_name, draw_order);
|
||||
do_update_regions();
|
||||
}
|
||||
#endif // NDEBUG
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ PUBLISHED:
|
|||
void write(ostream &out, int indent_level = 0) const;
|
||||
|
||||
#ifndef NDEBUG
|
||||
void show_regions(const NodePath &render2d);
|
||||
void show_regions(const NodePath &render2d,
|
||||
const string &bin_name, int draw_order);
|
||||
void set_color(const Colorf &color);
|
||||
void hide_regions();
|
||||
|
||||
|
|
@ -63,7 +64,8 @@ protected:
|
|||
bool do_remove_region(MouseWatcherRegion *region);
|
||||
|
||||
#ifndef NDEBUG
|
||||
virtual void do_show_regions(const NodePath &render2d);
|
||||
virtual void do_show_regions(const NodePath &render2d,
|
||||
const string &bin_name, int draw_order);
|
||||
virtual void do_hide_regions();
|
||||
void do_update_regions();
|
||||
#endif // NDEBUG
|
||||
|
|
|
|||
Loading…
Reference in New Issue