Morphingpopups effect, to animate tooltips
this effect, derived from the Maximize one, will take the place of the manual window position animation that Plasma tooltip are using. this should cause less problems as animationg positions on X is very error prone, plus it's less jarring when the tooltip sizes changes too, since that gets animated as well (behavior similar to Windows7 taskbar tooltips) REVIEW:126968
This commit is contained in:
parent
093e56ff05
commit
82a1b3ee13
5 changed files with 163 additions and 0 deletions
|
@ -129,6 +129,7 @@ add_subdirectory( fade )
|
|||
add_subdirectory( fadedesktop )
|
||||
add_subdirectory( login )
|
||||
add_subdirectory( maximize )
|
||||
add_subdirectory( morphingpopups )
|
||||
add_subdirectory( scalein )
|
||||
add_subdirectory( translucency )
|
||||
add_subdirectory( windowaperture )
|
||||
|
|
1
effects/morphingpopups/CMakeLists.txt
Normal file
1
effects/morphingpopups/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
|||
add_subdirectory( package )
|
6
effects/morphingpopups/package/CMakeLists.txt
Normal file
6
effects/morphingpopups/package/CMakeLists.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
install(DIRECTORY contents DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/effects/kwin4_effect_morphingpopups)
|
||||
install(FILES metadata.desktop DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/effects/kwin4_effect_morphingpopups)
|
||||
|
||||
install(FILES metadata.desktop
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME}
|
||||
RENAME kwin4_effect_morphingpopups.desktop)
|
134
effects/morphingpopups/package/contents/code/morphingpopups.js
Normal file
134
effects/morphingpopups/package/contents/code/morphingpopups.js
Normal file
|
@ -0,0 +1,134 @@
|
|||
/********************************************************************
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
|
||||
Copyright (C) 2016 Marco Martin <mart@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
/*global effect, effects, animate, animationTime, Effect*/
|
||||
var morphingEffect = {
|
||||
duration: animationTime(150),
|
||||
loadConfig: function () {
|
||||
"use strict";
|
||||
morphingEffect.duration = animationTime(150);
|
||||
},
|
||||
cleanup: function(window) {
|
||||
"use strict";
|
||||
|
||||
delete window.moveAnimation;
|
||||
delete window.fadeAnimation;
|
||||
},
|
||||
geometryChange: function (window, oldGeometry) {
|
||||
"use strict";
|
||||
|
||||
//only tooltips and notifications
|
||||
if (!window.tooltip && !window.notification) {
|
||||
return;
|
||||
}
|
||||
|
||||
var newGeometry = window.geometry;
|
||||
|
||||
//only do the transition for near enough tooltips,
|
||||
//don't cross the whole screen: ugly
|
||||
var distance = Math.abs(oldGeometry.x - newGeometry.x) + Math.abs(oldGeometry.y - newGeometry.y);
|
||||
|
||||
if (distance > (newGeometry.width + newGeometry.height) * 2) {
|
||||
return;
|
||||
//Also don't animate very small steps
|
||||
} else if (distance < 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
//don't resize it "too much", set as four times
|
||||
if ((newGeometry.width / oldGeometry.width) > 4 ||
|
||||
(oldGeometry.width / newGeometry.width) > 4 ||
|
||||
(newGeometry.height / oldGeometry.height) > 4 ||
|
||||
(oldGeometry.height / newGeometry.height) > 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
//WindowForceBackgroundContrastRole
|
||||
window.setData(7, true);
|
||||
//WindowForceBlurRole
|
||||
window.setData(5, true);
|
||||
|
||||
|
||||
if (window.moveAnimation) {
|
||||
if (window.moveAnimation[0]) {
|
||||
retarget(window.moveAnimation[0], {
|
||||
value1: newGeometry.width,
|
||||
value2: newGeometry.height
|
||||
}, morphingEffect.duration);
|
||||
}
|
||||
if (window.moveAnimation[1]) {
|
||||
retarget(window.moveAnimation[1], {
|
||||
value1: newGeometry.x + newGeometry.width/2,
|
||||
value2: newGeometry.y + newGeometry.height / 2
|
||||
}, morphingEffect.duration);
|
||||
}
|
||||
|
||||
} else {
|
||||
window.moveAnimation = animate({
|
||||
window: window,
|
||||
duration: morphingEffect.duration,
|
||||
animations: [{
|
||||
type: Effect.Size,
|
||||
to: {
|
||||
value1: newGeometry.width,
|
||||
value2: newGeometry.height
|
||||
},
|
||||
from: {
|
||||
value1: oldGeometry.width,
|
||||
value2: oldGeometry.height
|
||||
}
|
||||
}, {
|
||||
type: Effect.Position,
|
||||
to: {
|
||||
value1: newGeometry.x + newGeometry.width / 2,
|
||||
value2: newGeometry.y + newGeometry.height / 2
|
||||
},
|
||||
from: {
|
||||
value1: oldGeometry.x + oldGeometry.width / 2,
|
||||
value2: oldGeometry.y + oldGeometry.height / 2
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (window.fadeAnimation) {
|
||||
retarget(window.fadeAnimation[0], 1.0, morphingEffect.duration);
|
||||
|
||||
} else {
|
||||
window.fadeAnimation = animate({
|
||||
window: window,
|
||||
duration: morphingEffect.duration,
|
||||
animations: [{
|
||||
type: Effect.CrossFadePrevious,
|
||||
to: 1.0,
|
||||
from: 0.0
|
||||
}]
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
init: function () {
|
||||
"use strict";
|
||||
effect.configChanged.connect(morphingEffect.loadConfig);
|
||||
effects.windowGeometryShapeChanged.connect(morphingEffect.geometryChange);
|
||||
effect.animationEnded.connect(morphingEffect.cleanup);
|
||||
}
|
||||
};
|
||||
morphingEffect.init();
|
21
effects/morphingpopups/package/metadata.desktop
Normal file
21
effects/morphingpopups/package/metadata.desktop
Normal file
|
@ -0,0 +1,21 @@
|
|||
[Desktop Entry]
|
||||
Comment=Cross fade animation when Tooltips or Notifications change their geometry
|
||||
Encoding=UTF-8
|
||||
Icon=preferences-system-windows-effect-morphingpopups
|
||||
Name=Morphing popups
|
||||
Type=Service
|
||||
X-KDE-ParentApp=
|
||||
X-KDE-PluginInfo-Author=Marco Martin
|
||||
X-KDE-PluginInfo-Category=Appearance
|
||||
X-KDE-PluginInfo-Email=mart@kde.org
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-Name=kwin4_effect_morphingpopups
|
||||
X-KDE-PluginInfo-Version=1
|
||||
X-KDE-PluginInfo-Website=
|
||||
X-KDE-ServiceTypes=KWin/Effect
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
||||
X-KDE-Ordering=60
|
||||
X-Plasma-API=javascript
|
||||
X-Plasma-MainScript=code/morphingpopups.js
|
||||
X-Plasma-RemoteLocation=
|
||||
X-KWin-Video-Url=http://files.kde.org/plasma/kwin/effect-videos/morphingpopups.ogv
|
Loading…
Reference in a new issue