Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7880 in orxonox.OLD for branches/gui


Ignore:
Timestamp:
May 26, 2006, 11:35:21 PM (19 years ago)
Author:
bensch
Message:

focusable widgets

Location:
branches/gui/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/gui/gl_gui/glgui.h

    r7876 r7880  
    66#ifndef _GLGUI_H
    77#define _GLGUI_H
     8
     9#include "glgui_handler.h"
     10
    811#include "glgui_widget.h"
    912
  • branches/gui/src/lib/gui/gl_gui/glgui_handler.cc

    r7868 r7880  
    2020
    2121#include "glgui_mainwidget.h"
     22#include "glgui_cursor.h"
     23
     24#include "class_list.h"
     25
    2226
    2327namespace OrxGui
     
    3236    this->setName("GLGuiHandler");
    3337
     38
     39    this->cursor = NULL;
    3440    //this->subscribeEvent()
    3541
     
    4854    GLGuiHandler::singletonRef = NULL;
    4955  }
     56
     57  void GLGuiHandler::activateCursor()
     58  {
     59    this->cursor = new GLGuiCursor();
     60    this->cursor->show();
     61  }
     62
     63  void GLGuiHandler::deactivateCursor()
     64  {
     65    if (this->cursor)
     66    {
     67      delete this->cursor;
     68      this->cursor = NULL;
     69    }
     70  }
     71
    5072
    5173  void GLGuiHandler::activate()
     
    7698  void GLGuiHandler::tick(float dt)
    7799  {
     100
     101    // CHECK THE COLLISIONS.
     102    const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET);
     103
     104    if (objects != NULL && this->cursor != NULL)
     105    {
     106      for (std::list<BaseObject*>::const_iterator it = objects->begin(); it != objects->end(); it++)
     107      {
     108        GLGuiWidget* widget = dynamic_cast<GLGuiWidget*>(*it);
     109        if (widget->focusOverWidget(this->cursor->getAbsCoor2D().x, this->cursor->getAbsCoor2D().y))
     110        {
     111          // receiving Focus
     112          if (GLGuiWidget::focused() != widget)
     113          {
     114            printf("yeah\n");
     115            widget->giveFocus();
     116          }
     117        }
     118      }
     119    }
    78120  }
    79121}
  • branches/gui/src/lib/gui/gl_gui/glgui_handler.h

    r7779 r7880  
    88
    99#include "event_listener.h"
     10#include "glgui_widget.h"
    1011
    1112namespace OrxGui
    1213{
     14
     15  class GLGuiCursor;
     16
    1317  // FORWARD DECLARATION
    1418
     
    2125    /** @returns a Pointer to the only object of this Class */
    2226    inline static GLGuiHandler* getInstance(void) { if (!GLGuiHandler::singletonRef) GLGuiHandler::singletonRef = new GLGuiHandler();  return GLGuiHandler::singletonRef; };
     27
     28    void activateCursor();
     29    void deactivateCursor();
     30    GLGuiCursor* getCursor() const { return this->cursor; }
    2331
    2432    void activate();
     
    3644
    3745    bool                 isActive;
     46    GLGuiCursor*         cursor;
     47
    3848  };
    3949}
  • branches/gui/src/lib/gui/gl_gui/glgui_widget.cc

    r7879 r7880  
    6565
    6666
    67   bool GLGuiWidget::focusOverWidget(float x, float y)
     67  bool GLGuiWidget::focusOverWidget(float x, float y) const
    6868  {
    6969    if (this->getAbsCoor2D().x < x && this->getAbsCoor2D().x + this->getSizeX2D() > x &&
  • branches/gui/src/lib/gui/gl_gui/glgui_widget.h

    r7879 r7880  
    5252    void hide();
    5353
     54    void giveFocus() { GLGuiWidget::_focused = this; this->receivedFocus(); };
     55
    5456    void connectSignal(SignalType signalType, BaseObject* obj, const Executor* signal);
    5557    void disconnectSignal(SignalType signalType);
    56     bool focusOverWidget(float x, float y);
     58    bool focusOverWidget(float x, float y) const;
    5759
    5860
     
    6567    Material& frontMaterial() { return this->frontMat; };
    6668    const Material& frontMaterial() const { return this->frontMat; };
     69
     70
     71
     72    static const GLGuiWidget* const focused() { return GLGuiWidget::_focused; };
     73
    6774
    6875  protected:
  • branches/gui/src/story_entities/simple_game_menu.cc

    r7876 r7880  
    6767  pb->setAbsCoor2D(50, 50);
    6868
    69   OrxGui::GLGuiCursor* cursor = new OrxGui::GLGuiCursor();
    70   cursor->show();
     69  OrxGui::GLGuiHandler::getInstance()->activateCursor();
    7170
    7271  if (root != NULL)
     
    315314  GameWorld::tick();
    316315
     316  // Make the GLGui tick.
     317  OrxGui::GLGuiHandler::getInstance()->tick(this->dtS);
     318
    317319  this->animateScene(this->dtS);
    318320}
Note: See TracChangeset for help on using the changeset viewer.