Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/playability/src/world_entities/elements/glgui_energywidgetvertical.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.7 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_
17
18#include "glgui_energywidgetvertical.h"
19
20#include "multi_type.h"
21
22namespace OrxGui
23{
24  /**
25   * @brief standard constructor
26   */
27  GLGuiEnergyWidgetVertical::GLGuiEnergyWidgetVertical ()
28  {
29    //   this->setClassID(CL_PROTO_ID, "GLGuiEnergyWidget");
30
31    //this->_bar.setSize2D(100, 30);
32    //this->_bar.setRelCoor2D(-10,0);
33    //this->_name.setRelCoor2D(20,0);
34    //this->_valueText.setRelCoor2D(,0);
35    this->shiftDir2D(270);
36    this->setOrientation(OrxGui::Horizontal);
37    this->pack(&this->_name);
38    this->pack(&this->_valueText);
39    this->_bar.setParent2D(&this->_valueText);
40
41    this->_name.setForegroundColor(Color(1,1,1,.8));
42    this->_valueText.setChangedTextColor(Color::white);
43    this->_bar.setBackgroundTexture(Texture());
44
45    this->setBackgroundTexture(Texture());
46    this->setBackgroundColor(Color(.5,.5,.5,0.5));
47
48    //this->_name.setBackgroundTexture(Texture());
49    //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
50    this->_bar.setBackgroundTexture(Texture());
51    this->_bar.setBackgroundColor(Color(0,0,0,0));
52    this->_bar.setForegroundTexture("maps/gui_element_background_faded.png");
53    this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
54    this->_bar.setChangedValueColor(Color::black);
55  }
56
57
58  /**
59   * @brief standard deconstructor
60   */
61  GLGuiEnergyWidgetVertical::~GLGuiEnergyWidgetVertical ()
62  {
63  }
64
65
66  void GLGuiEnergyWidgetVertical::setDisplayedName(const std::string& name)
67  {
68    this->_name.setText(name);
69    this->_bar.setWidgetSize(this->_name.getSize2D());
70  }
71
72  void GLGuiEnergyWidgetVertical::setMaximum(float max)
73  {
74    this->_bar.setMaximum(max);
75  }
76
77  void GLGuiEnergyWidgetVertical::setValue(float value)
78  {
79    MultiType val(value);
80    val.setType(MT_INT);
81
82
83    this->_bar.setValue(value);
84    this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
85    this->_bar.setFrontColor(Color(1,1,1,1), true);
86    this->_valueText.setText(val.getString());
87  }
88
89  void GLGuiEnergyWidgetVertical::resize()
90  {
91    GLGuiBox::resize();
92  }
93
94
95  void GLGuiEnergyWidgetVertical::showing()
96  {
97    this->_name.show();
98    this->_valueText.show();
99    this->_bar.show();
100  }
101
102  void GLGuiEnergyWidgetVertical::hiding()
103  {
104    this->_name.hide();
105    this->_valueText.hide();
106    this->_bar.hide();
107  }
108}
Note: See TracBrowser for help on using the repository browser.