vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GUI_item.h
Go to the documentation of this file.
1 #pragma once
2 
3 //#include "precompiled.h"
4 #include "GUI_Text.h"
5 
6 #include <osgText/Font3D>
7 #include <osgText/Text3D>
8 
9 using namespace vrecko;
10 
11 namespace APGUI
12 {
13 
14  typedef enum GUI_ITEM_STATE {
15  GUI_ITEM_STATE_DEFAULT = 1, // default state
16  GUI_ITEM_STATE_ACTIVE, // active - used in ICON:SWITCH class, when icon represents active state - e.g. auto-rotate
17  GUI_ITEM_STATE_DISABLED, // item is temporary disabled - it is visible, but it is 'grayed' and can't be pointed nor clicked
18  };
19 
20  typedef enum GUI_ACTION {
23  };
24 
27  {
28  public:
29  Interconnection(const string typ, const string sen, const string rec) { type = typ; sender = sen; receiver = rec; }
30 
31  string type;
32  string sender;
33  string receiver;
34  };
35 
36  class GUI_Controller;
37 
38 
39 
40 
42 
54 class GUI_Item : public Ability
55 {
56 public:
57 
58  GUI_Item(const char* abName);
59  ~GUI_Item();
60 
61  string getGUIItemName() { return _name; }
62 
64 
71  virtual void pointed(bool pointed) = 0;
72 
74  //TODO should this be virtual?
75  virtual void setState(GUI_ITEM_STATE newState) = 0;
76 
78 
85  virtual bool processAction( const int sensorNumber, const APGUI::GUI_ACTION action, const bool pressed) = 0;
86 
88  inline bool isDefaultStateActive() { return _defaultStateActive; }
89 
90  inline void show() { _parent->show(); }
91 
92  inline void hide() { _parent->hide(); }
93 
94  void hideTooltip();
95 
96  void showTooltip();
97 
99  //virtual void switchModels() = 0;
100 
101 
102 
103  //void setLabel( const std::string& content, const osg::Vec3& pos, float size, osg::Vec4& color );
104 
105 
106  //for testing
107  //osgText::Text3D* createText3D( const osg::Vec3& pos, const std::string& content, float size, float depth );
108 
109  virtual void setColours( osg::Vec4 colourActive, osg::Vec4 colourDefault, osg::Vec4 colourHovered, osg::Vec4 colourPressed, osg::Vec4 colourDisabled );
110 
111 
112 protected:
113 
115 
118  string _name;
119 
121  string _receiver;
122 
125 
127  //FIXME if GUI_controller is implemented as singleton, this can be removed
129 
130  // Group for texts - label, tooltip, whatever
131  osg::Group *_texts;
132 
134  osg::ref_ptr<GUI_Text> _label;
135 
137  osg::ref_ptr<GUI_Text> _toolTip;
138 
141 
143  // used in Menu
145 
147  osg::ref_ptr<osg::MatrixTransform> _itemTransform;
148 
151 
153  bool _pressed;
154 
156  // e.g. one of tools and one color should be
158 
159 
160  // colors of items in different states
161 
162  osg::Vec4 _colourActive;
163 
164  osg::Vec4 _colourDefault;
165 
166  osg::Vec4 _colourHovered;
167 
168  osg::Vec4 _colourPressed;
169 
170  osg::Vec4 _colourDisabled;
171 
173  // for simplify deletion of interconnection during destructor
174  std::vector<Interconnection *> _interconnections;
175 
176 
177  // Create new structures, add to scene graph
178  osgText::Text* GUI_Item::createLabel();
179 
180 
182  bool initialize(bool pointable = true, int sensor = -1);
183 
184 };
185 
186 }