Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/gui/gl/glgui_bar.cc @ 8984

Last change on this file since 8984 was 8984, checked in by bensch, 19 years ago

orxonox/trunk: gui with fading :)

File size: 2.3 KB
RevLine 
[4744]1/*
[1853]2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
[1855]10
11   ### File Specific:
[5360]12   main-programmer: Benjamin Grauer
[1855]13   co-programmer: ...
[1853]14*/
15
[5360]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
[1853]17
[6287]18#include "glgui_bar.h"
[1853]19
[8983]20#include "debug.h"
[1853]21
[7779]22namespace OrxGui
[3365]23{
[4320]24
[7779]25  /**
26   * @brief standard constructor
27  */
28  GLGuiBar::GLGuiBar ()
29  {
30    this->init();
[1853]31
[7779]32  }
[1853]33
[5360]34
[7779]35  /**
36   * @brief standard deconstructor
37   */
38  GLGuiBar::~GLGuiBar()
[8983]39  {}
[5360]40
[7779]41  /**
42   * @brief initializes the GUI-element
43   */
44  void GLGuiBar::init()
45  {
46    this->setClassID(CL_GLGUI_BAR, "GLGuiBar");
[5360]47
[8448]48    this->setFrontColor(Color(1,1,1));
[6295]49
[7779]50    this->setSize2D(50, 10);
[6295]51
[8983]52    this->_minimum = 0.0f;
53    this->_maximum = 1.0f;
54    this->setValue(0.5f);
55    this->resize();
[7779]56  }
[5360]57
[8983]58  void GLGuiBar::setValue(float value)
59  {
60    if (value > _maximum)
61    {
62      value = _maximum;
63      PRINTF(2)("Oversteped range, set Value to %f\n", _maximum);
64    }
65    if (value < _minimum)
66    {
67      value = _minimum;
68      PRINTF(2)("Oversteped range, set Value to %f\n", _minimum);
69    }
70
71    this->_value = value;
[8984]72    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value -_minimum)/ (_minimum + _maximum)
73        ,this->getSizeY2D() - borderTop() - borderBottom());
[8983]74  }
75  void GLGuiBar::setMinimum(float minimum)
76  {
77    this->_minimum = minimum;
78  }
79  void GLGuiBar::setMaximum(float maximum)
80  {
81    this->_maximum = maximum;
82  }
83  void GLGuiBar::setRange(float minimum, float maximum)
84  {
85    this->setMinimum(minimum);
86    this->setMaximum(maximum);
87  }
88
[8972]89  void GLGuiBar::resize()
90  {
91    GLGuiWidget::resize();
92
[8983]93    this->_frontRect.setTopLeft(borderLeft(), borderTop());
94    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value -_minimum)/ (_minimum + _maximum)
95                             ,this->getSizeY2D() - borderTop() - borderBottom());
[8972]96
97  }
98
99
[7779]100  /**
101   * @brief draws the GLGuiBar
102   */
103  void GLGuiBar::draw() const
104  {
[8035]105    this->beginDraw();
[7779]106    GLGuiWidget::draw();
[6287]107
[8984]108    this->foreground().select();
[8983]109    this->drawRect(this->_frontRect);
110
[7779]111    this->endDraw();
112  }
[5360]113}
Note: See TracBrowser for help on using the repository browser.