1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-11 13:18:13 +03:00

first iteration for new parabolic

This commit is contained in:
Michail Vourlakos 2020-12-27 18:55:12 +02:00
parent 3c17c2e839
commit ae9836ccba
6 changed files with 130 additions and 107 deletions

View File

@ -1273,6 +1273,21 @@ void View::setColorizer(QQuickItem *colorizer)
emit colorizerChanged();
}
QQuickItem *View::currentParabolicItem() const
{
return m_currentParabolicItem;
}
void View::setCurrentParabolicItem(QQuickItem *item)
{
if (m_currentParabolicItem == item) {
return;
}
m_currentParabolicItem = item;
emit currentParabolicItemChanged();
}
ViewPart::Effects *View::effects() const
{
return m_effects;
@ -1352,6 +1367,7 @@ bool View::event(QEvent *e)
case QEvent::Leave:
m_containsMouse = false;
setContainsDrag(false);
setCurrentParabolicItem(nullptr);
break;
case QEvent::DragEnter:
@ -1408,6 +1424,23 @@ bool View::event(QEvent *e)
case QEvent::MouseMove:
if (auto me = dynamic_cast<QMouseEvent *>(e)) {
if (m_currentParabolicItem) {
QRectF grect = m_currentParabolicItem->mapRectToScene(QRectF(0, 0, m_currentParabolicItem->width(), m_currentParabolicItem->height()));
if (grect.contains(me->windowPos())) {
//! sending move event to parabolic item
QPointF internal = m_currentParabolicItem->mapFromScene(me->windowPos());
QMetaObject::invokeMethod(m_currentParabolicItem,
"parabolicMove",
Qt::DirectConnection,
Q_ARG(int, internal.x()),
Q_ARG(int, internal.y()));
} else {
//! clearing parabolic item
setCurrentParabolicItem(nullptr);
}
}
//! adjust event by taking into account paddings
if (m_padding
&& !m_padding->isEmpty()

View File

@ -117,6 +117,7 @@ class View : public PlasmaQuick::ContainmentView
Q_PROPERTY(float offset READ offset WRITE setOffset NOTIFY offsetChanged)
Q_PROPERTY(QQuickItem *colorizer READ colorizer WRITE setColorizer NOTIFY colorizerChanged)
Q_PROPERTY(QQuickItem *currentParabolicItem READ currentParabolicItem WRITE setCurrentParabolicItem NOTIFY currentParabolicItemChanged)
Q_PROPERTY(Latte::Layout::GenericLayout *layout READ layout WRITE setLayout NOTIFY layoutChanged)
Q_PROPERTY(Latte::ViewPart::Effects *effects READ effects NOTIFY effectsChanged)
@ -231,6 +232,9 @@ public:
QQuickItem *colorizer() const;
void setColorizer(QQuickItem *colorizer);
QQuickItem *currentParabolicItem() const;
void setCurrentParabolicItem(QQuickItem *item);
QQuickView *configView();
ViewPart::Effects *effects() const;
@ -298,6 +302,7 @@ signals:
void configWindowGeometryChanged(); // is called from config windows
void containsDragChanged();
void contextMenuIsShownChanged();
void currentParabolicItemChanged();
void dockLocationChanged();
void editThicknessChanged();
void effectsChanged();
@ -430,6 +435,7 @@ private:
Layout::GenericLayout *m_layout{nullptr};
QQuickItem *m_colorizer{nullptr};
QQuickItem *m_currentParabolicItem{nullptr};
QPointer<PlasmaQuick::ConfigView> m_appletConfigView;
QPointer<ViewPart::PrimaryConfigView> m_primaryConfigView;

View File

@ -65,6 +65,12 @@ AbilityHost.ParabolicEffect {
parabolic.startRestoreZoomTimer();
}
}
onCurrentParabolicItemChanged: {
if (!parabolic.view.currentParabolicItem) {
parabolic.startRestoreZoomTimer();
}
}
}
function startRestoreZoomTimer(){
@ -141,8 +147,8 @@ AbilityHost.ParabolicEffect {
interval: 90
onTriggered: {
if (parabolic.restoreZoomIsBlocked) {
return
if (parabolic.restoreZoomIsBlocked || parabolic.view.currentParabolicItem) {
return;
}
parabolic.sglClearZoom();

View File

@ -48,6 +48,10 @@ Item {
signal mousePressed(int x, int y, int button);
signal mouseReleased(int x, int y, int button);
signal parabolicEntered(int mouseX, int mouseY);
signal parabolicMove(int mouseX, int mouseY);
signal parabolicExited();
property bool animationsEnabled: true
property bool parabolicEffectIsSupported: true
property bool canShowAppletNumberBadge: !isSeparator && !isHidden && !isLattePlasmoid
@ -303,7 +307,7 @@ Item {
property Item shortcuts: null
property Item userRequests: null
property bool containsMouse: appletMouseArea.containsMouse || (isLattePlasmoid && latteApplet.containsMouse)
property bool containsMouse: (latteView && latteView.currentParabolicItem === appletItem) || (isLattePlasmoid && latteApplet.containsMouse)
property bool pressed: viewSignalsConnector.pressed || clickedAnimation.running
@ -725,6 +729,12 @@ Item {
}
}
}
onCurrentParabolicItemChanged: {
if (latteView && latteView.currentParabolicItem !== appletItem) {
appletItem.parabolicExited();
}
}
}
Connections {
@ -770,23 +780,6 @@ Item {
}*/
/* DEPRECATED in favor of VIEW::MouseSignalsTracking
MouseArea{
id: appletMouseAreaBottom
anchors.fill: parent
propagateComposedEvents: true
visible: (!appletMouseArea.visible || !appletMouseArea.enabled) && !root.editMode && !originalAppletBehavior
onPressed: {
appletItem.activateAppletForNeutralAreas(mouse);
mouse.accepted = false;
}
onReleased: {
mouse.accepted = false;
}
}*/
//! Main Applet Shown Area
Flow{
id: appletFlow
@ -1034,108 +1027,93 @@ Item {
]
}
MouseArea{
id: appletMouseArea
MouseArea {
id: parabolicMouseArea
anchors.fill: parent
enabled: visible
hoverEnabled: latteApplet ? false : true
propagateComposedEvents: visible
//! a way must be found in order for this be enabled
//! only to support springloading for plasma 5.10
//! also on this is based the tooltips behavior by enabling it
//! plasma tooltips are disabled
visible: acceptMouseEvents
property bool blockWheel: false
hoverEnabled: true
visible: parabolicEffectIsSupported && latteView && latteView.currentParabolicItem !== appletItem
onEntered: {
appletItem.parabolic.stopRestoreZoomTimer();
if (restoreAnimation.running) {
restoreAnimation.stop();
appletItem.parabolicEntered(mouseX, mouseY);
if (latteView) {
latteView.currentParabolicItem = appletItem;
}
}
}
if (!(isSeparator || isSpacer)) {
root.showTooltipLabel(appletItem, applet.title);
}
onParabolicEntered: {
appletItem.parabolic.stopRestoreZoomTimer();
if (originalAppletBehavior || communicator.requires.parabolicEffectLocked || !parabolicEffectIsSupported) {
return;
}
if (restoreAnimation.running) {
restoreAnimation.stop();
}
if (root.isHalfShown || (root.latteApplet
&& (root.latteApplet.noTasksInAnimation>0 || root.latteApplet.contextMenu))) {
return;
}
if (!(isSeparator || isSpacer)) {
root.showTooltipLabel(appletItem, applet.title);
}
if (originalAppletBehavior || communicator.requires.parabolicEffectLocked || !parabolicEffectIsSupported) {
return;
}
if (root.isHalfShown || (root.latteApplet
&& (root.latteApplet.noTasksInAnimation>0 || root.latteApplet.contextMenu))) {
return;
}
if (root.isHorizontal){
layoutsContainer.currentSpot = mouseX;
wrapper.calculateParabolicScales(mouseX);
}
else{
layoutsContainer.currentSpot = mouseY;
wrapper.calculateParabolicScales(mouseY);
}
}
onParabolicMove: {
if (root.isHalfShown || (root.latteApplet
&& (root.latteApplet.noTasksInAnimation>0 || root.latteApplet.contextMenu))) {
return;
}
var rapidMovement = appletItem.parabolic.lastIndex>=0 && Math.abs(appletItem.parabolic.lastIndex-index)>1;
if (rapidMovement) {
parabolic.setDirectRenderingEnabled(true);
}
if( ((wrapper.zoomScale == 1 || wrapper.zoomScale === appletItem.parabolic.factor.zoom) && !parabolic.directRenderingEnabled) || parabolic.directRenderingEnabled) {
if (root.isHorizontal){
layoutsContainer.currentSpot = mouseX;
wrapper.calculateParabolicScales(mouseX);
var step = Math.abs(layoutsContainer.currentSpot-mouseX);
if (step >= appletItem.animations.hoverPixelSensitivity){
layoutsContainer.currentSpot = mouseX;
wrapper.calculateParabolicScales(mouseX);
}
}
else{
layoutsContainer.currentSpot = mouseY;
wrapper.calculateParabolicScales(mouseY);
}
}
var step = Math.abs(layoutsContainer.currentSpot-mouseY);
if (step >= appletItem.animations.hoverPixelSensitivity){
layoutsContainer.currentSpot = mouseY;
onExited:{
if (communicator.appletIconItemIsShown()) {
communicator.setAppletIconItemActive(false);
}
root.hideTooltipLabel();
if (appletItem.parabolic.factor.zoom>1){
appletItem.parabolic.startRestoreZoomTimer();
}
}
onPositionChanged: {
if (originalAppletBehavior || !parabolicEffectIsSupported) {
mouse.accepted = false;
return;
}
if (root.isHalfShown || (root.latteApplet
&& (root.latteApplet.noTasksInAnimation>0 || root.latteApplet.contextMenu))) {
return;
}
var rapidMovement = appletItem.parabolic.lastIndex>=0 && Math.abs(appletItem.parabolic.lastIndex-index)>1;
if (rapidMovement) {
parabolic.setDirectRenderingEnabled(true);
}
if( ((wrapper.zoomScale == 1 || wrapper.zoomScale === appletItem.parabolic.factor.zoom) && !parabolic.directRenderingEnabled) || parabolic.directRenderingEnabled) {
if (root.isHorizontal){
var step = Math.abs(layoutsContainer.currentSpot-mouse.x);
if (step >= appletItem.animations.hoverPixelSensitivity){
layoutsContainer.currentSpot = mouse.x;
wrapper.calculateParabolicScales(mouse.x);
}
}
else{
var step = Math.abs(layoutsContainer.currentSpot-mouse.y);
if (step >= appletItem.animations.hoverPixelSensitivity){
layoutsContainer.currentSpot = mouse.y;
wrapper.calculateParabolicScales(mouse.y);
}
wrapper.calculateParabolicScales(mouseY);
}
}
}
}
mouse.accepted = false;
onParabolicExited: {
if (communicator.appletIconItemIsShown()) {
communicator.setAppletIconItemActive(false);
}
//! these are needed in order for these events to be really forwarded underneath
//! otherwise there were applets that did not receive them e.g. lock/logout applet
//! when parabolic effect was used
onPressed: mouse.accepted = false;
onReleased: mouse.accepted = false;
root.hideTooltipLabel();
/* if (appletItem.parabolic.factor.zoom>1){
appletItem.parabolic.startRestoreZoomTimer();
} */
}
//! Debug Elements

View File

@ -559,7 +559,7 @@ Item{
source: _wrapperContainer
enabled: opacity != 0 ? true : false
opacity: appletMouseArea.containsMouse && isActive ? 1 : 0
opacity: appletItem.containsMouse && isActive ? 1 : 0
brightness: 0.25
contrast: 0.15
visible: !indicators.info.providesHoveredAnimation

View File

@ -46,9 +46,9 @@ Item{
readonly property bool isActive: appletIsValid ? appletItem.isActive : false
readonly property bool isGroup: false
readonly property bool isHovered: appletIsValid ? appletMouseArea.containsMouse : false
readonly property bool isHovered: appletIsValid ? appletItem.containsMouse : false
readonly property bool isMinimized: false
readonly property bool isPressed: appletIsValid ? appletMouseArea.pressed : false
readonly property bool isPressed: false //appletIsValid ? appletMouseArea.pressed : false
readonly property bool inAttention: false
readonly property bool inRemoving: false