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 | /**
|
---|
8 | * @file gui_element.hh
|
---|
9 | * @author Kornel Kisielewicz
|
---|
10 | * @brief GUI Element
|
---|
11 | */
|
---|
12 |
|
---|
13 | #ifndef NV_GUI_ELEMENT_HH
|
---|
14 | #define NV_GUI_ELEMENT_HH
|
---|
15 |
|
---|
16 | #include <nv/common.hh>
|
---|
17 | #include <nv/position.hh>
|
---|
18 | #include <nv/io_event.hh>
|
---|
19 | #include <nv/gui/gui_common.hh>
|
---|
20 |
|
---|
21 | namespace nv
|
---|
22 | {
|
---|
23 | namespace gui
|
---|
24 | {
|
---|
25 | class element
|
---|
26 | {
|
---|
27 | protected:
|
---|
28 | /// List type
|
---|
29 | typedef std::list<element*> list;
|
---|
30 |
|
---|
31 |
|
---|
32 | explicit element( const rectangle& r )
|
---|
33 | : m_id( "" )
|
---|
34 | , m_parent( nullptr )
|
---|
35 | , m_children()
|
---|
36 | , m_child_count(0)
|
---|
37 | , m_class("")
|
---|
38 | , m_relative( r )
|
---|
39 | , m_absolute( r )
|
---|
40 | , m_enabled( true )
|
---|
41 | , m_visible( true )
|
---|
42 | , m_dirty( true )
|
---|
43 | , m_render_data( nullptr ) {}
|
---|
44 |
|
---|
45 | protected:
|
---|
46 | virtual ~element() { delete m_render_data; }
|
---|
47 | protected:
|
---|
48 | friend class environment;
|
---|
49 | friend class renderer;
|
---|
50 | friend class style;
|
---|
51 |
|
---|
52 | string m_id; ///< id type of the object
|
---|
53 | element* m_parent; ///< pointer to parent
|
---|
54 | list m_children; ///< children objects
|
---|
55 | size_t m_child_count; ///< number of children
|
---|
56 | string m_class; ///< Class name.
|
---|
57 | string m_text; ///< Displayed label or text.
|
---|
58 | rectangle m_relative; ///< Position relative to parent.
|
---|
59 | rectangle m_absolute; ///< Position relative to window/screen.
|
---|
60 | bool m_enabled; ///< Whether the element accepts events.
|
---|
61 | bool m_visible; ///< Whether the element is drawn.
|
---|
62 | bool m_dirty; ///< Whether the element needs updating.
|
---|
63 | render_data* m_render_data; ///< -?-
|
---|
64 | };
|
---|
65 |
|
---|
66 | } // namespace gui
|
---|
67 |
|
---|
68 | } // namespace nv
|
---|
69 |
|
---|
70 | #endif // NV_GUI_ELEMENT_HH
|
---|