Parcourir la source

Hooked up property sheets to Undo/Redo system, made color picker in the IDE not continous

Ivan Safrin il y a 12 ans
Parent
commit
af36a2dcac

+ 1 - 0
IDE/Contents/Include/EntityEditorPropertyView.h

@@ -25,6 +25,7 @@
 #include "Polycode.h"
 #include "PolycodeUI.h"
 #include "PolycodeProps.h"
+
 #include "OSBasics.h"
 
 using namespace Polycode;

+ 5 - 1
IDE/Contents/Include/PolycodeEntityEditor.h

@@ -236,7 +236,7 @@ class EntityEditorMainView : public UIElement {
 
 class EntityEditorPropertyContainer : public UIElement {
     public:
-        EntityEditorPropertyContainer();
+        EntityEditorPropertyContainer(PolycodeEditor *editor);
         ~EntityEditorPropertyContainer();
         void Resize(Number width, Number height);
     
@@ -247,6 +247,10 @@ class EntityEditorPropertyContainer : public UIElement {
         EntityEditorTreeView *treeView;
         EntityEditorSettingsView *settingsView;
         UIIconSelector *propIconSelector;
+    
+    private:
+    
+        PolycodeEditor *editor;
 };
 
 class PolycodeEntityEditor : public PolycodeEditor {

+ 11 - 3
IDE/Contents/Source/EntityEditorPropertyView.cpp

@@ -96,9 +96,17 @@ void EntityEditorPropertyView::Resize(Number width, Number height) {
 }
 
 void EntityEditorPropertyView::handleEvent(Event *event) {
-    if(event->getDispatcher() == materialSheet) {
-        if(targetEntity) {
-            updateShaderOptions();
+    if(event->getEventCode() == PropEvent::EVENT_PROP_CHANGE) {
+        
+        PropEvent *propEvent = (PropEvent*) event;
+        
+        PropEvent *newPropEvent = new PropEvent(propEvent->prop, propEvent->sheet, propEvent->beforeData, propEvent->afterData);
+        dispatchEvent(newPropEvent, PropEvent::EVENT_PROP_CHANGE);
+    } else {
+        if(event->getDispatcher() == materialSheet) {
+            if(targetEntity) {
+                updateShaderOptions();
+            }
         }
     }
 }

+ 17 - 3
IDE/Contents/Source/PolycodeEntityEditor.cpp

@@ -1212,7 +1212,9 @@ void EntityEditorMainView::Resize(Number width, Number height) {
     Update();
 }
 
-EntityEditorPropertyContainer::EntityEditorPropertyContainer() : UIElement() {
+EntityEditorPropertyContainer::EntityEditorPropertyContainer(PolycodeEditor *editor) : UIElement() {
+    
+    this->editor = editor;
     
     propIconSelector = new UIIconSelector();
     addChild(propIconSelector);
@@ -1223,6 +1225,7 @@ EntityEditorPropertyContainer::EntityEditorPropertyContainer() : UIElement() {
     propIconSelector->addEventListener(this, UIEvent::SELECT_EVENT);
     
     propertyView = new EntityEditorPropertyView();
+    propertyView->addEventListener(this, PropEvent::EVENT_PROP_CHANGE);
     addChild(propertyView);
     propertyView->setPosition(0.0, 30.0);
     currentView = propertyView;
@@ -1258,6 +1261,11 @@ void EntityEditorPropertyContainer::handleEvent(Event *event) {
         }
         currentView->visible = true;
         currentView->enabled = true;
+    } else if(event->getDispatcher() == propertyView) {
+        if(event->getEventCode() == PropEvent::EVENT_PROP_CHANGE) {
+            PropEvent *propEvent  = (PropEvent*) event;
+            editor->didAction("prop_change", propEvent->beforeData, propEvent->afterData);
+        }
     }
 }
 
@@ -1282,7 +1290,7 @@ PolycodeEntityEditor::PolycodeEntityEditor() : PolycodeEditor(true){
     
     mainSizer->setMinimumSize(200);
     
-    propertyContainer = new EntityEditorPropertyContainer();
+    propertyContainer = new EntityEditorPropertyContainer(this);
     propertyView = propertyContainer->propertyView;
     treeView = propertyContainer->treeView;
     settingsView = propertyContainer->settingsView;
@@ -1312,7 +1320,13 @@ void PolycodeEntityEditor::handleEvent(Event *event) {
 }
 
 void PolycodeEntityEditor::doAction(String actionName, PolycodeEditorActionData *data) {
-    mainView->doAction(actionName, data);
+    
+    if(actionName == "prop_change") {
+        PolycodeEditorPropActionData *propData = (PolycodeEditorPropActionData*) data;
+		propData->sheet->applyPropActionData(propData);
+    } else {
+        mainView->doAction(actionName, data);
+    }
 }
 
 PolycodeEntityEditor::~PolycodeEntityEditor() {

+ 1 - 0
IDE/Contents/Source/PolycodeFrame.cpp

@@ -1432,6 +1432,7 @@ PolycodeFrame::PolycodeFrame(PolycodeEditorManager *editorManager) : UIElement()
 		
 	globalColorPicker = new UIColorPicker();
 	globalColorPicker->setPosition(300,300);
+    globalColorPicker->setContinuous(false);
 	addChild(globalColorPicker);
 
 	modalRoot = new UIElement();