source: trunk/src/gui/gui_environment.cc @ 128

Last change on this file since 128 was 126, checked in by epyon, 12 years ago
  • commiting the gui_element/gui_environment and gui_renderer in it's current state
  • the implementation is very WIP though, but too long stayed out of SVN
  • minor fix to c_file_system
File size: 1.8 KB
Line 
1// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
2// http://chaosforge.org/
3//
4// This file is part of NV Libraries.
5// For conditions of distribution and use, see copyright notice in nv.hh
6
7#include "nv/gui/gui_environment.hh"
8
9#include "nv/gui/gui_renderer.hh"
10
11
12        /*
13
14        TODO: parse a lua stylesheet as per Trac wiki
15
16        IDEA: Store everything in std::unordered_maps, with lua_value's?
17
18        A lua_value is a variant stores strings as const char* that deletes them on destructor?
19        Question is that there might not be much gained on speed anyway, due to Lua's speed.
20        Special function field allows delayed per parse execution?
21
22        */
23
24#include "nv/interface/mesh.hh"
25#include "nv/gfx/cached_buffer.hh"
26#include "nv/gfx/texture_atlas.hh"
27
28#include <vector>
29
30using namespace nv;
31using namespace nv::gui;
32
33environment::environment( window* w )
34        : m_renderer( nullptr ), m_window( w ), m_screen( nullptr )
35{
36        m_area.dim( dimension( w->get_width(), w->get_height() ) );
37        m_screen = new screen( this, m_area );
38        m_renderer = new renderer( w );
39        root::add_child( m_screen );
40}
41
42void nv::gui::environment::load_style( const std::string& filename )
43{
44        m_renderer->load_style( filename );
45}
46
47void environment::update( element* e, uint32 elapsed )
48{
49        if ( e->is_dirty() || e->m_render_data == nullptr )
50        {
51                m_renderer->redraw( e, elapsed );
52                e->set_dirty( false );
53        }
54}
55
56void environment::draw( element* e )
57{
58        m_renderer->draw( e );
59}
60
61void environment::update()
62{
63        m_screen->on_update( 0 );
64}
65
66void environment::draw()
67{
68        m_screen->on_draw();
69        m_renderer->draw();
70}
71
72void environment::add_child( object* child )
73{
74        // TODO: check if element
75        m_screen->add_child( child );
76}
77
78environment::~environment()
79{
80        destroy_children();
81        delete m_renderer;
82}
83
Note: See TracBrowser for help on using the repository browser.