nux-1.16.0
RGBProperty.h
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef RGBPROPERTY_H
00024 #define RGBPROPERTY_H
00025 
00026 #include "NuxCore/Color.h"
00027 
00028 namespace nux
00029 {
00030 
00031   class ToggleButton;
00032   class ColorGradientPropertyItem;
00033 
00034   // TODO: Tim Penhey 2011-05-12
00035   // Both this class and RGBAPropertyItem should share a base class
00036   // as many of the color calculations are common to the two.
00037   class RGBPropertyItem: public SectionProperty
00038   {
00039     NODE_XML_CLASS_MEMBER (RGBPropertyItem);
00040     NODE_SKIP_CHILD (true);
00041     NODE_SIG_RECEIVER (RecvPropertyChange, ColorGradient *);
00042 
00043   public:
00044     RGBPropertyItem (const TCHAR *name, float red = 0.0f, float green = 0.0f, float blue = 0.0f);
00045     virtual ~RGBPropertyItem();
00046 
00047     virtual long ProcessPropertyEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00048     virtual void DrawProperty (GraphicsEngine &GfxContext, TableCtrl *table, bool force_draw, Geometry geo, const BasePainter &Painter, RowHeader *row, const std::vector<ColumnHeader>& column_vector, Color ItemBackgroundColor = Color (0x0) );
00049     virtual void ComputePropertyLayout (int x, int y, RowHeader *row, const std::vector<ColumnHeader>& column_vector);
00050     virtual int GetItemBestHeight();
00051 
00052     void SetRed (double red)
00053     {
00054       m_red->SetValue (red);
00055       UpdateStartToEndColors();
00056     }
00057     void SetGreen (double green)
00058     {
00059       m_green->SetValue (green);
00060       UpdateStartToEndColors();
00061     }
00062     void SetBlue (double blue)
00063     {
00064       m_blue->SetValue (blue);
00065       UpdateStartToEndColors();
00066     }
00067 
00068     double GetRed()     const
00069     {
00070       return rgb_values_.red;
00071     }
00072     double GetGreen()   const
00073     {
00074       return rgb_values_.green;
00075     }
00076     double GetBlue()    const
00077     {
00078       return rgb_values_.blue;
00079     }
00080 
00081     void SetColor (double red, double green, double blue)
00082     {
00083       m_red->SetValue (red);
00084       m_green->SetValue (green);
00085       m_blue->SetValue (blue);
00086       UpdateStartToEndColors();
00087     }
00088 
00089     void OnChangeColorModel();
00090     void OnChangeColorFormat();
00091 
00092     void SetColorModel(color::Model cm);
00093     void SetColorFormat(color::Format cf);
00094 
00095   private:
00096     void UpdateStartToEndColors();
00097 
00098     void RedChange (ColorGradient *slider);
00099     void GreenChange (ColorGradient *slider);
00100     void BlueChange (ColorGradient *slider);
00101     void AlphaChange (ColorGradient *slider);
00102 
00103     ColorGradientPropertyItem *m_red;
00104     ColorGradientPropertyItem *m_green;
00105     ColorGradientPropertyItem *m_blue;
00106 
00107     color::RedGreenBlue rgb_values_;
00108     ToggleButton *m_ColorModel;
00109     ToggleButton *m_ColorFormat;
00110     color::Model color_model_;
00111     color::Format color_format_;
00112 
00113   };
00114 
00115 }
00116 
00117 #endif // RGBPROPERTY_H
00118 
00119 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends