~mc-return/nux/nux.merge-fix-deprecated-warnings

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * Copyright 2010 Inalogic® Inc.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License, as
 * published by the  Free Software Foundation; either version 2.1 or 3.0
 * of the License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of both the GNU Lesser General Public
 * License along with this program. If not, see <http://www.gnu.org/licenses/>
 *
 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
 *
 */


#include "Nux/Nux.h"
#include "line-separator.h"

namespace nux
{
  HSeparator::HSeparator()
  {
    SetMinimumHeight (1);
    SetMaximumHeight (1);
  }

  HSeparator::HSeparator (const Color &color, float Alpha0, float Alpha1, int Border)
    : AbstractSeparator (color, Alpha0, Alpha1, Border)
  {
    SetMinimumHeight (1);
    SetMaximumHeight (1);
  }

  HSeparator::~HSeparator()
  {
  }

  void HSeparator::Draw (GraphicsEngine &GfxContext, bool force_draw)
  {
    Geometry base = GetGeometry();
    base.OffsetPosition(3, 0);
    base.OffsetSize(-6, 0);
    int y0 = base.y + base.GetHeight() / 2;

    GetGraphicsDisplay()->GetGraphicsEngine()->GetRenderStates().SetBlend (TRUE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    if (base.GetWidth() - 2 * m_BorderSize > 0)
    {
      Color color0 = m_Color;
      Color color1 = m_Color;
      color0.alpha = m_Alpha0;
      color1.alpha = m_Alpha1;
      GetPainter().Draw2DLine (GfxContext, base.x, y0, base.x + m_BorderSize, y0, color0, color1);
      GetPainter().Draw2DLine (GfxContext, base.x + m_BorderSize, y0, base.x + base.GetWidth() - m_BorderSize, y0, color1, color1);
      GetPainter().Draw2DLine (GfxContext, base.x + base.GetWidth() - m_BorderSize, y0, base.x + base.GetWidth(), y0, color1, color0);
    }
    else
    {
      Color color1 = m_Color;
      color1.alpha = m_Alpha1;
      GetPainter().Draw2DLine (GfxContext, base.x, y0, base.x + base.GetWidth(), y0, color1, color1);
    }

    GetGraphicsDisplay()->GetGraphicsEngine()->GetRenderStates().SetBlend (FALSE);
  }
}