Make RenderParams fields optional
This commit is contained in:
1 parent
1475434c4c
commit
bf09c094e1
3 files changed
+29
-7
No files matched your search
+1
-1
@@ -139,7 +139,7 @@ int Cli::run(int argc, char * argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool parse_size(const char * flag, const char * value, size_t * out)
|
||||
static bool parse_size(const char * flag, const char * value, opt<size_t> * out)
|
||||
{
|
||||
bool valid = value[0] != '\0';
|
||||
for (const char * c = value; *c != '\0'; c++)
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
#include <fart/RenderParams.h>
|
||||
|
||||
RenderParams::RenderParams()
|
||||
void RenderParams::merge(const RenderParams & other)
|
||||
{
|
||||
width = 800;
|
||||
height = 600;
|
||||
if (!width)
|
||||
{
|
||||
width = other.width;
|
||||
}
|
||||
if (!height)
|
||||
{
|
||||
height = other.height;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderParams::apply_defaults()
|
||||
{
|
||||
if (!width)
|
||||
{
|
||||
width = 800u;
|
||||
}
|
||||
if (!height)
|
||||
{
|
||||
height = 600u;
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,12 @@
|
||||
|
||||
struct RenderParams
|
||||
{
|
||||
size_t width = 0u;
|
||||
size_t height = 0u;
|
||||
opt<size_t> width;
|
||||
opt<size_t> height;
|
||||
|
||||
RenderParams();
|
||||
/* Set each field that is not already set to the value from other. */
|
||||
void merge(const RenderParams & other);
|
||||
|
||||
/* Fill in any unset fields with default values. */
|
||||
void apply_defaults();
|
||||
};
|
||||
Reference in new issue
Block a user