Changeset 8509 in orxonox.OLD for branches/gui
- Timestamp:
- Jun 16, 2006, 12:22:35 AM (18 years ago)
- Location:
- branches/gui/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/gui/gl/glgui_style.cc
r8469 r8509 30 30 { 31 31 _font = NULL; 32 this->reset(); 32 33 33 34 … … 65 66 66 67 void GLGuiStyle::loadParams(const TiXmlElement* root) 67 { 68 } 68 {} 69 69 70 70 void GLGuiStyle::setBorderLeft(float value) … … 81 81 void GLGuiStyle::setBorderLeftS(float value, const std::string& state) 82 82 { 83 84 83 } 85 84 … … 107 106 108 107 void GLGuiStyle::setBorderTop(float value, OrxGui::State state) 109 { 110 _style[state]._borderTop = value; 108 { 109 _style[state]._borderTop = value; 110 } 111 112 void GLGuiStyle::setBorderTopS(float value, const std::string& state) 113 {} 114 115 116 void GLGuiStyle::setBorderBottom(float value) 117 { 118 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 119 setBorderBottom(value, (OrxGui::State)i); 120 } 121 122 void GLGuiStyle::setBorderBottom(float value, OrxGui::State state) 123 { 124 _style[state]._borderBottom = value; 125 } 126 127 void GLGuiStyle::setBorderBottomS(float value, const std::string& state) 128 {} 129 130 131 void GLGuiStyle::setTextSize(float value) 132 { 133 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 134 setTextSize(value, (OrxGui::State)i); 135 } 136 137 void GLGuiStyle::setTextSize(float value, OrxGui::State state) 138 { 139 _style[state]._textSize = value; 140 } 141 142 void GLGuiStyle::setTextSizeS(float value, const std::string& state) 143 {} 144 145 146 void GLGuiStyle::setBackgroundColor(const Color& color) 147 { 148 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 149 setBackgroundColor(color, (OrxGui::State)i); 150 } 151 152 void GLGuiStyle::setBackgroundColor(const Color& color, OrxGui::State state) 153 { 154 _style[state]._backgroundColor = color; 155 } 156 157 void GLGuiStyle::setBackgroundColorS(float r, float g, float b, float a, const std::string& state) 158 {} 159 160 161 void GLGuiStyle::setBackgroundTexture(const Texture& texture) 162 { 163 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 164 setBackgroundTexture(texture, (OrxGui::State)i); 165 } 166 167 void GLGuiStyle::setBackgroundTexture(const Texture& texture, OrxGui::State state) 168 { 169 _style[state]._backgroundTexture = texture; 170 } 171 172 void GLGuiStyle::setBackgroundTexture(const std::string& textureName, const std::string& state) 173 {} 174 175 176 void GLGuiStyle::setForegroundColor(const Color& color) 177 { 178 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 179 setForegroundColor(color, (OrxGui::State)i); 180 } 181 182 void GLGuiStyle::setForegroundColor(const Color& color, OrxGui::State state) 183 { 184 _style[state]._foregroundColor = color; 185 } 186 187 void GLGuiStyle::setForegroundColorS(float r, float g, float b, float a, const std::string& state) 188 {} 189 190 191 192 void GLGuiStyle::setFeaturePosition(FeaturePosition featurePosition) 193 { 194 this->_featurePosition = featurePosition; 195 } 196 197 void GLGuiStyle::setFeaturePosition(const std::string& featurePosition) 198 {} 199 200 201 void GLGuiStyle::setFont(Font* font) 202 { 203 this->_font = font; 204 } 205 206 void GLGuiStyle::setFont(const std::string& fontName) 207 { 208 //this->font = new Font(fontName); 209 } 210 211 212 void GLGuiStyle::setAnimated(bool animated) 213 { 214 this->_animated = animated; 215 } 216 217 void GLGuiStyle::setAnimatedStateChanges(bool animated) 218 { 219 this->_animatedStateChanges = animated; 220 } 221 111 222 } 112 113 void GLGuiStyle::setBorderTopS(float value, const std::string& state)114 {}115 116 117 void GLGuiStyle::setBorderBottom(float value)118 {119 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)120 setBorderBottom(value, (OrxGui::State)i);121 }122 123 void GLGuiStyle::setBorderBottom(float value, OrxGui::State state)124 {125 _style[state]._borderBottom = value;126 }127 128 void GLGuiStyle::setBorderBottomS(float value, const std::string& state)129 {}130 131 132 void GLGuiStyle::setTextSize(float value)133 {134 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)135 setTextSize(value, (OrxGui::State)i);136 }137 138 void GLGuiStyle::setTextSize(float value, OrxGui::State state)139 {140 _style[state]._textSize= value;141 }142 143 void GLGuiStyle::setTextSizeS(float value, const std::string& state)144 {}145 146 147 void GLGuiStyle::setBackgroundColor(const Color& color)148 {149 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)150 setBackgroundColor(color, (OrxGui::State)i);151 }152 153 void GLGuiStyle::setBackgroundColor(const Color& color, OrxGui::State state)154 {155 _style[state]._backgroundColor = color;156 }157 158 void GLGuiStyle::setBackgroundColorS(float r, float g, float b, float a, const std::string& state)159 {}160 161 162 void GLGuiStyle::setBackgroundTexture(const Texture& texture)163 {164 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)165 setBackgroundTexture(texture, (OrxGui::State)i);166 }167 168 void GLGuiStyle::setBackgroundTexture(const Texture& texture, OrxGui::State state)169 {170 _style[state]._backgroundTexture = texture;171 }172 173 void GLGuiStyle::setBackgroundTexture(const std::string& textureName, const std::string& state)174 {}175 176 177 void GLGuiStyle::setForegroundColor(const Color& color)178 {179 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)180 setForegroundColor(color, (OrxGui::State)i);181 }182 183 void GLGuiStyle::setForegroundColor(const Color& color, OrxGui::State state)184 {185 _style[state]._foregroundColor = color;186 }187 188 void GLGuiStyle::setForegroundColorS(float r, float g, float b, float a, const std::string& state)189 {}190 191 192 193 void GLGuiStyle::setFeaturePosition(FeaturePosition featurePosition)194 {195 this->_featurePosition = featurePosition;196 }197 198 void GLGuiStyle::setFeaturePosition(const std::string& featurePosition)199 {200 }201 202 203 void GLGuiStyle::setFont(Font* font)204 {205 this->_font = font;206 }207 208 void GLGuiStyle::setFont(const std::string& fontName)209 {210 //this->font = new Font(fontName);211 }212 213 214 void GLGuiStyle::setAnimated(bool animated)215 {216 this->_animated = animated;217 }218 219 void GLGuiStyle::setAnimatedStateChanges(bool animated)220 {221 this->_animatedStateChanges = animated;222 }223 224 } -
branches/gui/src/lib/gui/gl/glgui_widget.h
r8448 r8509 66 66 void disconnect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver); 67 67 68 69 GLGuiStyle& style() { return this->_style; }; 70 const GLGuiStyle style() const { return this->_style; }; 68 71 69 72 /// MATERIAL (looks) -
branches/gui/src/lib/gui/gl/specials/glgui_notifier.cc
r8503 r8509 33 33 // Element2D and generals 34 34 this->lineSpacing = 0; 35 this->linesProcessed = 0; 35 36 36 this->set BufferDisplaySize(10);37 this->setDisplayLineCount(10); 37 38 } 38 39 … … 43 44 { 44 45 // delete the displayable Buffers 45 while (!this->bufferText.empty()) 46 /* while (!this->displayLines.empty()) 47 { 48 delete this->displayLines.front().text; 49 this->displayLines.pop_front(); 50 } 51 52 while (!this->hiddenText.empty()) 53 { 54 delete this->hiddenText.top(); 55 this->hiddenText.pop(); 56 }*/ 57 } 58 59 void GLGuiNotifier::pushNotifyMessage(const std::string& message) 60 { 61 if (!this->hiddenText.empty()) 46 62 { 47 delete this->bufferText.front(); 48 this->bufferText.pop_front(); 63 printf("%s\n", message.c_str()); 64 DisplayLine dl; 65 dl.text = this->hiddenText.top(); 66 67 dl.text->setText(message); 68 this->hiddenText.pop(); 69 dl.age = 0.0f; 70 this->displayLines.push_back(dl); 71 72 this->repositionText(); 73 } 74 else 75 { 76 printf("grumble... must be fixed\n"); 49 77 } 50 78 } 51 79 80 81 void GLGuiNotifier::setDisplayLineCount(unsigned int count) 82 { 83 unsigned int currentCount = displayLines.size() + hiddenText.size(); 84 85 for (unsigned int i = currentCount; i < count; ++i) 86 { 87 MultiLineText* text = new MultiLineText(); 88 this->applyTextSettings(text); 89 this->hiddenText.push(text); 90 } 91 bufferDisplaySize = count; 92 } 52 93 53 94 … … 58 99 { 59 100 int linePos = -1; 60 std::list< MultiLineText*>::iterator textIt;61 for (textIt = this-> bufferText.begin() ; textIt != this->bufferText.end(); ++textIt )101 std::list<DisplayLine>::iterator textIt; 102 for (textIt = this->displayLines.begin() ; textIt != this->displayLines.end(); ++textIt ) 62 103 { 63 linePos += (*textIt)->getLineCount(); 64 (*textIt)->setRelCoorSoft2D(this->calculateLinePosition(linePos), 8); 104 linePos += (*textIt).text->getLineCount(); 105 (*textIt).text->setRelCoorSoft2D(this->calculateLinePosition(linePos), 8); 106 // printf("%f %f\n", (*textIt).text->getAbsCoor2D().x, (*textIt).text->getAbsCoor2D().y); 65 107 } 66 108 } … … 71 113 * @param text the Text to apply the settings to. 72 114 */ 73 void GLGuiNotifier::applyTextSettings( Text* text)115 void GLGuiNotifier::applyTextSettings(MultiLineText* text) 74 116 { 75 /* text->setSize(this->textSize);76 text->set Font(this->fontFile, this->textSize);77 text->setColor(this->textColor[0], this->textColor[1], this->textColor[2]);78 text->setBlending(this->textColor[3]); 79 text->setLayer(this->getLayer());117 text->setSize(this->style().textSize()); 118 text->setLineWidth( 300 ); 119 //text->setFont(this->fontFile, this->textSize); 120 121 //text->setColor( Color(1,1,1,1)/*this->style().foregroundColor() */); 80 122 if (text->getParent2D() != this) 81 text->setParent2D(this); */123 text->setParent2D(this); 82 124 } 83 125 … … 113 155 Vector2D GLGuiNotifier::calculateLinePosition(unsigned int lineNumber) 114 156 { 115 // return Vector2D(5.0f, (float)(this->textSize + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1)); 116 return Vector2D(); 157 return Vector2D(0.0f, (float)(this->style().textSize() + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1)); 117 158 } 118 159 119 160 161 void GLGuiNotifier::resize() 162 {} 120 163 121 164 /** -
branches/gui/src/lib/gui/gl/specials/glgui_notifier.h
r8503 r8509 13 13 #include "event_listener.h" 14 14 15 #include <stack> 16 15 17 // FORWARD DECLARATION 16 18 class MultiLineText; … … 22 24 class GLGuiNotifier : public GLGuiWidget 23 25 { 24 25 26 public: 26 27 GLGuiNotifier(); … … 30 31 31 32 // BUFFERS 32 void setBufferDisplaySize(unsigned int bufferDisplaySize); 33 void printToDisplayBuffer(const std::string& text); 33 void setDisplayLineCount(unsigned int count); 34 34 35 35 void clear(); 36 36 37 // EventListener38 virtual void processEvents(const Event &event);39 37 // Element2D-functions 40 38 virtual void tick(float dt); 41 39 virtual void draw() const; 42 40 43 44 41 void debug() const; 45 42 43 protected: 44 virtual void resize(); 45 46 46 private: 47 void updateResolution(unsigned int width);48 47 void repositionText(); 49 void applyTextSettings( Text* text);48 void applyTextSettings(MultiLineText* text); 50 49 void applySettings(); 51 50 // helpers // 52 51 Vector2D calculateLinePosition(unsigned int lineNumber); 53 52 53 54 54 55 private: 56 typedef struct 57 { 58 float age; 59 MultiLineText* text; 60 61 } 62 DisplayLine; 63 55 64 unsigned int lineSpacing; //!< The Spacing between lines. 56 65 57 66 // BUFFER 58 67 unsigned int bufferDisplaySize; //!< The Size of the Display-buffer, in lines (not in characters). 59 std::list< MultiLineText*> bufferText;//!< A list of stored bufferTexts for the display of the buffer.68 std::list<DisplayLine> displayLines; //!< A list of stored bufferTexts for the display of the buffer. 60 69 61 unsigned long linesProcessed; //!< How many Lines have been processed. 70 std::stack<MultiLineText*> hiddenText; //!< Text that is not shown, and not used is thrown in here 71 72 73 unsigned long linesProcessed; //!< How many Lines have been processed so far. 74 std::list<std::string> inputBuffer; //!< 75 62 76 }; 63 77 -
branches/gui/src/story_entities/simple_game_menu.cc
r8479 r8509 42 42 43 43 #include "glgui.h" 44 #include "gui/gl/specials/glgui_notifier.h" 44 45 45 46 //! This creates a Factory to fabricate a SimpleGameMenu … … 88 89 { 89 90 91 OrxGui::GLGuiNotifier* notifier = new OrxGui::GLGuiNotifier(); 92 notifier->show(); 93 notifier->setAbsCoor2D(300, 300); 94 95 96 90 97 OrxGui::GLGuiBox* box = new OrxGui::GLGuiBox(); 91 98 { … … 107 114 OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine(); 108 115 input->setText("input some text here"); 109 input->connect(SIGNAL(input, textChanged), this, SLOT(SimpleGameMenu, TEST)); 116 input->connect(SIGNAL(input, textChanged), notifier, SLOT(OrxGui::GLGuiNotifier, pushNotifyMessage)); 117 110 118 box->pack(input); 111 119
Note: See TracChangeset
for help on using the changeset viewer.