// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz // http://chaosforge.org/ // // This file is part of NV Libraries. // For conditions of distribution and use, see copyright notice in nv.hh /** * @file gui_element.hh * @author Kornel Kisielewicz * @brief GUI Element */ #ifndef NV_GUI_ELEMENT_HH #define NV_GUI_ELEMENT_HH #include #include #include #include namespace nv { namespace gui { class handle { public: handle() : m_index(0), m_counter(0) {} inline bool operator==(const handle& rhs){return m_index == rhs.m_index && m_counter == rhs.m_counter; } inline bool operator!=(const handle& rhs){return !(*this == rhs);} bool is_nil() { return m_index == 0 && m_counter == 0; } bool is_valid() { return !is_nil(); } private: friend class environment; explicit handle( uint16 a_index, uint16 a_counter ) : m_index( a_index ), m_counter(a_counter) {} uint16 m_index; uint16 m_counter; }; class element { public: /// List type typedef std::list list; element() : m_id( "" ) , m_this() , m_parent() , m_children() , m_child_count(0) , m_class("") , m_relative() , m_absolute() , m_enabled( true ) , m_visible( true ) , m_dirty( true ) , m_render_data( nullptr ) {} friend class environment; friend class renderer; friend class style; string m_id; ///< id type of the object handle m_this; ///< pointer to parent handle m_parent; ///< pointer to parent list m_children; ///< children objects size_t m_child_count; ///< number of children string m_class; ///< Class name. string m_text; ///< Displayed label or text. rectangle m_relative; ///< Position relative to parent. rectangle m_absolute; ///< Position relative to window/screen. bool m_enabled; ///< Whether the element accepts events. bool m_visible; ///< Whether the element is drawn. bool m_dirty; ///< Whether the element needs updating. render_data* m_render_data; ///< -?- }; } // namespace gui } // namespace nv #endif // NV_GUI_ELEMENT_HH