Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7855 in orxonox.OLD for trunk/src/lib/gui/gl_gui


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

qtgui: cleanup as patrick sugested

Location:
trunk/src/lib/gui/gl_gui
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/gui/gl_gui/Makefile.am

    r6287 r7855  
    1111libORXglgui_a_SOURCES = glmenu/glmenu_imagescreen.cc \
    1212                        glgui_handler.cc \
     13                        signal_connector.cc \
    1314                        glgui_mainwidget.cc \
    1415                        glgui_widget.cc \
     
    2324
    2425noinst_HEADERS= glmenu/glmenu_imagescreen.h \
     26                signal_connector.h \
    2527                glgui.h \
    2628                glgui_handler.h \
  • trunk/src/lib/gui/gl_gui/glgui.h

    r7779 r7855  
    88#include "glgui_widget.h"
    99
     10#include "glgui_bar.h"
     11#include "glgui_box.h"
     12#include "glgui_button.h"
     13#include "glgui_checkbutton.h"
     14#include "glgui_colorselector.h"
     15
    1016namespace OrxGui
    1117{
     18
    1219
    1320};
  • trunk/src/lib/gui/gl_gui/glgui_widget.cc

    r7779 r7855  
    5858    this->frontModel = 0;
    5959
    60     this->widgetSignals.resize(GLGuiSignalCount, NULL);
     60    this->widgetSignals.resize(SignalCount, SignalConnector());
    6161  }
    6262
     
    6464  bool GLGuiWidget::focusOverWidget(float x, float y)
    6565  {
    66     if (this->getAbsCoor2D().x < x && this->getAbsCoor2D().x+ this->getSizeX2D() > x &&
    67         this->getAbsCoor2D().y < y && this->getAbsCoor2D().y+ this->getSizeX2D() > y)
     66    if (this->getAbsCoor2D().x < x && this->getAbsCoor2D().x + this->getSizeX2D() > x &&
     67        this->getAbsCoor2D().y < y && this->getAbsCoor2D().y + this->getSizeY2D() > y)
    6868      return true;
    6969    else
     
    7676   * @param signal the name of the Signal
    7777   */
    78   void GLGuiWidget::connectSignal(GLGuiSignalType signalType, BaseObject*, const Executor* signal)
     78  void GLGuiWidget::connectSignal(SignalType signalType, BaseObject* object, const Executor* signal)
    7979  {
    80     if (signalType >= GLGuiSignalCount)
     80    if (signalType >= this->widgetSignals.size())
    8181      return;
    8282
    83     if (this->widgetSignals[signalType] != NULL)
    84       PRINTF(2)("Already connected a Signal to '%s::%s' type %s... overwriting\n", this->getClassName(), this->getName(), "TEST");
     83//    if (this->widgetSignals[signalType] != NULL)
     84//      PRINTF(2)("Already connected a Signal to '%s::%s' type %s... overwriting\n", this->getClassName(), this->getName(), "TEST");
    8585
    86     //this->widgetSignals[signalType] = ;
     86    this->widgetSignals[signalType] = SignalConnector(object, signal);
    8787  }
    8888
     
    9191   * @param signalType the type of Signal to remove.
    9292   */
    93   void GLGuiWidget::disconnectSignal(GLGuiSignalType signalType)
     93  void GLGuiWidget::disconnectSignal(SignalType signalType)
    9494  {
    95     if (signalType > GLGuiSignalCount)
     95    if (signalType >= this->widgetSignals.size())
    9696      return;
    9797
    98     this->widgetSignals[signalType] = NULL;
     98    this->widgetSignals[signalType] = SignalConnector();
    9999  }
    100100
  • trunk/src/lib/gui/gl_gui/glgui_widget.h

    r7779 r7855  
    2222  typedef enum
    2323  {
    24     GLGuiSignal_click     = 0,
    25     GLGuiSignal_release,
    26     GLGuiSignal_rollOn,
    27     GLGuiSignal_rollOff,
    28     GLGuiSignal_open,
    29     GLGuiSignal_close,
    30     GLGuiSignal_destroy,
     24    Signal_click     = 0,
     25    Signal_release,
     26    Signal_rollOn,
     27    Signal_rollOff,
     28    Signal_open,
     29    Signal_close,
     30    Signal_destroy,
    3131
    32     GLGuiSignalCount,
    33   } GLGuiSignalType;
     32    SignalCount,
     33  } SignalType;
     34
    3435
    3536  //! if the Element should be visible by default.
     
    5152    void hide();
    5253
    53     void connectSignal(GLGuiSignalType signalType, BaseObject* obj, const Executor* signal);
    54     void disconnectSignal(GLGuiSignalType signalType);
     54    void connectSignal(SignalType signalType, BaseObject* obj, const Executor* signal);
     55    void disconnectSignal(SignalType signalType);
    5556    bool focusOverWidget(float x, float y);
    5657
    5758    // if something was clickt on the GUI-widget.
    58     virtual void click(const Event& event) {};
    59     virtual void release(const Event& event) {};
     59    virtual void clicked(const Event& event) {};
     60    virtual void released(const Event& event) {};
    6061
    61     virtual void receiveFocus() {};
    62     virtual void removeFocus() {};
     62    virtual void receivedFocus() {};
     63    virtual void removedFocus() {};
     64
     65    virtual void destroyed() {};
    6366
    6467    virtual void update() {};
     
    7578    void init();
    7679
     80
     81
     82
    7783  protected:
    7884    Material               backMat;
     
    8389
    8490  private:
    85     std::vector<SignalConnector*> widgetSignals;
     91    std::vector<SignalConnector> widgetSignals;
    8692
    8793    bool                   focusable;        //!< If this widget can receive focus.
  • trunk/src/lib/gui/gl_gui/signal_connector.cc

    r7779 r7855  
    2121{
    2222
     23  SignalConnector::SignalConnector( )
     24  {
     25    this->object = NULL;
     26    this->exec = NULL;
     27  }
     28
    2329  SignalConnector::SignalConnector(BaseObject* object, const Executor* executor)
    24       : object(object), exec(exec)
    25   {};
     30  {
     31    this->object = object;
     32    this->exec = executor;
     33  };
     34
     35  SignalConnector::SignalConnector(const SignalConnector& signalConnector)
     36  {
     37    this->object = signalConnector.object;
     38    this->exec = (signalConnector.exec == NULL) ? NULL : signalConnector.exec->clone();
     39  }
     40
     41  SignalConnector::~SignalConnector()
     42  {
     43    delete exec;
     44  }
     45
     46  SignalConnector& SignalConnector::operator=(const SignalConnector& signalConnector)
     47  {
     48    delete this->exec;
     49    this->object = signalConnector.object;
     50    this->exec = (signalConnector.exec == NULL) ? NULL : signalConnector.exec->clone();
     51  }
     52
     53  void SignalConnector::operator()(const std::string& parameters) const
     54  {
     55    if (exec != NULL && object != NULL)
     56      (*this->exec)(this->object, parameters);
     57  }
     58
    2659}
  • trunk/src/lib/gui/gl_gui/signal_connector.h

    r7779 r7855  
    11/*!
    22 * @file signal_connector.h
    3  * @brief Definition of ...
     3 * @brief Definition of a SignalConnector class
    44*/
    55
     
    1111namespace OrxGui
    1212{
    13   //! A class for ...
     13  //! A class for Conncting Signals to Objects, inside of the GUI
    1414  class SignalConnector
    1515  {
    1616  public:
     17    SignalConnector();
    1718    SignalConnector(BaseObject* object, const Executor* exec);
    1819    SignalConnector(const SignalConnector& signalConnector);
    19     ~SignalConnector() { delete exec; }
     20    ~SignalConnector();
    2021
    2122    SignalConnector& operator=(const SignalConnector& signalConnector);
    2223
     24    void operator()(const std::string& parameters) const;
     25    void execute(const std::string& parameters) const { (*this)(parameters); };
     26
     27    bool isClean() const { return (this->object == NULL || this->exec == NULL); }
     28
     29
    2330  private:
    24     const Executor*     exec;
    25     BaseObject*         object;
     31    BaseObject*          object;         //!< The object to call.
     32    const Executor*      exec;           //!< The Executor, that will be called, on object.
    2633  };
    2734}
Note: See TracChangeset for help on using the changeset viewer.