summaryrefslogtreecommitdiff
path: root/src/editor/properties.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/editor/properties.h')
-rw-r--r--src/editor/properties.h54
1 files changed, 46 insertions, 8 deletions
diff --git a/src/editor/properties.h b/src/editor/properties.h
index d663a6b..ef59b0d 100644
--- a/src/editor/properties.h
+++ b/src/editor/properties.h
@@ -5,14 +5,15 @@
#if IS_EDITOR
#include <math.h>
#include "../util/string.h"
+#include "../util/fnv.h"
#define EPROP( _type, name, value, display ) \
_type name = value; \
- EDITOR_PROP name##_prop{ &name, eprop_type<_type>(), display, this, 0 }
+ EDITOR_PROP name##_prop{ &name, eprop_type<_type>(), display, this, sizeof(_type), 0 }
#define EPROP_RO( _type, name, value, display ) \
_type name = value; \
- EDITOR_PROP name##_prop{ &name, eprop_type<_type>(), display, this, 1 }
+ EDITOR_PROP name##_prop{ &name, eprop_type<_type>(), display, this, sizeof(_type), 1 }
#define EPROP_RANGED( _type, name, value, display, _min, _max ) \
_type name = value; \
@@ -23,6 +24,7 @@
this, \
_min, \
_max, \
+ sizeof(_type), \
0 \
}
@@ -34,6 +36,7 @@
display, \
step, \
this, \
+ sizeof(_type), \
0 \
}
@@ -47,6 +50,7 @@
this, \
min, \
max, \
+ sizeof(_type), \
0 \
}
@@ -90,13 +94,15 @@ concept __eobject_base = __is_base_of(EOBJECT, T);
// editor object property
struct EDITOR_PROP {
- EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, struct EOBJECT* _parent, U8 _readonly = 0 ) {
+ EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, struct EOBJECT* _parent, U32 _size, U8 _readonly = 0 ) {
type = _type;
displayname = _displayname;
min = -INFINITY;
max = INFINITY;
step = 0;
readonly = _readonly;
+ hash = fnv1a( _displayname );
+ size = _size;
U64 _this = (U64)this;
U64 pdata = (U64)_pdata;
@@ -109,13 +115,15 @@ struct EDITOR_PROP {
dataoff = offset;
}
- EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, F32 _step, struct EOBJECT* _parent, U8 _readonly = 0 ) {
+ EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, F32 _step, struct EOBJECT* _parent, U32 _size, U8 _readonly = 0 ) {
type = _type;
displayname = _displayname;
min = -INFINITY;
max = INFINITY;
step = _step;
readonly = _readonly;
+ hash = fnv1a( _displayname );
+ size = _size;
U64 _this = (U64)this;
U64 pdata = (U64)_pdata;
@@ -128,13 +136,15 @@ struct EDITOR_PROP {
dataoff = offset;
}
- EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, struct EOBJECT* _parent, F32 _min, F32 _max, U8 _readonly = 0 ) {
+ EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, struct EOBJECT* _parent, F32 _min, F32 _max, U32 _size, U8 _readonly = 0 ) {
type = _type;
displayname = _displayname;
min = _min;
max = _max;
step = 0;
readonly = _readonly;
+ hash = fnv1a( _displayname );
+ size = _size;
U64 _this = (U64)this;
U64 pdata = (U64)_pdata;
@@ -147,13 +157,15 @@ struct EDITOR_PROP {
dataoff = offset;
}
- EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, F32 _step, struct EOBJECT* _parent, F32 _min, F32 _max, U8 _readonly = 0 ) {
+ EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, F32 _step, struct EOBJECT* _parent, F32 _min, F32 _max, U32 _size, U8 _readonly = 0 ) {
type = _type;
displayname = _displayname;
min = _min;
max = _max;
step = _step;
readonly = _readonly;
+ hash = fnv1a( _displayname );
+ size = _size;
U64 _this = (U64)this;
U64 pdata = (U64)_pdata;
@@ -173,6 +185,8 @@ struct EDITOR_PROP {
F64 max{ INFINITY };
F32 step;
U8 readonly;
+ FNV1A hash;
+ U32 size;
template <typename T> struct __eprop_type {
static const U8 type = EPROP_INVALID;
@@ -209,6 +223,18 @@ inline void* eprop_ptr( EDITOR_PROP* prop ) {
return (void*)( (U64)prop - prop->dataoff);
}
+inline EDITOR_PROP* eprop_from_name( EOBJECT* obj, STR name ) {
+ FNV1A fnv = fnv1a( name );
+
+ for( auto& it : obj->eprops ) {
+ EDITOR_PROP* prop = eprop_from_ref( obj, it );
+ if( fnv == prop->hash )
+ return prop;
+ }
+
+ return 0;
+}
+
template <typename T>
const U8 eprop_type() {
return EDITOR_PROP::__eprop_type<T>::type;
@@ -216,6 +242,18 @@ const U8 eprop_type() {
#else
struct EOBJECT {};
-#define EPROP( type, name, value, displayname ) \
- type name{ value };
+#define EPROP( _type, name, value, display ) \
+ _type name = value;
+
+#define EPROP_RO( _type, name, value, display ) \
+ _type name = value;
+
+#define EPROP_RANGED( _type, name, value, display, _min, _max ) \
+ _type name = value;
+
+#define EPROP_STEP( _type, name, value, display, step ) \
+ _type name = value;
+
+#define EPROP_RANGED_STEP( _type, name, value, display, min, max, step ) \
+ _type name = value;
#endif