Changeset 69 for trunk


Ignore:
Timestamp:
05/31/13 19:33:59 (12 years ago)
Author:
epyon
Message:
  • gui::element - render_data, class, dirty and text fields added with proper accessors
  • gui::element - on_event implemented and draw calling environment
  • gui::environment skeleton class added
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/gui/gui_common.hh

    r66 r69  
    3030                };
    3131
     32                class render_data
     33                {
     34                public:
     35                        ~render_data(){}
     36                };
     37
     38                class element;
     39                class environment;
     40
    3241        } // namespace gui
    3342
  • trunk/nv/gui/gui_element.hh

    r66 r69  
    1616#include <nv/object.hh>
    1717#include <nv/position.hh>
     18#include <nv/io_event.hh>
     19#include <nv/gui/gui_common.hh>
    1820
    1921namespace nv
     
    2123        namespace gui
    2224        {
    23 
    2425                class element : public object
    2526                {
     
    3031                        virtual void on_update( uint32 elapsed );
    3132                        virtual void on_draw();
    32                         // bool on_event( event );
    33                         bool contains( const position& p ) const;
     33                        virtual bool on_event( const io_event& event );
     34                        virtual bool contains( const position& p ) const;
    3435                        virtual void set_relative( const rectangle& r );
    3536                        virtual void set_relative( const position& p );
     
    3940                        virtual bool is_enabled() const { return m_enabled; }
    4041                        virtual bool is_visible() const { return m_visible; }
     42                        virtual bool is_dirty()   const { return m_dirty; }
    4143                        virtual void set_enabled( bool value ) { m_enabled = value; }
    4244                        virtual void set_visible( bool value ) { m_visible = value; }
     45                        virtual void set_dirty( bool value )   { m_dirty   = value; }
     46                        virtual const string& get_text() const { return m_text; }
     47                        virtual void set_text( const string& text ) { m_text = text; m_dirty = true; }
     48                        virtual const string& get_class() const { return m_class; }
     49                        virtual void set_class( const string& class_ ) { m_class = class_; m_dirty = true; }
    4350                        virtual void recalculate_absolute();
    4451                protected:
     52                        string    m_class;
     53                        string    m_text;
    4554                        rectangle m_relative;
    4655                        rectangle m_absolute;
    4756                        bool m_enabled;
    4857                        bool m_visible;
     58                        bool m_dirty;
     59                        render_data* m_render_data;
    4960                };
    5061
  • trunk/src/gui/gui_element.cc

    r66 r69  
    77#include "nv/gui/gui_element.hh"
    88
     9#include "nv/gui/gui_environment.hh"
     10
    911using namespace nv;
    1012using namespace nv::gui;
    1113
    1214element::element( root* aroot, const rectangle r )
    13         : object( aroot, "", 0 ), m_relative( r ), m_absolute( r ), m_enabled( true ), m_visible( true )
     15        : object( aroot, "", 0 ), m_class(""), m_relative( r ), m_absolute( r ), m_enabled( true ), m_visible( true ), m_dirty( true )
    1416{
    1517
     
    3133        if ( is_visible() )
    3234        {
     35                ((environment*)m_root)->draw( this );
    3336                for ( object* i : *this )
    3437                {
     
    3639                }
    3740        }
     41}
     42
     43bool element::on_event( const io_event& event )
     44{
     45        return m_parent ? ((element*)m_parent)->on_event( event ) : false;
    3846}
    3947
     
    6371void element::set_relative( const rectangle& r )
    6472{
     73        m_dirty    = true;
    6574        m_relative = r;
    6675        recalculate_absolute();
  • trunk/tests/lualib_test/lualib_test.cc

    r62 r69  
    88#include <iostream>
    99#include <functional>
     10#include <nv/gui/gui_element.hh>
    1011
    1112struct test_struct
Note: See TracChangeset for help on using the changeset viewer.