#ifndef _GUI_SETTING_
#define _GUI_SETTING_

#include "ofMain.h"
#include "ofAddons.h"

//float/int/bool settings control


class guiSetting
{
	public:
		
		guiSetting(){
			valueF 	= 0.0;
			incrF  	= 1.0;			
			maxF   	= 999999;
			minF   	= -999999;	
			section	= 0;
			changed = false;
		}
		
		void setGroupID(int groupID){
			section = groupID;
		}
		
		void setValue(float val){
			float tmp = valueF;
		
			valueF = val;
			
			if(tmp != valueF)changed = true;
		}
		
		void setValue(int val){		
			float tmp = valueF;

			valueF  = (float)val;
			
			if(tmp != valueF)changed = true;
		}
	
		float getValueF(){
			return valueF;
		}
		
		int getValueI(){
			return (int)valueF;
		}		
		
		void setChanged(bool isChanged){
			changed = isChanged;
		}
		
		bool getChanged(){
			
			bool rtnVal = false;
			
			if(changed){
				rtnVal  = true;
				changed = false;
			}
			
			return rtnVal;
		}
		
		int getGroupID(){
			return section;
		}
		
		void setName(string xmlName, string displayName){			
			xml 	= xmlName;
			name 	= displayName;
		}
		
		void setIncr(float increment)
		{
			incrF = increment;
		}
		
		void setIncr(int increment)
		{
			incrF = (float)increment;
		}		
		
		void setMinMax( float mn, float mx)
		{
			maxF = mx;
			minF = mn;
		}
		
		void increase()
		{
			float tmp = valueF;
		
			valueF += incrF;
			if(valueF >= maxF) valueF = maxF;
			
			if(tmp != valueF)changed = true;
		}
		
		void decrease()
		{
			float tmp = valueF;

			valueF -= incrF;
			if(valueF <= minF) valueF = minF;
			
			if(tmp != valueF)changed = true;
		}
		
		string getXmlName(){
			return xml;
		}
		
		string getDisplayName(){
			return name;
		}

	protected:
	
		float maxF;
		float minF;		
		float incrF;		
		float valueF;
				
		string name;
		string xml;
		int section;
		bool changed;
};

#endif