Merge pull request #307 from RobLoach/getter-setters

Update a few get/set values
This commit is contained in:
Rob Loach
2024-03-14 11:26:11 -04:00
committed by GitHub
11 changed files with 70 additions and 53 deletions

View File

@@ -48,11 +48,11 @@ class AudioStream : public ::AudioStream {
Unload();
}
GETTERSETTER(rAudioBuffer *, Buffer, buffer)
GETTERSETTER(rAudioProcessor *, Processor, processor)
GETTERSETTER(unsigned int, SampleRate, sampleRate)
GETTERSETTER(unsigned int, SampleSize, sampleSize)
GETTERSETTER(unsigned int, Channels, channels)
GETTER(rAudioBuffer *, Buffer, buffer)
GETTER(rAudioProcessor *, Processor, processor)
GETTER(unsigned int, SampleRate, sampleRate)
GETTER(unsigned int, SampleSize, sampleSize)
GETTER(unsigned int, Channels, channels)
AudioStream& operator=(const ::AudioStream& stream) {
set(stream);

View File

@@ -39,9 +39,9 @@ class AutomationEventList : public ::AutomationEventList {
Unload();
}
GETTERSETTER(unsigned int, Capacity, capacity)
GETTERSETTER(unsigned int, Count, count)
GETTERSETTER(AutomationEvent*, Events, events)
GETTER(unsigned int, Capacity, capacity)
GETTER(unsigned int, Count, count)
GETTER(AutomationEvent*, Events, events)
AutomationEventList& operator=(const ::AutomationEventList& other) {
set(other);

View File

@@ -108,11 +108,11 @@ class Font : public ::Font {
}
}
GETTERSETTER(int, BaseSize, baseSize)
GETTERSETTER(int, GlyphCount, glyphCount)
GETTERSETTER(int, GlyphPadding, glyphPadding)
GETTERSETTER(::Rectangle*, Recs, recs)
GETTERSETTER(::GlyphInfo*, Glyphs, glyphs)
GETTER(int, BaseSize, baseSize)
GETTER(int, GlyphCount, glyphCount)
GETTER(int, GlyphPadding, glyphPadding)
GETTER(::Rectangle*, Recs, recs)
GETTER(::GlyphInfo*, Glyphs, glyphs)
/**
* Get the texture atlas containing the glyphs.

View File

@@ -316,11 +316,29 @@ class Image : public ::Image {
}
}
GETTERSETTER(void*, Data, data)
GETTERSETTER(int, Width, width)
GETTERSETTER(int, Height, height)
GETTERSETTER(int, Mipmaps, mipmaps)
GETTERSETTER(int, Format, format)
GETTER(void*, Data, data)
GETTER(int, Width, width)
GETTER(int, Height, height)
GETTER(int, Mipmaps, mipmaps)
GETTER(int, Format, format)
/**
* Set the width of the image canvas.
*
* @see ResizeCanvas
*/
void SetWidth(int width, int offsetX = 0, int offsetY = 0, ::Color fill = {255, 255, 255, 255}) {
ResizeCanvas(width, height, offsetX, offsetY, fill);
}
/**
* Set the height of the image canvas.
*
* @see ResizeCanvas
*/
void SetHeight(int height, int offsetX = 0, int offsetY = 0, ::Color fill = {255, 255, 255, 255}) {
ResizeCanvas(width, height, offsetX, offsetY, fill);
}
/**
* Retrieve the width and height of the image.

View File

@@ -60,11 +60,11 @@ class Music : public ::Music {
Unload();
}
GETTERSETTER(::AudioStream, Stream, stream)
GETTERSETTER(unsigned int, FrameCount, frameCount)
GETTER(::AudioStream, Stream, stream)
GETTER(unsigned int, FrameCount, frameCount)
GETTERSETTER(bool, Looping, looping)
GETTERSETTER(int, CtxType, ctxType)
GETTERSETTER(void*, CtxData, ctxData)
GETTER(int, CtxType, ctxType)
GETTER(void*, CtxData, ctxData)
Music& operator=(const ::Music& music) {
set(music);

View File

@@ -43,7 +43,7 @@ class RenderTexture : public ::RenderTexture {
other.depth = {};
}
GETTERSETTER(unsigned int, Id, id)
GETTER(unsigned int, Id, id)
/**
* Get the color buffer attachment texture.

View File

@@ -62,8 +62,8 @@ class Shader : public ::Shader {
return ::LoadShaderFromMemory(vsCode, fsCode);
}
GETTERSETTER(unsigned int, Id, id)
GETTERSETTER(int*, Locs, locs)
GETTER(unsigned int, Id, id)
GETTER(int*, Locs, locs)
Shader& operator=(const ::Shader& shader) {
set(shader);

View File

@@ -59,8 +59,8 @@ class Sound : public ::Sound {
Unload();
}
GETTERSETTER(unsigned int, FrameCount, frameCount)
GETTERSETTER(::AudioStream, Stream, stream)
GETTER(unsigned int, FrameCount, frameCount)
GETTER(::AudioStream, Stream, stream)
Sound& operator=(Sound&& other) noexcept {
if (this == &other) {

View File

@@ -80,11 +80,11 @@ class TextureUnmanaged : public ::Texture {
// Nothing.
}
GETTERSETTER(unsigned int, Id, id)
GETTERSETTER(int, Width, width)
GETTERSETTER(int, Height, height)
GETTERSETTER(int, Mipmaps, mipmaps)
GETTERSETTER(int, Format, format)
GETTER(unsigned int, Id, id)
GETTER(int, Width, width)
GETTER(int, Height, height)
GETTER(int, Mipmaps, mipmaps)
GETTER(int, Format, format)
TextureUnmanaged& operator=(const ::Texture& texture) {
set(texture);

View File

@@ -65,11 +65,11 @@ class Wave : public ::Wave {
Unload();
}
GETTERSETTER(unsigned int, FrameCount, frameCount)
GETTERSETTER(unsigned int, SampleRate, sampleRate)
GETTERSETTER(unsigned int, SampleSize, sampleSize)
GETTERSETTER(unsigned int, Channels, channels)
GETTERSETTER(void *, Data, data)
GETTER(unsigned int, FrameCount, frameCount)
GETTER(unsigned int, SampleRate, sampleRate)
GETTER(unsigned int, SampleSize, sampleSize)
GETTER(unsigned int, Channels, channels)
GETTER(void *, Data, data)
Wave& operator=(const ::Wave& wave) {
set(wave);

View File

@@ -4,24 +4,9 @@
#ifndef RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_
#define RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_
#ifndef GETTERSETTER
/**
* A utility to build get and set methods on top of a property.
*
* @param type The type of the property.
* @param method The human-readable name for the method.
* @param name The machine-readable name of the property.
*/
#define GETTERSETTER(type, method, name) \
/** Retrieves the name value for the object. @return The name value of the object. */ \
type Get##method() const { return name; } \
/** Sets the name value for the object. @param value The value of which to set name to. */ \
void Set##method(type value) { name = value; }
#endif
#ifndef GETTER
/**
* A utility to build get methods on top of a property.
* A utility to build a get method on top of a property.
*
* @param type The type of the property.
* @param method The human-readable name for the method.
@@ -32,4 +17,18 @@
type Get##method() const { return name; }
#endif
#ifndef GETTERSETTER
/**
* A utility to build get and set methods on top of a property.
*
* @param type The type of the property.
* @param method The human-readable name for the method.
* @param name The machine-readable name of the property.
*/
#define GETTERSETTER(type, method, name) \
GETTER(type, method, name) \
/** Sets the name value for the object. @param value The value of which to set name to. */ \
void Set##method(type value) { name = value; }
#endif
#endif // RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_