nux-1.14.0
HueRangeValuator.cpp
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 #include "Nux.h"
00024 #include "EditTextBox.h"
00025 #include "HLayout.h"
00026 #include "RangeValue.h"
00027 #include "HueRangeValuator.h"
00028 
00029 namespace nux
00030 {
00031 
00032   HueRangeValuator::HueRangeValuator (float value, float vmin, float vmax)
00033     :   RangeValue (value, vmin, vmax)
00034     ,   m_HLSSaturation (1.0f)
00035     ,   m_HLSLight (1.0f)
00036     ,   m_HSVSaturation (1.0f)
00037     ,   m_HSVValue (1.0f)
00038     ,   m_Model (color::HLS)
00039   {
00040     InitializeLayout();
00041     InitializeWidgets();
00042   }
00043 
00044   HueRangeValuator::~HueRangeValuator()
00045   {
00046   }
00047 
00048   void HueRangeValuator::InitializeWidgets()
00049   {
00050 
00051   }
00052 
00053   void HueRangeValuator::InitializeLayout()
00054   {
00055 
00056   }
00057 
00058   void HueRangeValuator::Draw (GraphicsEngine &GfxContext, bool force_draw)
00059   {
00060     Geometry base = GetGeometry();
00061 
00062     GfxContext.PushClippingRectangle (base);
00063 
00064     Geometry P = m_Percentage->GetGeometry();
00065 
00066     if (m_Model == color::HLS)
00067     {
00068       float s = 1.0f - m_HLSSaturation;
00069       float l = m_HLSLight;
00070       float fw = P.GetWidth() / 6;
00071 
00072       Geometry p = Geometry (P.x, P.y, fw, P.GetHeight() );
00073       GetPainter().Paint2DQuadColor (GfxContext, p, Color (1.0f * l, s * l, s * l), Color (1.0f * l, s * l, s * l),
00074                                  Color (1.0f * l, 1.0f * l, s * l), Color (1.0f * l, 1.0f * l, s * l) );
00075       p.SetX (P.x + fw);
00076       GetPainter().Paint2DQuadColor (GfxContext, p, Color (1.0f * l, 1.0f * l, s * l), Color (1.0f * l, 1.0f * l, s * l),
00077                                  Color (s * l, 1.0f * l, s * l), Color (s * l, 1.0f * l, s * l) );
00078 
00079       p.SetX (P.x + 2 * fw);
00080       GetPainter().Paint2DQuadColor (GfxContext, p, Color (s * l, 1.0f * l, s * l), Color (s * l, 1.0f * l, s * l),
00081                                  Color (s * l, 1.0f * l, 1.0f * l), Color (s * l, 1.0f * l, 1.0f * l) );
00082       p.SetX (P.x + 3 * fw);
00083       GetPainter().Paint2DQuadColor (GfxContext, p, Color (s * l, 1.0f * l, 1.0f * l), Color (s * l, 1.0f * l, 1.0f * l),
00084                                  Color (s * l, s * l, 1.0f * l), Color (s * l, s * l, 1.0f * l) );
00085 
00086       p.SetX (P.x + 4 * fw);
00087       GetPainter().Paint2DQuadColor (GfxContext, p, Color (s * l, s * l, 1.0f * l), Color (s * l, s * l, 1.0f * l),
00088                                  Color (1.0f * l, s * l, 1.0f * l), Color (1.0f * l, s * l, 1.0f * l) );
00089       p.SetX (P.x + 5 * fw);
00090       p.SetWidth (P.GetWidth() - 5 * fw); // correct rounding errors
00091       GetPainter().Paint2DQuadColor (GfxContext, p, Color (1.0f * l, s * l, 1.0f * l), Color (1.0f * l, s * l, 1.0f * l),
00092                                  Color (1.0f * l, s * l, s * l), Color (1.0f * l, s * l, s * l) );
00093     }
00094     else
00095     {
00096       float s = 1.0f - m_HSVSaturation;
00097       float v = m_HSVValue;
00098       float fw = P.GetWidth() / 6;
00099 
00100       Geometry p = Geometry (P.x, P.y, fw, P.GetHeight() );
00101       GetPainter().Paint2DQuadColor (GfxContext, p, Color (1.0f * v, s * v, s * v), Color (1.0f * v, s * v, s * v),
00102                                  Color (1.0f * v, 1.0f * v, s * v), Color (1.0f * v, 1.0f * v, s * v) );
00103       p.SetX (P.x + fw);
00104       GetPainter().Paint2DQuadColor (GfxContext, p, Color (1.0f * v, 1.0f * v, s * v), Color (1.0f * v, 1.0f * v, s * v),
00105                                  Color (s * v, 1.0f * v, s * v), Color (s * v, 1.0f * v, s * v) );
00106 
00107       p.SetX (P.x + 2 * fw);
00108       GetPainter().Paint2DQuadColor (GfxContext, p, Color (s * v, 1.0f * v, s * v), Color (s * v, 1.0f * v, s * v),
00109                                  Color (s * v, 1.0f * v, 1.0f * v), Color (s * v, 1.0f * v, 1.0f * v) );
00110       p.SetX (P.x + 3 * fw);
00111       GetPainter().Paint2DQuadColor (GfxContext, p, Color (s * v, 1.0f * v, 1.0f * v), Color (s * v, 1.0f * v, 1.0f * v),
00112                                  Color (s * v, s * v, 1.0f * v), Color (s * v, s * v, 1.0f * v) );
00113 
00114       p.SetX (P.x + 4 * fw);
00115       GetPainter().Paint2DQuadColor (GfxContext, p, Color (s * v, s * v, 1.0f * v), Color (s * v, s * v, 1.0f * v),
00116                                  Color (1.0f * v, s * v, 1.0f * v), Color (1.0f * v, s * v, 1.0f * v) );
00117       p.SetX (P.x + 5 * fw);
00118       p.SetWidth (P.GetWidth() - 5 * fw); // correct rounding errors
00119       GetPainter().Paint2DQuadColor (GfxContext, p, Color (1.0f * v, s * v, 1.0f * v), Color (1.0f * v, s * v, 1.0f * v),
00120                                  Color (1.0f * v, s * v, s * v), Color (1.0f * v, s * v, s * v) );
00121     }
00122 
00123     m_ValueString->QueueDraw();
00124     DrawMarker (GfxContext);
00125 
00126     GfxContext.PopClippingRectangle();
00127   }
00128 
00129 
00130 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends