[66] | 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 |
|
---|
[268] | 16 | #include <nv/common.hh>
|
---|
[66] | 17 | #include <nv/position.hh>
|
---|
[69] | 18 | #include <nv/io_event.hh>
|
---|
| 19 | #include <nv/gui/gui_common.hh>
|
---|
[66] | 20 |
|
---|
| 21 | namespace nv
|
---|
| 22 | {
|
---|
| 23 | namespace gui
|
---|
| 24 | {
|
---|
[269] | 25 |
|
---|
| 26 | class handle
|
---|
| 27 | {
|
---|
| 28 | public:
|
---|
| 29 | handle() : m_index(0), m_counter(0) {}
|
---|
| 30 |
|
---|
| 31 | inline bool operator==(const handle& rhs){return m_index == rhs.m_index && m_counter == rhs.m_counter; }
|
---|
| 32 | inline bool operator!=(const handle& rhs){return !(*this == rhs);}
|
---|
| 33 |
|
---|
| 34 | bool is_nil() { return m_index == 0 && m_counter == 0; }
|
---|
| 35 | bool is_valid() { return !is_nil(); }
|
---|
| 36 | private:
|
---|
| 37 | friend class environment;
|
---|
| 38 |
|
---|
| 39 | explicit handle( uint16 a_index, uint16 a_counter ) : m_index( a_index ), m_counter(a_counter) {}
|
---|
| 40 |
|
---|
| 41 | uint16 m_index;
|
---|
| 42 | uint16 m_counter;
|
---|
| 43 | };
|
---|
| 44 |
|
---|
| 45 |
|
---|
[268] | 46 | class element
|
---|
[66] | 47 | {
|
---|
[269] | 48 | public:
|
---|
[268] | 49 | /// List type
|
---|
[269] | 50 | typedef std::list<handle> list;
|
---|
[110] | 51 |
|
---|
[268] | 52 |
|
---|
[269] | 53 | element()
|
---|
[268] | 54 | : m_id( "" )
|
---|
[269] | 55 | , m_this()
|
---|
| 56 | , m_parent()
|
---|
[268] | 57 | , m_children()
|
---|
| 58 | , m_child_count(0)
|
---|
| 59 | , m_class("")
|
---|
[269] | 60 | , m_relative()
|
---|
| 61 | , m_absolute()
|
---|
[268] | 62 | , m_enabled( true )
|
---|
| 63 | , m_visible( true )
|
---|
| 64 | , m_dirty( true )
|
---|
| 65 | , m_render_data( nullptr ) {}
|
---|
[110] | 66 |
|
---|
[99] | 67 | friend class environment;
|
---|
[126] | 68 | friend class renderer;
|
---|
[268] | 69 | friend class style;
|
---|
[99] | 70 |
|
---|
[268] | 71 | string m_id; ///< id type of the object
|
---|
[269] | 72 | handle m_this; ///< pointer to parent
|
---|
| 73 | handle m_parent; ///< pointer to parent
|
---|
[268] | 74 | list m_children; ///< children objects
|
---|
| 75 | size_t m_child_count; ///< number of children
|
---|
[110] | 76 | string m_class; ///< Class name.
|
---|
| 77 | string m_text; ///< Displayed label or text.
|
---|
| 78 | rectangle m_relative; ///< Position relative to parent.
|
---|
| 79 | rectangle m_absolute; ///< Position relative to window/screen.
|
---|
| 80 | bool m_enabled; ///< Whether the element accepts events.
|
---|
| 81 | bool m_visible; ///< Whether the element is drawn.
|
---|
| 82 | bool m_dirty; ///< Whether the element needs updating.
|
---|
| 83 | render_data* m_render_data; ///< -?-
|
---|
[66] | 84 | };
|
---|
| 85 |
|
---|
| 86 | } // namespace gui
|
---|
| 87 |
|
---|
| 88 | } // namespace nv
|
---|
| 89 |
|
---|
| 90 | #endif // NV_GUI_ELEMENT_HH
|
---|