Back to index

nux  3.0.0
line-separator.cpp
Go to the documentation of this file.
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/Nux.h"
00024 #include "line-separator.h"
00025 
00026 namespace nux
00027 {
00028   HSeparator::HSeparator()
00029   {
00030     SetMinimumHeight (1);
00031     SetMaximumHeight (1);
00032   }
00033 
00034   HSeparator::HSeparator (const Color &color, float Alpha0, float Alpha1, int Border)
00035     : AbstractSeparator (color, Alpha0, Alpha1, Border)
00036   {
00037     SetMinimumHeight (1);
00038     SetMaximumHeight (1);
00039   }
00040 
00041   HSeparator::~HSeparator()
00042   {
00043   }
00044 
00045   void HSeparator::Draw (GraphicsEngine &GfxContext, bool force_draw)
00046   {
00047     Geometry base = GetGeometry();
00048     base.OffsetPosition(3, 0);
00049     base.OffsetSize(-6, 0);
00050     int y0 = base.y + base.GetHeight() / 2;
00051 
00052     GetGraphicsDisplay()->GetGraphicsEngine()->GetRenderStates().SetBlend (TRUE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00053 
00054     if (base.GetWidth() - 2 * m_BorderSize > 0)
00055     {
00056       Color color0 = m_Color;
00057       Color color1 = m_Color;
00058       color0.alpha = m_Alpha0;
00059       color1.alpha = m_Alpha1;
00060       GetPainter().Draw2DLine (GfxContext, base.x, y0, base.x + m_BorderSize, y0, color0, color1);
00061       GetPainter().Draw2DLine (GfxContext, base.x + m_BorderSize, y0, base.x + base.GetWidth() - m_BorderSize, y0, color1, color1);
00062       GetPainter().Draw2DLine (GfxContext, base.x + base.GetWidth() - m_BorderSize, y0, base.x + base.GetWidth(), y0, color1, color0);
00063     }
00064     else
00065     {
00066       Color color1 = m_Color;
00067       color1.alpha = m_Alpha1;
00068       GetPainter().Draw2DLine (GfxContext, base.x, y0, base.x + base.GetWidth(), y0, color1, color1);
00069     }
00070 
00071     GetGraphicsDisplay()->GetGraphicsEngine()->GetRenderStates().SetBlend (FALSE);
00072   }
00073 }