|
@@ -353,6 +353,7 @@ PropProp::~PropProp() {
|
|
|
ButtonProp::ButtonProp(const String &caption) : PropProp("", "ButtonProp") {
|
|
ButtonProp::ButtonProp(const String &caption) : PropProp("", "ButtonProp") {
|
|
|
button = new UIButton(caption, 100);
|
|
button = new UIButton(caption, 100);
|
|
|
addChild(button);
|
|
addChild(button);
|
|
|
|
|
+ setHeight(25);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ButtonProp::~ButtonProp() {
|
|
ButtonProp::~ButtonProp() {
|
|
@@ -588,6 +589,13 @@ CustomProp::CustomProp(String key, String value) : PropProp("", "Custom") {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void CustomProp::setPropWidth(Number width) {
|
|
|
|
|
+ Number halfWidth = (width-PROP_PADDING-10) * 0.5;
|
|
|
|
|
+ keyEntry->Resize(halfWidth, keyEntry->getHeight());
|
|
|
|
|
+ valueEntry->Resize(halfWidth, valueEntry->getHeight());
|
|
|
|
|
+ valueEntry->setPositionX(keyEntry->getPosition().x + halfWidth);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
CustomProp::~CustomProp() {
|
|
CustomProp::~CustomProp() {
|
|
|
keyEntry->removeAllHandlersForListener(this);
|
|
keyEntry->removeAllHandlersForListener(this);
|
|
|
valueEntry->removeAllHandlersForListener(this);
|
|
valueEntry->removeAllHandlersForListener(this);
|
|
@@ -1925,22 +1933,18 @@ void RenderTargetsSheet::handleEvent(Event *event) {
|
|
|
|
|
|
|
|
|
|
|
|
|
EntityPropSheet::EntityPropSheet() : PropSheet("CUSTOM PROPERTIES", "entityProps"){
|
|
EntityPropSheet::EntityPropSheet() : PropSheet("CUSTOM PROPERTIES", "entityProps"){
|
|
|
-
|
|
|
|
|
- propHeight = 75;
|
|
|
|
|
-
|
|
|
|
|
- addButton = new UIButton("Add Property", 150);
|
|
|
|
|
- addButton->addEventListener(this, UIEvent::CLICK_EVENT);
|
|
|
|
|
- contents->addChild(addButton);
|
|
|
|
|
- addButton->setPosition(15, 35);
|
|
|
|
|
|
|
|
|
|
|
|
+ addButtonProp = new ButtonProp("Add Property");
|
|
|
|
|
+ addProp(addButtonProp);
|
|
|
|
|
+ addButtonProp->getButton()->addEventListener(this, UIEvent::CLICK_EVENT);
|
|
|
|
|
+
|
|
|
customUndoHandler = true;
|
|
customUndoHandler = true;
|
|
|
|
|
|
|
|
entity = NULL;
|
|
entity = NULL;
|
|
|
- lastEntity = NULL;
|
|
|
|
|
|
|
|
|
|
lastNumProps = 0;
|
|
lastNumProps = 0;
|
|
|
-
|
|
|
|
|
removeIndex = -1;
|
|
removeIndex = -1;
|
|
|
|
|
+ enabled = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void EntityPropSheet::applyPropActionData(PolycodeEditorPropActionData *data) {
|
|
void EntityPropSheet::applyPropActionData(PolycodeEditorPropActionData *data) {
|
|
@@ -1960,7 +1964,7 @@ void EntityPropSheet::handleEvent(Event *event) {
|
|
|
if(!entity)
|
|
if(!entity)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- if(event->getDispatcher() == addButton && event->getEventType() == "UIEvent") {
|
|
|
|
|
|
|
+ if(event->getDispatcher() == addButtonProp->getButton() && event->getEventType() == "UIEvent") {
|
|
|
PolycodeEditorPropActionData *beforeData = PropDataEntity(entity);
|
|
PolycodeEditorPropActionData *beforeData = PropDataEntity(entity);
|
|
|
entity->entityProps.push_back(EntityProp());
|
|
entity->entityProps.push_back(EntityProp());
|
|
|
refreshProps();
|
|
refreshProps();
|
|
@@ -1974,13 +1978,13 @@ void EntityPropSheet::handleEvent(Event *event) {
|
|
|
if(event->getDispatcher() == props[i] && event->getEventType() == "") {
|
|
if(event->getDispatcher() == props[i] && event->getEventType() == "") {
|
|
|
switch(event->getEventCode()) {
|
|
switch(event->getEventCode()) {
|
|
|
case Event::CANCEL_EVENT:
|
|
case Event::CANCEL_EVENT:
|
|
|
- removeIndex = i;
|
|
|
|
|
|
|
+ removeIndex = i-1;
|
|
|
break;
|
|
break;
|
|
|
case Event::CHANGE_EVENT:
|
|
case Event::CHANGE_EVENT:
|
|
|
PolycodeEditorPropActionData *beforeData = PropDataEntity(entity);
|
|
PolycodeEditorPropActionData *beforeData = PropDataEntity(entity);
|
|
|
- if(i < entity->entityProps.size()) {
|
|
|
|
|
- entity->entityProps[i].propName = ((CustomProp*)props[i])->getKey();
|
|
|
|
|
- entity->entityProps[i].propValue = ((CustomProp*)props[i])->getValue();
|
|
|
|
|
|
|
+ if(i-1 < entity->entityProps.size()) {
|
|
|
|
|
+ entity->entityProps[i-1].propName = ((CustomProp*)props[i])->getKey();
|
|
|
|
|
+ entity->entityProps[i-1].propValue = ((CustomProp*)props[i])->getValue();
|
|
|
}
|
|
}
|
|
|
PolycodeEditorPropActionData *afterData = PropDataEntity(entity);
|
|
PolycodeEditorPropActionData *afterData = PropDataEntity(entity);
|
|
|
PropEvent *propEvent = new PropEvent(NULL, this, beforeData, afterData);
|
|
PropEvent *propEvent = new PropEvent(NULL, this, beforeData, afterData);
|
|
@@ -1995,12 +1999,15 @@ void EntityPropSheet::handleEvent(Event *event) {
|
|
|
void EntityPropSheet::refreshProps() {
|
|
void EntityPropSheet::refreshProps() {
|
|
|
|
|
|
|
|
for(int i=0; i < props.size(); i++) {
|
|
for(int i=0; i < props.size(); i++) {
|
|
|
- contents->removeChild(props[i]);
|
|
|
|
|
- props[i]->removeAllHandlersForListener(this);
|
|
|
|
|
- delete props[i];
|
|
|
|
|
|
|
+ if(props[i] != addButtonProp) {
|
|
|
|
|
+ contents->removeChild(props[i]);
|
|
|
|
|
+ props[i]->removeAllHandlersForListener(this);
|
|
|
|
|
+ delete props[i];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
props.clear();
|
|
props.clear();
|
|
|
- propHeight = 0;
|
|
|
|
|
|
|
+ props.push_back(addButtonProp);
|
|
|
|
|
+
|
|
|
|
|
|
|
|
for(int i=0; i < entity->entityProps.size(); i++) {
|
|
for(int i=0; i < entity->entityProps.size(); i++) {
|
|
|
EntityProp prop = entity->entityProps[i];
|
|
EntityProp prop = entity->entityProps[i];
|
|
@@ -2008,13 +2015,9 @@ void EntityPropSheet::refreshProps() {
|
|
|
newProp->addEventListener(this, Event::CANCEL_EVENT);
|
|
newProp->addEventListener(this, Event::CANCEL_EVENT);
|
|
|
newProp->addEventListener(this, Event::CHANGE_EVENT);
|
|
newProp->addEventListener(this, Event::CHANGE_EVENT);
|
|
|
addProp(newProp);
|
|
addProp(newProp);
|
|
|
- propHeight += 30;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- addButton->setPosition(15, propHeight);
|
|
|
|
|
- propHeight += 70;
|
|
|
|
|
-
|
|
|
|
|
if(lastNumProps != entity->entityProps.size()) {
|
|
if(lastNumProps != entity->entityProps.size()) {
|
|
|
dispatchEvent(new Event(), Event::COMPLETE_EVENT);
|
|
dispatchEvent(new Event(), Event::COMPLETE_EVENT);
|
|
|
}
|
|
}
|
|
@@ -2024,11 +2027,19 @@ void EntityPropSheet::refreshProps() {
|
|
|
Resize(getWidth(), getHeight());
|
|
Resize(getWidth(), getHeight());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void EntityPropSheet::setEntity(Entity *entity){
|
|
|
|
|
+ this->entity = entity;
|
|
|
|
|
+ if(entity) {
|
|
|
|
|
+ enabled = true;
|
|
|
|
|
+ refreshProps();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ enabled = false;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void EntityPropSheet::Update() {
|
|
void EntityPropSheet::Update() {
|
|
|
if(entity) {
|
|
if(entity) {
|
|
|
-
|
|
|
|
|
if(removeIndex != -1) {
|
|
if(removeIndex != -1) {
|
|
|
-
|
|
|
|
|
PolycodeEditorPropActionData *beforeData = PropDataEntity(entity);
|
|
PolycodeEditorPropActionData *beforeData = PropDataEntity(entity);
|
|
|
|
|
|
|
|
if(removeIndex < entity->entityProps.size()) {
|
|
if(removeIndex < entity->entityProps.size()) {
|
|
@@ -2040,14 +2051,6 @@ void EntityPropSheet::Update() {
|
|
|
PropEvent *propEvent = new PropEvent(NULL, this, beforeData, afterData);
|
|
PropEvent *propEvent = new PropEvent(NULL, this, beforeData, afterData);
|
|
|
dispatchEvent(propEvent, PropEvent::EVENT_PROP_CHANGE);
|
|
dispatchEvent(propEvent, PropEvent::EVENT_PROP_CHANGE);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- enabled = true;
|
|
|
|
|
- if(entity != lastEntity) {
|
|
|
|
|
- refreshProps();
|
|
|
|
|
- lastEntity = entity;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- enabled = false;
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|