Фикс: editorContent property (явное присвоение вместо биндинга на функцию), граф — pan левой кнопкой по пустому месту + lastMouseXY, календарь — точка под цифрой (dayLabel.bottom), orphan code cleanup GraphView
This commit is contained in:
+19
-21
@@ -14,6 +14,8 @@ Canvas {
|
||||
property real zoom: 1.0
|
||||
property real panX: 0
|
||||
property real panY: 0
|
||||
property real lastMouseX: 0
|
||||
property real lastMouseY: 0
|
||||
|
||||
function nodeForKey(key) {
|
||||
for (let i = 0; i < nodes.length; ++i)
|
||||
@@ -91,45 +93,42 @@ Canvas {
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onWheel: (w) => {
|
||||
// Масштабирование колесом мыши
|
||||
const factor = w.angleDelta.y > 0 ? 1.15 : 0.87
|
||||
g.zoom = Math.max(0.2, Math.min(5.0, g.zoom * factor))
|
||||
g.requestPaint()
|
||||
}
|
||||
onPressed: (m) => {
|
||||
dragKey = ""
|
||||
// Переводим экранные координаты в координаты графа
|
||||
g.dragKey = ""
|
||||
g.lastMouseX = m.x
|
||||
g.lastMouseY = m.y
|
||||
const gx = (m.x - width / 2 - panX) / zoom + width / 2
|
||||
const gy = (m.y - height / 2 - panY) / zoom + height / 2
|
||||
for (const key in g.pos) {
|
||||
const p = g.pos[key]
|
||||
const dx = gx - p.x, dy = gy - p.y
|
||||
if (dx * dx + dy * dy <= 256) { // радиус захвата 16px
|
||||
dragKey = key
|
||||
if (dx * dx + dy * dy <= 256) {
|
||||
g.dragKey = key
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
onPositionChanged: (m) => {
|
||||
if (dragKey.length > 0 && g.pos[dragKey]) {
|
||||
if (g.dragKey.length > 0 && g.pos[g.dragKey]) {
|
||||
const gx = (m.x - width / 2 - panX) / zoom + width / 2
|
||||
const gy = (m.y - height / 2 - panY) / zoom + height / 2
|
||||
g.pos[dragKey] = { x: gx, y: gy }
|
||||
g.requestPaint()
|
||||
} else if (m.buttons & Qt.RightButton) {
|
||||
// Перетаскивание фона (pan)
|
||||
panX += m.x - m.__lastX
|
||||
panY += m.y - m.__lastY
|
||||
g.requestPaint()
|
||||
g.pos[g.dragKey] = { x: gx, y: gy }
|
||||
} else {
|
||||
g.panX += m.x - g.lastMouseX
|
||||
g.panY += m.y - g.lastMouseY
|
||||
}
|
||||
m.__lastX = m.x
|
||||
m.__lastY = m.y
|
||||
g.lastMouseX = m.x
|
||||
g.lastMouseY = m.y
|
||||
g.requestPaint()
|
||||
}
|
||||
onReleased: (m) => {
|
||||
if (dragKey.length === 0) {
|
||||
// Клик по узлу (открыть файл)
|
||||
if (g.dragKey.length === 0) {
|
||||
const gx = (m.x - width / 2 - panX) / zoom + width / 2
|
||||
const gy = (m.y - height / 2 - panY) / zoom + height / 2
|
||||
for (const key in g.pos) {
|
||||
@@ -143,10 +142,9 @@ Canvas {
|
||||
}
|
||||
}
|
||||
}
|
||||
dragKey = ""
|
||||
g.dragKey = ""
|
||||
}
|
||||
onDoubleClicked: (m) => {
|
||||
// Двойной клик — сброс позиции/масштаба
|
||||
onDoubleClicked: {
|
||||
g.zoom = 1.0; g.panX = 0; g.panY = 0; g.relayout()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user