Skip to content

Commit

Permalink
#218 Fix the node dragging problem (strange that it was not present w…
Browse files Browse the repository at this point in the history
…ith Qt5...)

Signed-off-by: cneben <[email protected]>
  • Loading branch information
cneben committed Jan 14, 2024
1 parent 314effd commit 881d3a6
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 40 deletions.
48 changes: 20 additions & 28 deletions samples/style/RoundNode.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
//-----------------------------------------------------------------------------

import QtQuick
import QtQuick.Controls.Material
import QtQuick.Layouts
import QtQuick.Controls.Material
import QtQuick.Effects

import QuickQanava 2.0 as Qan
import "qrc:/QuickQanava" as Qan
Expand All @@ -51,29 +52,19 @@ Qan.NodeItem {
radius: width / 2;
border.color: Material.accent; border.width: 2
color: roundNode.style.backColor
}
property color styleBackColor: style.backColor
onStyleBackColorChanged: nodeColor = Qt.rgba( style.backColor.r, style.backColor.g, style.backColor.b, 0.2 )
property color nodeColor
property color backColor: Material.background

// FIXME #218
/*
Qan.LinearGradient {
anchors.fill: parent
z: 2
source: background
start: Qt.point(0.,0.)
end: Qt.point(background.width, background.height)
gradient: Gradient {
id: backGrad
GradientStop { position: 0.0; color: roundNode.nodeColor }
GradientStop {
position: 1.0;
color: Qt.tint( roundNode.nodeColor, roundNode.backColor )
color: Qt.tint(roundNode.nodeColor, roundNode.backColor)
}
}
}*/
}
property color styleBackColor: style.backColor
onStyleBackColorChanged: nodeColor = Qt.rgba( style.backColor.r, style.backColor.g, style.backColor.b, 0.2 )
property color nodeColor
property color backColor: Material.background

Rectangle {
id: border
z: 3
Expand All @@ -87,14 +78,15 @@ Qan.NodeItem {
z: 3
anchors.centerIn: parent
}
// FIXME #218
/*
Qan.Glow {
z: 0
MultiEffect {
source: background
anchors.fill: parent
color: Material.theme === Material.Light ? Qt.lighter( Material.foreground ) : Qt.darker( Material.foreground )
radius: 12; samples: 15
spread: 0.25; transparentBorder: true
}*/
}
anchors.centerIn: parent
width: background.width + (6 * 2) // glowRadius = 6
height: background.height + (6 * 2)
blurEnabled: true
blurMax: 30
blur: 1.
colorization: 1.0
colorizationColor: Qt.rgba(1, 1, 1, 0.3)
}
} // Qan.NodeItem: roundNode
3 changes: 1 addition & 2 deletions src/RectGlowEffect.qml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Item {
blurEnabled: glowEffect.style !== undefined ? style.effectEnabled : false
blurMax: 30
blur: 1.
//blurMultiplier: 0.1
colorization: 1.0
colorizationColor: glowColor

Expand All @@ -90,7 +89,7 @@ Item {
height: border.height - 2
border.width: 1
border.color: Qt.rgba(1, 1, 1, 0.3)
color: 'transparent'
color: Qt.rgba(0, 0, 0, 0)
radius: backRadius
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/RectNodeTemplate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ Item {
if (delegateLoader?.item?.nodeItem)
delegateLoader.item.nodeItem = nodeItem
}
onWidthChanged: updateDefaultBoundingShape()
onHeightChanged: updateDefaultBoundingShape()
function updateDefaultBoundingShape() {
if (nodeItem)
nodeItem.setDefaultBoundingShape()
}

readonly property real backRadius: nodeItem?.style ? nodeItem.style.backRadius : 4.
Loader {
id: delegateLoader
Expand Down
2 changes: 1 addition & 1 deletion src/qanBottomResizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void BottomResizer::hoverLeaveEvent(QHoverEvent *event)
}
void BottomResizer::mouseMoveEvent(QMouseEvent* event)
{
const auto mePos = event->scenePosition(); // FIXME #218 check at high scale...
const auto mePos = event->scenePosition();
if (event->buttons() | Qt::LeftButton &&
!_dragInitialPos.isNull() &&
!_targetInitialSize.isEmpty()) {
Expand Down
8 changes: 2 additions & 6 deletions src/qanEdgeItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ void EdgeItem::configureDestinationItem(QQuickItem* item)
/* Edge Drawing Management *///------------------------------------------------
void EdgeItem::setHidden(bool hidden) noexcept
{
if ( hidden != _hidden ) {
if (hidden != _hidden) {
_hidden = hidden;
emit hiddenChanged();
}
}

void EdgeItem::setArrowSize( qreal arrowSize ) noexcept
{
if ( !qFuzzyCompare(1. + arrowSize, 1. + _arrowSize ) ) {
if (!qFuzzyCompare(1. + arrowSize, 1. + _arrowSize)) {
_arrowSize = arrowSize;
emit arrowSizeChanged();
updateItem();
Expand Down Expand Up @@ -637,8 +637,6 @@ void EdgeItem::generateArrowGeometry(GeometryCache& cache) const noexcept
// Update source arrow cache points
const auto srcShape = getSrcShape();
switch (srcShape) {
// FIXME AHN
//case qan::EdgeItem::ArrowShape::Undefined: // [[fallthrough]]
case qan::EdgeItem::ArrowShape::Arrow: // [[fallthrough]]
case qan::EdgeItem::ArrowShape::ArrowOpen:
cache.srcA1 = arrowA1;
Expand All @@ -658,8 +656,6 @@ void EdgeItem::generateArrowGeometry(GeometryCache& cache) const noexcept
// Update destination arrow cache points
const auto dstShape = getDstShape();
switch (dstShape) {
// FIXME AHN
//case qan::EdgeItem::ArrowShape::Undefined: // [[fallthrough]]
case qan::EdgeItem::ArrowShape::Arrow: // [[fallthrough]]
case qan::EdgeItem::ArrowShape::ArrowOpen:
cache.dstA1 = arrowA1;
Expand Down
2 changes: 1 addition & 1 deletion src/qanNodeItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public slots:
void boundingShapeChanged();
//! signal is Emitted when the bounding shape become invalid and should be regenerated from QML.
void requestUpdateBoundingShape();
protected:
public:
QPolygonF generateDefaultBoundingShape() const;
private:
QPolygonF _boundingShape;
Expand Down
2 changes: 0 additions & 2 deletions src/qanStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,6 @@ class EdgeStyle : public qan::Style
public:
//! End type drawing configuration
enum class ArrowShape {
//! Invalid undefined value, usefull for serialization (if Undefined, default to Arrow).
//Undefined = 0,
//! Do not draw an end.
None = 0,
//! End shape is an arrow.
Expand Down

0 comments on commit 881d3a6

Please sign in to comment.