Editor graph delegate: Add update callback functionality for graph edits

directional-lights
Sven Eberhardt 2016-11-12 22:19:42 -05:00
parent 83c1d25b84
commit 072e1dcde0
4 changed files with 9 additions and 0 deletions

View File

@ -2162,6 +2162,7 @@ C4PropertyDelegateGraph::C4PropertyDelegateGraph(const class C4PropertyDelegateF
horizontal_fix = props->GetPropertyBool(P_HorizontalFix);
vertical_fix = props->GetPropertyBool(P_VerticalFix);
structure_fix = props->GetPropertyBool(P_StructureFix);
update_callback = props->GetPropertyStr(P_OnUpdate);
}
}
@ -2246,6 +2247,11 @@ void C4PropertyDelegateGraph::ConnectSignals(C4ConsoleQtShape *shape, const C4Pr
connect(shape_graph, &C4ConsoleQtGraph::GraphEdit, this, [this, shape, property_path](C4ControlEditGraph::Action action, int32_t index, int32_t x, int32_t y) {
// Send graph editing via queue
::Control.DoInput(CID_EditGraph, new C4ControlEditGraph(property_path.GetGetPath(), action, index, x, y), CDT_Decide);
// Also send update callback to root object
if (update_callback)
{
::Console.EditCursor.EMControl(CID_Script, new C4ControlScript(FormatString("%s->%s(%s)", property_path.GetRoot(), update_callback->GetCStr(), property_path.GetGetPath()).getData(), 0, false));
}
});
connect(shape, &C4ConsoleQtShape::BorderSelectionChanged, this, []() {
// Different part of the shape selected: Refresh info on next update

View File

@ -562,6 +562,7 @@ class C4PropertyDelegateGraph : public C4PropertyDelegateShape
bool horizontal_fix = false;
bool vertical_fix = false;
bool structure_fix = false;
C4RefCntPointer<C4String> update_callback;
void DoPaint(QPainter *painter, const QRect &inner_rect) const override;
protected:

View File

@ -270,6 +270,7 @@ C4StringTable::C4StringTable()
P[P_HorizontalFix] = "HorizontalFix";
P[P_VerticalFix] = "VerticalFix";
P[P_StructureFix] = "StructureFix";
P[P_OnUpdate] = "OnUpdate";
P[P_Min] = "Min";
P[P_Max] = "Max";
P[P_Set] = "Set";

View File

@ -494,6 +494,7 @@ enum C4PropertyName
P_HorizontalFix,
P_VerticalFix,
P_StructureFix,
P_OnUpdate,
P_Min,
P_Max,
P_Set,