Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10644 was 10368, checked in by patrick, 18 years ago

merged the branche playability into the trunk

File size: 2.4 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
[9869]25  ObjectListDefinition(GLGuiBar);
[7779]26  /**
27   * @brief standard constructor
28  */
29  GLGuiBar::GLGuiBar ()
30  {
31    this->init();
[1853]32
[7779]33  }
[1853]34
[5360]35
[7779]36  /**
37   * @brief standard deconstructor
38   */
39  GLGuiBar::~GLGuiBar()
[8983]40  {}
[5360]41
[7779]42  /**
43   * @brief initializes the GUI-element
44   */
45  void GLGuiBar::init()
46  {
[9869]47    this->registerObject(this, GLGuiBar::_objectList);
[5360]48
[8991]49    this->setFrontColor(_changedValueColor, true);
[6295]50
[7779]51    this->setSize2D(50, 10);
[6295]52
[8983]53    this->_minimum = 0.0f;
54    this->_maximum = 1.0f;
55    this->setValue(0.5f);
56    this->resize();
[7779]57  }
[5360]58
[8983]59  void GLGuiBar::setValue(float value)
60  {
61    if (value > _maximum)
62    {
63      value = _maximum;
64      PRINTF(2)("Oversteped range, set Value to %f\n", _maximum);
65    }
66    if (value < _minimum)
67    {
68      value = _minimum;
69      PRINTF(2)("Oversteped range, set Value to %f\n", _minimum);
70    }
71
72    this->_value = value;
[10368]73    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value - _minimum) / (_maximum -_minimum)
[8984]74        ,this->getSizeY2D() - borderTop() - borderBottom());
[8983]75  }
76  void GLGuiBar::setMinimum(float minimum)
77  {
78    this->_minimum = minimum;
79  }
80  void GLGuiBar::setMaximum(float maximum)
81  {
82    this->_maximum = maximum;
83  }
84  void GLGuiBar::setRange(float minimum, float maximum)
85  {
86    this->setMinimum(minimum);
87    this->setMaximum(maximum);
88  }
89
[8991]90  void GLGuiBar::setChangedValueColor(const Color& color)
91  {
92    this->_changedValueColor = color;
93  }
94
95
[8972]96  void GLGuiBar::resize()
97  {
98    GLGuiWidget::resize();
99
[8983]100    this->_frontRect.setTopLeft(borderLeft(), borderTop());
[10368]101    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value - _minimum) / (_maximum -_minimum)
102        ,this->getSizeY2D() - borderTop() - borderBottom());
[8972]103
104  }
105
106
[7779]107  /**
108   * @brief draws the GLGuiBar
109   */
110  void GLGuiBar::draw() const
111  {
[8035]112    this->beginDraw();
[7779]113    GLGuiWidget::draw();
[6287]114
[8984]115    this->foreground().select();
[8983]116    this->drawRect(this->_frontRect);
117
[7779]118    this->endDraw();
119  }
[5360]120}
Note: See TracBrowser for help on using the repository browser.