Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8554 in orxonox.OLD


Ignore:
Timestamp:
Jun 17, 2006, 9:45:53 AM (18 years ago)
Author:
bensch
Message:

style should be loadable through strings

Location:
branches/gui/src/lib/gui/gl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/gui/gl/glgui_style.cc

    r8518 r8554  
    6868  {}
    6969
     70
    7071  void GLGuiStyle::setBorderLeft(float value)
    7172  {
     
    7980  }
    8081
    81   void GLGuiStyle::setBorderLeftS(float value, const std::string& state)
    82   {
     82  void GLGuiStyle::setBorderLeftS(float value, const std::string& stateName)
     83  {
     84    OrxGui::State state;
     85    if (getState(stateName, &state))
     86      this->setBorderLeft(value, state);
     87    else
     88      this->setBorderLeft(value);
    8389  }
    8490
     
    95101  }
    96102
    97   void GLGuiStyle::setBorderRightS(float value, const std::string& state)
    98   {}
     103  void GLGuiStyle::setBorderRightS(float value, const std::string& stateName)
     104  {
     105    OrxGui::State state;
     106    if (getState(stateName, &state))
     107      this->setBorderRight(value, state);
     108    else
     109      this->setBorderRight(value);
     110  }
    99111
    100112
     
    110122  }
    111123
    112   void GLGuiStyle::setBorderTopS(float value, const std::string& state)
    113   {}
     124  void GLGuiStyle::setBorderTopS(float value, const std::string& stateName)
     125  {
     126    OrxGui::State state;
     127    if (getState(stateName, &state))
     128      this->setBorderTop(value, state);
     129    else
     130      this->setBorderTop(value);
     131  }
    114132
    115133
     
    125143  }
    126144
    127   void GLGuiStyle::setBorderBottomS(float value, const std::string& state)
    128   {}
     145  void GLGuiStyle::setBorderBottomS(float value, const std::string& stateName)
     146  {
     147        OrxGui::State state;
     148  if (getState(stateName, &state))
     149    this->setBorderBottom(value, state);
     150  else
     151    this->setBorderBottom(value);
     152  }
    129153
    130154
     
    140164  }
    141165
    142   void GLGuiStyle::setTextSizeS(float value, const std::string& state)
    143   {}
     166  void GLGuiStyle::setTextSizeS(float value, const std::string& stateName)
     167  {
     168    OrxGui::State state;
     169    if (getState(stateName, &state))
     170      this->setTextSize(value, state);
     171    else
     172      this->setTextSize(value);
     173  }
    144174
    145175
     
    155185  }
    156186
    157   void GLGuiStyle::setBackgroundColorS(float r, float g, float b, float a, const std::string& state)
    158   {}
     187  void GLGuiStyle::setBackgroundColorS(float r, float g, float b, float a, const std::string& stateName)
     188  {
     189    OrxGui::State state;
     190    if (getState(stateName, &state))
     191      this->setBackgroundColor(Color(r,g,b,a), state);
     192    else
     193      this->setBackgroundColor(Color(r,g,b,a));
     194  }
    159195
    160196
     
    170206  }
    171207
    172   void GLGuiStyle::setBackgroundTexture(const std::string& textureName, const std::string& state)
    173   {}
     208  void GLGuiStyle::setBackgroundTexture(const std::string& textureName, const std::string& stateName)
     209  {
     210        OrxGui::State state;
     211  if (getState(stateName, &state))
     212    ; /// FIXME this->setBackgroundTexture(textureName, state);
     213  else
     214      ; ///    this->setBackgroundTexture(textureName);
     215  }
    174216
    175217
     
    185227  }
    186228
    187   void GLGuiStyle::setForegroundColorS(float r, float g, float b, float a, const std::string& state)
    188   {}
     229  void GLGuiStyle::setForegroundColorS(float r, float g, float b, float a, const std::string& stateName)
     230  {
     231    OrxGui::State state;
     232    if (getState(stateName, &state))
     233      this->setForegroundColor(Color(r,g,b,a), state);
     234    else
     235      this->setForegroundColor(Color(r,g,b,a));
     236  }
    189237
    190238
     
    196244
    197245  void GLGuiStyle::setFeaturePosition(const std::string& featurePosition)
    198   {}
    199 
     246  {
     247    for (unsigned int i = 0; i < 4; ++i)
     248    {
     249      if (featurePosition == FeaturePositionString[i])
     250      {
     251        this->setFeaturePosition((FeaturePosition)i);
     252      }
     253    }
     254  }
    200255
    201256  void GLGuiStyle::setFont(Font* font)
     
    220275  }
    221276
     277
     278
     279  bool GLGuiStyle::getState(const std::string& stateName, OrxGui::State* state)
     280  {
     281    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     282      if (stateName == OrxGui::StateString[i])
     283    {
     284      *state = (OrxGui::State)i;
     285        return true;
     286    }
     287    return false;
     288  }
     289
    222290}
  • branches/gui/src/lib/gui/gl/glgui_style.h

    r8518 r8554  
    4848    void setBorderLeft(float value);
    4949    void setBorderLeft(float value, OrxGui::State state);
    50     void setBorderLeftS(float value, const std::string& state);
     50    void setBorderLeftS(float value, const std::string& stateName);
    5151
    5252    void setBorderRight(float value);
    5353    void setBorderRight(float value, OrxGui::State state);
    54     void setBorderRightS(float value, const std::string& state);
     54    void setBorderRightS(float value, const std::string& stateName);
    5555
    5656    void setBorderTop(float value);
    5757    void setBorderTop(float value, OrxGui::State state);
    58     void setBorderTopS(float value, const std::string& state);
     58    void setBorderTopS(float value, const std::string& stateName);
    5959
    6060    void setBorderBottom(float value);
    6161    void setBorderBottom(float value, OrxGui::State state);
    62     void setBorderBottomS(float value, const std::string& state);
     62    void setBorderBottomS(float value, const std::string& stateName);
    6363
    6464    void setTextSize(float value);
    6565    void setTextSize(float value, OrxGui::State state);
    66     void setTextSizeS(float value, const std::string& state);
     66    void setTextSizeS(float value, const std::string& stateName);
    6767
    6868    void setBackgroundColor(const Color& color);
    6969    void setBackgroundColor(const Color& color, OrxGui::State state);
    70     void setBackgroundColorS(float r, float g, float b, float a, const std::string& state);
     70    void setBackgroundColorS(float r, float g, float b, float a, const std::string& stateName);
    7171
    7272    void setBackgroundTexture(const Texture& texture);
    7373    void setBackgroundTexture(const Texture& texture, OrxGui::State state);
    74     void setBackgroundTexture(const std::string& textureName, const std::string& state);
     74    void setBackgroundTexture(const std::string& textureName, const std::string& stateName);
    7575
    7676    void setForegroundColor(const Color& color);
    7777    void setForegroundColor(const Color& color, OrxGui::State state);
    78     void setForegroundColorS(float r, float g, float b, float a, const std::string& state);
     78    void setForegroundColorS(float r, float g, float b, float a, const std::string& stateName);
    7979
    8080
     
    8787    void setAnimated(bool animated);
    8888    void setAnimatedStateChanges(bool animated);
     89
     90    private:
     91      bool getState(const std::string& stateName, OrxGui::State* state);
    8992
    9093  private:
Note: See TracChangeset for help on using the changeset viewer.