Changeset 110
- Timestamp:
- 06/07/13 09:25:32 (12 years ago)
- Location:
- trunk/nv
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/gfx/image.hh
r90 r110 31 31 * By an image we understand a group of pixels, limited to X and Y 32 32 * dimensions, of a certain depth (by depth we mean how rich 33 * the colors are .33 * the colors are). 34 34 */ 35 35 class image -
trunk/nv/gfx/texture_font.hh
r96 r110 18 18 struct texture_glyph 19 19 { 20 uint16 charcode; 21 glm::ivec2 size; 22 glm::ivec2 offset; 23 glm::vec2 advance; 24 glm::vec2 tl; 25 glm::vec2 br; 26 std::unordered_map< uint16, float > kerning; 20 uint16 charcode; ///< Character code value. 21 glm::ivec2 size; ///< Width and height of the glyph. 22 glm::ivec2 offset; ///< Offset of the glyph's position from the base line. 23 glm::vec2 advance; ///< Cursor advance distance. 24 glm::vec2 tl; ///< Top-left of the glyph's bounding box. 25 glm::vec2 br; ///< Bottom-right of the glyph's bounding box. 26 std::unordered_map< uint16, float > kerning; ///< Kerning space between other characters. 27 27 28 /** 29 *Creates a new texture_glyph. 30 */ 28 31 texture_glyph(); 29 float get_kerning( const uint16 charcode ); 32 33 /** 34 *Gets the kerning space between this character and the requested character. 35 * 36 *@param charcode The character to get the spacing for. 37 *@returns The amount of space for kerning. 38 */ 39 float get_kerning( const uint16 charcode ); 30 40 }; 31 41 … … 40 50 void generate_kerning(); 41 51 private: 42 std::unordered_map< uint16, texture_glyph > m_glyphs; 43 texture_atlas* m_atlas; 44 std::string m_filename; 45 float m_size; 46 float m_height; 47 float m_linegap; 48 float m_ascender; 49 float m_descender; 50 bool m_hinting; 51 bool m_filtering; 52 uint8 m_lcd_weights[5]; 53 void* m_rlibrary; 54 void* m_rface; 52 std::unordered_map< uint16, texture_glyph > m_glyphs; ///< Hash table of glyphs for this font. 53 texture_atlas* m_atlas; ///< Atlas Image object for this font. 54 std::string m_filename; ///< Name of the file. 55 float m_size; ///< Font size. 56 float m_height; ///< Height of the font. (x-height?) 57 float m_linegap; ///< Amount of space between lines. 58 float m_ascender; ///< Height of ascender lines (lines extending above the glyph's x-height). 59 float m_descender; ///< Height of descender lines (lines extending below the glyph's x-height). 60 bool m_hinting; ///< Whether or not glyph hints are used. 61 bool m_filtering; ///< Whether or not glyphs are color filtered for LCD displays. 62 uint8 m_lcd_weights[5]; ///< Color filtering weights. 63 void* m_rlibrary; ///< Pointer to the library. 64 void* m_rface; ///< Pointer to the font face. 55 65 }; 56 66 } -
trunk/nv/gui/gui_element.hh
r99 r110 26 26 { 27 27 public: 28 29 /** 30 *Creates a new GUI element. 31 */ 28 32 element() : object() {} 33 34 /** 35 *Creates a new GUI element with the give root node and postioning data. 36 * 37 *@param aroot The root object that will be this object's parent. 38 *@param r The rectangle representing the position and size of this element. 39 */ 29 40 element( root* aroot, const rectangle& r ); 41 42 /** 43 *Gets the deepest child element that contains the indicated point. 44 * 45 *@param p The position to check. 46 *@returns The last child element that contains the given point. 47 */ 30 48 element* get_element( const position& p ); 49 50 /** 51 *Event handler for update events. Calls on_update for all affected children. 52 * 53 *@param elapsed Time since last update. 54 */ 31 55 virtual void on_update( uint32 elapsed ); 56 57 /** 58 *Event handler for draw events. Calls on_draw for all affected children. 59 */ 32 60 virtual void on_draw(); 61 62 /** 63 *Event handler for IO events. Class on_event for all affected children. 64 * 65 *@param event The event data. 66 *@returns ??? 67 */ 33 68 virtual bool on_event( const io_event& event ); 69 70 /** 71 *Checks if this element contains the given point. 72 * 73 *@param p The point to check. 74 *@returns True if the point is within the region of the element, false otherwise. 75 */ 34 76 virtual bool contains( const position& p ) const; 77 78 /** 79 *Sets the position and size of this element relative to its parent. 80 * 81 *@param r The new position and size of the element. 82 */ 35 83 virtual void set_relative( const rectangle& r ); 84 85 /** 86 *Sets the position of this element relative to its parent. 87 * 88 *@param p The new position of the element. 89 */ 36 90 virtual void set_relative( const position& p ); 91 92 /** 93 *Gets the position and size of the element relative to its parent. 94 * 95 *@returns The element's position and size relative to its parent. 96 */ 37 97 virtual const rectangle& get_relative() const { return m_relative; } 98 99 /** 100 *Gets the position and size of the element relative to the root (window). 101 * 102 *@returns The element's position and size relative to the root (window). 103 */ 38 104 virtual const rectangle& get_absolute() const { return m_absolute; } 105 106 /** 107 *Gets the parent element of this element. 108 * 109 *@returns The parent element. 110 */ 39 111 virtual element* get_parent() const { return (element*)m_parent; } 112 113 /** 114 *Gets whether this element is currently accepting events. 115 * 116 *@returns True if the element is receiving events, false otherwise. 117 */ 40 118 virtual bool is_enabled() const { return m_enabled; } 119 120 /** 121 *Gets whether this element is currently visible. 122 * 123 *@returns True if the element is visible, false otherwise. 124 */ 41 125 virtual bool is_visible() const { return m_visible; } 126 127 /** 128 *Gets whether this element needs to be redrawn. 129 * 130 *@returns True if the element needs to be redrawn, false if not. 131 */ 42 132 virtual bool is_dirty() const { return m_dirty; } 133 134 /** 135 *Sets whether this element is currently accepting events. 136 * 137 *@param value True to allow the element and its children to receive events, false to disable. 138 */ 43 139 virtual void set_enabled( bool value ) { m_enabled = value; } 140 141 /** 142 *Sets whether this element is visible on the screen. 143 * 144 *@param value True to display the element and its children, false to hide it and its children. 145 */ 44 146 virtual void set_visible( bool value ) { m_visible = value; } 147 148 /** 149 *Sets whether this element needs to be redrawn. 150 * 151 *@param value True to request that the element and its children be redrawn, false if not. 152 */ 45 153 virtual void set_dirty( bool value ) { m_dirty = value; } 154 155 /** 156 *Gets the text associated with this element. 157 * 158 *@returns A string containing the associated text. 159 */ 46 160 virtual const string& get_text() const { return m_text; } 161 162 /** 163 *Sets the text associated with this element. 164 * 165 *@param text The new text to associate with this element. 166 */ 47 167 virtual void set_text( const string& text ) { m_text = text; m_dirty = true; } 168 169 /** 170 *Gets the class name associated with this element. 171 * 172 *@returns A string containing the class name of this element. 173 */ 48 174 virtual const string& get_class() const { return m_class; } 175 176 /** 177 *sets the class name associated with this element. 178 * 179 *@param class_ The new class name. 180 */ 49 181 virtual void set_class( const string& class_ ) { m_class = class_; m_dirty = true; } 182 183 /** 184 *Recalcuates the absolute position of the element and the element's children. 185 */ 50 186 virtual void recalculate_absolute(); 187 188 /** 189 *Recalculates the aboslute position of the element's children. 190 */ 51 191 virtual void recalculate_absolute_children(); 192 193 /** 194 *Destroys the element. 195 */ 52 196 virtual ~element(); 53 197 protected: 54 198 friend class environment; 55 199 56 string m_class; 57 string m_text; 58 rectangle m_relative; 59 rectangle m_absolute; 60 bool m_enabled; 61 bool m_visible; 62 bool m_dirty; 63 render_data* m_render_data; 200 string m_class; ///< Class name. 201 string m_text; ///< Displayed label or text. 202 rectangle m_relative; ///< Position relative to parent. 203 rectangle m_absolute; ///< Position relative to window/screen. 204 bool m_enabled; ///< Whether the element accepts events. 205 bool m_visible; ///< Whether the element is drawn. 206 bool m_dirty; ///< Whether the element needs updating. 207 render_data* m_render_data; ///< -?- 64 208 }; 65 209 -
trunk/nv/interface/render_state.hh
r31 r110 186 186 }; 187 187 188 } // namespace n ova188 } // namespace nv 189 189 190 190 191 #endif // N OVA_RENDER_STATE_HH191 #endif // NV_RENDER_STATE_HH -
trunk/nv/io_event.hh
r93 r110 67 67 struct mouse_button_event 68 68 { 69 /// X position where mouse was clicked. 69 70 uint16 x; 71 /// Y position where mouse was clicked. 70 72 uint16 y; 71 /// 73 /// Button that was clicked. 72 74 uint32 button; 73 75 /// True if pressed … … 79 81 struct mouse_move_event 80 82 { 83 /// X Position the mouse moved to. 81 84 uint16 x; 85 /// Y Position the mouse moved to. 82 86 uint16 y; 87 /// Distance in x direction mouse was moved. 83 88 sint16 rx; 89 /// Distance in y direction mouse was moved. 84 90 sint16 ry; 85 91 /// True if pressed … … 91 97 struct resize_event 92 98 { 99 /// New x size of the object. 93 100 sint32 x; 101 /// New y size of the object. 94 102 sint32 y; 95 103 }; … … 97 105 struct active_event 98 106 { 107 /// Whether focus was gained or lost. 99 108 bool gain; 100 109 }; … … 121 130 }; 122 131 132 /** 133 *Gets the name of the key given the code. 134 * 135 *@param key The code value of the key. 136 *@returns The name of the key. 137 */ 123 138 const char* get_key_name( key_code key ); 139 140 /** 141 *Gets the name of the mouse button given the code. 142 * 143 *@param button The code value of the mouse button. 144 *@returns The name of the button. 145 */ 124 146 const char* get_mouse_name( mouse_code button ); 147 148 /** 149 *Gets the name of the IO event given the code. 150 * 151 *@param event The code value of the IO event. 152 *@returns The name of the event. 153 */ 125 154 const char* get_io_event_name( io_event_code event ); 155 156 /** 157 *Registers all events to the specified database. 158 * 159 *@param db The database to store all event data in. 160 */ 126 161 void register_io_types( type_database* db ); 127 162 } -
trunk/nv/position.hh
r108 r110 35 35 struct { value_type x1,y1,x2,y2; }; 36 36 }; 37 37 /** 38 *Creates a new rectangle assigned to {0, 0, 0, 0}. 39 */ 38 40 rectangle() : ul(), lr() {} 41 42 /** 43 *Creates a new rectangle given a position. 44 * 45 *@param p The position to assign the rectangle to. 46 */ 39 47 rectangle( position p ) : ul(p), lr(p) {} 48 49 /** 50 *Creates a new rectangle given an upper-left and lower-right position. 51 * 52 *@param ul The position of the upper-left corner of the rectangle. 53 *@param lr The position of the lower-right corner of the rectangle. 54 */ 40 55 rectangle( position ul, position lr ) : ul(ul), lr(lr) {} 56 57 /** 58 *Creates a new rectangle given an upper-left position, width, and height. 59 * 60 *@param ul The position of the upper-left corner of the rectangle. 61 *@param width The width of the rectangle. 62 *@param height The height of the rectangle. 63 */ 41 64 rectangle( position ul, value_type width, value_type height ) : ul(ul), lr(ul + position(width,height)) {} 65 66 /** 67 *Sets the dimensions of the rectangle without moving the upper-left of the rectangle. 68 * 69 *@param d The new dimensions of the rectangle. 70 */ 42 71 rectangle& dim( dimension d ) { lr = ul + d; return *this; } 72 73 /** 74 *Moves the rectangle to a new position while maintaining its size. 75 * 76 *@param p The new position of the rectangle's upper-left corner. 77 */ 43 78 rectangle& pos( position p ) { lr = p + (lr - ul); lr = p; return *this; } 44 79 80 /** 81 *Sets the dimensions of the rectangle without moving the upper-left of the rectangle. 82 * 83 *@param d The new dimensions of the rectangle. 84 */ 45 85 void set_dimension( dimension d ) { lr = ul + d; } 86 87 /** 88 *Moves the rectangle to a new position while maintaining its size. 89 * 90 *@param p The new position of the rectangle's upper-left corner. 91 */ 46 92 void set_position( position p ) { lr = p + (lr - ul); ul = p; } 47 93 94 /** 95 *Gets the dimensions of the rectangle. Synonym for get_size. 96 * 97 *@returns The dimensions of the rectangle. 98 *@see get_size 99 */ 48 100 dimension get_dimension() const { return lr - ul; } 101 102 /** 103 *Gets the position of the upper-left corner of the rectangle. 104 * 105 *@returns The position of the rectangle's upper-left corner. 106 */ 49 107 position get_position() const { return ul; } 108 109 /** 110 *Gets the dimensions of the rectangle. Synonym for get_dimension. 111 * 112 *@returns The dimensions of the rectangle. 113 *@see get_dimension 114 */ 50 115 dimension get_size() const { return lr - ul; } 116 117 /** 118 *Gets the center of the rectangle. 119 * 120 *@returns The center of the rectangle. 121 */ 51 122 position get_center() const { return ( lr + ul ) / 2; } 123 124 /** 125 *Gets the width of the rectangle. 126 * 127 *@returns The width of the rectangle. 128 */ 52 129 value_type get_width() const { return x2 - x1; } 130 131 /** 132 *Gets the height of the rectangle. 133 * 134 *@returns The height of the rectangle. 135 */ 53 136 value_type get_height() const { return y2 - y1; } 137 138 /** 139 *Gets the area of the rectangle. 140 * 141 *@returns The area of the rectangle. 142 */ 54 143 value_type get_area() const { return (y2 - y1) * (x2 - x1); } 144 145 /** 146 *Checks to see if the rectangle is backwards. 147 * 148 *@returns True if the rectangle's upper-left is above and left (or equal to) the rectangle's lower-right, false if it is not. 149 */ 55 150 bool is_valid() const { return x2 >= x1 && y2 >= y1; } 56 151 152 /** 153 *Shifts the rectangle by a given amount. 154 * 155 *@param pos The amount to shift the rectangle by. 156 */ 57 157 rectangle& operator+=( const position& pos ) { ul += pos; lr += pos; return (*this); } 158 159 /** 160 *Returns a rectangle shifted by a given amount. 161 * 162 *@param pos The amount to shift by. 163 *@returns The shifted rectangle. 164 */ 58 165 rectangle operator+( const position& pos ) const { rectangle r(*this); return r += pos; } 166 167 /** 168 *Shifts the rectangle by a given amount. 169 * 170 *@param pos The amount to shift the rectangle by. 171 */ 59 172 rectangle& operator-=( const position& pos ) { ul -= pos; lr -= pos; return (*this); } 173 174 /** 175 *Returns a rectangle shifted by a given amount. 176 * 177 *@oaram pos The amount to shift by. 178 *@returns The shifted rectangle. 179 */ 60 180 rectangle operator-( const position& pos ) const { rectangle r(*this); return r -= pos; } 181 182 /** 183 *Compares two rectangles to see if they are the same. 184 * 185 *@param r The rectangle to compare to. 186 *@returns True if the rectangles have the same positions and dimensions, false otherwise. 187 */ 61 188 bool operator==( const rectangle& r ) const { return r.ul == ul && r.lr == lr; } 189 190 /** 191 *Compares two rectangles to see if they are different. 192 * 193 *@param r The rectangle to compare to. 194 *@returns True if the rectangles have different positions or dimensions, false otherwise. 195 */ 62 196 bool operator!=( const rectangle& r ) const { return r.ul != ul || r.lr != lr; } 63 197 198 /** 199 *Checks if a position is within the bounds of this rectangle. 200 * 201 *@param r The position to check. 202 *@returns True if the position is inside or on the edge of the rectangle, false otherwise. 203 */ 64 204 bool contains( const position& r ) const{ return y2 >= r.y && y1 <= r.y && x2 >= r.x && x1 <= r.x; } 205 206 /** 207 *Checks if a rectangle is within the bounds of this rectangle. 208 * 209 *@param r The rectangle to check. 210 *@returns True if the entire rectangle to check is inside or on the edge of this rectangle, false otherwise. 211 */ 65 212 bool contains( const rectangle& r ) const { return contains( r.ul ) && contains( r.lr ); } 213 214 /** 215 *Checks if another rectangle overlaps this one. 216 * 217 *@param r The rectangle to check. 218 *@returns True if any part of the rectangle to check overlaps this rectangle, false otherwise. 219 */ 66 220 bool collides( const rectangle& r ) const { return y2 > r.y1 && y1 < r.y2 && x2 > r.x1 && x1 < r.x2; } 67 221 222 /** 223 *Limits the region of the rectangle to the inidicated rectangle. 224 * 225 *@param r The rectangle that this rectangle is confined to. 226 *@returns True if the rectangle was changed, false otherwise. 227 */ 68 228 bool clamp_to( const rectangle& r ) 69 229 { … … 75 235 } 76 236 237 /** 238 *Limits the size of the rectangle to the given rectangle's size. 239 * 240 *@param r The rectangle representing the maximum dimensions this rectangle can be. 241 *@returns True if the rectangle needed to be resized, false otherwise. 242 */ 77 243 bool constrain_to( const rectangle& r ) 78 244 { … … 83 249 } 84 250 251 /** 252 *Fixes an invalid rectangle. 253 */ 85 254 void repair() 86 255 { … … 89 258 } 90 259 260 /** 261 *Expands the rectangle to just include the given point. 262 * 263 *@param p The point to include in the rectangle. 264 */ 91 265 void include_point( position p ) 92 266 { -
trunk/nv/singleton.hh
r3 r110 18 18 namespace nv 19 19 { 20 20 /** 21 *singleton 22 *@brief Represents an accessible static object that will only have one instance. 23 */ 21 24 template <class T> 22 25 class singleton 23 26 { 24 27 private: 25 static T *singleton_; 28 static T *singleton_; ///< Pointer to the instance of this object type. 26 29 27 30 protected: 31 32 /** 33 *Creates the single instance if one doesn't already exist. 34 */ 28 35 singleton() 29 36 { … … 32 39 } 33 40 41 /** 42 *Destroys the instance. 43 */ 34 44 ~singleton() 35 45 { … … 39 49 40 50 public: 51 /** 52 *Checks to see if the instance exists. 53 * 54 *@returns True if this singleton has an instance assigned, false otherwise. 55 */ 41 56 static bool is_valid() 42 57 { 43 58 return singleton_ != 0; 44 59 } 60 61 /** 62 *Returns the pointer to the instance. 63 * 64 *@returns The pointer to the instance. 65 */ 45 66 static T *pointer() 46 67 { … … 48 69 return singleton_; 49 70 } 71 /** 72 *Returns the object referenced by this singleton. 73 */ 50 74 static T &reference() 51 75 { … … 58 82 T* singleton<T>::singleton_ = 0; 59 83 84 85 /** 86 *auto_singleton 87 *@brief Represents a singleton that automatically creates an instance if one doesn't already exist. 88 */ 60 89 template <class T> 61 90 class auto_singleton : public singleton<T> 62 91 { 63 92 public: 93 /** 94 *Returns the pointer to the instance. Makes an instance if one doesn't already exist. 95 */ 64 96 static T *pointer() 65 97 { … … 70 102 return singleton<T>::pointer(); 71 103 } 104 105 /** 106 *Returns the object referenced by this singleton. Makes an instance if one doesn't already exist. 107 */ 72 108 static T &reference() 73 109 { -
trunk/nv/uid.hh
r59 r110 22 22 { 23 23 public: 24 25 /** 26 *Creates a new instance of the unique indentifer store. 27 */ 24 28 uid_store(); 29 30 /** 31 *Gets the object with the specified ID. 32 * 33 *@param auid The ID to fetch. 34 *@returns The stored object for that ID. 35 */ 25 36 object* get( uid auid ) const; 37 38 /** 39 *Removes the object with the specified ID. 40 * 41 *@param auid The ID to remove. 42 *@returns True if the removal was successful, false if the ID didn't exist. 43 */ 26 44 bool remove( uid auid ); 45 46 /** 47 *Adds an object to the store assigned to the indicated ID. 48 * 49 *@param o The object to add to the store. 50 *@param auid The ID to assign to the object. 51 */ 27 52 void insert( object* o, uid auid ); 53 54 /** 55 *Adds an object to the store and assigns it a new ID. 56 * 57 *@param o The object to add to the store. 58 *@returns The ID the object was store under. 59 */ 28 60 uid insert( object* o ); 61 62 /** 63 *Gets the next available ID. 64 * 65 *@returns The next ID in the store. 66 */ 29 67 uid request_uid(); 68 69 /** 70 *Destroys the unique identifier store. 71 */ 30 72 ~uid_store(); 73 74 /** 75 *Retrieves an object and casts it to the specified type. 76 * 77 *@tparam T The type to cast to. 78 *@param auid The ID the object is stored under. 79 *@returns An object of the indicated type that was stored at the indicated ID. 80 */ 31 81 template< typename T > 32 82 T* get_as( uid auid ) const … … 36 86 private: 37 87 typedef std::unordered_map< uid, object* > map; 38 map m_map; 39 uid m_current; 88 map m_map; ///< The hash map everything is stored in. 89 uid m_current; ///< The last UID assigned. 40 90 }; 41 91 }
Note: See TracChangeset
for help on using the changeset viewer.