Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8619 in orxonox.OLD for trunk/src/lib/gui/gl/specials


Ignore:
Timestamp:
Jun 20, 2006, 1:24:11 PM (19 years ago)
Author:
bensch
Message:

trunk: merged the gui-branche back.
merged with command:
svn merge -r8520:HEAD https://svn.orxonox.net/orxonox/branches/gui
no conflicts

Location:
trunk/src/lib/gui/gl/specials
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/gui/gl/specials/glgui_notifier.cc

    r8518 r8619  
    2525
    2626  /**
    27    * standard constructor
     27   * @brief standard constructor
    2828   */
    2929  GLGuiNotifier::GLGuiNotifier ()
     
    3434    this->lineSpacing = 0;
    3535    this->linesProcessed = 0;
     36    this->_fadeAge = 3.0;
     37    this->setHideAge(4.0);
    3638
    3739    this->setDisplayLineCount(10);
     
    5759  }
    5860
     61  /**
     62   * @brief push a message onto the notifier.
     63   * @param message the message to be pushed.
     64   *
     65   * @note it is not guaranteed, that the message is delivered instantaniously
     66   * The possibility may arise, that the DisplayLines are all in use, then one
     67   * has to wait until a line gets hidden, until a new one can be pushed to be
     68   * displayed.
     69   */
    5970  void GLGuiNotifier::pushNotifyMessage(const std::string& message)
    6071  {
    6172    if (!this->hiddenText.empty())
    6273    {
    63       printf("%s\n", message.c_str());
    64       DisplayLine dl;
     74      DisplayLine dl; // put everything in here, and then display it
     75
     76      // retrieve a Text.
    6577      dl.text = this->hiddenText.top();
    66 
     78      this->hiddenText.pop();
     79
     80      // setup Text
    6781      dl.text->setBlending(1.0f);
    6882      dl.text->setText(message);
    69       this->hiddenText.pop();
     83      dl.text->setVisibility(true);
     84      dl.text->setRelCoor2D(this->calculateLinePosition(0));
     85
    7086      dl.age = 0.0f;
    7187      this->displayLines.push_front(dl);
    72 
    73       dl.text->setVisibility(true);
    74       dl.text->setRelCoor2D(this->calculateLinePosition(0));
    7588      this->repositionText();
    7689    }
    7790    else
    7891    {
     92      // push it onto the List of messages we still need.
    7993      this->inputBuffer.push_front(message);
    80       //printf("grumble... must be fixed\n");
    81     }
    82   }
    83 
    84 
     94    }
     95  }
     96
     97
     98  /**
     99   * @brief sets the Dipsplay Line Count of the Notifier.
     100   * @param coun the count of displayLines.
     101   */
    85102  void GLGuiNotifier::setDisplayLineCount(unsigned int count)
    86103  {
     
    96113  }
    97114
     115  void GLGuiNotifier::setFadeAge(float fadeAge)
     116  {
     117    this->_fadeAge = fadeAge;
     118    this->_transformAge = hideAge() - this->fadeAge();
     119  }
     120
     121  void GLGuiNotifier::setHideAge(float hideAge)
     122  {
     123    this->_hideAge = hideAge;
     124    this->_transformAge = this->hideAge() - fadeAge();
     125  }
     126
    98127
    99128  /**
     
    119148  void GLGuiNotifier::applyTextSettings(MultiLineText* text)
    120149  {
    121     text->setSize(this->style().textSize());
     150    text->setSize(this->textSize());
    122151    text->setLineWidth( 300 );
    123     text->setFont("fonts/final_frontier.ttf", (int)this->style().textSize());
    124 
    125     text->setColor(this->style().foregroundColor() );
     152    text->setFont("fonts/final_frontier.ttf", (int)this->textSize());
     153
     154    text->setColor(this->foregroundColor() );
    126155    if (text->getParent2D() != this)
    127156      text->setParent2D(this);
     
    129158
    130159
     160  /**
     161   * @brief ticks the entire Notifier.
     162   * @param dt the time passed since the last Tick
     163   */
    131164  void GLGuiNotifier::tick(float dt)
    132165  {
     
    135168    {
    136169      (*line).age+=dt;
    137       if ((*line).age > 3.0f)
     170      if ((*line).age > this->fadeAge())
    138171      {
    139         (*line).text->setBlending(4.0 - (*line).age);
    140         if ((*line).age > 4.0f)
     172        (*line).text->setBlending((hideAge() - (*line).age)/_transformAge);
     173        if ((*line).age > hideAge())
    141174        {
    142175          std::list<DisplayLine>::iterator tmp = line;
     
    167200    this->beginDraw();
    168201
    169     this->backMaterial().select();
     202    this->background().select();
    170203    this->drawRect(this->backRect());
    171204    this->endDraw();
     
    183216  Vector2D GLGuiNotifier::calculateLinePosition(unsigned int lineNumber)
    184217  {
    185     return Vector2D(0.0f, (float)(this->style().textSize() + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1));
     218    return Vector2D(0.0f, (float)(textSize() + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1));
    186219  }
    187220
  • trunk/src/lib/gui/gl/specials/glgui_notifier.h

    r8518 r8619  
    3030    void pushNotifyMessage(const std::string& message);
    3131
    32     // BUFFERS
     32    /// Setup
    3333    void setDisplayLineCount(unsigned int count);
     34    void setFadeAge(float fadeAge);
     35    void setHideAge(float hideAge);
     36
     37    /** @returns the beginning of the Hiding process */
     38    inline float fadeAge() const { return _fadeAge; };
     39    /** @returns at what age elements should be fully hidden */
     40    inline float hideAge() const { return _hideAge; };
    3441
    3542    void clear();
     
    5461
    5562  private:
     63    //! structure that defines a Displayed line.
    5664    typedef struct
    5765    {
     
    5967      MultiLineText*    text;
    6068
    61     }
    62     DisplayLine;
     69    } DisplayLine;
     70
     71
     72    float                       _fadeAge;
     73    float                       _hideAge;
     74    float                       _transformAge;
    6375
    6476    unsigned int                lineSpacing;            //!< The Spacing between lines.
     
    7284
    7385    unsigned long               linesProcessed;         //!< How many Lines have been processed so far.
    74     std::list<std::string>      inputBuffer;            //!<
     86    std::list<std::string>      inputBuffer;            //!< The input buffer for lines that were not yet printet out, because there is too much input.
    7587
    7688  };
Note: See TracChangeset for help on using the changeset viewer.