fix: Richtung und Kante für ausgewählte Segmente bearbeiten

- Kanten-/Richtungsbuttons ändern das aktive Segment statt nur den Default
- Toolbar spiegelt Richtung und Kante der Auswahl
- Statusleiste zeigt Richtung und Kante des ausgewählten Segments
- Regressionstests für Toolbar-Sync und Modelländerung ergänzt
This commit is contained in:
torsten 2026-10-30 07:56:24 +01:00
parent 18efa6ae3c
commit 5face42141
3 changed files with 111 additions and 12 deletions

View file

@ -216,6 +216,7 @@ func select_segment(segment_id: String) -> void:
set_tool(Tool.SELECT)
_selected_segment_id = segment_id
rink_canvas.set_selected_segment(segment_id)
_sync_toolbar_to_selection()
_update_status()
@ -297,10 +298,24 @@ func _tool_from_id(tool_id: int) -> Tool:
func _on_direction_pressed(direction: PathSegment.Direction) -> void:
_direction = direction
_update_direction_buttons()
var selected := get_selected_segment()
if selected != null:
selected.direction = direction
rink_canvas.refresh()
_update_status()
func _on_edge_pressed(edge: PathSegment.Edge) -> void:
_edge = edge
_update_edge_buttons()
var selected := get_selected_segment()
if selected != null:
selected.edge = edge
rink_canvas.refresh()
_update_status()
func _on_draw_started(model_point: Vector2) -> void:
@ -344,6 +359,7 @@ func _on_draw_cancelled() -> void:
func _on_segment_selected(segment_id: String) -> void:
_selected_segment_id = segment_id
rink_canvas.set_selected_segment(segment_id)
_sync_toolbar_to_selection()
_update_status()
@ -594,6 +610,30 @@ func _on_delete_confirmed() -> void:
delete_section(_active_section.section_id)
func _sync_toolbar_to_selection() -> void:
var selected := get_selected_segment()
if selected == null:
return
_direction = selected.direction
_edge = selected.edge
_update_direction_buttons()
_update_edge_buttons()
func _update_direction_buttons() -> void:
forward_button.set_pressed_no_signal(
_direction == PathSegment.Direction.FORWARD
)
backward_button.set_pressed_no_signal(
_direction == PathSegment.Direction.BACKWARD
)
func _update_edge_buttons() -> void:
inside_button.set_pressed_no_signal(_edge == PathSegment.Edge.INSIDE)
outside_button.set_pressed_no_signal(_edge == PathSegment.Edge.OUTSIDE)
func _update_status() -> void:
if _routine == null or _active_section == null:
return
@ -612,17 +652,31 @@ func _update_status() -> void:
var selected := get_selected_segment()
if selected != null:
var direction_word := (
"vorwärts"
if selected.direction == PathSegment.Direction.FORWARD
else "rückwärts"
)
var edge_word := (
"außen"
if selected.edge == PathSegment.Edge.OUTSIDE
else "innen"
)
var kind := "Linie"
if selected.is_arc():
var side := "links" if selected.arc_bulge_left else "rechts"
text += " | Auswahl: Bogen %s · Tiefe %d %%" % [
kind = "Bogen %s · Tiefe %d %%" % [
side,
roundi(selected.arc_depth_ratio * 100.0),
]
else:
text += " | Auswahl: Linie"
text += " | Auswahl: %s · %s · %s" % [
kind,
direction_word,
edge_word,
]
var hint := (
"Tippen: auswählen · Griffe ziehen: bearbeiten · leere Fläche: pan"
"Tippen: auswählen · Griffe/Buttons: bearbeiten · leere Fläche: pan"
if _tool == Tool.SELECT
else "Links ziehen: zeichnen · Mitte/2 Finger: pan · Rad/Pinch: zoom"
)

View file

@ -299,6 +299,49 @@ func _run() -> void:
"flipped arc lies on the other side of the chord"
)
controller.select_segment(arc_right.segment_id)
_check(
controller.get_selected_segment() == arc_right,
"a backward/inside segment can be selected"
)
_check(
controller.backward_button.button_pressed,
"toolbar shows the selected segment direction"
)
_check(
controller.inside_button.button_pressed,
"toolbar shows the selected segment edge"
)
_check(
not controller.forward_button.button_pressed,
"opposite direction button is not pressed"
)
_check(
not controller.outside_button.button_pressed,
"opposite edge button is not pressed"
)
controller.outside_button.pressed.emit()
controller.forward_button.pressed.emit()
_check(
arc_right.edge == PathSegment.Edge.OUTSIDE,
"edge button edits the selected segment"
)
_check(
arc_right.direction == PathSegment.Direction.FORWARD,
"direction button edits the selected segment"
)
_check(
controller.status_label.text.contains("vorwärts")
and controller.status_label.text.contains("außen"),
"status bar shows the edited direction and edge"
)
_check(
controller.outside_button.button_pressed
and controller.forward_button.button_pressed,
"toolbar stays in sync after editing"
)
controller.set_tool(WhiteboardController.Tool.LINE)
_check(
controller.get_selected_segment() == null,