Made properties work
This commit is contained in:
@@ -677,10 +677,6 @@
|
|||||||
<Filter
|
<Filter
|
||||||
Name="PropertiesV2"
|
Name="PropertiesV2"
|
||||||
>
|
>
|
||||||
<File
|
|
||||||
RelativePath=".\src\source\PropertiesV2\BaseProperty.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\source\PropertiesV2\BoolProperty.cpp"
|
RelativePath=".\src\source\PropertiesV2\BoolProperty.cpp"
|
||||||
>
|
>
|
||||||
@@ -970,10 +966,6 @@
|
|||||||
<Filter
|
<Filter
|
||||||
Name="PropertiesV2"
|
Name="PropertiesV2"
|
||||||
>
|
>
|
||||||
<File
|
|
||||||
RelativePath=".\src\include\PropertiesV2\BaseProperty.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\PropertiesV2\BoolProperty.h"
|
RelativePath=".\src\include\PropertiesV2\BoolProperty.h"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
//Deprecated
|
//Deprecated
|
||||||
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
|
|
||||||
virtual std::vector<BaseProperty> collectProperties();
|
virtual std::vector<Property *> collectProperties();
|
||||||
|
|
||||||
int listicon;
|
int listicon;
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <string>
|
|
||||||
#include <G3DAll.h>
|
|
||||||
#include "propertyGrid.h"
|
|
||||||
class Instance;
|
|
||||||
|
|
||||||
/**
|
|
||||||
DO NOT INHERIT FROM THIS CLASS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
INHERIT FROM PROPERTY INSTEAD
|
|
||||||
*/
|
|
||||||
class BaseProperty
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BaseProperty(LPSTR name, LPSTR desc, LPSTR catalog, Instance * owner) {
|
|
||||||
_name = name;
|
|
||||||
_desc = desc;
|
|
||||||
_owner = owner;
|
|
||||||
_catalog = catalog;
|
|
||||||
}
|
|
||||||
~BaseProperty(void){};
|
|
||||||
|
|
||||||
virtual PROPGRIDITEM getPropGridItem();
|
|
||||||
virtual void setProperty(LPPROPGRIDITEM &pItem);
|
|
||||||
protected:
|
|
||||||
Instance* _owner;
|
|
||||||
LPSTR _name;
|
|
||||||
LPSTR _desc;
|
|
||||||
LPSTR _catalog;
|
|
||||||
};
|
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Property.h"
|
#include "Property.h"
|
||||||
|
|
||||||
class BoolProperty : public Property<bool>
|
class BoolProperty : public Property
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef void (Instance::*instanceSetter)(bool);
|
typedef void (Instance::*instanceSetter)(bool);
|
||||||
//Win32 why
|
//Win32 why
|
||||||
~BoolProperty(void){};
|
~BoolProperty(void);
|
||||||
BoolProperty(LPSTR name, LPSTR desc, LPSTR catalog, bool value, Instance * owner, instanceSetter setterFunc)
|
BoolProperty(LPSTR name, LPSTR desc, LPSTR catalog, bool value, Instance * owner, instanceSetter setterFunc)
|
||||||
:Property(name, desc, catalog, value, owner)
|
:Property(name, desc, catalog, (void*)value, owner)
|
||||||
{
|
{
|
||||||
this->setterFunc = setterFunc;
|
this->setterFunc = setterFunc;
|
||||||
}
|
}
|
||||||
const void setValue(bool val){
|
const void setValue(bool val){
|
||||||
(_owner->*setterFunc)(val);
|
(_owner->*setterFunc)(val);
|
||||||
_value = val;
|
_value = (void *)val;
|
||||||
}
|
}
|
||||||
PROPGRIDITEM getPropGridItem();
|
PROPGRIDITEM getPropGridItem();
|
||||||
void setProperty(LPPROPGRIDITEM &pItem);
|
void setProperty(LPPROPGRIDITEM &pItem);
|
||||||
|
|||||||
@@ -1,21 +1,35 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "PropertiesV2/BaseProperty.h"
|
#include <G3DAll.h>
|
||||||
|
#include "propertyGrid.h"
|
||||||
|
|
||||||
template <typename T>
|
class Instance;
|
||||||
class Property : public BaseProperty
|
|
||||||
|
class Property
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Property(LPSTR name, LPSTR desc, LPSTR catalog, T value, Instance * owner)
|
Property(LPSTR name, LPSTR desc, LPSTR catalog, Instance * owner){
|
||||||
:BaseProperty(name, desc, catalog, owner)
|
_name = name;
|
||||||
{
|
_desc = desc;
|
||||||
|
_catalog = catalog;
|
||||||
|
_owner = owner;
|
||||||
|
}
|
||||||
|
Property(LPSTR name, LPSTR desc, LPSTR catalog, void* value, Instance * owner){
|
||||||
|
_name = name;
|
||||||
|
_desc = desc;
|
||||||
|
_catalog = catalog;
|
||||||
|
_owner = owner;
|
||||||
_value = value;
|
_value = value;
|
||||||
}
|
}
|
||||||
~Property(void){};
|
~Property(void){}
|
||||||
const T getValue() {
|
const void* getValue() {
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
virtual PROPGRIDITEM getPropGridItem();
|
virtual PROPGRIDITEM getPropGridItem();
|
||||||
virtual void setProperty(LPPROPGRIDITEM &pItem);
|
virtual void setProperty(LPPROPGRIDITEM &pItem);
|
||||||
protected:
|
protected:
|
||||||
T _value;
|
Instance* _owner;
|
||||||
|
LPSTR _name;
|
||||||
|
LPSTR _desc;
|
||||||
|
LPSTR _catalog;
|
||||||
|
void* _value;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Property.h"
|
#include "Property.h"
|
||||||
|
|
||||||
class StringProperty : public Property<std::string>
|
class StringProperty : public Property
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef void (Instance::*instanceSetter)(std::string);
|
typedef void (Instance::*instanceSetter)(std::string);
|
||||||
~StringProperty(void){};
|
~StringProperty(void){};
|
||||||
StringProperty(LPSTR name, LPSTR desc, LPSTR catalog, std::string value, Instance * owner, instanceSetter setterFunc)
|
StringProperty(LPSTR name, LPSTR desc, LPSTR catalog, std::string value, Instance * owner, instanceSetter setterFunc)
|
||||||
:Property(name, desc, catalog, value, owner)
|
:Property(name, desc, catalog, &_value, owner)
|
||||||
{
|
{
|
||||||
|
this->_value = value;
|
||||||
this->setterFunc = setterFunc;
|
this->setterFunc = setterFunc;
|
||||||
}
|
}
|
||||||
const void setValue(std::string val){
|
const void setValue(std::string val){
|
||||||
@@ -18,5 +19,6 @@ public:
|
|||||||
PROPGRIDITEM getPropGridItem();
|
PROPGRIDITEM getPropGridItem();
|
||||||
void setProperty(LPPROPGRIDITEM &pItem);
|
void setProperty(LPPROPGRIDITEM &pItem);
|
||||||
private:
|
private:
|
||||||
|
std::string _value;
|
||||||
instanceSetter setterFunc;
|
instanceSetter setterFunc;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -80,10 +80,10 @@ std::vector<PROPGRIDITEM> Instance::getProperties()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<BaseProperty> Instance::collectProperties()
|
std::vector<Property *> Instance::collectProperties()
|
||||||
{
|
{
|
||||||
std::vector<BaseProperty> properties;
|
std::vector<Property *> properties;
|
||||||
properties.push_back(StringProperty("Name", "The name of this instance", "Properties", name, this, &Instance::setName));
|
properties.push_back(new StringProperty("Name", "The name of this instance", "Properties", name, this, &Instance::setName));
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
#include "PropertiesV2/BaseProperty.h"
|
|
||||||
|
|
||||||
PROPGRIDITEM BaseProperty::getPropGridItem(){
|
|
||||||
PROPGRIDITEM pItem;
|
|
||||||
PropGrid_ItemInit(pItem);
|
|
||||||
pItem.lpszCatalog=_catalog;
|
|
||||||
pItem.lpszPropName=_name;
|
|
||||||
pItem.lpszPropDesc=_desc;
|
|
||||||
pItem.iItemType=PIT_EDIT;
|
|
||||||
return pItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseProperty::setProperty(LPPROPGRIDITEM &pItem){
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@ PROPGRIDITEM BoolProperty::getPropGridItem(){
|
|||||||
pItem.lpszCatalog=_catalog;
|
pItem.lpszCatalog=_catalog;
|
||||||
pItem.lpszPropName=_name;
|
pItem.lpszPropName=_name;
|
||||||
pItem.lpszPropDesc=_desc;
|
pItem.lpszPropDesc=_desc;
|
||||||
pItem.lpCurValue=_value;
|
pItem.lpCurValue=_value > 0;
|
||||||
pItem.iItemType=PIT_CHECK;
|
pItem.iItemType=PIT_CHECK;
|
||||||
return pItem;
|
return pItem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
#include "PropertiesV2/Property.h"
|
#include "PropertiesV2/Property.h"
|
||||||
|
|
||||||
template <typename T>
|
PROPGRIDITEM Property::getPropGridItem(){
|
||||||
PROPGRIDITEM Property<T>::getPropGridItem(){
|
|
||||||
PROPGRIDITEM pItem;
|
PROPGRIDITEM pItem;
|
||||||
PropGrid_ItemInit(pItem);
|
PropGrid_ItemInit(pItem);
|
||||||
pItem.lpszCatalog=_catalog;
|
pItem.lpszCatalog=_catalog;
|
||||||
pItem.lpszPropName=_name;
|
pItem.lpszPropName=_name;
|
||||||
pItem.lpszPropDesc=_desc;
|
pItem.lpszPropDesc=_desc;
|
||||||
pItem.lpCurValue="invalid";
|
|
||||||
pItem.iItemType=PIT_EDIT;
|
pItem.iItemType=PIT_EDIT;
|
||||||
return pItem;
|
return pItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
void Property::setProperty(LPPROPGRIDITEM &pItem){
|
||||||
void Property<T>::setProperty(LPPROPGRIDITEM &pItem){
|
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "strsafe.h"
|
#include "strsafe.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
std::vector<PROPGRIDITEM> prop;
|
std::vector<Property*> prop;
|
||||||
std::vector<Instance*> children;
|
std::vector<Instance*> children;
|
||||||
Instance * selectedInstance;
|
Instance * selectedInstance;
|
||||||
Instance * parent = NULL;
|
Instance * parent = NULL;
|
||||||
@@ -349,13 +349,13 @@ void PropertyWindow::UpdateSelected(std::vector<Instance *> instances)
|
|||||||
}
|
}
|
||||||
Instance * instance = instances[0];
|
Instance * instance = instances[0];
|
||||||
PropGrid_ResetContent(_propGrid);
|
PropGrid_ResetContent(_propGrid);
|
||||||
prop = instance->getProperties();
|
prop = instance->collectProperties();
|
||||||
//if (selectedInstance != instance)
|
//if (selectedInstance != instance)
|
||||||
{
|
{
|
||||||
selectedInstance = instance;
|
selectedInstance = instance;
|
||||||
for(size_t i = 0; i < prop.size(); i++)
|
for(size_t i = 0; i < prop.size(); i++)
|
||||||
{
|
{
|
||||||
::PROPGRIDITEM item = prop.at(i);
|
::PROPGRIDITEM item = prop.at(i)->getPropGridItem();
|
||||||
PropGrid_AddItem(_propGrid, &item);
|
PropGrid_AddItem(_propGrid, &item);
|
||||||
//PRGP propgp;
|
//PRGP propgp;
|
||||||
//propgp.instance = instance;
|
//propgp.instance = instance;
|
||||||
|
|||||||
Reference in New Issue
Block a user