Implemented the new port-management and grid workflow.

Right-click blocks in the graph, Document tree, or Libraries tree and choose “Port Options…”.
Unified port list with:Add/remove port
Name
Type (Signal currently)
Input/output orientation

New ports start at (0, 0) in the icon editor.
Connected ports cannot be removed, reoriented, or changed incompatibly.
Added a PortType registry; connections require matching port types.
Removed/hid the separate Add Input and Add Output workspace tools.
Library port changes are written back to the library JSON.
Added independent graph and icon grid-size settings.
Components, interface terminals, icon shapes, resize handles, and icon ports snap to their corresponding grid.
Icon canvases and component hitboxes are now fixed at 128×128.
Selected icon shapes show a bottom-right resize handle.
Circles preserve equal width and height while resizing.
Shapes and ports are constrained to the icon hitbox.

Fixed the icon-editor crash and grid behavior.
Renamed the resize handle’s shape attribute, which was overriding Qt’s required shape() method.
Icon shapes, resize handles, and port anchors now snap while dragging.
Graph blocks and interface terminals also snap while dragging.
Replaced the nearly invisible dotted graph grid with higher-contrast grid lines.
Retained final release-time snapping as a safety check.
Python compilation and diff validation pass.
This commit is contained in:
2026-07-19 22:06:36 +02:00
parent 09824195c9
commit dbca41640f
10 changed files with 551 additions and 59 deletions

View File

@@ -1,7 +1,7 @@
from pathlib import Path
from PySide6.QtCore import QSettings, Signal
from PySide6.QtWidgets import QDialog, QFileDialog
from PySide6.QtWidgets import QDialog, QFileDialog, QFormLayout, QGroupBox, QSpinBox
from bedit.library.repository import default_library_paths
from bedit.ui_settings_dialog import Ui_SettingsDialog
@@ -16,6 +16,17 @@ class SettingsDialog(QDialog):
super().__init__(parent)
self.ui = Ui_SettingsDialog()
self.ui.setupUi(self)
self.grid_group = QGroupBox("Editor grids", self.ui.generalTab)
grid_form = QFormLayout(self.grid_group)
self.graph_grid_spin = QSpinBox()
self.graph_grid_spin.setRange(2, 256)
self.graph_grid_spin.setSuffix(" units")
self.icon_grid_spin = QSpinBox()
self.icon_grid_spin.setRange(1, 64)
self.icon_grid_spin.setSuffix(" units")
grid_form.addRow("Graph grid size:", self.graph_grid_spin)
grid_form.addRow("Icon grid size:", self.icon_grid_spin)
self.ui.generalLayout.insertWidget(1, self.grid_group)
self.settings = QSettings()
self.ui.addLibraryFileButton.clicked.connect(self._add_library_file)
self.ui.addLibraryFolderButton.clicked.connect(self._add_library_folder)
@@ -32,6 +43,8 @@ class SettingsDialog(QDialog):
)
self.ui.libraryPathsList.clear()
self.ui.libraryPathsList.addItems(self.library_paths(self.settings))
self.graph_grid_spin.setValue(self.graph_grid_size(self.settings))
self.icon_grid_spin.setValue(self.icon_grid_size(self.settings))
self._update_remove_button()
@staticmethod
@@ -42,6 +55,14 @@ class SettingsDialog(QDialog):
return [value]
return [str(path) for path in value]
@staticmethod
def graph_grid_size(settings: QSettings | None = None) -> int:
return (settings or QSettings()).value("grid/graphSize", 32, type=int)
@staticmethod
def icon_grid_size(settings: QSettings | None = None) -> int:
return (settings or QSettings()).value("grid/iconSize", 8, type=int)
def _add_library_file(self) -> None:
path, _ = QFileDialog.getOpenFileName(
self,
@@ -83,6 +104,8 @@ class SettingsDialog(QDialog):
for row in range(self.ui.libraryPathsList.count())
]
self.settings.setValue("libraries/paths", paths)
self.settings.setValue("grid/graphSize", self.graph_grid_spin.value())
self.settings.setValue("grid/iconSize", self.icon_grid_spin.value())
self.settings.sync()
self.settingsChanged.emit()
super().accept()