Commit 906a423c authored by Marco Martin's avatar Marco Martin
Browse files

More button-like appearance for handles

handles have to pop up on any background, as they will be on top of the wallpaper
adding a super light gradient which reminds breeze buttons, contrast pixel and
a shadow makes it easier for it to not get lost
parent b847d33e
......@@ -21,16 +21,43 @@ import QtQuick 2.12
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.14 as Kirigami
ContainmentLayoutManager.ResizeHandle {
id: handle
width: overlay.touchInteraction ? PlasmaCore.Units.gridUnit * 2 : PlasmaCore.Units.gridUnit
height: width
z: 999
Rectangle {
color: resizeBlocked ? PlasmaCore.Theme.negativeTextColor : PlasmaCore.Theme.backgroundColor
Kirigami.ShadowedRectangle {
anchors.fill: parent
color: resizeBlocked ? PlasmaCore.Theme.negativeTextColor : PlasmaCore.Theme.backgroundColor
radius: width
shadow.size: PlasmaCore.Units.smallSpacing
shadow.color: Qt.rgba(0.0, 0.0, 0.0, 0.2)
shadow.yOffset: Kirigami.Units.devicePixelRatio * 2
border.width: PlasmaCore.Units.devicePixelRatio
border.color: Qt.tint(Kirigami.Theme.textColor,
Qt.rgba(color.r, color.g, color.b, 0.3))
}
Rectangle {
anchors {
fill: parent
margins: PlasmaCore.Units.devicePixelRatio / 2
}
border {
width: PlasmaCore.Units.devicePixelRatio / 2
color: Qt.rgba(1, 1, 1, 0.2)
}
gradient: Gradient {
GradientStop { position: 0.0; color: handle.pressed ? Qt.rgba(0, 0, 0, 0.15) : Qt.rgba(1, 1, 1, 0.05) }
GradientStop { position: 1.0; color: handle.pressed ? Qt.rgba(0, 0, 0, 0.15) : Qt.rgba(0, 0, 0, 0.05) }
}
radius: width
opacity: 0.6
}
scale: overlay.open ? 1 : 0
Behavior on scale {
......
......@@ -86,6 +86,21 @@ bool ResizeHandle::resizeBlocked() const
return m_resizeWidthBlocked || m_resizeHeightBlocked;
}
void ResizeHandle::setPressed(bool pressed)
{
if (pressed == m_pressed) {
return;
}
m_pressed = pressed;
emit pressedChanged();
}
bool ResizeHandle::isPressed() const
{
return m_pressed;
}
bool ResizeHandle::resizeLeft() const
{
return m_resizeCorner == Left || m_resizeCorner == TopLeft || m_resizeCorner == BottomLeft;
......@@ -127,6 +142,7 @@ void ResizeHandle::mousePressEvent(QMouseEvent *event)
m_mouseDownPosition = event->windowPos();
m_mouseDownGeometry = QRectF(itemContainer->x(), itemContainer->y(), itemContainer->width(), itemContainer->height());
setResizeBlocked(false, false);
setPressed(true);
event->accept();
}
......@@ -209,6 +225,7 @@ void ResizeHandle::mouseMoveEvent(QMouseEvent *event)
void ResizeHandle::mouseReleaseEvent(QMouseEvent *event)
{
setPressed(false);
if (!m_configOverlay || !m_configOverlay->itemContainer()) {
return;
}
......@@ -228,6 +245,11 @@ void ResizeHandle::mouseReleaseEvent(QMouseEvent *event)
emit resizeBlockedChanged();
}
void ResizeHandle::mouseUngrabEvent()
{
setPressed(false);
}
void ResizeHandle::setConfigOverlay(ConfigOverlay *handle)
{
if (handle == m_configOverlay) {
......
......@@ -29,6 +29,7 @@ class ResizeHandle : public QQuickItem
Q_OBJECT
Q_PROPERTY(Corner resizeCorner MEMBER m_resizeCorner NOTIFY resizeCornerChanged)
Q_PROPERTY(bool resizeBlocked READ resizeBlocked NOTIFY resizeBlockedChanged)
Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged)
public:
enum Corner {
......@@ -48,14 +49,19 @@ public:
bool resizeBlocked() const;
void setPressed(bool pressed);
bool isPressed() const;
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseUngrabEvent() override;
Q_SIGNALS:
void resizeCornerChanged();
void resizeBlockedChanged();
void pressedChanged();
private:
void setConfigOverlay(ConfigOverlay *configOverlay);
......@@ -73,4 +79,5 @@ private:
Corner m_resizeCorner = Left;
bool m_resizeWidthBlocked = false;
bool m_resizeHeightBlocked = false;
bool m_pressed = false;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment