Mutable Event Raising
Moderators: CEGUI MVP, CEGUI Team
- Jeff_Leigh
- Just popping in
- Posts: 13
- Joined: Wed Jan 12, 2005 12:06
- Location: Yes
- Contact:
Mutable Event Raising
Hmm... I don't seem to be able to set the value of a scrollbar without firing it's event handler. It would be nice to be able to disable event raising when setting these properties, perhaps via an optional boolean to the function or something.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Mutable Event Raising
This is something that I did consider, but ultimately left out (no reason other than the fact that I thought it not so very useful).
I'll add it to the to-do list (basically, I'll offer this for every setting on every widget). I'll do it using an additional boolean parameter as you suggested, since then I can default it to true, and not break any existing code. This will probably be done by around this time next week, providing everything else goes smoothly in the mean time.
I'll add it to the to-do list (basically, I'll offer this for every setting on every widget). I'll do it using an additional boolean parameter as you suggested, since then I can default it to true, and not break any existing code. This will probably be done by around this time next week, providing everything else goes smoothly in the mean time.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Mutable Event Raising
Hey Jeff,
Do you still nedd this? I made a start (I'm about a 3rd of the way through), though it's turning out to be a major modification I'm now on the fence about whether or not to actually go though with this, as the changes I'm making feel very "uncomfortable" IYKWIM
it's only adding an optional parameter to the event handlers, but this change permeates thoughout the entire system, so now half the methods need an additional parameter. The other option was to set an enable/disable events option, but I didn't particularly like that either.
Any other suggestions? Or perhaps we can work around your issue?
Do you still nedd this? I made a start (I'm about a 3rd of the way through), though it's turning out to be a major modification I'm now on the fence about whether or not to actually go though with this, as the changes I'm making feel very "uncomfortable" IYKWIM
it's only adding an optional parameter to the event handlers, but this change permeates thoughout the entire system, so now half the methods need an additional parameter. The other option was to set an enable/disable events option, but I didn't particularly like that either.
Any other suggestions? Or perhaps we can work around your issue?
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Mutable Event Raising
I have thought about this some more, and I will add a method to the EventSet class which enables you to mute/unmute all events attached to it. This will enable you to do what you need (as well as some other things, obviously) without needing complex changes throughout the system. I'll get this change into CVS tonight.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Mutable Event Raising
Okay. This is now done. As stated above the change was made to EventSet, so any class with this as a base class will automatically get this functionality (so all Windows & widgets).
You have to use it like this:
It's maybe not the most elegant solution, but it's cetainly better than the vast changes needed to implement it within the windowing system itself. This has been committed to CVS, but since there's a 5hr wait for anonymous access to sync, this is the patch:
You have to use it like this:
Code: Select all
// disable events
myScrollbar->setMutedState(true);
.
Do whatever here
.
// re-enable events
myScrollbar->setMutedState(false);
It's maybe not the most elegant solution, but it's cetainly better than the vast changes needed to implement it within the windowing system itself. This has been committed to CVS, but since there's a 5hr wait for anonymous access to sync, this is the patch:
Code: Select all
Index: include/CEGUIEventSet.h
===================================================================
RCS file: /cvsroot/crayzedsgui/cegui_mk2/include/CEGUIEventSet.h,v
retrieving revision 1.1
diff -u -r1.1 CEGUIEventSet.h
--- include/CEGUIEventSet.h 26 Mar 2004 14:27:19 -0000 1.1
+++ include/CEGUIEventSet.h 12 Jul 2004 18:15:21 -0000
@@ -163,6 +163,32 @@
*/
void fireEvent(const String& name, const EventArgs& args);
+
+ /*!
+ \brief
+ Return whether the EventSet is muted or not.
+
+ \return
+ - true if the EventSet is muted. All requests to fire events will be ignored.
+ - false if the EventSet is not muted. All requests to fire events are processed as normal.
+ */
+ bool isMuted(void) const;
+
+
+ /*!
+ \brief
+ Set the mute state for this EventSet.
+
+ \param setting
+ - true if the EventSet is to be muted (no further event firing requests will be honoured until EventSet is unmuted).
+ - false if the EventSet is not to be muted and all events should fired as requested.
+
+ \return
+ Nothing.
+ */
+ void setMutedState(bool setting);
+
+
private:
// Do not allow copying, assignment, or any other usage than simple creation.
EventSet(EventSet& e) {}
@@ -170,6 +196,8 @@
typedef std::map<String, Event*> EventMap;
EventMap d_events;
+
+ bool d_muted; //!< true if events for this EventSet have been muted.
};
} // End of CEGUI namespace section
Index: src/CEGUIEventSet.cpp
===================================================================
RCS file: /cvsroot/crayzedsgui/cegui_mk2/src/CEGUIEventSet.cpp,v
retrieving revision 1.1
diff -u -r1.1 CEGUIEventSet.cpp
--- src/CEGUIEventSet.cpp 26 Mar 2004 14:27:19 -0000 1.1
+++ src/CEGUIEventSet.cpp 12 Jul 2004 18:15:21 -0000
@@ -33,7 +33,8 @@
/*************************************************************************
Constructor
*************************************************************************/
-EventSet::EventSet(void)
+EventSet::EventSet(void) :
+ d_muted(false)
{
}
@@ -147,7 +148,30 @@
}
// fire the event
- (*pos->second)(args);
+ if (!d_muted)
+ {
+ (*pos->second)(args);
+ }
+
+}
+
+
+/*************************************************************************
+ Return whether the EventSet is muted or not.
+*************************************************************************/
+bool EventSet::isMuted(void) const
+{
+ return d_muted;
+}
+
+
+/*************************************************************************
+ Set the mute state for this EventSet.
+*************************************************************************/
+void EventSet::setMutedState(bool setting)
+{
+ d_muted = setting;
}
+
} // End of CEGUI namespace section
- Jeff_Leigh
- Just popping in
- Posts: 13
- Joined: Wed Jan 12, 2005 12:06
- Location: Yes
- Contact:
Mutable Event Raising
Oh, great.
Sorry I couldn't get back to you sooner, I've been on vacation.
Your approach looks good. The only thing I really needed it for was in the case of my colour rect demo, you could set the RGB and HSL bars seperately... and moving one would update the other. Unfortunatly, when the RGB bars updated the HSL bars... it would fire events in the HSL bars that updated the RGB bars.... etc. So it's good to be able to mute them.
I'll update to the latest CVS tonight and implement my new ColourRect stuff tomarrow hopefully.
Sorry I couldn't get back to you sooner, I've been on vacation.
Your approach looks good. The only thing I really needed it for was in the case of my colour rect demo, you could set the RGB and HSL bars seperately... and moving one would update the other. Unfortunatly, when the RGB bars updated the HSL bars... it would fire events in the HSL bars that updated the RGB bars.... etc. So it's good to be able to mute them.
I'll update to the latest CVS tonight and implement my new ColourRect stuff tomarrow hopefully.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Mutable Event Raising
That's okay
I figured the issue would be some infinite cycle of some kind.
I figured the issue would be some infinite cycle of some kind.
Return to “Bug Reports, Suggestions, Feature Requests”
Who is online
Users browsing this forum: No registered users and 1 guest