diff --git a/panda/src/gui/guiButton.cxx b/panda/src/gui/guiButton.cxx index ec7d7ba6d9..58efc0e577 100644 --- a/panda/src/gui/guiButton.cxx +++ b/panda/src/gui/guiButton.cxx @@ -61,10 +61,11 @@ inline void GetExtents(GuiLabel* v, GuiLabel* w, GuiLabel* x, GuiLabel* y, static void enter_button(CPT_Event e) { GuiButton* val = find_in_buttons_map(e->get_name()); if (val == (GuiButton *)NULL) { - if (gui_cat.is_debug()) { +#ifdef _DEBUG + if (gui_cat.is_debug()) gui_cat.debug() << "Ignoring event " << e->get_name() << " for deleted button\n"; - } +#endif return; } val->test_ref_count_integrity(); @@ -74,10 +75,11 @@ static void enter_button(CPT_Event e) { static void exit_button(CPT_Event e) { GuiButton* val = find_in_buttons_map(e->get_name()); if (val == (GuiButton *)NULL) { - if (gui_cat.is_debug()) { +#ifdef _DEBUG + if (gui_cat.is_debug()) gui_cat.debug() << "Ignoring event " << e->get_name() << " for deleted button\n"; - } +#endif return; } val->test_ref_count_integrity(); @@ -87,10 +89,11 @@ static void exit_button(CPT_Event e) { static void click_button_down(CPT_Event e) { GuiButton* val = find_in_buttons_map(e->get_name()); if (val == (GuiButton *)NULL) { - if (gui_cat.is_debug()) { +#ifdef _DEBUG + if (gui_cat.is_debug()) gui_cat.debug() << "Ignoring event " << e->get_name() << " for deleted button\n"; - } +#endif return; } val->test_ref_count_integrity(); @@ -100,10 +103,12 @@ static void click_button_down(CPT_Event e) { static void click_button_up(CPT_Event e) { GuiButton* val = find_in_buttons_map(e->get_name()); if (val == (GuiButton *)NULL) { +#ifdef _DEBUG if (gui_cat.is_debug()) { gui_cat.debug() << "Ignoring event " << e->get_name() << " for deleted button\n"; } +#endif return; } val->test_ref_count_integrity(); @@ -162,10 +167,12 @@ void GuiButton::switch_state(GuiButton::States nstate) { else _mgr->add_label(_up, _alt_root); if (!_up_event.empty()) { +#ifdef _DEBUG gui_cat->debug() << "throwing _up_event '" << _up_event << "'" << endl; +#endif throw_event(_up_event); - } else - gui_cat->debug() << "_up_event is empty!" << endl; + } else + gui_cat->debug() << "_up_event is empty!" << endl; _rgn->trap_clicks(true); if ((ostate == INACTIVE) || (ostate == INACTIVE_ROLLOVER)) _mgr->add_region(_rgn); @@ -177,10 +184,12 @@ void GuiButton::switch_state(GuiButton::States nstate) { else _mgr->add_label(_up_rollover, _alt_root); if (!_up_rollover_event.empty()) { +#ifdef _DEBUG gui_cat->debug() << "throwing _up_rollover_event '" << _up_rollover_event << "'" << endl; +#endif throw_event(_up_rollover_event); - } else + } else gui_cat->debug() << "_up_rollover_event is empty!" << endl; } else { if (_alt_root.is_null()) @@ -188,7 +197,9 @@ void GuiButton::switch_state(GuiButton::States nstate) { else _mgr->add_label(_up, _alt_root); if (!_up_event.empty()) { +#ifdef _DEBUG gui_cat->debug() << "throwing _up_event '" << _up_event << "'" << endl; +#endif throw_event(_up_event); } else gui_cat->debug() << "_up_event is empty!" << endl; @@ -306,22 +317,30 @@ void GuiButton::set_priority(GuiLabel* l, GuiItem::Priority p) { void GuiButton::behavior_up(CPT_Event, void* data) { GuiButton* button = (GuiButton*)data; +#ifdef _DEBUG gui_cat->debug() << "behavior_up (0x" << data << ")" << endl; +#endif button->run_button_up(); } void GuiButton::behavior_down(CPT_Event, void* data) { GuiButton* button = (GuiButton*)data; +#ifdef _DEBUG gui_cat->debug() << "behavior_down (0x" << data << ")" << endl; +#endif button->run_button_down(); } void GuiButton::run_button_up(void) { +#ifdef _DEBUG gui_cat->debug() << "run_button_up (0x" << (void*)this << " '" << this->get_name() << "')" << endl; +#endif if (_eh == (EventHandler*)0L) return; +#ifdef _DEBUG gui_cat->debug() << "doing work" << endl; +#endif _eh->remove_hook(_up_event, GuiButton::behavior_up, (void*)this); _eh->remove_hook(_up_rollover_event, GuiButton::behavior_up, (void*)this); if (!_behavior_event.empty()) { @@ -335,12 +354,16 @@ void GuiButton::run_button_up(void) { } void GuiButton::run_button_down(void) { +#ifdef _DEBUG gui_cat->debug() << "run_button_down (0x" << (void*)this << " '" << this->get_name() << "')" << endl; +#endif if (_eh == (EventHandler*)0L) return; +#ifdef _DEBUG gui_cat->debug() << "doing work, up_event is '" << _up_event << "' '" << _up_rollover_event << "'" << endl; +#endif _eh->add_hook(_up_event, GuiButton::behavior_up, (void*)this); _eh->add_hook(_up_rollover_event, GuiButton::behavior_up, (void*)this); } @@ -579,7 +602,9 @@ void GuiButton::stop_behavior(void) { } void GuiButton::reset_behavior(void) { +#ifdef _DEBUG gui_cat->debug() << this->get_name() << "::reset_behavior()" << endl; +#endif GuiBehavior::reset_behavior(); if (_mgr == (GuiManager*)0L) return; diff --git a/panda/src/gui/guiListBox.cxx b/panda/src/gui/guiListBox.cxx index 5d685ac5b5..25d1dd872b 100644 --- a/panda/src/gui/guiListBox.cxx +++ b/panda/src/gui/guiListBox.cxx @@ -44,8 +44,10 @@ void GuiListBox::recompute_frame(void) { tp = frm[3]; (*i)->freeze(); int lvl = (*i)->thaw(); +#ifdef _DEBUG gui_cat->debug() << "in recompute: freeze lvl (" << (*i)->get_name() << ") = " << lvl << endl; +#endif } _left = lft; _right = rgt; diff --git a/panda/src/gui/guiManager.cxx b/panda/src/gui/guiManager.cxx index b8a2b15b9b..4b932a1fef 100644 --- a/panda/src/gui/guiManager.cxx +++ b/panda/src/gui/guiManager.cxx @@ -22,21 +22,27 @@ GuiManager* GuiManager::get_ptr(GraphicsWindow* w, MouseAndKeyboard* mak, Node *root2d) { GuiManager* ret; if (_map == (GuiMap*)0L) { +#ifdef _DEBUG if (gui_cat->is_debug()) gui_cat->debug() << "allocating a manager map" << endl; +#endif _map = new GuiMap; } GuiMap::const_iterator gi; gi = _map->find(w); if (gi != _map->end()) { ret = (*gi).second; +#ifdef _DEBUG if (gui_cat->is_debug()) gui_cat->debug() << "a manager for this window already exists (0x" << (void*)ret << ")" << endl; +#endif } else { // going to allocate a new GuiManager for this window +#ifdef _DEBUG if (gui_cat->is_debug()) gui_cat->debug() << "allocating a new manager for this window" << endl; +#endif // first see if there is a mouseWatcher already under the MouseAndKeyboard bool has_watcher = false; TypeHandle dgt = DataRelation::get_class_type(); @@ -50,8 +56,10 @@ GuiManager* GuiManager::get_ptr(GraphicsWindow* w, MouseAndKeyboard* mak, if (!has_watcher) { // there isn't already a mousewatcher in the data graph, so we'll make // one and re-parent everything to it. +#ifdef _DEBUG if (gui_cat->is_debug()) gui_cat->debug() << "no MouseWatcher found, making one" << endl; +#endif watcher = new MouseWatcher("GUI watcher"); DataRelation* tmp = new DataRelation(mak, watcher); for (int j=0; jget_num_children(dgt); ++j) { @@ -60,29 +68,38 @@ GuiManager* GuiManager::get_ptr(GraphicsWindow* w, MouseAndKeyboard* mak, // it's not the node we just created, so reparent it to ours rel->change_parent(watcher); } - } else if (gui_cat->is_debug()) + } else { + if (gui_cat->is_debug()) gui_cat->debug() << "found a MouseWatcher, don't have to make one" << endl; + } // now setup event triggers for the watcher - if (has_watcher && !watcher->get_button_down_pattern().empty()) +#ifdef _DEBUG + if (has_watcher && !watcher->get_button_down_pattern().empty()) { gui_cat->warning() << "overwriting existing button down pattern '" << watcher->get_button_down_pattern() << "' with 'gui-%r-%b'" << endl; - watcher->set_button_down_pattern("gui-%r-%b"); - if (has_watcher && !watcher->get_button_up_pattern().empty()) + } + if (has_watcher && !watcher->get_button_up_pattern().empty()) { gui_cat->warning() << "overwriting existing button up pattern '" << watcher->get_button_up_pattern() << "' with 'gui-%r-%b-up'" << endl; - watcher->set_button_up_pattern("gui-%r-%b-up"); - if (has_watcher && !watcher->get_enter_pattern().empty()) + } + if (has_watcher && !watcher->get_enter_pattern().empty()) { gui_cat->warning() << "overwriting existing enter pattern '" << watcher->get_enter_pattern() << "' with 'gui-in-%r'" << endl; - watcher->set_enter_pattern("gui-in-%r"); - if (has_watcher && !watcher->get_leave_pattern().empty()) + } + + if (has_watcher && !watcher->get_leave_pattern().empty()) { gui_cat->warning() << "overwriting existing exit pattern '" << watcher->get_leave_pattern() << "' with 'gui-out-%r'" << endl; + } +#endif + watcher->set_button_down_pattern("gui-%r-%b"); + watcher->set_button_up_pattern("gui-%r-%b-up"); + watcher->set_enter_pattern("gui-in-%r"); watcher->set_leave_pattern("gui-out-%r"); if (root2d == (Node *)NULL) { @@ -110,15 +127,19 @@ GuiManager* GuiManager::get_ptr(GraphicsWindow* w, MouseAndKeyboard* mak, DisplayRegion *dr = layer->make_display_region(); nassertr(dr != (DisplayRegion*)0L, NULL); dr->set_camera(cam); +#ifdef _DEBUG if (gui_cat->is_debug()) gui_cat->debug() << "2D layer created" << endl; +#endif } // now make the manager for this window ret = new GuiManager(watcher, root2d); +#ifdef _DEBUG if (gui_cat->is_debug()) gui_cat->debug() << "new manager allocated (0x" << (void*)ret << ")" << endl; +#endif (*_map)[w] = ret; } return ret; diff --git a/panda/src/gui/guiRegion.cxx b/panda/src/gui/guiRegion.cxx index 7c8849af4f..b24b473417 100644 --- a/panda/src/gui/guiRegion.cxx +++ b/panda/src/gui/guiRegion.cxx @@ -9,6 +9,8 @@ TypeHandle GuiRegion::_type_handle; GuiRegion::~GuiRegion(void) { +#ifdef _DEBUG if (gui_cat->is_debug()) gui_cat->debug() << "deleting region '" << *this << "'" << endl; +#endif } diff --git a/panda/src/gui/guiRollover.I b/panda/src/gui/guiRollover.I index 091459e307..bb3730e3e0 100644 --- a/panda/src/gui/guiRollover.I +++ b/panda/src/gui/guiRollover.I @@ -8,9 +8,11 @@ INLINE GuiRollover::GuiRollover(void) { INLINE void GuiRollover::enter(void) { if (_state) { +#ifdef _DEBUG if (gui_cat->is_debug()) gui_cat->debug() << "entered '" << *this << "' more then once without exit" << endl; +#endif } else if (_mgr != (GuiManager*)0L) { _mgr->remove_label(_off); if (_alt_root.is_null()) @@ -23,9 +25,11 @@ INLINE void GuiRollover::enter(void) { INLINE void GuiRollover::exit(void) { if (!_state) { +#ifdef _DEBUG if (gui_cat->is_debug()) gui_cat->debug() << "exited '" << *this << "' more then once without enter" << endl; +#endif } else if (_mgr != (GuiManager*)0L) { _mgr->remove_label(_on); if (_alt_root.is_null()) diff --git a/panda/src/gui/guiRollover.cxx b/panda/src/gui/guiRollover.cxx index 75b5c17ac2..fdcb2c96b0 100644 --- a/panda/src/gui/guiRollover.cxx +++ b/panda/src/gui/guiRollover.cxx @@ -38,10 +38,11 @@ inline void GetExtents(GuiLabel* x, GuiLabel* y, float& l, float& r, float& b, static void enter_rollover(CPT_Event e) { GuiRollover* val = find_in_rollovers_map(e->get_name()); if (val == (GuiRollover *)NULL) { - if (gui_cat.is_debug()) { +#ifdef _DEBUG + if (gui_cat.is_debug()) gui_cat.debug() << "Ignoring event " << e->get_name() << " for deleted rollover\n"; - } +#endif return; } val->enter(); @@ -50,10 +51,11 @@ static void enter_rollover(CPT_Event e) { static void exit_rollover(CPT_Event e) { GuiRollover* val = find_in_rollovers_map(e->get_name()); if (val == (GuiRollover *)NULL) { - if (gui_cat.is_debug()) { +#ifdef _DEBUG + if (gui_cat.is_debug()) gui_cat.debug() << "Ignoring event " << e->get_name() << " for deleted rollover\n"; - } +#endif return; } val->exit(); diff --git a/panda/src/gui/guiSign.cxx b/panda/src/gui/guiSign.cxx index 2b36f99c95..2abc879ebb 100644 --- a/panda/src/gui/guiSign.cxx +++ b/panda/src/gui/guiSign.cxx @@ -58,12 +58,16 @@ void GuiSign::unmanage(void) { } int GuiSign::freeze() { +#ifdef _DEBUG gui_cat->spam() << "GuiSign::freeze (" << this->get_name() << ")" << endl; +#endif return _sign->freeze(); } int GuiSign::thaw() { +#ifdef _DEBUG gui_cat->spam() << "GuiSign::thaw (" << this->get_name() << ")" << endl; +#endif return _sign->thaw(); }