Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/playability/src/lib/gui/gl/glgui_bar.cc @ 10139

Last change on this file since 10139 was 10139, checked in by muellmic, 17 years ago

trying to adjust interface

File size: 2.4 KB
Line 
1/*
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.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
17
18#include "glgui_bar.h"
19
20#include "debug.h"
21
22namespace OrxGui
23{
24
25  ObjectListDefinition(GLGuiBar);
26  /**
27   * @brief standard constructor
28  */
29  GLGuiBar::GLGuiBar ()
30  {
31    this->init();
32
33  }
34
35
36  /**
37   * @brief standard deconstructor
38   */
39  GLGuiBar::~GLGuiBar()
40  {}
41
42  /**
43   * @brief initializes the GUI-element
44   */
45  void GLGuiBar::init()
46  {
47    this->registerObject(this, GLGuiBar::_objectList);
48
49    this->setFrontColor(_changedValueColor, true);
50
51    this->setSize2D(50, 10);
52
53    this->_minimum = 0.0f;
54    this->_maximum = 1.0f;
55    this->setValue(0.5f);
56    this->resize();
57  }
58
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;
73    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value - _minimum) / (_maximum -_minimum)
74        ,this->getSizeY2D() - borderTop() - borderBottom());
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
90  void GLGuiBar::setChangedValueColor(const Color& color)
91  {
92    this->_changedValueColor = color;
93  }
94
95
96  void GLGuiBar::resize()
97  {
98    GLGuiWidget::resize();
99
100    this->_frontRect.setTopLeft(borderLeft(), borderTop());
101    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value - _minimum) / (_maximum -_minimum)
102        ,this->getSizeY2D() - borderTop() - borderBottom());
103
104  }
105
106
107  /**
108   * @brief draws the GLGuiBar
109   */
110  void GLGuiBar::draw() const
111  {
112    this->beginDraw();
113    GLGuiWidget::draw();
114
115    this->foreground().select();
116    this->drawRect(this->_frontRect);
117
118    this->endDraw();
119  }
120}
Note: See TracBrowser for help on using the repository browser.