aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikko Syrjä <mikko@3d-system.fi>2019-02-27 23:51:50 +0200
committerMikko Syrjä <mikko@3d-system.fi>2019-02-27 23:51:50 +0200
commitbc9e3fec14b0b17fb082f271f58f76c549704b59 (patch)
tree963ff39496650620150b91075dd6694137e6fb72
parentab3e047e2a1eb10946f6c3217db426ac27e98fbb (diff)
downloadsymedit-bc9e3fec14b0b17fb082f271f58f76c549704b59.tar.gz
symedit-bc9e3fec14b0b17fb082f271f58f76c549704b59.zip
Fixes for toobar buttons and tooltips.
-rw-r--r--BarSeparator.qml3
-rw-r--r--BarTool.qml24
-rw-r--r--ToolTip.qml2
-rw-r--r--TooltipCreator.js1
-rw-r--r--symbol.cpp7
5 files changed, 30 insertions, 7 deletions
diff --git a/BarSeparator.qml b/BarSeparator.qml
index 2ac4832..e2e82b3 100644
--- a/BarSeparator.qml
+++ b/BarSeparator.qml
@@ -4,4 +4,7 @@ import QtQuick.Controls 1.4
ToolButton
{
implicitWidth: 8
+
+ // prevent clicking animation
+ MouseArea { anchors.fill: parent }
}
diff --git a/BarTool.qml b/BarTool.qml
index a403fc9..a6ce03e 100644
--- a/BarTool.qml
+++ b/BarTool.qml
@@ -11,23 +11,39 @@ ToolButton
implicitHeight: parent.height - 2
implicitWidth: parent.height - 2
z: 20
+
Image
{
source: image
- anchors { fill: parent; margins: 2 }
+ anchors { fill: parent; margins: 4 }
}
+ checkable: (tool !== 0)
+ checked: (window.tool === tool)
+
onHoveredChanged:
{
if ( popup !== null )
popup.hide()
- popup = TooltipCreator.create(tooltip, this)
- popup.show()
+ if ( hovered )
+ {
+ popup = TooltipCreator.create(tooltip, this)
+ popup.show()
+ }
+ }
+
+ onPressedChanged:
+ {
+ if ( popup !== null )
+ popup.hide()
}
onClicked:
{
if ( tool )
- window.tool = tool
+ {
+ window.tool = tool // clicking button seems to break binding
+ checked = Qt.binding(function() { return (window.tool === tool) })
+ }
}
}
diff --git a/ToolTip.qml b/ToolTip.qml
index e8b09c2..94be0a5 100644
--- a/ToolTip.qml
+++ b/ToolTip.qml
@@ -29,7 +29,7 @@ Rectangle
width: tooltipText.width + 20
height: tooltipText.height + 10
color: "#dd000000"
- radius: 6
+ radius: 5
opacity: 0
z: 30
diff --git a/TooltipCreator.js b/TooltipCreator.js
index 49a71e3..6b21b13 100644
--- a/TooltipCreator.js
+++ b/TooltipCreator.js
@@ -10,7 +10,6 @@ function create(text, parent, properties)
{
left: parent.horizontalCenter,
top: parent.bottom,
-// topMargin: parent.height / 8
}
};
}
diff --git a/symbol.cpp b/symbol.cpp
index 93891ea..b06027a 100644
--- a/symbol.cpp
+++ b/symbol.cpp
@@ -4,6 +4,11 @@
#include "symbol.h"
+const double ConstPi = 3.14159265358979323846; //!< Constant for PI.
+const double Const2Pi = 2.0 * ConstPi; //!< Constant for PI * 2.
+const double ConstPi2 = ConstPi / 2.0; //!< Constant for PI / 2.
+const double ConstPi4 = ConstPi / 4.0; //!< Constant for PI / 4.
+
//
// symbol item functions
//
@@ -292,7 +297,7 @@ void SymEditSymbol::RotateSymbol(int dir)
{
double length = sqrt(point.x() * point.x() + point.y() * point.y());
double angle = atan2(point.y(), point.x());
- angle += (dir > 0 ? -M_PI / 2.0 : M_PI / 2.0);
+ angle += (dir > 0 ? -ConstPi2 : ConstPi2);
double x = cos(angle) * length, y = sin(angle) * length;
point.setX(static_cast<int>(x + (x > 0.0 ? 0.5 : -0.5)));
point.setY(static_cast<int>(y + (y > 0.0 ? 0.5 : -0.5)));