Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8035 in orxonox.OLD for trunk


Ignore:
Timestamp:
May 31, 2006, 4:20:51 PM (19 years ago)
Author:
bensch
Message:

gui: merged the gui back to the trunk

Location:
trunk/src
Files:
45 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r7954 r8035  
    337337  CL_GLGUI_INPUTLINE            =    0x00000b60,
    338338  CL_GLGUI_TEXTFIELD            =    0x00000b61,
     339  CL_GLGUI_IMAGE                =    0x00000b70,
    339340
    340341  // QT_GUI
  • trunk/src/lib/event/event_handler.cc

    r7919 r8035  
    337337  else
    338338  {
    339     SDL_WM_GrabInput(SDL_GRAB_ON);
     339    //SDL_WM_GrabInput(SDL_GRAB_ON);
    340340    SDL_ShowCursor(SDL_DISABLE);
    341341  }
     
    380380      case SDL_MOUSEBUTTONUP:
    381381        ev.bPressed = false;
     382        ev.x = event.motion.x;
     383        ev.y = event.motion.y;
    382384        ev.type = event.button.button + SDLK_LAST;
    383385        break;
    384386      case SDL_MOUSEBUTTONDOWN:
    385387        ev.bPressed = true;
     388        ev.x = event.motion.x;
     389        ev.y = event.motion.y;
    386390        ev.type = event.button.button + SDLK_LAST;
    387391        break;
     
    474478    {
    475479      EventHandler::getInstance()->grabEvents( true);
    476       return 0;
     480      return 1;
    477481    }
    478482  }
  • trunk/src/lib/graphics/importer/model.h

    r7193 r8035  
    2525#include "base_object.h"
    2626#include "vector.h"
    27 
    28 using namespace std;
    2927
    3028
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r7919 r8035  
    299299
    300300/**
     301 * @brief updates the Rel - Coordinate in x-direction
     302 * @param x the x coordinate
     303 */
     304void Element2D::setRelCoorX2D(float x)
     305{
     306  this->setRelCoor2D(Vector2D(x, this->relCoordinate.y));
     307}
     308
     309/**
     310 * @brief updates the Rel - Coordinate in y-direction
     311 * @param y the y coordinate
     312 */
     313void Element2D::setRelCoorY2D(float y)
     314{
     315  this->setRelCoor2D(Vector2D(this->relCoordinate.x, y));
     316}
     317
     318
     319/**
    301320 * @brief sets the Relative coordinate to the parent in Pixels
    302321 * @param x the relCoord X
     
    388407  this->setAbsCoor2D(Vector2D(x, y));
    389408}
     409
     410/**
     411 * @brief updates the Abs - Coordinate in x-direction
     412 * @param x the x coordinate
     413 */
     414void Element2D::setAbsCoorX2D(float x)
     415{
     416  this->setAbsCoor2D(x, this->getAbsCoor2D().y);
     417}
     418
     419/**
     420 * @brief updates the Abs - Coordinate in y-direction
     421 * @param y the y coordinate
     422 */
     423void Element2D::setAbsCoorY2D(float y)
     424{
     425  this->setAbsCoor2D(this->getAbsCoor2D().x, y);
     426}
     427
    390428
    391429/**
  • trunk/src/lib/graphics/render2D/element_2d.h

    r7919 r8035  
    143143  public:
    144144    void setRelCoor2D (const Vector2D& relCoord);
     145    void setRelCoorX2D(float x);
     146    void setRelCoorY2D(float y);
    145147    void setRelCoor2D (float x, float y);
    146148    void setRelCoor2Dpx (int x, int y);
     
    155157    void setAbsCoor2D (const Vector2D& absCoord);
    156158    void setAbsCoor2D (float x, float y);
     159    void setAbsCoorX2D(float x);
     160    void setAbsCoorY2D(float y);
    157161    void setAbsCoor2Dpx (int x, int y);
    158162    void setAbsCoorSoft2D (const Vector2D& absCoordSoft, float bias = 1.0);
  • trunk/src/lib/gui/gl_gui/Makefile.am

    r7919 r8035  
    2525                glgui_inputline.cc \
    2626                glgui_textfield.cc \
     27                glgui_image.cc \
    2728                glgui_window.cc \
    2829                glgui_cursor.cc
     
    4748                glgui_inputline.h \
    4849                glgui_textfield.h \
     50                glgui_image.h \
    4951                glgui_window.h \
    5052                glgui_cursor.h
  • trunk/src/lib/gui/gl_gui/glgui.h

    r7919 r8035  
    77#define _GLGUI_H
    88
     9#include "glgui_defs.h"
    910#include "glgui_handler.h"
    1011
     
    1718//#include "glgui_colorselector.h"
    1819#include "glgui_pushbutton.h"
     20#include "glgui_slider.h"
    1921#include "glgui_cursor.h"
    2022#include "glgui_inputline.h"
    2123#include "glgui_textfield.h"
     24#include "glgui_image.h"
    2225
    2326
  • trunk/src/lib/gui/gl_gui/glgui_bar.cc

    r7919 r8035  
    6060  void GLGuiBar::draw() const
    6161  {
    62     this->startDraw();
     62    this->beginDraw();
    6363
    6464    GLGuiWidget::draw();
  • trunk/src/lib/gui/gl_gui/glgui_box.cc

    r7779 r8035  
    2323   * standard constructor
    2424  */
    25   GLGuiBox::GLGuiBox (BoxType type)
     25  GLGuiBox::GLGuiBox (OrxGui::Orientation orientation)
    2626  {
    2727    this->init();
    2828
    29     this->setType (type);
     29    this->setOrientation(orientation);
    3030  }
    3131
     
    4747  void GLGuiBox::pack(GLGuiWidget* widget)
    4848  {
    49     if (widget == NULL)
    50       return;
     49    assert (widget != NULL);
    5150
    5251    this->children.push_back(widget);
     52    widget->setParentWidget(this);
     53
     54    this->resize();
    5355  }
    5456
     
    5658  void GLGuiBox::unpack(GLGuiWidget* widget)
    5759  {
    58     if (widget == NULL)
     60    assert(widget == NULL);
     61
     62    std::vector<GLGuiWidget*>::iterator delWidget = std::find(this->children.begin(), this->children.end(), widget);
     63    if (delWidget != this->children.end())
    5964    {
    60       this->children.clear();
     65      (*delWidget)->setParentWidget(NULL);
     66      this->children.erase(delWidget);
    6167    }
    62     else
    63     {
    64       this->children.remove(widget);
    65     }
     68    this->resize();
     69  }
     70
     71  void GLGuiBox::clear()
     72  {
     73    this->children.clear();
     74    this->resize();
    6675  }
    6776
    6877  void GLGuiBox::showAll()
    6978  {
    70     std::list<GLGuiWidget*>::iterator itC = this->children.begin();
     79    std::vector<GLGuiWidget*>::iterator itC = this->children.begin();
    7180    while (itC != this->children.end())
    7281    {
     
    7988
    8089    this->show();
    81 
    8290  }
    8391
    8492  void GLGuiBox::hideAll()
    8593  {
    86     std::list<GLGuiWidget*>::iterator itC = this->children.begin();
     94    std::vector<GLGuiWidget*>::iterator itC = this->children.begin();
    8795    while (itC != this->children.end())
    8896    {
     
    97105  }
    98106
     107  void GLGuiBox::resize()
     108  {
     109    if (orientation() == OrxGui::Vertical)
     110    {
     111      float height = this->borderSize();
     112      float width = 0.0f;
     113      std::vector<GLGuiWidget*>::iterator widget;
     114
     115      // find out how big the Widgets are.
     116      for (widget = this->children.begin(); widget != this->children.end(); ++widget)
     117      {
     118        (*widget)->setRelCoor2D(this->borderSize(), height);
     119        height += (*widget)->getSizeY2D();
     120        width = fmax(width, (*widget)->getSizeX2D());
     121      }
     122
     123      width += this->borderSize() * 2.0;
     124      height += this->borderSize(); /* *2 done further up */
     125
     126      printf("%f %f\n", width, height);
     127      this->setSize2D(width, height);
     128    }
     129    else
     130    {
     131      float height = this->borderSize();
     132      float width = this->borderSize();
     133      std::vector<GLGuiWidget*>::iterator widget;
     134
     135      // find out how big the Widgets are.
     136      for (widget = this->children.begin(); widget != this->children.end(); ++widget)
     137      {
     138        (*widget)->setRelCoor2D(width, this->borderSize());
     139        height = fmax(height, (*widget)->getSizeY2D());
     140        width += (*widget)->getSizeX2D();
     141      }
     142
     143      width += this->borderSize() ;
     144      height += this->borderSize(); /* *2 done further up */
     145
     146      printf("%f %f\n", width, height);
     147      this->setSize2D(width, height);
     148    }
     149    GLGuiWidget::resize();
     150
     151    // resize everything.
     152    //for (widget = this->children.begin(); widget != this->children.end(); ++widget)
     153    //{}
     154  }
    99155
    100156  /**
    101    * draws the GLGuiBox
     157   * @brief draws the GLGuiBox
    102158   */
    103159  void GLGuiBox::draw() const
    104160  {
     161    this->beginDraw();
     162    GLGuiWidget::draw();
     163    this->endDraw();
    105164  }
    106165}
  • trunk/src/lib/gui/gl_gui/glgui_box.h

    r7779 r8035  
    99
    1010#include "glgui_container.h"
    11 
     11#include "glgui_defs.h"
    1212
    1313namespace OrxGui
    1414{
    15   typedef enum
    16   {
    17     Box_H,
    18     Box_V,
    19   } BoxType;
    20 
    2115  //! This is BOX part of the openglGUI class
    2216  /**
     
    2721
    2822  public:
    29     GLGuiBox(BoxType type = Box_H);
     23    GLGuiBox(OrxGui::Orientation orientation = OrxGui::Vertical);
    3024    virtual ~GLGuiBox();
    3125
    32     void init();
    33     void setType(BoxType type) { this->type = type; };
     26    /** @returns the Orientation of the Box */
     27    OrxGui::Orientation orientation() const { return this->_orientation; };
     28    /** @param orientation the Orientation of the Box */
     29    void setOrientation(OrxGui::Orientation orientation) { this->_orientation = orientation; };
    3430
    3531    virtual void pack(GLGuiWidget* widget);
    3632    virtual void unpack(GLGuiWidget* widget);
     33    virtual void clear();
     34
    3735    virtual void showAll();
    3836    virtual void hideAll();
     
    4038    virtual void draw() const;
    4139
     40  protected:
     41    virtual void resize();
     42
    4243  private:
    43     BoxType                  type;
    44     std::list<GLGuiWidget*>  children;
     44    void init();
     45
     46    Orientation                _orientation;
     47    std::vector<GLGuiWidget*>  children;
    4548  };
    4649}
  • trunk/src/lib/gui/gl_gui/glgui_button.cc

    r7919 r8035  
    6767  }
    6868
     69
     70
     71  void GLGuiButton::clicking(const Vector2D& pos)
     72  {
     73    emit(clicked());
     74  }
     75  void GLGuiButton::releasing(const Vector2D& pos)
     76  {
     77    emit(released());
     78  }
     79
    6980  /**
    7081   * @brief draws the GLGuiButton
  • trunk/src/lib/gui/gl_gui/glgui_button.h

    r7919 r8035  
    3232  {
    3333
    34   public:
    35     GLGuiButton(const std::string& label);
    36     virtual ~GLGuiButton();
     34    public:
     35      GLGuiButton(const std::string& label);
     36      virtual ~GLGuiButton();
    3737
    38     const std::string& getLabel() const { return this->label.getText(); };
    39     void setLabel(const std::string& label);
     38      const std::string& getLabel() const { return this->label.getText(); };
     39      void setLabel(const std::string& label);
    4040
    41     virtual void resize() = 0;
     41      virtual void draw() const;
    4242
    43     virtual void draw() const;
     43      DeclareSignal0(released);
     44      DeclareSignal0(clicked);
     45
     46    protected:
     47      virtual void clicking(const Vector2D& pos);
     48      virtual void releasing(const Vector2D& pos);
    4449
    4550    private:
     
    4752
    4853
    49   protected:
    5054
    51     Text                 label;
     55    protected:
    5256
    53   private:
    54     ButtonState          state;
     57      Text                 label;
     58
     59    private:
     60      ButtonState          state;
    5561  };
    5662}
  • trunk/src/lib/gui/gl_gui/glgui_checkbutton.cc

    r7919 r8035  
    5252  }
    5353
     54  void GLGuiCheckButton::setActivity(bool bActive)
     55  {
     56    this->bActive = bActive;
     57    emit(this->toggled(this->bActive));
     58  }
    5459
    5560  void GLGuiCheckButton::toggleActiveState()
    5661  {
    57     this->bActive = !this->bActive;
     62    this->setActivity(!this->isActive());
    5863  }
    5964
     
    6267    this->label.setRelCoor2D(25, 5);
    6368    this->setSize2D(this->label.getSizeX2D() + 30, this->label.getSizeY2D() + 10);
     69    GLGuiWidget::resize();
     70    this->frontRect().setTopLeft(borderSize(), borderSize());
     71    this->frontRect().setSize(this->getSizeX2D() -2.0*borderSize(), this->getSizeY2D() -2.0*borderSize());
    6472  }
    6573
    6674
    67   void GLGuiCheckButton::released()
     75  void GLGuiCheckButton::releasing(const Vector2D& pos)
    6876  {
    69     printf("%s released\n", this->getLabel().c_str());
    70     GLGuiWidget::released();
     77    GLGuiButton::releasing(pos);
    7178    this->toggleActiveState();
    7279  }
     80
     81
    7382
    7483  /**
     
    7786  void GLGuiCheckButton::draw() const
    7887  {
    79     this->startDraw();
     88    this->beginDraw();
    8089    GLGuiButton::draw();
    8190
    8291    this->frontMaterial().select();
    83     glBegin(GL_QUADS);
    84 
    85     glTexCoord2i(0,0); glVertex2d(1, 1);
    86     glTexCoord2i(0,1); glVertex2d(1, this->getSizeY2D() - 1);
    87     glTexCoord2i(1,1); glVertex2d(this->getSizeX2D() - 1, this->getSizeY2D() -1);
    88     glTexCoord2i(1,0); glVertex2d(this->getSizeX2D() - 1, 1);
     92    this->drawRect(this->frontRect());
    8993
    9094    if (this->bActive)
    9195    {
     96      glBegin(GL_QUADS);
    9297      glColor3f( 1, 1 ,1);
    9398      glTexCoord2i(0,0); glVertex2d(8, 8);
     
    117122    else
    118123    {
     124      glBegin(GL_QUADS);
    119125      glColor3f(0, 0, 0);
    120126      glTexCoord2i(0,0); glVertex2d(8, 8);
     
    125131    }
    126132
    127 
    128133    this->endDraw();
    129     //   this->label->draw();
    130     //  printf("test");
    131134  }
    132135}
  • trunk/src/lib/gui/gl_gui/glgui_checkbutton.h

    r7919 r8035  
    2626    virtual ~GLGuiCheckButton();
    2727
    28     virtual void resize();
    29     virtual void released();
    3028
    3129    bool    isActive() { return this->bActive; };
     
    3533    virtual void draw() const;
    3634    virtual void update() {};
     35
     36    DeclareSignal1(toggled, bool);
     37
     38  protected:
     39    virtual void resize();
     40    virtual void releasing(const Vector2D& pos);
    3741
    3842  private:
  • trunk/src/lib/gui/gl_gui/glgui_container.h

    r7779 r8035  
    2525    virtual ~GLGuiContainer();
    2626
    27     void init();
    28 
    29 
    30     void setBorderWidth(float borderwidth);
    31 
    32 
     27    /** @brief packs a widget into this one. */
    3328    virtual void pack(GLGuiWidget* widget) = 0;
    3429    /** unpacks a Widget from this container. @param widget the GLGuiWidget to unpack, if NULL all subwidgets will be unpackt. */
    3530    virtual void unpack(GLGuiWidget* widget) = 0;
     31    /** @brief clears all Widgets out. */
     32    virtual void clear() = 0;
     33
    3634    virtual void hideAll() = 0;
    3735    virtual void showAll() = 0;
     
    4139
    4240  private:
    43 
     41    void init();
    4442  };
    4543}
  • trunk/src/lib/gui/gl_gui/glgui_cursor.cc

    r7919 r8035  
    5959    this->backMaterial().setDiffuse(1.0,0.0,0.0);
    6060    this->backMaterial().setDiffuseMap("cursor.png");
    61     this->setSize2D(10, 20);
     61    this->backMaterial().setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     62    this->setSize2D(20, 30);
    6263    this->setAbsCoor2D(100, 100);
    6364    this->setLayer(E2D_LAYER_ABOVE_ALL);
    6465    this->color = 0.0f;
    6566
     67    this->resize();
    6668  }
    6769
     
    7476    this->backMaterial().setDiffuse(color.x, color.y, color.z);
    7577
    76     if (this->movement != Vector2D())
     78    //if (this->movement != Vector2D())
    7779    {
    7880      newPos += movement;
     
    8890
    8991
    90       this->setAbsCoorSoft2D(newPos, 10);
    9192      movement = Vector2D();
    9293    }
     94    this->setAbsCoor2D(newPos);
    9395  }
    9496
     
    98100  void GLGuiCursor::draw() const
    99101  {
    100     this->startDraw();
     102    this->beginDraw();
    101103    GLGuiWidget::draw();
    102104    this->endDraw();
  • trunk/src/lib/gui/gl_gui/glgui_handler.cc

    r7919 r8035  
    107107          {
    108108            if (GLGuiWidget::focused()->clickable())
    109               GLGuiWidget::focused()->click();
     109            {
     110              Vector2D cursorPos = (this->cursor != NULL) ? this->cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
     111              GLGuiWidget::focused()->click(cursorPos - GLGuiWidget::focused()->getAbsCoor2D());
     112            }
    110113          }
    111114          else
    112115          {
    113116            if (GLGuiWidget::focused()->clickable())
    114               GLGuiWidget::focused()->release();
     117            {
     118              Vector2D cursorPos = (this->cursor != NULL) ? this->cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
     119              GLGuiWidget::focused()->release(cursorPos - GLGuiWidget::focused()->getAbsCoor2D());
     120            }
    115121          }
    116122        }
     
    137143
    138144  }
     145
     146
     147  Vector2D GLGuiHandler::cursorPositionOverFocusedWidget() const
     148  {
     149    return (this->cursor != NULL) ? this->cursor->getAbsCoor2D() : Vector2D(0,0);
     150  }
     151
     152  const Vector2D& GLGuiHandler::cursorPositionAbs() const
     153  {
     154    if (this->cursor)
     155      return this->cursor->getAbsCoor2D();
     156    else
     157      return Vector2D::nullVector();
     158  }
     159  Vector2D GLGuiHandler::cursorPositionRel(const GLGuiWidget* const widget) const
     160  {
     161    assert (widget != NULL);
     162    if (this->cursor)
     163      return  this->cursor->getAbsCoor2D() - widget->getAbsCoor2D();
     164    else
     165      return Vector2D::nullVector();
     166  }
     167
    139168
    140169  void GLGuiHandler::draw()
  • trunk/src/lib/gui/gl_gui/glgui_handler.h

    r7919 r8035  
    3030    GLGuiCursor* getCursor() const { return this->cursor; }
    3131
     32    Vector2D cursorPositionOverFocusedWidget() const;
     33    const Vector2D& cursorPositionAbs() const;
     34    Vector2D cursorPositionRel(const GLGuiWidget* const widget) const;
     35
    3236    void activate();
    3337    void deactivate();
  • trunk/src/lib/gui/gl_gui/glgui_image.cc

    r7779 r8035  
    4343  void GLGuiImage::init()
    4444  {
    45     this->setClassID(CL_GLGUI_, "GLGuiImage");
     45    this->setClassID(CL_GLGUI_IMAGE, "GLGuiImage");
    4646
     47    this->frontMaterial().setDiffuseMap(this->texture);
     48    this->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     49
     50    this->resize();
    4751  }
    4852
     53
     54  void GLGuiImage::loadImageFromTexture(const Texture& texture)
     55  {
     56    this->frontMaterial().setDiffuseMap(texture);
     57    this->frontMaterial().setDiffuse(1,1,1);
     58  }
     59
     60  void GLGuiImage::loadImageFromFile(const std::string& fileName)
     61  {
     62    this->texture.loadImage(fileName);
     63  }
     64
     65  void GLGuiImage::loadImageFromSDLSurface(SDL_Surface* surface)
     66  {
     67    //this->texture.loadSurface(surface);
     68  }
     69
     70  void GLGuiImage::loadImageFromDisplayList(GLuint texture)
     71  {
     72//    this->texture.setTexture(texture);
     73  }
     74
     75  void GLGuiImage::resize()
     76  {
     77    this->frontRect().setTopLeft(this->borderSize(), this->borderSize());
     78    this->frontRect().setSize(this->getSizeX2D() -2.0*this->borderSize(), this->getSizeY2D() - 2.0* this->borderSize() );
     79    GLGuiWidget::resize();
     80  }
     81
     82
    4983  /**
    50    * draws the GLGuiImage
     84   * @brief draws the GLGuiImage
    5185   */
    52   void GLGuiImage::draw()
     86  void GLGuiImage::draw() const
    5387  {
     88    this->beginDraw();
     89    GLGuiWidget::draw();
     90
     91    this->frontMaterial().select();
     92    this->drawRect(this->frontRect());
     93    this->endDraw();
    5494  }
    5595}
  • trunk/src/lib/gui/gl_gui/glgui_image.h

    r7779 r8035  
    88#define _GLGUI_IMAGE_H
    99
    10 #include "base_object.h"
     10#include "glgui_widget.h"
    1111
    1212// FORWARD DECLARATION
     
    2626    virtual ~GLGuiImage();
    2727
    28     void init();
    29     void loadImageFromFile(const char* fileName);
     28    void loadImageFromTexture(const Texture& texture);
     29
     30    void loadImageFromFile(const std::string& fileName);
    3031    void loadImageFromSDLSurface(SDL_Surface* surface);
    31     void loadImageFromDisplayList(GLuint displayList);
     32    void loadImageFromDisplayList(GLuint texture);
    3233
    33     virtual void draw();
     34    virtual void draw() const;
     35
     36    DeclareSignal0(imageChanged);
    3437
    3538  private:
     39    void init();
     40    virtual void resize();
    3641
     42  private:
     43    Texture       texture;
    3744  };
    3845}
  • trunk/src/lib/gui/gl_gui/glgui_inputline.cc

    r7919 r8035  
    2121{
    2222  /**
    23    * standard constructor
     23   * @brief standard constructor
    2424  */
    2525  GLGuiInputLine::GLGuiInputLine ()
    2626  {
    2727    this->init();
    28 
    29   }
    30 
    31 
    32   /**
    33    * standard deconstructor
    34   */
     28  }
     29
     30
     31  /**
     32   * @brief standard deconstructor
     33   */
    3534  GLGuiInputLine::~GLGuiInputLine()
    3635  {}
     
    4140
    4241  /**
    43    * initializes the GUI-element
     42   * @brief initializes the GUI-element
    4443   */
    4544  void GLGuiInputLine::init()
     
    5251    this->text.setRelCoor2D(4,4);
    5352    this->text.setFont("fonts/final_frontier.ttf", 20);
    54   }
    55 
     53    this->resize();
     54  }
     55
     56
     57  /**
     58   * @brief sets the Text of the InputLine
     59   * @param text The new Text.
     60   */
    5661  void GLGuiInputLine::setText(const std::string& text)
    5762  {
    5863    this->text.setText(text);
    5964    this->resize();
    60   }
    61 
     65
     66    emit(this->textChanged(this->getText()));
     67  }
     68
     69  /**
     70   * @brief appends text to the InputLine
     71   * @param appendText the Text to append
     72   */
    6273  void GLGuiInputLine::append(const std::string& appendText)
    6374  {
    6475    this->text.append(appendText);
    6576    this->resize();
    66   }
    67 
     77    emit(this->textChanged(this->text.getText()));
     78  }
     79
     80
     81  /**
     82   * @brief appends a Character to the InputLine
     83   * @param character the Character to append.
     84   */
    6885  void GLGuiInputLine::appendCharacter(char character)
    6986  {
    7087    this->text.appendCharacter(character);
    7188    this->resize();
    72   }
    73 
    74 
     89    emit(this->textChanged(this->text.getText()));
     90  }
     91
     92
     93  /**
     94   * @brief Removes Characters from the InputLine
     95   * @param chars The count of characters to remove
     96   */
    7597  void GLGuiInputLine::removeCharacters(unsigned int chars)
    7698  {
    7799    this->text.removeCharacters(chars);
    78100    this->resize();
    79   }
    80 
    81 
     101    emit(this->textChanged(this->text.getText()));
     102  }
     103
     104
     105  /**
     106   * removes the focus from this Widget.
     107   */
    82108  void GLGuiInputLine::removedFocus()
    83109  {
     
    88114
    89115
     116  /**
     117   * Processes an Event.
     118   * @param event The event to be processed
     119   * @return true if the event was catched.
     120   */
    90121  bool GLGuiInputLine::processEvent(const Event& event)
    91122  {
     
    126157
    127158
     159  /**
     160   * @brief Resizes the Widget to the new Size-constraints.
     161   */
    128162  void GLGuiInputLine::resize()
    129163  {
    130164    this->setSize2D( this->text.getSize2D() + Vector2D(8, 8));
    131   }
    132 
    133 
     165    GLGuiWidget::resize();
     166    this->frontRect().setTopLeft(borderSize(), borderSize());
     167    this->frontRect().setSize(this->getSize2D() - Vector2D(borderSize(), borderSize()));
     168  }
     169
     170
     171  /**
     172   * ticks the InputLine
     173   * @param dt the time passed.
     174   */
    134175  void GLGuiInputLine::tick(float dt)
    135176  {
     
    156197
    157198  /**
    158    * draws the GLGuiInputLine
     199   * @brief draws the GLGuiInputLine
    159200   */
    160201  void GLGuiInputLine::draw() const
    161202  {
    162     this->startDraw();
     203    this->beginDraw();
    163204    GLGuiWidget::draw();
    164205
    165206    this->frontMaterial().select();
    166     glBegin(GL_QUADS);
    167 
    168     glTexCoord2i(0,0); glVertex2d(3, 3);
    169     glTexCoord2i(0,1); glVertex2d(3, this->getSizeY2D() - 3);
    170     glTexCoord2i(1,1); glVertex2d(this->getSizeX2D() - 3, this->getSizeY2D() -3);
    171     glTexCoord2i(1,0); glVertex2d(this->getSizeX2D() - 3, 3);
    172 
    173     glEnd();
     207    GLGuiWidget::drawRect(this->frontRect());
     208
    174209    this->endDraw();
    175210  }
  • trunk/src/lib/gui/gl_gui/glgui_inputline.h

    r7919 r8035  
    1616{
    1717
    18   //! This is part of the openglGUI class
     18  //! This is InputLine part of the openglGUI class
    1919  /**
     20   * The InputLine is a Widget, that displays a Line, that can be manipulated through
     21   * Writing Text on it.
    2022   *
     23   * Whenever the Text is changed the textChanged signal is emitted.
    2124   */
    2225  class GLGuiInputLine : public OrxGui::GLGuiWidget
     
    2730    virtual ~GLGuiInputLine();
    2831
    29     void init();
     32
     33    /** @returns the text of the inputLine */
     34    const std::string& getText() const { return this->text.getText(); };
    3035
    3136    void setText(const std::string& text);
     
    3338    void appendCharacter(char character);
    3439    void removeCharacters(unsigned int chars);
    35     const std::string& getName() const { return this->text.getText(); };
    36 
    3740
    3841    virtual void removedFocus();
     
    4346    virtual bool processEvent(const Event& event);
    4447
    45     private:
    46       void resize();
     48    DeclareSignal1(textChanged, const std::string&);
    4749
     50  private:
     51    void init();
     52    void resize();
    4853
    4954  private:
     
    5560    float                   delayNext;        //!< How much time must pass before next output.
    5661
    57     static float            repeatDelay;
    58     static float            repeatRate;
    59 
    60 
     62    static float            repeatDelay;      //!< Repead Delay.
     63    static float            repeatRate;       //!< Repeat Rate.
    6164  };
    6265}
  • trunk/src/lib/gui/gl_gui/glgui_pushbutton.cc

    r7919 r8035  
    4747    this->label.setRelCoor2D(5, 5);
    4848    this->setSize2D(this->label.getSizeX2D() + 10, this->label.getSizeY2D() + 10);
     49
     50    GLGuiWidget::resize();
     51    this->frontRect().setTopLeft(1, 1);
     52    this->frontRect().setSize(this->getSizeX2D() -2, this->getSizeY2D() -2);
    4953  }
    5054
     
    7074  }
    7175
    72   void GLGuiPushButton::clicked()
     76  void GLGuiPushButton::clicking(const Vector2D& pos)
    7377  {
    7478    printf("%s clicked\n", this->getLabel().c_str());
    75     GLGuiWidget::clicked();
     79    GLGuiButton::clicking(pos);
    7680  }
    7781
    7882
    79   void GLGuiPushButton::released()
     83  void GLGuiPushButton::releasing(const Vector2D& pos)
    8084  {
    8185    printf("%s released\n", this->getLabel().c_str());
    82     GLGuiWidget::released();
     86    GLGuiButton::releasing(pos);
    8387  }
    8488
     
    9094  void GLGuiPushButton::draw() const
    9195  {
    92     this->startDraw();
     96    this->beginDraw();
    9397    GLGuiButton::draw();
    9498
    9599    this->frontMaterial().select();
    96     glBegin(GL_QUADS);
    97 
    98     glTexCoord2i(0,0); glVertex2d(1, 1);
    99     glTexCoord2i(0,1); glVertex2d(1, this->getSizeY2D() - 1);
    100     glTexCoord2i(1,1); glVertex2d(this->getSizeX2D() - 1, this->getSizeY2D() -1);
    101     glTexCoord2i(1,0); glVertex2d(this->getSizeX2D() - 1, 1);
    102 
    103     glEnd();
     100    this->drawRect(this->frontRect());
    104101    this->endDraw();
    105102    //   this->label->draw();
  • trunk/src/lib/gui/gl_gui/glgui_pushbutton.h

    r7919 r8035  
    2727
    2828
    29     virtual void resize();
    30 
    31     virtual void receivedFocus();
    32     virtual void removedFocus();
    33     virtual void clicked();
    34     virtual void released();
    3529
    3630
    3731    virtual void draw() const;
    3832    virtual void update();
     33  protected:
     34    virtual void resize();
     35    virtual void clicking(const Vector2D& pos);
     36    virtual void releasing(const Vector2D& pos);
     37    virtual void receivedFocus();
     38    virtual void removedFocus();
     39
     40
     41
    3942  private:
    4043    void init();
  • trunk/src/lib/gui/gl_gui/glgui_slider.cc

    r7919 r8035  
    1717
    1818#include "glgui_slider.h"
     19#include "event_def.h"
     20
     21#include "glgui_handler.h"
    1922
    2023namespace OrxGui
     
    2225
    2326  /**
    24    * standard constructor
    25   */
     27   * @brief standard constructor
     28   */
    2629  GLGuiSlider::GLGuiSlider ()
    2730  {
     
    3235
    3336  /**
    34    * standard deconstructor
    35   */
     37   * @brief standard deconstructor
     38   */
    3639  GLGuiSlider::~GLGuiSlider()
    37   {
    38   }
    39 
    40   /**
    41    * initializes the GUI-element
     40  {}
     41
     42  /**
     43   * @brief initializes the GUI-element
    4244   */
    4345  void GLGuiSlider::init()
    4446  {
     47
    4548    this->setClassID(CL_GLGUI_SLIDER, "GLGuiSlider");
    4649
    47   }
    48 
    49   /**
    50    * draws the GLGuiSlider
     50    this->setClickable( );
     51    this->setFocusable( );
     52
     53    this->_value = 0.0;
     54    this->_minValue = 0.0;
     55    this->_maxValue = 1.0;
     56    this->_step = 0.1;
     57    this->_sliderWidth = 5.0;
     58    this->grabbed = false;
     59
     60    this->setSize2D(100, 30);
     61    this->resize();
     62  }
     63
     64  /**
     65   * @param value the new Value.
     66   * @note will automatically be set between max() and min()
     67   */
     68  void GLGuiSlider::setValue(float value)
     69  {
     70    if (value < this->min())
     71      this->_value = min();
     72    else if (value > max())
     73      this->_value = max();
     74    else
     75      this->_value = value;
     76    emit(valueChanged(this->_value));
     77  }
     78
     79  /**
     80   * @param minimum the minumum of the range.
     81   *
     82   * @note will rearange value if necessary and will not be made bigger than max()
     83   */
     84  void GLGuiSlider::setMin(float minimum)
     85  {
     86    if (minimum <= max())
     87    {
     88      this->_minValue = minimum;
     89      emit(rangeChanged(this->_minValue, this->_maxValue));
     90    }
     91    if (this->value() < this->min())
     92      this->setValue(this->min());
     93  }
     94
     95
     96  /**
     97   * @param maximum the maximum of the range.
     98   *
     99   * @note will rearange value if necessary and will not be made smaller than min()
     100   */
     101  void GLGuiSlider::setMax(float maximum)
     102  {
     103    if (maximum >= min())
     104    {
     105      this->_maxValue = maximum;
     106      emit(rangeChanged(this->_minValue, this->_maxValue));
     107    }
     108    if (this->value() > this->max())
     109      this->setValue(this->max());
     110  }
     111
     112  /**
     113   * @param minimum the minimum
     114   * @param maximum the maximum
     115   *
     116   * @see setMax
     117   * @see setMin
     118   */
     119  void GLGuiSlider::setRange(float minimum, float maximum)
     120  {
     121    if (minimum < maximum)
     122    {
     123      this->_minValue = minimum;
     124      this->_maxValue = maximum;
     125      emit(rangeChanged(this->_minValue, this->_maxValue));
     126    }
     127    if (this->value() < this->min())
     128      this->setValue(this->min());
     129    else if (this->value() > this->max())
     130      this->setValue(this->max());
     131  }
     132
     133  /**
     134   * @brief sets the stepSize
     135   */
     136  void GLGuiSlider::setStep(float step)
     137  {
     138    this->_step = step;
     139  }
     140
     141  /**
     142   * @brief makes one step into the minus direction
     143   */
     144  void GLGuiSlider::stepMinus()
     145  {
     146    this->setValue(value() - step());
     147  }
     148
     149  /**
     150   * @brief makes one step into the minus direction
     151   */
     152  void GLGuiSlider::stepPlus()
     153  {
     154    this->setValue(value() + step());
     155  }
     156
     157  /**
     158   * @brief resizes the Slider, and through this Synchronizes the GUI-size.
     159   */
     160  void GLGuiSlider::resize()
     161  {
     162    GLGuiWidget::resize();
     163    this->frontRect().setTopLeft(5, this->getSizeY2D()/2.0 - 2.0);
     164    this->frontRect().setSize(this->getSizeX2D() - 10.0, 4.0);
     165  }
     166
     167  /**
     168   * @brief handle the clicked event.
     169   * @param pos the position the Click occured (from the topleft corner out)
     170   */
     171  void GLGuiSlider::clicking(const Vector2D& pos)
     172  {
     173    GLGuiWidget::clicking(pos);
     174
     175    float sliderPosition = this->sliderPosition();
     176    if (sliderPosition > pos.x + this->_sliderWidth)
     177      this->setValue(this->value() - this->step());
     178
     179    else if (sliderPosition < pos.x - this->_sliderWidth)
     180      this->setValue(this->value() + this->step());
     181    else
     182      this->grabbed = true;
     183  }
     184
     185  void GLGuiSlider::releasing(const Vector2D& pos)
     186  {
     187    GLGuiWidget::releasing(pos);
     188    this->grabbed = false;
     189  }
     190
     191  void GLGuiSlider::removedFocus()
     192  {
     193    GLGuiWidget::removedFocus();
     194    this->grabbed = false;
     195  }
     196
     197  /**
     198   * @returns the current SliderPosition calculated from the current value and the Silders' size.
     199   */
     200  float GLGuiSlider::sliderPosition() const
     201  {
     202    return (this->_value - this->_minValue)/( this->_maxValue - this->_minValue) *
     203           (this->getSizeX2D() - 2.0*(borderSize() + _sliderWidth)) +
     204           (borderSize() +_sliderWidth);
     205  }
     206
     207  /**
     208   * @param position the position relative from the left border.
     209   * @returns the Value at the given position.
     210   */
     211  float GLGuiSlider::sliderValue(float position) const
     212  {
     213    return (position - (borderSize()+_sliderWidth)) / (this->getSizeX2D() - 2.0*(borderSize() + _sliderWidth))
     214           *( this->_maxValue - this->_minValue) +
     215           this->_minValue ;
     216  }
     217
     218  void GLGuiSlider::tick(float dt)
     219  {
     220  }
     221
     222  /**
     223   * @brief draws the GLGuiSlider
    51224   */
    52225  void GLGuiSlider::draw() const
    53226  {
     227    this->beginDraw();
     228    GLGuiWidget::draw();
     229
     230    this->frontMaterial().select();
     231    this->drawRect(this->frontRect());
     232
     233    this->drawRect(Rect2D(this->sliderPosition()-_sliderWidth/2.0, borderSize(), _sliderWidth, this->getSizeY2D() - 2 * borderSize()));
     234
     235    this->endDraw();
     236  }
     237
     238
     239  bool GLGuiSlider::processEvent( const Event& event )
     240  {
     241    if (this->grabbed && event.type == EV_MOUSE_MOTION)
     242    {
     243      this->setValue(sliderValue(GLGuiHandler::getInstance()->cursorPositionRel(this).x));
     244      return true;
     245    }
     246    else if (event.bPressed)
     247    {
     248      if (event.type == SDLK_LEFT)
     249      {
     250        this->stepMinus();
     251        return true;
     252      }
     253      else if (event.type == SDLK_RIGHT)
     254      {
     255        this->stepPlus();
     256        return true;
     257      }
     258    }
     259    return false;
    54260  }
    55261}
  • trunk/src/lib/gui/gl_gui/glgui_slider.h

    r7919 r8035  
    1717  //! This is part of the openglGUI class
    1818  /**
    19    *
     19   * The Slider is a Widget, with a Range and a Value.
    2020   */
    2121  class GLGuiSlider : public GLGuiWidget
     
    2626    virtual ~GLGuiSlider();
    2727
     28    /** @returns the Value of the Slider. */
     29    float value() const { return this->_value; }
     30    /** @returns the minimum of the sliders range */
     31    float min() const { return this->_minValue; };
     32    /** @returns the maximum of the sliders range */
     33    float max() const { return this->_maxValue; };
     34    /** @returns the step size */
     35    float step() const { return this->_step; };
     36
     37    void setValue(float value);
     38
     39    void setMin(float minimum);
     40    void setMax(float maximum);
     41    void setRange(float minimum, float maximum);
     42
     43    void setStep(float step);
     44
     45    void stepPlus();
     46    void stepMinus();
     47
     48
     49    virtual void tick(float dt);
     50    virtual bool processEvent(const Event& event);
     51    virtual void draw() const;
     52
     53    DeclareSignal1(valueChanged, float);
     54    DeclareSignal2(rangeChanged, float, float);
     55
     56  protected:
     57    virtual void resize();
     58
     59    virtual void clicking(const Vector2D& pos);
     60    virtual void releasing(const Vector2D& pos);
     61    virtual void removedFocus();
     62
     63  private:
    2864    void init();
    29 
    30     virtual void draw() const;
     65    float sliderPosition() const;
     66    float sliderValue(float position) const;
    3167
    3268  private:
     
    3571    float            _maxValue;
    3672    float            _minValue;
     73    float            _step;
    3774
    3875    float            _value;
     76
     77    float            _sliderWidth;
     78
     79    bool             grabbed;
    3980
    4081  };
  • trunk/src/lib/gui/gl_gui/glgui_text.h

    r7779 r8035  
    2626    virtual ~GLGuiText();
    2727
     28    void setText();
     29
     30    virtual void draw();
     31
     32  private:
    2833    void init();
    2934
    30     virtual void draw();
    3135
    3236  private:
  • trunk/src/lib/gui/gl_gui/glgui_textfield.cc

    r7919 r8035  
    4343  {
    4444    this->setClassID(CL_GLGUI_TEXTFIELD, "GLGuiTextfield");
    45 
    46 
    4745  }
    4846
    4947  /**
    50    * draws the GLGuiTextfield
     48   * @brief draws the GLGuiTextfield
    5149   */
    5250  void GLGuiTextfield::draw() const
    5351  {
     52    this->beginDraw();
     53    GLGuiWidget::draw();
     54
     55    this->frontMaterial().select();
     56    this->drawRect(this->frontRect());
     57    this->endDraw();
    5458  }
    5559}
  • trunk/src/lib/gui/gl_gui/glgui_widget.cc

    r7919 r8035  
    2828
    2929  /**
    30    * standard constructor
     30   * @brief standard constructor
    3131  */
    32   GLGuiWidget::GLGuiWidget ( )
     32  GLGuiWidget::GLGuiWidget (GLGuiWidget* parent)
    3333  {
    3434    this->init();
    35   }
    36 
    37 
    38   /**
    39    * standard deconstructor
     35
     36    this->setParentWidget(parent);
     37  }
     38
     39
     40  /**
     41   * @brief standard deconstructor
    4042   */
    4143  GLGuiWidget::~GLGuiWidget()
     
    4547  }
    4648
     49  GLGuiWidget* GLGuiWidget::_selected = NULL;
    4750  GLGuiWidget* GLGuiWidget::_focused = NULL;
    4851  GLGuiWidget* GLGuiWidget::_inputGrabber = NULL;
     
    6366    this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
    6467
    65     this->backMat.setDiffuse(1.0, 1.0, 1.0);
    66     this->frontMat.setDiffuse(1.0, 0.0, 0.0);
    67 
    68     this->widgetSignals.resize(SignalCount, SignalConnector());
    69   }
    70 
     68    this->_backMat.setDiffuse(1.0, 1.0, 1.0);
     69    this->_frontMat.setDiffuse(1.0, 0.0, 0.0);
     70    this->_borderSize = 1.0;
     71  }
     72
     73
     74  void GLGuiWidget::setParentWidget(GLGuiWidget* parent)
     75  {
     76    this->_parent = parent;
     77
     78    if (parent != NULL)
     79      parent->addChild2D(this);
     80  }
    7181
    7282  /** @brief gives focus to this widget */
     
    93103  {
    94104    return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x &&
    95         this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);
     105            this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);
    96106  }
    97107
     
    101111  }
    102112
    103   void GLGuiWidget::click()
     113
     114  void GLGuiWidget::setBorderSize(float borderSize)
     115  {
     116    this->_borderSize = borderSize;
     117    this->resize();
     118  }
     119
     120
     121  void GLGuiWidget::resize()
     122  {
     123    this->backRect().setSize(this->getSize2D());
     124    if (this->parent() != NULL)
     125      this->parent()->resize();
     126  }
     127
     128
     129  void GLGuiWidget::click(const Vector2D& pos)
    104130  {
    105131    assert (!this->_pushed);
    106     this->widgetSignals[Signal_click]("none");
    107132    this->_pushed = true;
    108133
    109     this->clicked();
    110   }
    111 
    112   void GLGuiWidget::release()
     134    this->clicking(pos);
     135  }
     136
     137  void GLGuiWidget::release(const Vector2D& pos)
    113138  {
    114139    if (this->_pushed)
    115140    {
    116       this->widgetSignals[Signal_release]("none");
    117 
    118       this->released();
     141      this->releasing(pos);
    119142      this->_pushed = false;
    120143    }
     
    122145
    123146
    124   void GLGuiWidget::clicked()
     147  void GLGuiWidget::clicking(const Vector2D& pos)
    125148  {
    126149    this->frontMaterial().setDiffuse(0, 0, 1);
     
    128151  }
    129152
    130   void GLGuiWidget::released()
    131   {
    132     this->frontMat.setDiffuse(0,1,0);
     153  void GLGuiWidget::releasing(const Vector2D& pos)
     154  {
     155    this->frontMaterial().setDiffuse(0,1,0);
    133156
    134157  }
     
    146169
    147170  void GLGuiWidget::destroyed()
    148   {
    149   };
    150 
    151 
    152 
    153 
    154   /**
    155    * @brief connects a Signal to the Gui-Elements' Event.
    156    * @param sinalType the Type of Signal to set. @see GLGuiSignalType
    157    * @param signal the name of the Signal
     171  {}
     172  ;
     173
     174  void GLGuiWidget::setWidgetSize(const Vector2D& size)
     175  {
     176    this->setSize2D(size);
     177    this->resize();
     178
     179  }
     180
     181
     182  void GLGuiWidget::setWidgetSize(float x, float y)
     183  {
     184    this->setWidgetSize(Vector2D(x, y));
     185  }
     186
     187
     188
     189  void GLGuiWidget::connect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver, Slot executor)
     190  {
     191    sender->connect(signal, receiver, executor);
     192  }
     193
     194  void GLGuiWidget::connect(Signal& signal, BaseObject* receiver, Slot executor)
     195  {
     196    signal.push_back(SignalConnector(receiver, executor));
     197  }
     198
     199
     200  void GLGuiWidget::show()
     201  {
     202    this->setVisibility(true);
     203  }
     204
     205
     206  void GLGuiWidget::hide()
     207  {
     208    this->setVisibility(false);
     209  }
     210
     211
     212  /**
     213   * USE THIS FUNCTION ONLY FROM DERIVED CLASS
    158214   */
    159   void GLGuiWidget::connectSignal(SignalType signalType, BaseObject* object, const Executor* signal)
    160   {
    161     if (signalType >= this->widgetSignals.size())
    162       return;
    163 
    164 //    if (this->widgetSignals[signalType] != NULL)
    165 //      PRINTF(2)("Already connected a Signal to '%s::%s' type %s... overwriting\n", this->getClassName(), this->getName(), "TEST");
    166 
    167     this->widgetSignals[signalType] = SignalConnector(object, signal);
    168   }
    169 
    170   /**
    171    * @brief removes a Signal from a Gui-ELements' Event
    172    * @param signalType the type of Signal to remove.
    173    */
    174   void GLGuiWidget::disconnectSignal(SignalType signalType)
    175   {
    176     if (signalType >= this->widgetSignals.size())
    177       return;
    178 
    179     this->widgetSignals[signalType] = SignalConnector();
    180   }
    181 
    182 
    183   void GLGuiWidget::show()
    184   {
    185     this->setVisibility(true);
    186   }
    187 
    188   void GLGuiWidget::hide()
    189   {
    190     this->setVisibility(false);
    191   }
    192 
    193 
    194215  void GLGuiWidget::draw() const
    195216  {
    196     this->backMat.select();
    197 
    198     glBegin(GL_QUADS);
    199     glTexCoord2i(0,0); glVertex2d(0, 0);
    200     glTexCoord2i(0,1); glVertex2d(0, this->getSizeY2D());
    201     glTexCoord2i(1,1); glVertex2d(this->getSizeX2D(), this->getSizeY2D());
    202     glTexCoord2i(1,0); glVertex2d(this->getSizeX2D(), 0);
    203     glEnd();
     217    this->backMaterial().select();
     218    this->drawRect(this->backRect());
    204219  }
    205220
  • trunk/src/lib/gui/gl_gui/glgui_widget.h

    r7919 r8035  
    2424namespace OrxGui
    2525{
    26   typedef enum
    27   {
    28     Signal_click     = 0,
    29     Signal_release,
    30     Signal_rollOn,
    31     Signal_rollOff,
    32     Signal_open,
    33     Signal_close,
    34     Signal_destroy,
    35 
    36     SignalCount,
    37   } SignalType;
    38 
    3926
    4027  class GLGuiCursor;
     
    4936  class GLGuiWidget : public Element2D
    5037  {
    51 
    52   private:
    53 
    5438  public:
    55     GLGuiWidget();
     39    GLGuiWidget(GLGuiWidget* parent = NULL);
    5640    virtual ~GLGuiWidget();
    5741
     
    5943    void hide();
    6044
    61     /// INTERCONNECTIVITY
    62     void connectSignal(SignalType signalType, BaseObject* obj, const Executor* signal);
    63     void disconnectSignal(SignalType signalType);
    6445
     46    void setParentWidget(GLGuiWidget* parent);
     47    GLGuiWidget* parent() const { return this->_parent; }
    6548
    6649    /// FOCUS
     
    8265
    8366    /// CLICK
    84     void click();
    85     void release();
     67    void click(const Vector2D& pos);
     68    void release(const Vector2D& pos);
    8669    bool clickable() const { return this->_clickable; };
    8770    void setClickable(bool clickable = true) { this->_clickable = clickable; };
     71
     72    static void connect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver, Slot executor);
     73    void connect(Signal& signal, BaseObject* receiver, Slot executor);
     74
     75    void disconnect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver);
     76
     77
     78    /// MATERIAL (looks)
     79    Material& backMaterial() { return this->_backMat; };
     80    const Material& backMaterial() const { return this->_backMat; };
     81    Rect2D& backRect() { return this->_backRect; };
     82    const Rect2D& backRect() const { return this->_backRect; };
     83
     84    Material& frontMaterial() { return this->_frontMat; };
     85    const Material& frontMaterial() const { return this->_frontMat; };
     86    Rect2D& frontRect() { return this->_frontRect; };
     87    const Rect2D& frontRect() const { return this->_frontRect; };
     88
     89    float borderSize() const { return this->_borderSize; };
     90    void setBorderSize(float borderSize);
     91
     92    void setWidgetSize(const Vector2D& size);
     93    void setWidgetSize(float x, float y);
     94
     95
     96    void setBackgroundColor(float x, float y, float z) { this->backMaterial().setDiffuse(x,y,z); };
     97
     98    inline void drawRect(const Rect2D& rect) const {
     99      glBegin(GL_QUADS);
     100      glTexCoord2i(0,0); glVertex2d(rect.left(), rect.top());
     101      glTexCoord2i(0,1); glVertex2d(rect.left(), rect.bottom());
     102      glTexCoord2i(1,1); glVertex2d(rect.right(), rect.bottom());
     103      glTexCoord2i(1,0); glVertex2d(rect.right(), rect.top());
     104      glEnd();
     105    }
     106
    88107
    89108    virtual void update() {};
    90109    virtual void draw() const;
    91110
    92 
    93     /// MATERIAL (looks)
    94     Material& backMaterial() { return this->backMat; };
    95     const Material& backMaterial() const { return this->backMat; };
    96 
    97     Material& frontMaterial() { return this->frontMat; };
    98     const Material& frontMaterial() const { return this->frontMat; };
    99 
    100111    /** @param the Event to process. @returns true if the Event has been consumed*/
    101112    virtual bool processEvent(const Event& event) { };
    102113
     114  protected:
    103115
    104     DeclareSignal(testSignal, ());
     116    /// LOOKS
     117    virtual void resize();
    105118
    106   protected:
    107         // if something was clickt on the GUI-widget.
    108     virtual void clicked();
    109     virtual void released();
     119    // if something was clickt on the GUI-widget.
     120    virtual void clicking(const Vector2D& pos);
     121    virtual void releasing(const Vector2D& pos);
    110122    virtual void receivedFocus();
    111123    virtual void removedFocus();
     
    114126
    115127
    116     inline void startDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
     128    inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
    117129    inline void endDraw() const { glPopMatrix(); };
    118130
     
    122134
    123135  private:
     136    GLGuiWidget*                   _parent;           //!< The parent of this Widget.
     137
    124138    /// LOOKS
    125     Material                       backMat;
    126     Rect2D                         backRect;
     139    Material                       _backMat;
     140    Rect2D                         _backRect;
    127141
    128     Material                       frontMat;
    129     Rect2D                         frontRect;
     142    Material                       _frontMat;
     143    Rect2D                         _frontRect;
    130144
    131 
    132     /// SIGNALS
    133     std::vector<SignalConnector>   widgetSignals;
     145    float                          _borderSize;
    134146
    135147    /// EVENTS
     
    139151    bool                           _pushed;
    140152
    141     static GLGuiWidget*            _focused;
    142     static GLGuiWidget*            _inputGrabber;
     153
     154    static GLGuiWidget*            _selected;         //!< The currently selected Widget.
     155    static GLGuiWidget*            _focused;          //!< The currently Focused Widget.
     156
     157    static GLGuiWidget*            _inputGrabber;     //!< The Widget that grabs input.
    143158  };
    144159}
  • trunk/src/lib/gui/gl_gui/signal_connector.cc

    r7855 r8035  
    2121{
    2222
     23  /**
     24   * @brief creates a clean SignalConnector
     25   */
    2326  SignalConnector::SignalConnector( )
    2427  {
     
    2730  }
    2831
     32  /**
     33   * @brief Creates a SignalConnector out of an ObjectPointer, and an Executor.
     34   * @param object the Object the Executor will apply to.
     35   * @param executor the Executor that will be executed.
     36   * @return a new SignalConnector.
     37   */
    2938  SignalConnector::SignalConnector(BaseObject* object, const Executor* executor)
    3039  {
     
    3342  };
    3443
     44  /**
     45   * @brief Creates a SignalConnector as a copy of another one.
     46   * @param signalConnector The SignalConnector to copy.
     47   */
    3548  SignalConnector::SignalConnector(const SignalConnector& signalConnector)
    3649  {
     
    3952  }
    4053
     54  /**
     55   * @brief deletes a SignalConnector.
     56   *
     57   * frees the stored executor
     58   */
    4159  SignalConnector::~SignalConnector()
    4260  {
     
    4462  }
    4563
     64  /**
     65   * @brief assignes a SignalConnector to the current one
     66   * @param signalConnector the SignalConnector to assign to this one
     67   * @return A Reference to this SignalConnector.
     68   */
    4669  SignalConnector& SignalConnector::operator=(const SignalConnector& signalConnector)
    4770  {
     
    5174  }
    5275
    53   void SignalConnector::operator()(const std::string& parameters) const
     76
     77  /**
     78   * @brief compares two SignalConnectors.
     79   * @param signalConnector the SignalConnector to compare against this one.
     80   * @return true if the Connectors are the same.
     81   */
     82  bool SignalConnector::operator==(const SignalConnector& signalConnector) const
     83  {
     84    return (this->object == signalConnector.object /* && this->exec == signalConnector.exec */ );
     85  }
     86
     87
     88  /**
     89   * @brief Executes the SignalConnector.
     90   */
     91  void SignalConnector::operator()() const
     92  {
     93    if (this->isValid())
     94      (*this->exec)(this->object, 0, NULL);
     95  }
     96
     97  /**
     98   * @brief Executes the SignalConnector.
     99   * @param value0 First Value.
     100   */
     101  void SignalConnector::operator()(const MultiType& value0) const
    54102  {
    55103    if (exec != NULL && object != NULL)
    56       (*this->exec)(this->object, parameters);
     104      (*this->exec)(this->object, 1, &value0);
    57105  }
    58106
     107  /**
     108   * @brief Executes the SignalConnector.
     109   * @param value0 First Value
     110   * @param value1 Second Value
     111   */
     112  void SignalConnector::operator()(const MultiType& value0, const MultiType& value1) const
     113  {
     114    if (exec != NULL && object != NULL)
     115    {
     116      MultiType mt[] = { value0, value1 };
     117      (*this->exec)(this->object, 2, mt);
     118    }
     119  }
     120
     121  /**
     122   * @brief Executes the SignalConnector.
     123   * @param value0 First Value
     124   * @param value1 Second Value
     125   * @param value2 Third Value
     126   */
     127  void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2) const
     128  {
     129    if (exec != NULL && object != NULL)
     130    {
     131      MultiType mt[] = { value0, value1, value2 };
     132      (*this->exec)(this->object, 3, mt);
     133    }
     134  }
     135
     136  /**
     137   * @brief Executes the SignalConnector.
     138   * @param value0 First Value
     139   * @param value1 Second Value
     140   * @param value2 Third Value
     141   * @param value3 Fourth Value
     142   */
     143  void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3) const
     144  {
     145    if (exec != NULL && object != NULL)
     146    {
     147      MultiType mt[] = { value0, value1, value2, value3 };
     148      (*this->exec)(this->object, 4, mt);
     149    }
     150  }
     151
     152  /**
     153   * @brief Executes the SignalConnector.
     154   * @param value0 First Value
     155   * @param value1 Second Value
     156   * @param value2 Third Value
     157   * @param value3 Fourth Value
     158   * @param value3 Fifth Value
     159   */
     160  void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3, const MultiType& value4) const
     161  {
     162    if (exec != NULL && object != NULL)
     163    {
     164      MultiType mt[] = { value0, value1, value2, value3, value4 };
     165      (*this->exec)(this->object, 5, mt);
     166    }
     167  }
    59168}
  • trunk/src/lib/gui/gl_gui/signal_connector.h

    r7919 r8035  
    1212{
    1313
    14 #define DeclareSignal(name, params) \
     14  //////////////// TO BE IGNORED BY YOU /////
     15#define DeclareSignalBegin(SignalName) \
    1516  public: \
    16    void signal_ ##connect ##name(const SignalConnector& connector) { \
    17      name ## connected.push_back(connector); \
     17   void signal_ ## connect ## SignalName(const SignalConnector& connector) { \
     18     SignalName ## connected.push_back(connector); \
     19}\
     20   Signal& getSignalVector_##SignalName () { return this->SignalName ## connected; }; \
     21  private:
     22
     23#define DeclareSignalEnd(SignalName) \
     24  Signal SignalName ## connected
     25  /////////////////////////////////////////////
     26
     27
     28  /**
     29   * @brief declares a new Signal.
     30   * @param SignalName the Name of the Signal.
     31   */
     32#define DeclareSignal0(SignalName) \
     33  DeclareSignalBegin(SignalName) \
     34   void  SignalName () { \
     35     for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \
     36       SignalName ## connected[i] (); \
    1837   }\
    19   private: \
    20    void  signal_ ## name params { \
    21      for (unsigned int i = 0; i < name ## connected . size(); i++) \
    22        name ## connected[i] ("TEST"); \
    23    }\
    24    std::vector<SignalConnector> name ## connected
     38     DeclareSignalEnd(SignalName)
    2539
    26   //! A class for Conncting Signals to Objects, inside of the GUI
     40
     41  /**
     42   * @brief declares a new Signal.
     43   * @param SignalName the Name of the Signal.
     44   * @param param0 the first Parameter the Function takes
     45   */
     46#define DeclareSignal1(SignalName, param0) \
     47  DeclareSignalBegin(SignalName) \
     48   void  SignalName (param0 val0) { \
     49     for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \
     50       SignalName ## connected[i] (val0); \
     51    }\
     52    DeclareSignalEnd(SignalName)
     53
     54  /**
     55   * @brief declares a new Signal.
     56   * @param SignalName the Name of the Signal.
     57   * @param param0 the first Parameter the Function takes
     58   * @param param1 the second Parameter the Function takes
     59   */
     60#define DeclareSignal2(SignalName, param0, param1) \
     61  DeclareSignalBegin(SignalName) \
     62   void  SignalName (param0 val0, param1 val1) { \
     63     for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \
     64       SignalName ## connected[i] (val0, val1); \
     65}\
     66    DeclareSignalEnd(SignalName)
     67
     68
     69
     70  /**
     71   * @brief declares a new Signal.
     72   * @param SignalName the Name of the Signal.
     73   * @param param0 the first Parameter the Function takes
     74   * @param param1 the second Parameter the Function takes
     75   * @param param2 the third Parameter the Function takes
     76   */
     77#define DeclareSignal3(SignalName, param0, param1, param2) \
     78  DeclareSignalBegin(SignalName) \
     79   void  SignalName (param0 val0, param1 val1, param2 val2) { \
     80     for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \
     81       SignalName ## connected[i] (val0, val1, val2); \
     82}\
     83    DeclareSignalEnd(SignalName)
     84
     85  /**
     86   * @brief declares a new Signal.
     87   * @param SignalName the Name of the Signal.
     88   * @param param0 the first Parameter the Function takes
     89   * @param param1 the second Parameter the Function takes
     90   * @param param2 the third Parameter the Function takes
     91   * @param param3 the fourth Parameter the Function takes
     92   */
     93#define DeclareSignal4(SignalName, param0, param1, param2, param3) \
     94  DeclareSignalBegin(SignalName) \
     95   void  SignalName (param0 val0, param1 val1, param2 val2, param3 val3) { \
     96     for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \
     97       SignalName ## connected[i] (val0, val1, val2, val3); \
     98}\
     99    DeclareSignalEnd(SignalName)
     100
     101
     102  /**
     103   * @brief declares a new Signal.
     104   * @param SignalName the Name of the Signal.
     105   * @param param0 the first Parameter the Function takes
     106   * @param param1 the second Parameter the Function takes
     107   * @param param2 the third Parameter the Function takes
     108   * @param param4 the fifth Parameter the Function takes
     109   */
     110#define DeclareSignal5(SignalName, param0, param1, param2, param3, param4) \
     111  DeclareSignalBegin(SignalName) \
     112   void  SignalName (param0 val0, param1 val1, param2 val2, param3 val3, param4 val4) { \
     113     for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \
     114       SignalName ## connected[i] (val0, val1, val2, val3, val4); \
     115}\
     116    DeclareSignalEnd(SignalName)
     117
     118
     119  /**
     120   * @brief selects a Signal.
     121   * @param SignalName the Signal to be retrieved.
     122   */
     123#define SIGNAL(Object, SignalName) \
     124    Object->getSignalVector_##SignalName()
     125
     126  /**
     127   * @brief defines a Slot, the sink of a Signal.
     128   * @param Class the Class the Slot belongs to.
     129   * @param function the Function to Connect to.
     130   */
     131#define SLOT(Class, function) \
     132    createExecutor<Class>(&Class::function)
     133
     134  /**
     135   * @brief emits function
     136   */
     137#define emit(function) function
     138
     139  //! A class for Conncting Signals to Objects, inside of the Graphical user interface.
     140  /**
     141   * The SignalConnector binds an Object to a Functional (Executor)
     142   * The Usage is quite easy in the Widget for this:
     143   *
     144   * int the header (Class Definition) you can add a definition of a Signal with:
     145   * @verbatim DeclareSignal3(my_signal, int, int, float)
     146   * and a Signal with the the Parameters int,int and float will be created.
     147   *
     148   * now you can use the connect function of GLWidget to connect this Signal to a Slot.
     149   * @see GLGuiWidget::connect
     150   */
    27151  class SignalConnector
    28152  {
     
    34158
    35159    SignalConnector& operator=(const SignalConnector& signalConnector);
     160    bool operator==(const SignalConnector& signalConnector) const;
    36161
    37     void operator()(const std::string& parameters) const;
    38     void execute(const std::string& parameters) const { (*this)(parameters); };
     162    void operator()() const;
     163    void operator()(const MultiType& value0) const;
     164    void operator()(const MultiType& value0, const MultiType& value1) const;
     165    void operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2) const;
     166    void operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3) const;
     167    void operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3, const MultiType& value4) const;
    39168
     169    /** checks wether the SignalConnector is valid @return true on valid. */
     170    bool isValid() const { return (this->object && this->exec); };
     171    /** @brief checks if the SignalConnector is clean, invalid @returns true if invalid */
    40172    bool isClean() const { return (this->object == NULL || this->exec == NULL); }
    41173
     
    45177    const Executor*      exec;           //!< The Executor, that will be called, on object.
    46178  };
     179
     180  //! TypeDefinition for SignalLists
     181  typedef std::vector<SignalConnector> Signal;
     182  //! TypeDefinition for a Slot.
     183  typedef Executor*                    Slot;
     184
    47185}
    48186#endif /* _SIGNAL_CONNECTOR_H */
  • trunk/src/lib/lang/base_object.h

    r7954 r8035  
    1212#include "class_id.h"
    1313#include "debug.h"
    14 #ifndef NULL
    15 #define NULL     0    //!< NULL
    16 #endif
     14#include <string>
    1715
    18 #include <string>
    1916#include "stdincl.h"
    2017
  • trunk/src/lib/math/rect2D.h

    r7919 r8035  
    8383  inline void setRight(float right) { _bottomRight.x = right; };
    8484  /** @param topLeft the top left corner of the Rectangle */
    85   void setTopLeft(const Vector2D& topLeft) { _topLeft = topLeft; };
     85  inline void setTopLeft(const Vector2D& topLeft) { _topLeft = topLeft; };
     86  /** @param x the left border of the Rectangle @param y the top border */
     87  inline void setTopLeft(float x, float y) { this->setTopLeft(Vector2D(x,y)); };
    8688  /** @param bottomRight the lower right corner of the Rectangle */
    87   void setBottomRight(const Vector2D& bottomRight) { _bottomRight = bottomRight; };
     89  inline void setBottomRight(const Vector2D& bottomRight) { _bottomRight = bottomRight; };
     90  /** @param x the right border of the Rectangle @param y the bottom border */
     91  inline void setBottomRight(float x, float y) { this->setBottomRight(Vector2D(x,y)); };
    8892
    8993  void setWidth(float width);
  • trunk/src/lib/math/vector.h

    r7711 r8035  
    3232//! this is a small and performant 3D vector
    3333typedef float sVec3D[3];
    34 
    35 
    36 //! small and performant 2D vector
    37 typedef float sVec2D[2];
    38 
    3934
    4035
     
    10196  inline void slerpTo(const Vector& toVec, float t) { *this + (toVec - *this) * t; };
    10297
     98  /** @returns a Null Vector */
     99  inline static const Vector& nullVector() { static Vector nullVector; return nullVector; }
    103100  void debug() const;
    104101
  • trunk/src/lib/math/vector2D.h

    r7919 r8035  
    9393  void slerp(const Vector2D& v, float val) { *this += (*this - v) * val; }
    9494
     95  /** @returns a Vector of (0,0) */
     96  static const Vector2D& nullVector() { static Vector2D nullVector; return nullVector; };
     97
    9598  void debug() const;
    9699
  • trunk/src/lib/util/executor/executor.h

    r7725 r8035  
    3838class Executor : public BaseObject
    3939{
    40 public:
    41   virtual ~Executor();
     40  public:
     41    virtual ~Executor();
    4242
    43   virtual Executor* clone () const = 0;
     43    virtual Executor* clone () const = 0;
     44//    virtual bool operator==(const Executor* executor) const = 0;
    4445
    45   // SETTING up the EXECUTOR
    46   Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
    47                           const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
    48                           const MultiType& value4 = MT_NULL);
    49   /** @param i the i'th defaultValue, @returns reference to the MultiType */
    50   inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; };
     46    // SETTING up the EXECUTOR
     47    Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
     48                            const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
     49                            const MultiType& value4 = MT_NULL);
     50    /** @param i the i'th defaultValue, @returns reference to the MultiType */
     51    inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; };
    5152
    52   // EXECUTE
    53   /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
    54   virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0;
    55   /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes @brief here for your convenience*/
    56   void execute (BaseObject* object, const std::string& parameters = "") const { (*this)(object, parameters); };
     53    // EXECUTE
     54    /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     55    virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const = 0;
     56    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
     57    virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0;
     58    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes @brief here for your convenience*/
     59    void execute (BaseObject* object, const std::string& parameters = "") const { (*this)(object, parameters); };
    5760
    58   // RETRIEVE INFORMATION
    59   /** @returns the Type of this Function (either static or objective) */
    60   inline long getType() const { return this->functorType; };
    61   /** @returns the Count of Parameters this Executor takes */
    62   inline unsigned int getParamCount() const { return this->paramCount; };
    6361
    64   static void debug();
     62    // RETRIEVE INFORMATION
     63    /** @returns the Type of this Function (either static or objective) */
     64    inline long getType() const { return this->functorType; };
     65    /** @returns the Count of Parameters this Executor takes */
     66    inline unsigned int getParamCount() const { return this->paramCount; };
    6567
    66 protected:
    67   Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
    68            const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
    69            const MultiType& param4 = MT_NULL);
     68    static void debug();
    7069
    71   void cloning(Executor* executor) const;
     70  protected:
     71    Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
     72             const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
     73             const MultiType& param4 = MT_NULL);
    7274
    73 protected:
    74   short                       functorType;      //!< The type of Function we've got (either static or objective).
    75   unsigned int                paramCount;       //!< the count of parameters.
    76   MultiType                   defaultValue[5];  //!< Default Values.
     75    void cloning(Executor* executor) const;
     76
     77  protected:
     78    short                       functorType;      //!< The type of Function we've got (either static or objective).
     79    unsigned int                paramCount;       //!< the count of parameters.
     80    MultiType                   defaultValue[5];  //!< Default Values.
    7781};
    7882
  • trunk/src/lib/util/executor/executor_functional.cc

    r7728 r8035  
    3434template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { return ExecutorFunctional_returningString_from = isString(input, defaultValue); };
    3535
     36
     37template<> bool fromMulti<bool>(const MultiType& multi) { return multi.getBool(); };
     38template<> int fromMulti<int>(const MultiType& multi) { return multi.getInt(); }
     39template<> unsigned int fromMulti<unsigned int>(const MultiType& multi) { return multi.getInt(); };
     40template<> float fromMulti<float>(const MultiType& multi) { return multi.getFloat(); };
     41template<> char fromMulti<char>(const MultiType& multi) { return multi.getChar(); };
     42template<> const std::string& fromMulti<const std::string&>(const MultiType& multi) { return multi.getConstString(); };
     43
     44
    3645template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getBool(); };
    3746template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); };
     
    4049template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); };
    4150template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { return ExecutorFunctional_returningString_default = defaultValues[i].getString(); };
     51
     52
    4253
    4354
  • trunk/src/lib/util/executor/executor_functional.h

    r7725 r8035  
    3333template<> MT_Type ExecutorParamType<const std::string&>();
    3434
    35 template<typename type> type fromString(const std::string& input, type defaultValue) {return defaultValue; };
     35template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; };
    3636template<> bool fromString<bool>(const std::string& input, bool defaultValue);
    3737template<> int fromString<int>(const std::string& input, int defaultValue);
     
    4040template<> char fromString<char>(const std::string& input, char defaultValue);
    4141template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue);
     42
     43template<typename type> type fromMulti(const MultiType& multi) { /* return defaultValue; */ };
     44template<> bool fromMulti<bool>(const MultiType& multi);
     45template<> int fromMulti<int>(const MultiType& multi);
     46template<> unsigned int fromMulti<unsigned int>(const MultiType& multi);
     47template<> float fromMulti<float>(const MultiType& multi);
     48template<> char fromMulti<char>(const MultiType& multi);
     49template<> const std::string& fromMulti<const std::string&>(const MultiType& multi);
     50
    4251
    4352template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; };
     
    8190#endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */
    8291
     92///////////
     93//// 0 ////
     94///////////
    8395//! @brief ExecutorClass, that can execute Functions without any parameters.
    8496template<class T> class __EXECUTOR_FUNCTIONAL_NAME(0) : public Executor
     
    110122  };
    111123
     124  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     125  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     126  {
     127    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)();
     128  }
     129
    112130  /**
    113131   * @brief copies the Executor
     
    120138};
    121139
     140
     141
     142///////////
     143//// 1 ////
     144///////////
    122145//! @brief ExecutorClass, that can execute Functions with one parameter.
    123146template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor
     
    139162  };
    140163
     164  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     165  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     166  {
     167    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     168             fromMulti<type0>((count > 0)? values[0] : this->defaultValue[0]) );
     169  }
     170
     171
    141172  /**
    142173   * @brief executes the Functional
     
    146177  virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const
    147178  {
    148 
    149     /* // THE VERY COOL DEBUG
    150       printf("SUB[0] : %s\n", sub[0].c_str());
    151       printf("getDefault<type0>(this->defaultValue, 0):::: %d\n", getDefault<type0>(this->defaultValue, 0));
    152       printf("VALUE: %d\n", fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)));
    153     */
    154179    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    155180      fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) );
     
    166191};
    167192
     193///////////
     194//// 2 ////
     195///////////
    168196//! @brief ExecutorClass, that can execute Functions with two parameters.
    169197template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor
     
    197225  };
    198226
     227  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     228  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     229  {
     230    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     231             fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]),
     232             fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]) );
     233  }
     234
    199235  /**
    200236   * @brief copies the Executor
     
    208244
    209245
     246///////////
     247//// 3 ////
     248///////////
    210249//! @brief ExecutorClass, that can execute Functions with three parameters.
    211250template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor
     
    240279  };
    241280
     281  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     282  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     283  {
     284    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     285             fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]),
     286             fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]),
     287             fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]) );
     288  }
     289
    242290  /**
    243291   * @brief copies the Executor
     
    252300
    253301
     302///////////
     303//// 4 ////
     304///////////
    254305//! @brief ExecutorClass, that can execute Functions with four parameters.
    255306template<class T, typename type0, typename type1, typename type2, typename type3> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor
     
    285336  };
    286337
     338  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     339  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     340  {
     341    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     342             fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]),
     343             fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]),
     344             fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]),
     345             fromMulti<type3>((count > 3) ? values[3] : this->defaultValue[3]) );
     346  }
     347
    287348  /**
    288349   * @brief copies the Executor
     
    295356};
    296357
     358
     359
     360///////////
     361//// 5 ////
     362///////////
    297363//! @brief ExecutorClass, that can execute Functions with five parameters.
    298364template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor
     
    329395  };
    330396
     397  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     398  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     399  {
     400    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     401             fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]),
     402             fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]),
     403             fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]),
     404             fromMulti<type3>((count > 3) ? values[3] : this->defaultValue[3]),
     405             fromMulti<type4>((count > 4) ? values[4] : this->defaultValue[4]) );
     406  }
     407
    331408  /**
    332409   * @brief copies the Executor
     
    344421 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    345422 */
    346 #define EXECUTOR_FUNCTIONAL_CREATOR0() \
    347 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \
     423#define EXECUTOR_FUNCTIONAL_CREATOR0(ret) \
     424template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \
    348425{ \
    349426  return new __EXECUTOR_FUNCTIONAL_NAME(0)<T>(functionPointer); \
     
    354431 * @param type0 for internal usage: the first Argument
    355432 */
    356 #define EXECUTOR_FUNCTIONAL_CREATOR1(type0) \
    357 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     433#define EXECUTOR_FUNCTIONAL_CREATOR1(ret, type0) \
     434template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    358435{ \
    359436  return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, type0##_TYPE>(functionPointer); \
     
    365442 * @param type1 for internal usage: the second Argument
    366443 */
    367 #define EXECUTOR_FUNCTIONAL_CREATOR2(type0, type1) \
    368 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     444#define EXECUTOR_FUNCTIONAL_CREATOR2(ret, type0, type1) \
     445template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    369446{ \
    370447  return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, type0##_TYPE, type1##_TYPE>(functionPointer); \
     
    377454 * @param type2 for internal usage: the third Argument
    378455 */
    379 #define EXECUTOR_FUNCTIONAL_CREATOR3(type0, type1, type2) \
    380 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     456#define EXECUTOR_FUNCTIONAL_CREATOR3(ret, type0, type1, type2) \
     457template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    381458{ \
    382459  return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE>(functionPointer); \
     
    390467 * @param type3 for internal usage: the fourth Argument
    391468 */
    392 #define EXECUTOR_FUNCTIONAL_CREATOR4(type0, type1, type2, type3) \
    393 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     469#define EXECUTOR_FUNCTIONAL_CREATOR4(ret, type0, type1, type2, type3) \
     470template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    394471{ \
    395472  return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE>(functionPointer); \
     
    404481 * @param type4 for internal usage: the fifth Argument
    405482 */
    406 #define EXECUTOR_FUNCTIONAL_CREATOR5(type0, type1, type2, type3, type4) \
    407 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     483#define EXECUTOR_FUNCTIONAL_CREATOR5(ret, type0, type1, type2, type3, type4) \
     484template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    408485{ \
    409486    return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE>(functionPointer); \
  • trunk/src/lib/util/executor/executor_specials.h

    r7711 r8035  
    6767    }
    6868
     69    virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     70    {
     71
     72    }
     73
    6974  private:
    7075    /**
  • trunk/src/lib/util/executor/functor_list.h

    r7785 r8035  
    9090#ifdef FUNCTOR_LIST
    9191
    92   FUNCTOR_LIST(0)();
     92  FUNCTOR_LIST(0)(void);
    9393  //! makes functions with one string
    94   FUNCTOR_LIST(1)(l_STRING);
     94  FUNCTOR_LIST(1)(void, l_STRING);
    9595  //! makes functions with two strings
    96   FUNCTOR_LIST(2)(l_STRING, l_STRING);
     96  FUNCTOR_LIST(2)(void, l_STRING, l_STRING);
    9797  //! makes functions with three strings
    98   FUNCTOR_LIST(3)(l_STRING, l_STRING, l_STRING);
     98  FUNCTOR_LIST(3)(void, l_STRING, l_STRING, l_STRING);
    9999  //! makes functions with four strings
    100   FUNCTOR_LIST(4)(l_STRING, l_STRING, l_STRING, l_STRING);
     100  FUNCTOR_LIST(4)(void, l_STRING, l_STRING, l_STRING, l_STRING);
    101101
    102102
    103103  //! makes functions with one bool
    104   FUNCTOR_LIST(1)(l_BOOL);
     104  FUNCTOR_LIST(1)(void, l_BOOL);
    105105
    106106  //! makes functions with one int
    107   FUNCTOR_LIST(1)(l_INT);
     107  FUNCTOR_LIST(1)(void, l_INT);
    108108  //! makes functions with two ints
    109   FUNCTOR_LIST(2)(l_INT, l_INT);
     109  FUNCTOR_LIST(2)(void, l_INT, l_INT);
    110110  //! makes functions with three ints
    111   FUNCTOR_LIST(3)(l_INT, l_INT, l_INT);
     111  FUNCTOR_LIST(3)(void, l_INT, l_INT, l_INT);
    112112  //! makes functions with four ints
    113   FUNCTOR_LIST(4)(l_INT, l_INT, l_INT, l_INT);
     113  FUNCTOR_LIST(4)(void, l_INT, l_INT, l_INT, l_INT);
    114114
    115115
    116116  //! makes functions with one unsigned int
    117   FUNCTOR_LIST(1)(l_UINT);
     117  FUNCTOR_LIST(1)(void, l_UINT);
    118118  //! makes functions with two unsigned ints
    119   FUNCTOR_LIST(2)(l_UINT, l_UINT);
     119  FUNCTOR_LIST(2)(void, l_UINT, l_UINT);
    120120  //! makes functions with three unsigned ints
    121   FUNCTOR_LIST(3)(l_UINT, l_UINT, l_UINT);
     121  FUNCTOR_LIST(3)(void, l_UINT, l_UINT, l_UINT);
    122122  //! makes functions with four unsigned ints
    123   FUNCTOR_LIST(4)(l_UINT, l_UINT, l_UINT, l_UINT);
     123  FUNCTOR_LIST(4)(void, l_UINT, l_UINT, l_UINT, l_UINT);
    124124
    125125  //! makes functions with one float
    126   FUNCTOR_LIST(1)(l_FLOAT);
     126  FUNCTOR_LIST(1)(void, l_FLOAT);
    127127  //! makes functions with two floats
    128   FUNCTOR_LIST(2)(l_FLOAT, l_FLOAT);
     128  FUNCTOR_LIST(2)(void, l_FLOAT, l_FLOAT);
    129129  //! makes functions with three floats
    130   FUNCTOR_LIST(3)(l_FLOAT, l_FLOAT, l_FLOAT);
     130  FUNCTOR_LIST(3)(void, l_FLOAT, l_FLOAT, l_FLOAT);
    131131  //! makes functions with four floats
    132   FUNCTOR_LIST(4)(l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);
     132  FUNCTOR_LIST(4)(void, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);
    133133  //! makes functions with four floats
    134   FUNCTOR_LIST(5)(l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);
     134  FUNCTOR_LIST(5)(void, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);
    135135
    136136  //! mixed values:
    137   FUNCTOR_LIST(2)(l_STRING, l_FLOAT);
    138   FUNCTOR_LIST(2)(l_UINT, l_LONG);
    139   FUNCTOR_LIST(2)(l_STRING, l_UINT);
     137  FUNCTOR_LIST(2)(void, l_STRING, l_FLOAT);
     138  FUNCTOR_LIST(2)(void, l_UINT, l_LONG);
     139  FUNCTOR_LIST(2)(void, l_STRING, l_UINT);
    140140
    141   FUNCTOR_LIST(3)(l_STRING, l_FLOAT, l_UINT);
    142   FUNCTOR_LIST(4)(l_STRING, l_FLOAT, l_UINT, l_UINT);
    143   FUNCTOR_LIST(3)(l_STRING, l_INT, l_UINT);
    144   FUNCTOR_LIST(3)(l_STRING, l_UINT, l_UINT);
     141  FUNCTOR_LIST(3)(void, l_STRING, l_FLOAT, l_UINT);
     142  FUNCTOR_LIST(4)(void, l_STRING, l_FLOAT, l_UINT, l_UINT);
     143  FUNCTOR_LIST(3)(void, l_STRING, l_INT, l_UINT);
     144  FUNCTOR_LIST(3)(void, l_STRING, l_UINT, l_UINT);
    145145
    146146#endif /* FUNCTOR_LIST */
  • trunk/src/lib/util/multi_type.cc

    r7401 r8035  
    3939  switch (this->type)
    4040  {
    41       default:
     41    default:
    4242      this->value.Float = 0.0f;
    4343      break;
    44       case MT_BOOL:
     44    case MT_BOOL:
    4545      this->value.Bool = false;
    4646      break;
    47       case MT_INT:
     47    case MT_INT:
    4848      this->value.Int = 0;
    4949      break;
    50       case MT_FLOAT:
     50    case MT_FLOAT:
    5151      this->value.Float = 0.0f;
    5252      break;
    53       case MT_CHAR:
     53    case MT_CHAR:
    5454      this->value.Char = '\0';
    5555      break;
    56       case MT_STRING:
     56    case MT_STRING:
    5757      this->storedString = "";
    5858      break;
     
    148148  switch (this->type)
    149149  {
    150       case MT_NULL:
     150    case MT_NULL:
    151151      return true;
    152       case MT_BOOL:
     152    case MT_BOOL:
    153153      return (this->value.Bool == mt.value.Bool);
    154       case MT_INT:
     154    case MT_INT:
    155155      return (this->value.Int == mt.value.Int);
    156       case MT_CHAR:
     156    case MT_CHAR:
    157157      return (this->value.Char == mt.value.Char);
    158       case MT_FLOAT:
     158    case MT_FLOAT:
    159159      return (this->value.Float == mt.value.Float);
    160       case MT_STRING:
     160    case MT_STRING:
    161161      return (this->storedString == mt.storedString);
    162162  }
     
    175175  switch (type)
    176176  {
    177       case MT_BOOL:
     177    case MT_BOOL:
    178178      this->setBool(this->getBool());
    179179      break;
    180       case MT_INT:
     180    case MT_INT:
    181181      this->setInt(this->getInt());
    182182      break;
    183       case MT_FLOAT:
     183    case MT_FLOAT:
    184184      this->setFloat(this->getFloat());
    185185      break;
    186       case MT_CHAR:
     186    case MT_CHAR:
    187187      this->setChar(this->getChar());
    188188      break;
    189       case MT_STRING:
     189    case MT_STRING:
    190190      this->setString(this->getString());
    191191      break;
     
    382382
    383383/**
     384 * @brief returns a Constant string (actually this is slower than getString()
     385 * @returns a constant string of the stored version's one.
     386 * @note this  could lead to a inconsistency of data
     387 */
     388const std::string& MultiType::getConstString() const
     389{
     390
     391  MultiType::constString = this->getString();
     392  return MultiType::constString;
     393}
     394
     395
     396/**
    384397 * @returns a formated c-string of the held value
    385398 */
     
    422435  switch ( this->type )
    423436  {
    424       case MT_BOOL:
     437    case MT_BOOL:
    425438      this->setBool(false);
    426439      break;
    427       case MT_INT:
     440    case MT_INT:
    428441      this->setInt(0);
    429442      break;
    430       case MT_FLOAT:
     443    case MT_FLOAT:
    431444      this->setFloat(0.0f);
    432445      break;
    433       case MT_CHAR:
     446    case MT_CHAR:
    434447      this->setChar('\0');
    435448      break;
    436       case MT_STRING:
     449    case MT_STRING:
    437450      this->setString("");
    438451      break;
    439       default:
     452    default:
    440453#ifdef DEBUG
    441454      PRINTF(2)("Unknown Type not reseting\n");
     
    454467  switch ( type )
    455468  {
    456       case MT_BOOL:
     469    case MT_BOOL:
    457470      return MultiType::typeNames[1];
    458       case MT_INT:
     471    case MT_INT:
    459472      return MultiType::typeNames[2];
    460       case MT_FLOAT:
     473    case MT_FLOAT:
    461474      return MultiType::typeNames[3];
    462       case MT_CHAR:
     475    case MT_CHAR:
    463476      return MultiType::typeNames[4];
    464       case MT_STRING:
     477    case MT_STRING:
    465478      return MultiType::typeNames[5];
    466479  }
     
    490503
    491504
     505std::string MultiType::constString = "";
    492506const std::string MultiType::typeNames[] =
    493507  {
  • trunk/src/lib/util/multi_type.h

    r7401 r8035  
    8787    const char* getCString();
    8888    std::string getString() const;
     89    const std::string& getConstString() const;
    8990
    9091    void reset();
     
    107108    MT_Type                      type;              //!< The Type stored in this MultiType
    108109
     110
     111    static std::string           constString;       //!< A String for returning Constant strings.
     112
    109113    static const std::string     typeNames[];       //!< List of TypeNames for conversion.
    110114};
  • trunk/src/story_entities/simple_game_menu.cc

    r7919 r8035  
    6767  ///(this is as modular as it is possible).
    6868  OrxGui::GLGuiPushButton* pb = new OrxGui::GLGuiPushButton("PUSH ME");
    69   pb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::enterGui));
     69  //pb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::enterGui));
     70  pb->connect(SIGNAL(pb, released), this, SLOT(SimpleGameMenu, enterGui));
    7071  pb->show();
    7172  pb->setAbsCoor2D(50, 50);
     
    8485void SimpleGameMenu::enterGui()
    8586{
    86   ///
    87   OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("Push the button");
    88   dnpb->show();
    89   dnpb->setAbsCoor2D(350, 50);
    90   dnpb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::execURL));
    91 
    92   OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("Quit ORXONOX!!");
    93   rdnpb->show();
    94   rdnpb->setAbsCoor2D(200, 180);
    95   rdnpb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::quitMenu));
    96 
    97   OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine();
    98   input->setText("input some text here");
    99   input->show();
    100   input->setAbsCoor2D(200, 230);
     87
     88  OrxGui::GLGuiBox* box = new OrxGui::GLGuiBox();
     89  {
     90    ///
     91    OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("Push the button");
     92
     93    box->pack(dnpb);
     94
     95    OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("Quit ORXONOX!!");
     96    rdnpb->connect(SIGNAL(rdnpb, released), this, SLOT(SimpleGameMenu, quitMenu));
     97
     98    box->pack(rdnpb);
     99
     100    OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine();
     101    input->setText("input some text here");
     102    input->connect(SIGNAL(input, textChanged), this, SLOT(SimpleGameMenu, TEST));
     103    box->pack(input);
     104
     105    OrxGui::GLGuiSlider* slider = new OrxGui::GLGuiSlider();
     106    slider->connect(SIGNAL(slider, valueChanged), this, SLOT(SimpleGameMenu, TEST));
     107    slider->connect(SIGNAL(slider, valueChanged), box, SLOT(OrxGui::GLGuiWidget, setBackgroundColor));
     108    slider->setRange(0, 1);
     109    slider->setValue(slider->min());
     110    box->pack(slider);
     111  }
     112  box->setAbsCoor2D(50, 200);
     113
     114  box->showAll();
     115
     116
     117  OrxGui::GLGuiBox* imageSelector = new OrxGui::GLGuiBox();
     118  {
     119    image = new OrxGui::GLGuiImage();
     120    image->setWidgetSize(300, 300);
     121    image->setAbsCoor2D(300, 300);
     122    imageSelector->pack(image);
     123
     124    imageName = new OrxGui::GLGuiInputLine();
     125    imageSelector->pack(imageName);
     126
     127    OrxGui::GLGuiSlider* slider = new OrxGui::GLGuiSlider();
     128    slider->setWidgetSize(200, 30);
     129    slider->setRange(0, 100);
     130    slider->setStep(1);
     131    slider->setValue(slider->min());
     132    slider->connect(SIGNAL(slider, valueChanged), this, SLOT(SimpleGameMenu, setImage));
     133
     134    imageSelector->pack(slider);
     135    slider->setValue(0);
     136  }
     137  imageSelector->showAll();
     138  imageSelector->setAbsCoor2D(400, 30);
    101139
    102140
    103141  /////
     142}
     143
     144
     145#include "class_list.h"
     146void SimpleGameMenu::setImage(int i)
     147{
     148  const std::list<BaseObject*>* textures = ClassList::getList(CL_TEXTURE);
     149
     150  if(textures)
     151  {
     152    std::list<BaseObject*>::const_iterator test = textures->begin();
     153    std::list<BaseObject*>::const_iterator lastOK = textures->begin();
     154    while (true)
     155    {
     156      if (--i == 0 || test == textures->end())
     157        break;
     158      if (dynamic_cast<Texture*>(*test)->getTexture() != 0)
     159        lastOK = test;
     160      test++;
     161    }
     162    this->image->loadImageFromTexture(*dynamic_cast<Texture*>(*lastOK));
     163    this->imageName->setText((*lastOK)->getName());
     164  }
    104165}
    105166
     
    124185  system ((std::string("firefox ") + URL).c_str());
    125186#elif defined __OSX__
    126     CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(),
    127                                          kCFStringEncodingASCII, NULL);
    128     LSOpenCFURLRef (url_handle, NULL);
    129     CFRelease (url_handle);
     187  CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(),
     188                        kCFStringEncodingASCII, NULL);
     189  LSOpenCFURLRef (url_handle, NULL);
     190  CFRelease (url_handle);
    130191#elif defined __WIN32__
    131     ShellExecute(GetActiveWindow(),
    132                  "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL);
    133   }
     192  ShellExecute(GetActiveWindow(),
     193               "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL);
     194}
    134195#endif
    135196  PRINTF(3)("loaded external webpage %s\n", URL.c_str());
  • trunk/src/story_entities/simple_game_menu.h

    r7919 r8035  
    1717#include "elements/text_element.h"
    1818
     19#include "glgui.h"
     20
    1921class SimpleGameMenuData;
    2022class TiXmlElement;
     
    3133
    3234  public:
    33     std::vector<TextElement*>          menuList;                        //!< the list of the menu items
     35    std::vector<TextElement*>         menuList;                        //!< the list of the menu items
    3436    std::vector<StoryEntity*>         storyList;                       //!< the list of the StoryEntities for the menu
    3537    std::vector<ImageEntity*>         screenshootList;                 //!< list of the screen shoots FIXME: make a better structure for this stuff
     
    5355    void execURL() const;
    5456    static int startURL(void* data);
     57
     58    void setImage(int i);
     59    OrxGui::GLGuiImage* image;
     60    OrxGui::GLGuiInputLine* imageName;
    5561    ///
    5662    virtual void loadParams(const TiXmlElement* root);
     
    6975    void quitMenu();
    7076
    71     void TEST() { printf("TEST\n"); }
     77    void TEST(int val) { printf("TEST %d\n", val); }
    7278
    7379  protected:
Note: See TracChangeset for help on using the changeset viewer.