Skip to content

Commit fefdd67

Browse files
committed
added bulk editor actions
1 parent eb41e26 commit fefdd67

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

fxgl-tools/src/main/kotlin/com/almasb/fxgl/tools/dialogues/DialoguePane.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ class DialoguePane(graph: DialogueGraph = DialogueGraph()) : Pane() {
147147

148148
mouseGestures.makeDraggable(selectionRect) {
149149
selectionStart = Point2D(selectionRect.layoutX, selectionRect.layoutY)
150+
151+
performUIAction(BulkAction(
152+
selectedNodeViews.map {
153+
val layoutX = it.properties["startLayoutX"] as Double
154+
val layoutY = it.properties["startLayoutY"] as Double
155+
156+
MoveNodeAction(it.node, this::getNodeView, layoutX, layoutY, it.layoutX, it.layoutY)
157+
}
158+
))
150159
}
151160

152161
selectionRect.layoutXProperty().addListener { _, prevX, layoutX ->
@@ -218,6 +227,11 @@ class DialoguePane(graph: DialogueGraph = DialogueGraph()) : Pane() {
218227
isSelectingRectangle = false
219228
selectedNodeViews.addAll(selectionRect.getSelectedNodesIn(nodeViews, NodeView::class.java))
220229

230+
selectedNodeViews.forEach {
231+
it.properties["startLayoutX"] = it.layoutX
232+
it.properties["startLayoutY"] = it.layoutY
233+
}
234+
221235
if (selectedNodeViews.isEmpty()) {
222236
selectionRect.isVisible = false
223237
}

fxgl-tools/src/main/kotlin/com/almasb/fxgl/tools/dialogues/EditorActions.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,22 @@ interface EditorAction {
2828
// * remove node (and its incident edges)
2929
// * add edge
3030
// * remove edge
31+
// * bulk action
3132
// * TODO: node text editing
3233

34+
class BulkAction(
35+
private val actions: List<EditorAction>
36+
) : EditorAction {
37+
38+
override fun run() {
39+
actions.forEach { it.run() }
40+
}
41+
42+
override fun undo() {
43+
actions.forEach { it.undo() }
44+
}
45+
}
46+
3347
class MoveNodeAction(
3448
private val node: DialogueNode,
3549
private val newNodeViewGetter: (DialogueNode) -> NodeView,

0 commit comments

Comments
 (0)