- Timestamp:
- 06/25/13 18:43:24 (12 years ago)
- Location:
- trunk/nv
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/array2d.hh
r131 r132 36 36 37 37 /** 38 * Creates a new 2D array.38 * Creates a new 2D array. 39 39 */ 40 40 array2d() : m_size(), m_data( nullptr ) {} 41 41 42 42 /** 43 * Creates a new 2D array.44 * 45 * @param asize The dimensions of the new array.43 * Creates a new 2D array. 44 * 45 * @param asize The dimensions of the new array. 46 46 */ 47 47 array2d( const ivec2& asize ) : m_size(), m_data( nullptr ) { resize( asize ); } 48 48 49 49 /** 50 * Creates a new 2D array.51 * 52 * @param asize_x The width of the new array.53 * @param asize_y The height of the new array.50 * Creates a new 2D array. 51 * 52 * @param asize_x The width of the new array. 53 * @param asize_y The height of the new array. 54 54 */ 55 55 array2d( const sint32 asize_x, const sint32 asize_y ) : m_size(), m_data( nullptr ) { resize( new ivec2( asize_x, asize_y ) ); } 56 56 57 57 /** 58 * Gets the dimensions of the array.59 * 60 * @returns The size of the array.58 * Gets the dimensions of the array. 59 * 60 * @returns The size of the array. 61 61 */ 62 62 const ivec2& size() const { return m_size; } 63 63 64 64 /** 65 * Gets a pointer to the data in the array.66 * 67 * @returns A pointer to the data in the array.65 * Gets a pointer to the data in the array. 66 * 67 * @returns A pointer to the data in the array. 68 68 */ 69 69 pointer data() { return m_data; } 70 70 71 71 /** 72 * Gets a constant pointer to the data in the array.73 * 74 * @returns A constant pointer to the data in the array.72 * Gets a constant pointer to the data in the array. 73 * 74 * @returns A constant pointer to the data in the array. 75 75 */ 76 76 const_pointer data() const { return m_data; } 77 77 78 78 /** 79 * Changes the dimensions of the array.80 * 81 * @param new_size The new dimensions of the array.82 * @param preserve True to keep as much of the existing data as will fit in the new array, False to discard the existing data.79 * Changes the dimensions of the array. 80 * 81 * @param new_size The new dimensions of the array. 82 * @param preserve True to keep as much of the existing data as will fit in the new array, False to discard the existing data. 83 83 */ 84 84 void resize( const ivec2& new_size, bool preserve = false ) … … 110 110 111 111 /** 112 * Gets a pointer to the start of the array.113 * 114 * @returns A pointer to the first position in the array.112 * Gets a pointer to the start of the array. 113 * 114 * @returns A pointer to the first position in the array. 115 115 */ 116 116 iterator begin() { return m_data; } 117 117 118 118 /** 119 * Gets a constant pointer to the start of the array.120 * 121 * @returns A constant pointer to the first position in the array.119 * Gets a constant pointer to the start of the array. 120 * 121 * @returns A constant pointer to the first position in the array. 122 122 */ 123 123 const_iterator begin() const { return m_data; } 124 124 125 125 /** 126 * Gets a pointer to the end of the array.127 * 128 * @returns A pointer to the end of the array.126 * Gets a pointer to the end of the array. 127 * 128 * @returns A pointer to the end of the array. 129 129 */ 130 130 iterator end() { return m_data + ( m_size.x * m_size.y ); } 131 131 132 132 /** 133 * Gets a constant pointer to the end of the array.134 * 135 * @returns A constant pointer to the end of the array.133 * Gets a constant pointer to the end of the array. 134 * 135 * @returns A constant pointer to the end of the array. 136 136 */ 137 137 const_iterator end() const { return m_data + ( m_size.x * m_size.y ); } … … 139 139 140 140 /** 141 * Looks up a position by X and Y value.142 * 143 * @param x The X position of the array to look up.144 * @param y The Y position of the array to look up.145 * @returns A reference to the data at the indicated position.141 * Looks up a position by X and Y value. 142 * 143 * @param x The X position of the array to look up. 144 * @param y The Y position of the array to look up. 145 * @returns A reference to the data at the indicated position. 146 146 */ 147 147 inline const_reference operator() ( sint32 x, sint32 y ) const … … 152 152 153 153 /** 154 * Looks up a position by X and Y value.155 * 156 * @param x The X position of the array to look up.157 * @param y The Y position of the array to look up.158 * @returns A reference to the data at the indicated position.154 * Looks up a position by X and Y value. 155 * 156 * @param x The X position of the array to look up. 157 * @param y The Y position of the array to look up. 158 * @returns A reference to the data at the indicated position. 159 159 */ 160 160 inline reference operator() ( sint32 x, sint32 y ) … … 165 165 166 166 /** 167 * Looks up the given position in the array.168 * 169 * @param c The position to look up.170 * @returns A reference to the data at the indicated position.167 * Looks up the given position in the array. 168 * 169 * @param c The position to look up. 170 * @returns A reference to the data at the indicated position. 171 171 */ 172 172 inline const_reference operator[] ( const ivec2& c ) const … … 177 177 178 178 /** 179 * Looks up the given position in the array.180 * 181 * @param c The position to look up.182 * @returns A reference to the data at the indicated position.179 * Looks up the given position in the array. 180 * 181 * @param c The position to look up. 182 * @returns A reference to the data at the indicated position. 183 183 */ 184 184 inline reference operator[] ( const ivec2& c ) … … 189 189 190 190 /** 191 * Returns a copy of this array in a new instance.192 * 193 * @returns An independent copy of this array.191 * Returns a copy of this array in a new instance. 192 * 193 * @returns An independent copy of this array. 194 194 */ 195 195 array2d<T> clone() … … 204 204 205 205 /** 206 * Returns an array that represents a subset of the data in this array.207 * 208 * @param start The upper and left bounds of data to retrieve.209 * @param size The width and height of the data to retrieve.210 * @returns A new 2D array containing the subset of data within the bounds specified.206 * Returns an array that represents a subset of the data in this array. 207 * 208 * @param start The upper and left bounds of data to retrieve. 209 * @param size The width and height of the data to retrieve. 210 * @returns A new 2D array containing the subset of data within the bounds specified. 211 211 */ 212 212 array2d<T> get_sub_array( const ivec2& start, const ivec2& size ) { return get_sub_array( start.x, start.y, size.x, size.y ); } 213 /** 214 *Returns an array that represents a subset of the data in this array. 215 * 216 *@param start_x The left bound of the data to retrieve. 217 *@param start_y The upper bound of the data to retrieve. 218 *@param size_x The width of the data to retrieve. 219 *@param size_y The height of the data to retrieve. 220 *@returns A new 2D array containing the subset of data within the bounds specified. 213 214 /** 215 * Returns an array that represents a subset of the data in this array. 216 * 217 * @param start_x The left bound of the data to retrieve. 218 * @param start_y The upper bound of the data to retrieve. 219 * @param size_x The width of the data to retrieve. 220 * @param size_y The height of the data to retrieve. 221 * @returns A new 2D array containing the subset of data within the bounds specified. 221 222 */ 222 223 array2d<T> get_sub_array( const sint32 start_x, const sint32 start_y, const sint32 size_x, const sint32 size_y) … … 239 240 240 241 /** 241 * Fills this array with another array.242 * 243 * @param source The array to fill with. If it does not fit in the destination it will be truncated.244 * @param dest_start The upper and left bounds of the data to fill.242 * Fills this array with another array. 243 * 244 * @param source The array to fill with. If it does not fit in the destination it will be truncated. 245 * @param dest_start The upper and left bounds of the data to fill. 245 246 */ 246 247 void set_sub_array( const array2d<T> source, const ivec2& dest_start ) … … 250 251 251 252 /** 252 * Fills this array with a subset of another array.253 * 254 * @param source The arrya to fill with. If it does not fit in the destination it will be truncated.255 * @param dest_start The upper and left bounds of the data to fill.256 * @param size The size of the area to copy over.253 * Fills this array with a subset of another array. 254 * 255 * @param source The arrya to fill with. If it does not fit in the destination it will be truncated. 256 * @param dest_start The upper and left bounds of the data to fill. 257 * @param size The size of the area to copy over. 257 258 */ 258 259 void set_sub_array( const array2d<T> source, const ivec2& dest_start, const ivec2& size ) … … 263 264 264 265 /** 265 * Fills this array with a subset of another array.266 * 267 * @param source The array to fill with. If it does not fit in the destination it will be truncated.268 * @param dest_start The upper and left bounds of the data to fill.269 * @param source_start The upper and left bounds of the source to fill with.270 * @param size The size of the area to copy over.266 * Fills this array with a subset of another array. 267 * 268 * @param source The array to fill with. If it does not fit in the destination it will be truncated. 269 * @param dest_start The upper and left bounds of the data to fill. 270 * @param source_start The upper and left bounds of the source to fill with. 271 * @param size The size of the area to copy over. 271 272 */ 272 273 void set_sub_array( const array2d<T> source, const ivec2& dest_start, const ivec2& source_start, const ivec2& size ) … … 276 277 277 278 /** 278 * Fills this array with another array.279 * 280 * @param source The array to fill with. If it does not fit in the area to fill, it will be truncated.281 * @param dest_start_x The left bound of the data to fill.282 * @param dest_start_y The upper bound of the data to fill.279 * Fills this array with another array. 280 * 281 * @param source The array to fill with. If it does not fit in the area to fill, it will be truncated. 282 * @param dest_start_x The left bound of the data to fill. 283 * @param dest_start_y The upper bound of the data to fill. 283 284 */ 284 285 void set_sub_array( const array2d<T> source, const sint32 dest_start_x, const sint32 dest_start_y ) … … 288 289 289 290 /** 290 * Fills this array with another array.291 * 292 * @param source The array to fill with. If it does not fit in the area to fill, it will be truncated.293 * @param dest_start_x The left bound of the data to fill.294 * @param dest_start_y The upper bound of the data to fill.295 * @param size_x The width of the area to copy over.296 * @param size_y The height of the area to copy over.291 * Fills this array with another array. 292 * 293 * @param source The array to fill with. If it does not fit in the area to fill, it will be truncated. 294 * @param dest_start_x The left bound of the data to fill. 295 * @param dest_start_y The upper bound of the data to fill. 296 * @param size_x The width of the area to copy over. 297 * @param size_y The height of the area to copy over. 297 298 */ 298 299 void set_sub_array( const array2d<T> source, const sint32 dest_start_x, const sint32 dest_start_y, const sint32 size_x, const sint32 size_y ) … … 302 303 303 304 /** 304 * Fills this array with a subset of another array.305 * 306 * @param source The array to fill with. If it does not fit in the area to fill, it will be truncated.307 * @param dest_start_x The left bound of the data to fill.308 * @param dest_start_y The upper bound of the data to fill.309 * @param source_start_x The left bound of the source to fill with.310 * @param source_start_y The upper bound of the source to fill with.311 * @param size_x The width of the area to copy over.312 * @param size_y The height of the area to copy over.305 * Fills this array with a subset of another array. 306 * 307 * @param source The array to fill with. If it does not fit in the area to fill, it will be truncated. 308 * @param dest_start_x The left bound of the data to fill. 309 * @param dest_start_y The upper bound of the data to fill. 310 * @param source_start_x The left bound of the source to fill with. 311 * @param source_start_y The upper bound of the source to fill with. 312 * @param size_x The width of the area to copy over. 313 * @param size_y The height of the area to copy over. 313 314 */ 314 315 void set_sub_array( const array2d<T> source, const sint32 dest_start_x, const sint32 dest_start_y, const sint32 source_start_x, const sint32 source_start_y, const sint32 size_x, const sint32 size_y ) … … 342 343 343 344 /** 344 * Destructor.345 * Destructor. 345 346 */ 346 347 ~array2d() -
trunk/nv/gfx/texture_font.hh
r121 r132 27 27 28 28 /** 29 * Creates a new texture_glyph.29 * Creates a new texture_glyph. 30 30 */ 31 31 texture_glyph(); 32 32 33 33 /** 34 * Gets the kerning space between this character and the requested character.34 * Gets the kerning space between this character and the requested character. 35 35 * 36 * @param other The character to get the spacing for.37 * @returns The amount of space for kerning.36 * @param other The character to get the spacing for. 37 * @returns The amount of space for kerning. 38 38 */ 39 39 float get_kerning( const uint16 other ); -
trunk/nv/gui/gui_element.hh
r126 r132 28 28 29 29 /** 30 * Creates a new GUI element.30 * Creates a new GUI element. 31 31 */ 32 32 element() : object() {} 33 33 34 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.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 39 */ 40 40 element( root* aroot, const rectangle& r ); 41 41 42 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.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 47 */ 48 48 element* get_element( const position& p ); 49 49 50 50 /** 51 * Event handler for update events. Calls on_update for all affected children.52 * 53 * @param elapsed Time since last update.51 * Event handler for update events. Calls on_update for all affected children. 52 * 53 * @param elapsed Time since last update. 54 54 */ 55 55 virtual void on_update( uint32 elapsed ); 56 56 57 57 /** 58 * Event handler for draw events. Calls on_draw for all affected children.58 * Event handler for draw events. Calls on_draw for all affected children. 59 59 */ 60 60 virtual void on_draw(); 61 61 62 62 /** 63 * Event handler for IO events. Class on_event for all affected children.64 * 65 * @param event The event data.66 * @returns ???63 * Event handler for IO events. Calls on_event for all affected children. 64 * 65 * @param event The event data. 66 * @returns ??? 67 67 */ 68 68 virtual bool on_event( const io_event& event ); 69 69 70 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.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 75 */ 76 76 virtual bool contains( const position& p ) const; 77 77 78 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.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 82 */ 83 83 virtual void set_relative( const rectangle& r ); 84 84 85 85 /** 86 * Sets the position of this element relative to its parent.87 * 88 * @param p The new position of the element.86 * Sets the position of this element relative to its parent. 87 * 88 * @param p The new position of the element. 89 89 */ 90 90 virtual void set_relative( const position& p ); 91 91 92 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.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 96 */ 97 97 virtual const rectangle& get_relative() const { return m_relative; } 98 98 99 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).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 103 */ 104 104 virtual const rectangle& get_absolute() const { return m_absolute; } 105 105 106 106 /** 107 * Gets the parent element of this element.108 * 109 * @returns The parent element.107 * Gets the parent element of this element. 108 * 109 * @returns The parent element. 110 110 */ 111 111 virtual element* get_parent() const { return (element*)m_parent; } 112 112 113 113 /** 114 * Gets whether this element is currently accepting events.115 * 116 * @returns True if the element is receiving events, false otherwise.114 * Gets whether this element is currently accepting events. 115 * 116 * @returns True if the element is receiving events, false otherwise. 117 117 */ 118 118 virtual bool is_enabled() const { return m_enabled; } 119 119 120 120 /** 121 * Gets whether this element is currently visible.122 * 123 * @returns True if the element is visible, false otherwise.121 * Gets whether this element is currently visible. 122 * 123 * @returns True if the element is visible, false otherwise. 124 124 */ 125 125 virtual bool is_visible() const { return m_visible; } 126 126 127 127 /** 128 * Gets whether this element needs to be redrawn.129 * 130 * @returns True if the element needs to be redrawn, false if not.128 * Gets whether this element needs to be redrawn. 129 * 130 * @returns True if the element needs to be redrawn, false if not. 131 131 */ 132 132 virtual bool is_dirty() const { return m_dirty; } 133 133 134 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.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 138 */ 139 139 virtual void set_enabled( bool value ) { m_enabled = value; } 140 140 141 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.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 145 */ 146 146 virtual void set_visible( bool value ) { m_visible = value; } 147 147 148 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.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 152 */ 153 153 virtual void set_dirty( bool value ) { m_dirty = value; } 154 154 155 155 /** 156 * Gets the text associated with this element.157 * 158 * @returns A string containing the associated text.156 * Gets the text associated with this element. 157 * 158 * @returns A string containing the associated text. 159 159 */ 160 160 virtual const string& get_text() const { return m_text; } 161 161 162 162 /** 163 * Sets the text associated with this element.164 * 165 * @param text The new text to associate with this element.163 * Sets the text associated with this element. 164 * 165 * @param text The new text to associate with this element. 166 166 */ 167 167 virtual void set_text( const string& text ) { m_text = text; m_dirty = true; } 168 168 169 169 /** 170 * Gets the class name associated with this element.171 * 172 * @returns A string containing the class name of this element.170 * Gets the class name associated with this element. 171 * 172 * @returns A string containing the class name of this element. 173 173 */ 174 174 virtual const string& get_class() const { return m_class; } 175 175 176 176 /** 177 * sets the class name associated with this element.178 * 179 * @param class_ The new class name.177 * sets the class name associated with this element. 178 * 179 * @param class_ The new class name. 180 180 */ 181 181 virtual void set_class( const string& class_ ) { m_class = class_; m_dirty = true; } 182 182 183 183 /** 184 * Recalcuates the absolute position of the element and the element's children.184 * Recalcuates the absolute position of the element and the element's children. 185 185 */ 186 186 virtual void recalculate_absolute(); 187 187 188 188 /** 189 * Recalculates the aboslute position of the element's children.189 * Recalculates the aboslute position of the element's children. 190 190 */ 191 191 virtual void recalculate_absolute_children(); 192 192 193 193 /** 194 * Destroys the element.194 * Destroys the element. 195 195 */ 196 196 virtual ~element(); -
trunk/nv/io_event.hh
r110 r132 131 131 132 132 /** 133 * Gets the name of the key given the code.133 * Gets the name of the key given the code. 134 134 * 135 * @param key The code value of the key.136 * @returns The name of the key.135 * @param key The code value of the key. 136 * @returns The name of the key. 137 137 */ 138 138 const char* get_key_name( key_code key ); 139 139 140 140 /** 141 * Gets the name of the mouse button given the code.141 * Gets the name of the mouse button given the code. 142 142 * 143 * @param button The code value of the mouse button.144 * @returns The name of the button.143 * @param button The code value of the mouse button. 144 * @returns The name of the button. 145 145 */ 146 146 const char* get_mouse_name( mouse_code button ); 147 147 148 148 /** 149 * Gets the name of the IO event given the code.149 * Gets the name of the IO event given the code. 150 150 * 151 * @param event The code value of the IO event.152 * @returns The name of the event.151 * @param event The code value of the IO event. 152 * @returns The name of the event. 153 153 */ 154 154 const char* get_io_event_name( io_event_code event ); 155 155 156 156 /** 157 * Registers all events to the specified database.157 * Registers all events to the specified database. 158 158 * 159 * @param db The database to store all event data in.159 * @param db The database to store all event data in. 160 160 */ 161 161 void register_io_types( type_database* db ); -
trunk/nv/position.hh
r121 r132 32 32 position lr; 33 33 /** 34 * Creates a new rectangle assigned to {0, 0, 0, 0}.34 * Creates a new rectangle assigned to {0, 0, 0, 0}. 35 35 */ 36 36 rectangle() : ul(), lr() {} 37 37 38 38 /** 39 * Creates a new rectangle given a position.40 * 41 * @param p The position to assign the rectangle to.39 * Creates a new rectangle given a position. 40 * 41 * @param p The position to assign the rectangle to. 42 42 */ 43 43 rectangle( position p ) : ul(p), lr(p) {} 44 44 45 45 /** 46 * Creates a new rectangle given an upper-left and lower-right position.47 * 48 * @param aul The position of the upper-left corner of the rectangle.49 * @param alr The position of the lower-right corner of the rectangle.46 * Creates a new rectangle given an upper-left and lower-right position. 47 * 48 * @param aul The position of the upper-left corner of the rectangle. 49 * @param alr The position of the lower-right corner of the rectangle. 50 50 */ 51 51 rectangle( position aul, position alr ) : ul(aul), lr(alr) {} 52 52 53 53 /** 54 * Creates a new rectangle given an upper-left position, width, and height.55 * 56 * @param aul The position of the upper-left corner of the rectangle.57 * @param width The width of the rectangle.58 * @param height The height of the rectangle.54 * Creates a new rectangle given an upper-left position, width, and height. 55 * 56 * @param aul The position of the upper-left corner of the rectangle. 57 * @param width The width of the rectangle. 58 * @param height The height of the rectangle. 59 59 */ 60 60 rectangle( position aul, value_type width, value_type height ) : ul(aul), lr(aul + position(width,height)) {} … … 66 66 67 67 /** 68 * Explicit Copy constructor68 * Explicit Copy assignment operator 69 69 */ 70 70 rectangle& operator= (const rectangle& r) { ul = r.ul; lr = r.lr; return *this; } 71 71 72 72 /** 73 * Sets the dimensions of the rectangle without moving the upper-left of the rectangle.74 * 75 * @param d The new dimensions of the rectangle.73 * Sets the dimensions of the rectangle without moving the upper-left of the rectangle. 74 * 75 * @param d The new dimensions of the rectangle. 76 76 */ 77 77 rectangle& dim( dimension d ) { lr = ul + d; return *this; } 78 78 79 79 /** 80 * Moves the rectangle to a new position while maintaining its size.81 * 82 * @param p The new position of the rectangle's upper-left corner.80 * Moves the rectangle to a new position while maintaining its size. 81 * 82 * @param p The new position of the rectangle's upper-left corner. 83 83 */ 84 84 rectangle& pos( position p ) { lr = p + (lr - ul); lr = p; return *this; } 85 85 86 86 /** 87 * Sets the dimensions of the rectangle without moving the upper-left of the rectangle.88 * 89 * @param d The new dimensions of the rectangle.87 * Sets the dimensions of the rectangle without moving the upper-left of the rectangle. 88 * 89 * @param d The new dimensions of the rectangle. 90 90 */ 91 91 void set_dimension( dimension d ) { lr = ul + d; } 92 92 93 93 /** 94 * Moves the rectangle to a new position while maintaining its size.95 * 96 * @param p The new position of the rectangle's upper-left corner.94 * Moves the rectangle to a new position while maintaining its size. 95 * 96 * @param p The new position of the rectangle's upper-left corner. 97 97 */ 98 98 void set_position( position p ) { lr = p + (lr - ul); ul = p; } … … 101 101 position ll() const { return position( ul.x, lr.y ); } 102 102 /** 103 * Gets the dimensions of the rectangle. Synonym for get_size.104 * 105 * @returns The dimensions of the rectangle.106 * @see get_size103 * Gets the dimensions of the rectangle. Synonym for get_size. 104 * 105 * @returns The dimensions of the rectangle. 106 * @see get_size 107 107 */ 108 108 dimension get_dimension() const { return lr - ul; } 109 109 110 110 /** 111 * Gets the position of the upper-left corner of the rectangle.112 * 113 * @returns The position of the rectangle's upper-left corner.111 * Gets the position of the upper-left corner of the rectangle. 112 * 113 * @returns The position of the rectangle's upper-left corner. 114 114 */ 115 115 position get_position() const { return ul; } 116 116 117 117 /** 118 * Gets the dimensions of the rectangle. Synonym for get_dimension.119 * 120 * @returns The dimensions of the rectangle.121 * @see get_dimension118 * Gets the dimensions of the rectangle. Synonym for get_dimension. 119 * 120 * @returns The dimensions of the rectangle. 121 * @see get_dimension 122 122 */ 123 123 dimension get_size() const { return lr - ul; } 124 124 125 125 /** 126 * Gets the center of the rectangle.127 * 128 * @returns The center of the rectangle.126 * Gets the center of the rectangle. 127 * 128 * @returns The center of the rectangle. 129 129 */ 130 130 position get_center() const { return ( lr + ul ) / 2; } 131 131 132 132 /** 133 * Gets the width of the rectangle.134 * 135 * @returns The width of the rectangle.133 * Gets the width of the rectangle. 134 * 135 * @returns The width of the rectangle. 136 136 */ 137 137 value_type get_width() const { return lr.x - ul.x; } 138 138 139 139 /** 140 * Gets the height of the rectangle.141 * 142 * @returns The height of the rectangle.140 * Gets the height of the rectangle. 141 * 142 * @returns The height of the rectangle. 143 143 */ 144 144 value_type get_height() const { return lr.y - ul.y; } 145 145 146 146 /** 147 * Gets the area of the rectangle.148 * 149 * @returns The area of the rectangle.147 * Gets the area of the rectangle. 148 * 149 * @returns The area of the rectangle. 150 150 */ 151 151 value_type get_area() const { return (lr.y - ul.y) * (lr.x - ul.x); } 152 152 153 153 /** 154 * Checks to see if the rectangle is backwards.155 * 156 * @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.154 * Checks to see if the rectangle is backwards. 155 * 156 * @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. 157 157 */ 158 158 bool is_valid() const { return lr.x >= ul.x && lr.y >= ul.y; } 159 159 160 160 /** 161 * Enlarges the rectangle by a given amount. Each side is adjusted by the given amount, e.g. expanding by 1 increases the width and height by 2 each.162 * 163 * @param value The amount to adjust each sides by.161 * Enlarges the rectangle by a given amount. Each side is adjusted by the given amount, e.g. expanding by 1 increases the width and height by 2 each. 162 * 163 * @param value The amount to adjust each sides by. 164 164 */ 165 165 void expand( value_type value ) { position p(value,value); ul -= p; lr += p; } 166 166 167 167 /** 168 * Reduces the rectangle by a given amount. Each side is adjusted by the given amount, e.g. shrinking by 1 decreases the width and height by 2 each.169 * 170 * @param value The amount to adjust each side by.168 * Reduces the rectangle by a given amount. Each side is adjusted by the given amount, e.g. shrinking by 1 decreases the width and height by 2 each. 169 * 170 * @param value The amount to adjust each side by. 171 171 */ 172 172 void shrink( value_type value ) { position p(value,value); ul += p; lr -= p; } 173 173 174 174 /** 175 * Gets a rectangle that is an expanded version of this rectangle.176 * 177 * @param value The amount to adjust each side by.178 * @returns An expanded rectangle.179 * @see expand175 * Gets a rectangle that is an expanded version of this rectangle. 176 * 177 * @param value The amount to adjust each side by. 178 * @returns An expanded rectangle. 179 * @see expand 180 180 */ 181 181 rectangle expanded( int value ) { position p(value,value); return rectangle(ul-p, lr+p); } 182 182 183 183 /** 184 * Gets a rectangle that is a shrunk version of this rectangle.185 * 186 * @param value The amount to adjust each side by.187 * @returns A shrunk rectangle.188 * @see shrink184 * Gets a rectangle that is a shrunk version of this rectangle. 185 * 186 * @param value The amount to adjust each side by. 187 * @returns A shrunk rectangle. 188 * @see shrink 189 189 */ 190 190 rectangle shrinked( int value ) { position p(value,value); return rectangle(ul+p, lr-p); } 191 191 192 192 /** 193 * Shifts the rectangle by a given amount.194 * 195 * @param pos The amount to shift the rectangle by.193 * Shifts the rectangle by a given amount. 194 * 195 * @param pos The amount to shift the rectangle by. 196 196 */ 197 197 rectangle& operator+=( const position& pos ) { ul += pos; lr += pos; return (*this); } 198 198 199 199 /** 200 * Returns a rectangle shifted by a given amount.201 * 202 * @param pos The amount to shift by.203 * @returns The shifted rectangle.200 * Returns a rectangle shifted by a given amount. 201 * 202 * @param pos The amount to shift by. 203 * @returns The shifted rectangle. 204 204 */ 205 205 rectangle operator+( const position& pos ) const { rectangle r(*this); return r += pos; } 206 206 207 207 /** 208 * Shifts the rectangle by a given amount.209 * 210 * @param pos The amount to shift the rectangle by.208 * Shifts the rectangle by a given amount. 209 * 210 * @param pos The amount to shift the rectangle by. 211 211 */ 212 212 rectangle& operator-=( const position& pos ) { ul -= pos; lr -= pos; return (*this); } 213 213 214 214 /** 215 * Returns a rectangle shifted by a given amount.216 * 217 * @oaram pos The amount to shift by.218 * @returns The shifted rectangle.215 * Returns a rectangle shifted by a given amount. 216 * 217 * @param pos The amount to shift by. 218 * @returns The shifted rectangle. 219 219 */ 220 220 rectangle operator-( const position& pos ) const { rectangle r(*this); return r -= pos; } 221 221 222 222 /** 223 * Compares two rectangles to see if they are the same.224 * 225 * @param r The rectangle to compare to.226 * @returns True if the rectangles have the same positions and dimensions, false otherwise.223 * Compares two rectangles to see if they are the same. 224 * 225 * @param r The rectangle to compare to. 226 * @returns True if the rectangles have the same positions and dimensions, false otherwise. 227 227 */ 228 228 bool operator==( const rectangle& r ) const { return r.ul == ul && r.lr == lr; } 229 229 230 230 /** 231 * Compares two rectangles to see if they are different.232 * 233 * @param r The rectangle to compare to.234 * @returns True if the rectangles have different positions or dimensions, false otherwise.231 * Compares two rectangles to see if they are different. 232 * 233 * @param r The rectangle to compare to. 234 * @returns True if the rectangles have different positions or dimensions, false otherwise. 235 235 */ 236 236 bool operator!=( const rectangle& r ) const { return r.ul != ul || r.lr != lr; } 237 237 238 238 /** 239 * Checks if a position is within the bounds of this rectangle.240 * 241 * @param r The position to check.242 * @returns True if the position is inside or on the edge of the rectangle, false otherwise.239 * Checks if a position is within the bounds of this rectangle. 240 * 241 * @param r The position to check. 242 * @returns True if the position is inside or on the edge of the rectangle, false otherwise. 243 243 */ 244 244 bool contains( const position& r ) const{ return lr.y >= r.y && ul.y <= r.y && lr.x >= r.x && ul.x <= r.x; } 245 245 246 246 /** 247 * Checks if a rectangle is within the bounds of this rectangle.248 * 249 * @param r The rectangle to check.250 * @returns True if the entire rectangle to check is inside or on the edge of this rectangle, false otherwise.247 * Checks if a rectangle is within the bounds of this rectangle. 248 * 249 * @param r The rectangle to check. 250 * @returns True if the entire rectangle to check is inside or on the edge of this rectangle, false otherwise. 251 251 */ 252 252 bool contains( const rectangle& r ) const { return contains( r.ul ) && contains( r.lr ); } 253 253 254 254 /** 255 * Checks if another rectangle overlaps this one.256 * 257 * @param r The rectangle to check.258 * @returns True if any part of the rectangle to check overlaps this rectangle, false otherwise.255 * Checks if another rectangle overlaps this one. 256 * 257 * @param r The rectangle to check. 258 * @returns True if any part of the rectangle to check overlaps this rectangle, false otherwise. 259 259 */ 260 260 bool collides( const rectangle& r ) const { return lr.y > r.ul.y && ul.y < r.lr.y && lr.x > r.ul.x && ul.x < r.lr.x; } 261 261 262 262 /** 263 * Limits the region of the rectangle to the inidicated rectangle.264 * 265 * @param r The rectangle that this rectangle is confined to.266 * @returns True if the rectangle was changed, false otherwise.263 * Limits the region of the rectangle to the inidicated rectangle. 264 * 265 * @param r The rectangle that this rectangle is confined to. 266 * @returns True if the rectangle was changed, false otherwise. 267 267 */ 268 268 bool clamp_to( const rectangle& r ) … … 276 276 277 277 /** 278 * Limits the size of the rectangle to the given rectangle's size.279 * 280 * @param r The rectangle representing the maximum dimensions this rectangle can be.281 * @returns True if the rectangle needed to be resized, false otherwise.278 * Limits the size of the rectangle to the given rectangle's size. 279 * 280 * @param r The rectangle representing the maximum dimensions this rectangle can be. 281 * @returns True if the rectangle needed to be resized, false otherwise. 282 282 */ 283 283 bool constrain_to( const rectangle& r ) … … 290 290 291 291 /** 292 * Fixes an invalid rectangle.292 * Fixes an invalid rectangle. 293 293 */ 294 294 void repair() … … 299 299 300 300 /** 301 * Expands the rectangle to just include the given point.302 * 303 * @param p The point to include in the rectangle.301 * Expands the rectangle to just include the given point. 302 * 303 * @param p The point to include in the rectangle. 304 304 */ 305 305 void include_point( position p ) -
trunk/nv/singleton.hh
r110 r132 19 19 { 20 20 /** 21 * singleton22 * @brief Represents an accessible static object that will only have one instance.21 * singleton 22 * @brief Represents an accessible static object that will only have one instance. 23 23 */ 24 24 template <class T> … … 31 31 32 32 /** 33 * Creates the single instance if one doesn't already exist.33 * Creates the single instance if one doesn't already exist. 34 34 */ 35 35 singleton() … … 40 40 41 41 /** 42 * Destroys the instance.42 * Destroys the instance. 43 43 */ 44 44 ~singleton() … … 50 50 public: 51 51 /** 52 * Checks to see if the instance exists.52 * Checks to see if the instance exists. 53 53 * 54 * @returns True if this singleton has an instance assigned, false otherwise.54 * @returns True if this singleton has an instance assigned, false otherwise. 55 55 */ 56 56 static bool is_valid() … … 60 60 61 61 /** 62 * Returns the pointer to the instance.62 * Returns the pointer to the instance. 63 63 * 64 * @returns The pointer to the instance.64 * @returns The pointer to the instance. 65 65 */ 66 66 static T *pointer() … … 70 70 } 71 71 /** 72 * Returns the object referenced by this singleton.72 * Returns the object referenced by this singleton. 73 73 */ 74 74 static T &reference() … … 84 84 85 85 /** 86 * auto_singleton87 * @brief Represents a singleton that automatically creates an instance if one doesn't already exist.86 * auto_singleton 87 * @brief Represents a singleton that automatically creates an instance if one doesn't already exist. 88 88 */ 89 89 template <class T> … … 92 92 public: 93 93 /** 94 * Returns the pointer to the instance. Makes an instance if one doesn't already exist.94 * Returns the pointer to the instance. Makes an instance if one doesn't already exist. 95 95 */ 96 96 static T *pointer() … … 104 104 105 105 /** 106 * Returns the object referenced by this singleton. Makes an instance if one doesn't already exist.106 * Returns the object referenced by this singleton. Makes an instance if one doesn't already exist. 107 107 */ 108 108 static T &reference() -
trunk/nv/string.hh
r64 r132 42 42 * value passed. 43 43 */ 44 template <> 44 45 inline string to_string( const string& value) 45 46 { … … 91 92 * value passed. 92 93 */ 94 template <> 93 95 inline void from_string( const string& vin, string& vout ) 94 96 { -
trunk/nv/uid.hh
r110 r132 24 24 25 25 /** 26 * Creates a new instance of the unique indentifer store.26 * Creates a new instance of the unique indentifer store. 27 27 */ 28 28 uid_store(); 29 29 30 30 /** 31 * Gets the object with the specified ID.31 * Gets the object with the specified ID. 32 32 * 33 * @param auid The ID to fetch.34 * @returns The stored object for that ID.33 * @param auid The ID to fetch. 34 * @returns The stored object for that ID. 35 35 */ 36 36 object* get( uid auid ) const; 37 37 38 38 /** 39 * Removes the object with the specified ID.39 * Removes the object with the specified ID. 40 40 * 41 * @param auid The ID to remove.42 * @returns True if the removal was successful, false if the ID didn't exist.41 * @param auid The ID to remove. 42 * @returns True if the removal was successful, false if the ID didn't exist. 43 43 */ 44 44 bool remove( uid auid ); 45 45 46 46 /** 47 * Adds an object to the store assigned to the indicated ID.47 * Adds an object to the store assigned to the indicated ID. 48 48 * 49 * @param o The object to add to the store.50 * @param auid The ID to assign to the object.49 * @param o The object to add to the store. 50 * @param auid The ID to assign to the object. 51 51 */ 52 52 void insert( object* o, uid auid ); 53 53 54 54 /** 55 * Adds an object to the store and assigns it a new ID.55 * Adds an object to the store and assigns it a new ID. 56 56 * 57 * @param o The object to add to the store.58 * @returns The ID the object was store under.57 * @param o The object to add to the store. 58 * @returns The ID the object was store under. 59 59 */ 60 60 uid insert( object* o ); 61 61 62 62 /** 63 * Gets the next available ID.63 * Gets the next available ID. 64 64 * 65 * @returns The next ID in the store.65 * @returns The next ID in the store. 66 66 */ 67 67 uid request_uid(); 68 68 69 69 /** 70 * Destroys the unique identifier store.70 * Destroys the unique identifier store. 71 71 */ 72 72 ~uid_store(); 73 73 74 74 /** 75 * Retrieves an object and casts it to the specified type.75 * Retrieves an object and casts it to the specified type. 76 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.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 80 */ 81 81 template< typename T >
Note: See TracChangeset
for help on using the changeset viewer.