Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7985 in orxonox.OLD for branches


Ignore:
Timestamp:
May 30, 2006, 6:25:19 PM (18 years ago)
Author:
bensch
Message:

EVENTS WORK :)

Location:
branches/gui/src
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/gui/gl_gui/glgui_button.cc

    r7919 r7985  
    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
  • branches/gui/src/lib/gui/gl_gui/glgui_button.h

    r7925 r7985  
    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 draw() const;
     41      virtual void draw() const;
     42
     43      DeclareSignal0(released);
     44      DeclareSignal0(clicked);
     45
     46    protected:
     47      virtual void clicking(const Vector2D& pos);
     48      virtual void releasing(const Vector2D& pos);
    4249
    4350    private:
     
    4653
    4754
    48   protected:
     55    protected:
    4956
    50     Text                 label;
     57      Text                 label;
    5158
    52   private:
    53     ButtonState          state;
     59    private:
     60      ButtonState          state;
    5461  };
    5562}
  • branches/gui/src/lib/gui/gl_gui/glgui_checkbutton.cc

    r7936 r7985  
    6868
    6969
    70   void GLGuiCheckButton::released(const Vector2D& pos)
     70  void GLGuiCheckButton::releasing(const Vector2D& pos)
    7171  {
    7272    printf("%s released\n", this->getLabel().c_str());
    73     GLGuiWidget::released(pos);
     73    GLGuiButton::releasing(pos);
    7474    this->toggleActiveState();
    7575  }
  • branches/gui/src/lib/gui/gl_gui/glgui_checkbutton.h

    r7929 r7985  
    2626    virtual ~GLGuiCheckButton();
    2727
    28     virtual void released(const Vector2D& pos);
    2928
    3029    bool    isActive() { return this->bActive; };
     
    3736  protected:
    3837    virtual void resize();
     38    virtual void releasing(const Vector2D& pos);
    3939
    4040  private:
  • branches/gui/src/lib/gui/gl_gui/glgui_cursor.cc

    r7980 r7985  
    9191      movement = Vector2D();
    9292    }
    93     this->setAbsCoor2D(newPos);
     93    this->setAbsCoorSoft2D(newPos, 10);
    9494  }
    9595
  • branches/gui/src/lib/gui/gl_gui/glgui_pushbutton.cc

    r7929 r7985  
    7474  }
    7575
    76   void GLGuiPushButton::clicked(const Vector2D& pos)
     76  void GLGuiPushButton::clicking(const Vector2D& pos)
    7777  {
    7878    printf("%s clicked\n", this->getLabel().c_str());
    79     GLGuiWidget::clicked(pos);
     79    GLGuiButton::clicking(pos);
    8080  }
    8181
    8282
    83   void GLGuiPushButton::released(const Vector2D& pos)
     83  void GLGuiPushButton::releasing(const Vector2D& pos)
    8484  {
    8585    printf("%s released\n", this->getLabel().c_str());
    86     GLGuiWidget::released(pos);
     86    GLGuiButton::releasing(pos);
    8787  }
    8888
  • branches/gui/src/lib/gui/gl_gui/glgui_pushbutton.h

    r7929 r7985  
    2727
    2828
    29     virtual void receivedFocus();
    30     virtual void removedFocus();
    31     virtual void clicked(const Vector2D& pos);
    32     virtual void released(const Vector2D& pos);
    3329
    3430
     
    3733  protected:
    3834    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
    3940
    4041
  • branches/gui/src/lib/gui/gl_gui/glgui_slider.cc

    r7972 r7985  
    164164   * @param pos the position the Click occured (from the topleft corner out)
    165165   */
    166   void GLGuiSlider::clicked(const Vector2D& pos)
    167   {
    168     GLGuiWidget::clicked(pos);
     166  void GLGuiSlider::clicking(const Vector2D& pos)
     167  {
     168    GLGuiWidget::clicking(pos);
    169169
    170170    float sliderPosition = this->sliderPosition();
     
    178178  }
    179179
    180   void GLGuiSlider::released(const Vector2D& pos)
    181   {
    182     GLGuiWidget::released(pos);
     180  void GLGuiSlider::releasing(const Vector2D& pos)
     181  {
     182    GLGuiWidget::releasing(pos);
    183183    this->grabbed = false;
    184184  }
  • branches/gui/src/lib/gui/gl_gui/glgui_slider.h

    r7972 r7985  
    5151    virtual void draw() const;
    5252
    53     DeclareSignal(valueChanged, (float));
     53    DeclareSignal1(valueChanged, float);
    5454
    5555  protected:
    5656    virtual void resize();
    5757
    58     virtual void clicked(const Vector2D& pos);
    59     virtual void released(const Vector2D& pos);
     58    virtual void clicking(const Vector2D& pos);
     59    virtual void releasing(const Vector2D& pos);
    6060    virtual void removedFocus();
    6161
  • branches/gui/src/lib/gui/gl_gui/glgui_widget.cc

    r7972 r7985  
    126126    this->_pushed = true;
    127127
    128     this->clicked(pos);
     128    this->clicking(pos);
    129129  }
    130130
     
    135135      this->widgetSignals[Signal_release]("none");
    136136
    137       this->released(pos);
     137      this->releasing(pos);
    138138      this->_pushed = false;
    139139    }
     
    141141
    142142
    143   void GLGuiWidget::clicked(const Vector2D& pos)
     143  void GLGuiWidget::clicking(const Vector2D& pos)
    144144  {
    145145    this->frontMaterial().setDiffuse(0, 0, 1);
     
    147147  }
    148148
    149   void GLGuiWidget::released(const Vector2D& pos)
     149  void GLGuiWidget::releasing(const Vector2D& pos)
    150150  {
    151151    this->frontMaterial().setDiffuse(0,1,0);
  • branches/gui/src/lib/gui/gl_gui/glgui_widget.h

    r7972 r7985  
    127127
    128128    // if something was clickt on the GUI-widget.
    129     virtual void clicked(const Vector2D& pos);
    130     virtual void released(const Vector2D& pos);
     129    virtual void clicking(const Vector2D& pos);
     130    virtual void releasing(const Vector2D& pos);
    131131    virtual void receivedFocus();
    132132    virtual void removedFocus();
  • branches/gui/src/lib/gui/gl_gui/signal_connector.cc

    r7855 r7985  
    5151  }
    5252
    53   void SignalConnector::operator()(const std::string& parameters) const
     53
     54  void SignalConnector::operator()() const
     55  {
     56    if (this->isValid())
     57      (*this->exec)(this->object, 0, NULL);
     58  }
     59
     60  void SignalConnector::operator()(const MultiType& value0) const
    5461  {
    5562    if (exec != NULL && object != NULL)
    56       (*this->exec)(this->object, parameters);
     63      (*this->exec)(this->object, 1, &value0);
    5764  }
    5865
  • branches/gui/src/lib/gui/gl_gui/signal_connector.h

    r7980 r7985  
    1111namespace OrxGui
    1212{
     13
     14  //////////////// TO BE IGNORED BY YOU /////
     15#define DeclareSignalBegin(SignalName) \
     16  public: \
     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
    1328  /**
    1429   * @brief declares a new Signal.
    1530   * @param SignalName the Name of the Signal.
    16    * @param params the Parameters to be taken
    1731   */
    18 #define DeclareSignal(SignalName, params) \
    19   public: \
    20    void signal_ ## connect ## SignalName(const SignalConnector& connector) { \
    21      SignalName ## connected.push_back(connector); \
     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] (); \
    2237   }\
    23    Signal& getSignalVector_##SignalName () { return this->SignalName ## connected; }; \
    24   private: \
    25    void  SignalName params { \
     38     DeclareSignalEnd(SignalName)
     39
     40
     41  /**
     42 * @brief declares a new Signal.
     43 * @param SignalName the Name of the Signal.
     44   */
     45#define DeclareSignal1(SignalName, param0) \
     46  DeclareSignalBegin(SignalName) \
     47   void  SignalName (param0 val0) { \
    2648     for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \
    27        SignalName ## connected[i] ("TEST"); \
    28    }\
    29    Signal SignalName ## connected
     49       SignalName ## connected[i] (val0); \
     50    }\
     51    DeclareSignalEnd(SignalName)
     52
    3053
    3154   /**
     
    6083    SignalConnector& operator=(const SignalConnector& signalConnector);
    6184
    62     void operator()(const std::string& parameters) const;
    63     void execute(const std::string& parameters) const { (*this)(parameters); };
     85    void operator()() const;
     86    void operator()(const MultiType& value0) const;
    6487
     88    bool isValid() const { return (this->object && this->exec); };
    6589    bool isClean() const { return (this->object == NULL || this->exec == NULL); }
    6690
  • branches/gui/src/lib/util/executor/executor.h

    r7725 r7985  
    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;
    4444
    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]; };
     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]; };
    5151
    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); };
     52    // EXECUTE
     53    virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const = 0;
    5754
    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; };
     55    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
     56    virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0;
     57    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes @brief here for your convenience*/
     58    void execute (BaseObject* object, const std::string& parameters = "") const { (*this)(object, parameters); };
    6359
    64   static void debug();
    6560
    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);
     61    // RETRIEVE INFORMATION
     62    /** @returns the Type of this Function (either static or objective) */
     63    inline long getType() const { return this->functorType; };
     64    /** @returns the Count of Parameters this Executor takes */
     65    inline unsigned int getParamCount() const { return this->paramCount; };
    7066
    71   void cloning(Executor* executor) const;
     67    static void debug();
    7268
    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.
     69  protected:
     70    Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
     71             const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
     72             const MultiType& param4 = MT_NULL);
     73
     74    void cloning(Executor* executor) const;
     75
     76  protected:
     77    short                       functorType;      //!< The type of Function we've got (either static or objective).
     78    unsigned int                paramCount;       //!< the count of parameters.
     79    MultiType                   defaultValue[5];  //!< Default Values.
    7780};
    7881
  • branches/gui/src/lib/util/executor/executor_functional.cc

    r7728 r7985  
    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.getString(); };
     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
  • branches/gui/src/lib/util/executor/executor_functional.h

    r7725 r7985  
    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  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     125  {
     126    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)();
     127  }
     128
    112129  /**
    113130   * @brief copies the Executor
     
    120137};
    121138
     139
     140
     141///////////
     142//// 1 ////
     143///////////
    122144//! @brief ExecutorClass, that can execute Functions with one parameter.
    123145template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor
     
    138160    this->functionPointer = functionPointer;
    139161  };
     162
     163  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     164  {
     165    switch(count)
     166    {
     167      case 0:
     168        return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(fromMulti<type0>(this->defaultValue[0]));
     169      default:
     170       return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(fromMulti<type0>(values[0]));
     171    }
     172  }
     173
    140174
    141175  /**
     
    166200};
    167201
     202///////////
     203//// 2 ////
     204///////////
    168205//! @brief ExecutorClass, that can execute Functions with two parameters.
    169206template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor
     
    197234  };
    198235
     236  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     237  {
     238  }
     239
    199240  /**
    200241   * @brief copies the Executor
     
    208249
    209250
     251///////////
     252//// 3 ////
     253///////////
    210254//! @brief ExecutorClass, that can execute Functions with three parameters.
    211255template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor
     
    240284  };
    241285
     286  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     287  {
     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  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     339  {
     340  }
     341
    287342  /**
    288343   * @brief copies the Executor
     
    295350};
    296351
     352
     353
     354///////////
     355//// 5 ////
     356///////////
    297357//! @brief ExecutorClass, that can execute Functions with five parameters.
    298358template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor
     
    329389  };
    330390
     391  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     392  {
     393  }
     394
    331395  /**
    332396   * @brief copies the Executor
  • branches/gui/src/lib/util/executor/executor_specials.h

    r7711 r7985  
    6767    }
    6868
     69    virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     70    {
     71
     72    }
     73
    6974  private:
    7075    /**
  • branches/gui/src/story_entities/simple_game_menu.cc

    r7980 r7985  
    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);
  • branches/gui/src/story_entities/simple_game_menu.h

    r7972 r7985  
    6969    void quitMenu();
    7070
    71     void TEST(float val) { printf("TEST %f\n", val); }
     71    void TEST(int val) { printf("TEST %d\n", val); }
    7272
    7373  protected:
Note: See TracChangeset for help on using the changeset viewer.