inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/sg/base_button
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file inlib.license for terms.
00003 
00004 #ifndef inlib_sg_base_button
00005 #define inlib_sg_base_button
00006 
00007 // inheritance :
00008 #include "cbks"
00009 
00010 #include "sfs"
00011 #include "../colorf"
00012 
00013 namespace inlib {
00014 namespace sg {
00015 
00016 class base_button : public inlib::sg::cbks {
00017 public:
00018   static const std::string& s_class() {
00019     static const std::string s_v("inlib::sg::base_button");
00020     return s_v;
00021   }
00022 public:
00023   virtual void* cast(const std::string& a_class) const {
00024     if(void* p = inlib::cmp_cast<base_button>(this,a_class)) return p;
00025     return inlib::sg::cbks::cast(a_class);
00026   }
00027 public:
00028   sf_vec<colorf,float> arm_color;
00029 public:
00030   base_button(inlib::sg::sf_vec<inlib::colorf,float>& a_field)
00031   : inlib::sg::cbks()
00032   ,arm_color(inlib::colorf::grey())
00033   ,m_color_sf(a_field)
00034 
00035   ,m_is_armed(false)
00036   {
00037   }
00038   virtual ~base_button(){}
00039 public:
00040   base_button(const base_button& a_from)
00041   : inlib::sg::cbks(a_from)
00042   ,arm_color(a_from.arm_color)
00043   ,m_color_sf(a_from.m_color_sf)
00044 
00045   ,m_is_armed(a_from.m_is_armed)
00046   {
00047     //add_fields();
00048   }
00049   base_button& operator=(const base_button& a_from){
00050     inlib::sg::cbks::operator=(a_from);
00051     arm_color = a_from.arm_color;
00052     m_is_armed = a_from.m_is_armed;
00053     return *this;
00054   }
00055 public:
00056   void touch() {m_color_sf.touch();}
00057 
00058   void arm() {
00059     if(m_is_armed) return; //done.
00060     m_saved_color = m_color_sf.value();
00061     m_color_sf = arm_color;
00062     m_is_armed = true;
00063   }
00064   void disarm() {
00065     if(!m_is_armed) return;
00066     m_color_sf = m_saved_color;
00067     m_is_armed = false;
00068   }
00069 
00070   bool is_armed() const {return m_is_armed;}
00071 protected:
00072   inlib::sg::sf_vec<inlib::colorf,float>& m_color_sf;
00073   inlib::colorf m_saved_color;
00074   bool m_is_armed;
00075 };
00076 
00077 }}
00078 
00079 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines