From 82ea6fbb99dff48aedd7c9956f705eb71c1151fc Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Sun, 2 Sep 2012 16:08:13 -0500 Subject: [PATCH 1/7] Update extensions/GUI/CCControlExtension/CCControlSlider.h Added fields and methods for setting the maximum allowed value. --- extensions/GUI/CCControlExtension/CCControlSlider.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.h b/extensions/GUI/CCControlExtension/CCControlSlider.h index 21b6a934d9..bfe8136f2e 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -55,6 +55,11 @@ class CCControlSlider: public CCControl virtual void setMinimumValue(float val); CC_SYNTHESIZE_READONLY(float, m_maximumValue, MaximumValue); virtual void setMaximumValue(float val); + CC_SYNTHESIZE_READONLY(float, m_minimumAllowedValue, MinimumAllowedValue); + virtual void setMinimumAllowedValue(float val); + CC_SYNTHESIZE_READONLY(float, m_maximumAllowedValue, MaximumAllowedValue); + virtual void setMaximumAllowedValue(float val); + //interval to snap to CC_SYNTHESIZE(float, m_snappingInterval, SnappingInterval); From e07320f6a8a18aeb4b262ace220b89b87b9f9b8f Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Sun, 2 Sep 2012 16:10:25 -0500 Subject: [PATCH 2/7] Update extensions/GUI/CCControlExtension/CCControlSlider.cpp Added minimum/maximum allowed values --- .../GUI/CCControlExtension/CCControlSlider.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index b8b3c1bd6a..d47df67c7c 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -161,6 +161,16 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* m_minimumValue = m_maximumValue - 1.0f; setValue(m_value); } + + void CCControlSlider::setMinimumAllowedValue(float minimumAllowedValue) + { + m_minimumAllowedValue = minimumAllowedValue; + } + + void CCControlSlider::setMaximumAllowedValue(float maximumAllowedValue) + { + m_maximumAllowedValue = maximumAllowedValue; + } //this is the same as CCControl::getTouchLocation, but it returns the position relative to the position of this control CCPoint CCControlSlider::getTouchLocationInControl(CCTouch* touch) @@ -224,7 +234,7 @@ void CCControlSlider::sliderEnded(CCPoint location) float CCControlSlider::valueForLocation(CCPoint location) { float percent = (location.x-SLIDER_MARGIN_H)/ m_backgroundSprite->getContentSize().width; - return m_minimumValue + percent * (m_maximumValue - m_minimumValue); + return max(min(m_minimumValue + percent * (m_maximumValue - m_minimumValue), m_maximumAllowedValue), m_minimumAllowedValue); } NS_CC_EXT_END From da819e1109563c5f73edfa4bf49f153aeca88552 Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Sun, 2 Sep 2012 16:31:12 -0500 Subject: [PATCH 3/7] Update extensions/GUI/CCControlExtension/CCControlSlider.cpp Added default values for max/min allowed values --- extensions/GUI/CCControlExtension/CCControlSlider.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index d47df67c7c..077cc7288b 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -149,6 +149,7 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* void CCControlSlider::setMinimumValue(float minimumValue) { m_minimumValue=minimumValue; + m_minimumAllowedValue = minimumValue; if (m_minimumValue >= m_maximumValue) m_maximumValue = m_minimumValue + 1.0f; setValue(m_value); @@ -157,6 +158,7 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* void CCControlSlider::setMaximumValue(float maximumValue) { m_maximumValue=maximumValue; + m_maximumAllowedValue = maximumValue; if (m_maximumValue <= m_minimumValue) m_minimumValue = m_maximumValue - 1.0f; setValue(m_value); From a4d2d317b53a67ca588e295fa04fa36c8a0be442 Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Mon, 3 Sep 2012 09:46:55 -0500 Subject: [PATCH 4/7] Update extensions/GUI/CCControlExtension/CCControlSlider.cpp --- extensions/GUI/CCControlExtension/CCControlSlider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index 077cc7288b..061527f710 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -236,7 +236,7 @@ void CCControlSlider::sliderEnded(CCPoint location) float CCControlSlider::valueForLocation(CCPoint location) { float percent = (location.x-SLIDER_MARGIN_H)/ m_backgroundSprite->getContentSize().width; - return max(min(m_minimumValue + percent * (m_maximumValue - m_minimumValue), m_maximumAllowedValue), m_minimumAllowedValue); + return MAX(MIN(m_minimumValue + percent * (m_maximumValue - m_minimumValue), m_maximumAllowedValue), m_minimumAllowedValue); } NS_CC_EXT_END From f6f370ffeab2c654595f1e1a659b37c91cf8e560 Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Tue, 4 Sep 2012 20:48:04 -0500 Subject: [PATCH 5/7] Update extensions/GUI/CCControlExtension/CCControlSlider.h changed CC_SYNTHESIZE_READONLY to CC_SYNTHESIZE --- extensions/GUI/CCControlExtension/CCControlSlider.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.h b/extensions/GUI/CCControlExtension/CCControlSlider.h index bfe8136f2e..e8fe9de314 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -55,9 +55,9 @@ class CCControlSlider: public CCControl virtual void setMinimumValue(float val); CC_SYNTHESIZE_READONLY(float, m_maximumValue, MaximumValue); virtual void setMaximumValue(float val); - CC_SYNTHESIZE_READONLY(float, m_minimumAllowedValue, MinimumAllowedValue); + CC_SYNTHESIZE(float, m_minimumAllowedValue, MinimumAllowedValue); virtual void setMinimumAllowedValue(float val); - CC_SYNTHESIZE_READONLY(float, m_maximumAllowedValue, MaximumAllowedValue); + CC_SYNTHESIZE(float, m_maximumAllowedValue, MaximumAllowedValue); virtual void setMaximumAllowedValue(float val); From 423abc6f1070742b901ea9eaeb968808da9d086b Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Tue, 4 Sep 2012 20:54:17 -0500 Subject: [PATCH 6/7] Update extensions/GUI/CCControlExtension/CCControlSlider.h Removed meaningless setter...the macro already makes one... --- extensions/GUI/CCControlExtension/CCControlSlider.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.h b/extensions/GUI/CCControlExtension/CCControlSlider.h index e8fe9de314..407c2b41ec 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -55,10 +55,9 @@ class CCControlSlider: public CCControl virtual void setMinimumValue(float val); CC_SYNTHESIZE_READONLY(float, m_maximumValue, MaximumValue); virtual void setMaximumValue(float val); + CC_SYNTHESIZE(float, m_minimumAllowedValue, MinimumAllowedValue); - virtual void setMinimumAllowedValue(float val); CC_SYNTHESIZE(float, m_maximumAllowedValue, MaximumAllowedValue); - virtual void setMaximumAllowedValue(float val); //interval to snap to From 0a96915da2ad3b66b09f1ee2b0a65dd91f4f15c7 Mon Sep 17 00:00:00 2001 From: ThePickleMan Date: Tue, 4 Sep 2012 20:54:34 -0500 Subject: [PATCH 7/7] Update extensions/GUI/CCControlExtension/CCControlSlider.cpp Removed meaningless setter...the macro already makes one... --- extensions/GUI/CCControlExtension/CCControlSlider.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index 061527f710..18a7bc28c4 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -163,16 +163,6 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* m_minimumValue = m_maximumValue - 1.0f; setValue(m_value); } - - void CCControlSlider::setMinimumAllowedValue(float minimumAllowedValue) - { - m_minimumAllowedValue = minimumAllowedValue; - } - - void CCControlSlider::setMaximumAllowedValue(float maximumAllowedValue) - { - m_maximumAllowedValue = maximumAllowedValue; - } //this is the same as CCControl::getTouchLocation, but it returns the position relative to the position of this control CCPoint CCControlSlider::getTouchLocationInControl(CCTouch* touch)