Changeset View
Standalone View
libkwineffects/kwineffects.h
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org> | 5 | Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org> | ||
6 | Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com> | 6 | Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com> | ||
7 | Copyright (C) 2010, 2011 Martin Gräßlin <mgraesslin@kde.org> | 7 | Copyright (C) 2010, 2011 Martin Gräßlin <mgraesslin@kde.org> | ||
8 | Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com> | ||||
8 | 9 | | |||
9 | This program is free software; you can redistribute it and/or modify | 10 | This program is free software; you can redistribute it and/or modify | ||
10 | it under the terms of the GNU General Public License as published by | 11 | it under the terms of the GNU General Public License as published by | ||
11 | the Free Software Foundation; either version 2 of the License, or | 12 | the Free Software Foundation; either version 2 of the License, or | ||
12 | (at your option) any later version. | 13 | (at your option) any later version. | ||
13 | 14 | | |||
14 | This program is distributed in the hope that it will be useful, | 15 | This program is distributed in the hope that it will be useful, | ||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | 18 | GNU General Public License for more details. | ||
18 | 19 | | |||
19 | You should have received a copy of the GNU General Public License | 20 | You should have received a copy of the GNU General Public License | ||
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | *********************************************************************/ | 22 | *********************************************************************/ | ||
22 | 23 | | |||
23 | #ifndef KWINEFFECTS_H | 24 | #ifndef KWINEFFECTS_H | ||
24 | #define KWINEFFECTS_H | 25 | #define KWINEFFECTS_H | ||
25 | 26 | | |||
26 | #include <kwinconfig.h> | 27 | #include <kwinconfig.h> | ||
27 | #include <kwineffects_export.h> | 28 | #include <kwineffects_export.h> | ||
28 | #include <kwinglobals.h> | 29 | #include <kwinglobals.h> | ||
29 | 30 | | |||
31 | #include <QEasingCurve> | ||||
30 | #include <QIcon> | 32 | #include <QIcon> | ||
31 | #include <QPair> | 33 | #include <QPair> | ||
32 | #include <QSet> | 34 | #include <QSet> | ||
33 | #include <QRect> | 35 | #include <QRect> | ||
34 | #include <QRegion> | 36 | #include <QRegion> | ||
35 | #include <QVector2D> | 37 | #include <QVector2D> | ||
36 | #include <QVector3D> | 38 | #include <QVector3D> | ||
37 | 39 | | |||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Line(s) | |||||
181 | * For more information about this, see the documentation of the corresponding | 183 | * For more information about this, see the documentation of the corresponding | ||
182 | * classes. | 184 | * classes. | ||
183 | * | 185 | * | ||
184 | * @{ | 186 | * @{ | ||
185 | **/ | 187 | **/ | ||
186 | 188 | | |||
187 | #define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor )) | 189 | #define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor )) | ||
188 | #define KWIN_EFFECT_API_VERSION_MAJOR 0 | 190 | #define KWIN_EFFECT_API_VERSION_MAJOR 0 | ||
189 | #define KWIN_EFFECT_API_VERSION_MINOR 225 | 191 | #define KWIN_EFFECT_API_VERSION_MINOR 226 | ||
190 | #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ | 192 | #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ | ||
191 | KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) | 193 | KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) | ||
192 | 194 | | |||
193 | enum WindowQuadType { | 195 | enum WindowQuadType { | ||
194 | WindowQuadError, // for the stupid default ctor | 196 | WindowQuadError, // for the stupid default ctor | ||
195 | WindowQuadContents, | 197 | WindowQuadContents, | ||
196 | WindowQuadDecoration, | 198 | WindowQuadDecoration, | ||
197 | // Shadow Quad types | 199 | // Shadow Quad types | ||
▲ Show 20 Lines • Show All 3081 Lines • ▼ Show 20 Line(s) | |||||
3279 | protected: | 3281 | protected: | ||
3280 | void setScreenProjectionMatrix(const QMatrix4x4 &projection); | 3282 | void setScreenProjectionMatrix(const QMatrix4x4 &projection); | ||
3281 | 3283 | | |||
3282 | private: | 3284 | private: | ||
3283 | EffectFramePrivate* const d; | 3285 | EffectFramePrivate* const d; | ||
3284 | }; | 3286 | }; | ||
3285 | 3287 | | |||
3286 | /** | 3288 | /** | ||
3289 | * The TimeLine class is a helper for controlling animations. | ||||
3290 | **/ | ||||
3291 | class KWINEFFECTS_EXPORT TimeLine | ||||
3292 | { | ||||
3293 | public: | ||||
3294 | /** | ||||
3295 | * Direction of the timeline. | ||||
3296 | * | ||||
3297 | * When the direction of the timeline is Forward, the progress | ||||
3298 | * value will go from 0.0 to 1.0. | ||||
3299 | * | ||||
3300 | * When the direction of the timeline is Backward, the progress | ||||
3301 | * value will go from 1.0 to 0.0. | ||||
3302 | **/ | ||||
3303 | enum Direction { | ||||
3304 | Forward, | ||||
3305 | Backward | ||||
3306 | }; | ||||
3307 | | ||||
3308 | /** | ||||
3309 | * Constructs a new instance of TimeLine. | ||||
3310 | * | ||||
3311 | * @param duration Duration of the timeline, in milliseconds | ||||
3312 | * @param direction Direction of the timeline | ||||
3313 | * @since 5.14 | ||||
3314 | **/ | ||||
3315 | explicit TimeLine(std::chrono::milliseconds duration = std::chrono::milliseconds(1000), | ||||
graesslin: As it's new API: maybe use std::chrono::msec instead of int. | |||||
Not sure if it is worth it right now. That would be the only place where std::chrono::milliseconds is used. Maybe, it would be better to switch to std::chrono::milliseconds in the next major release(KWin 6)? So animationTime, prePaintScreen, and prePaintWindow use it too. zzag: Not sure if it is worth it right now. That would be the only place where std::chrono… | |||||
We don't need to wait for KWin 6 for this. If we want to use chrono, we can integrate and in worst case have to change the ABI. Personally I think it is worth it as it gives way more semantics to the API. If we start with new code it will be easier to migrate the code in future. From having done two large ports in KWin: I would start with such a small class. So for long time perspective I would say it's worth to start now and it's not a problem to mix it. Just like QTimer supports chrono now. graesslin: We don't need to wait for KWin 6 for this. If we want to use chrono, we can integrate and in… | |||||
3316 | Direction direction = Forward); | ||||
3317 | TimeLine(const TimeLine &other); | ||||
3318 | ~TimeLine(); | ||||
3319 | | ||||
3320 | /** | ||||
3321 | * Returns the current value of the timeline. | ||||
3322 | * | ||||
3323 | * @since 5.14 | ||||
3324 | **/ | ||||
3325 | qreal value() const; | ||||
3326 | | ||||
3327 | /** | ||||
3328 | * Updates the progress of the timeline. | ||||
3329 | * | ||||
romangg: Name it differently, could be confused with l- and rvalues. | |||||
3330 | * @note The delta value should be a non-negative number, i.e. it | ||||
3331 | * should be greater or equal to 0. | ||||
3332 | * | ||||
3333 | * @param delta The number milliseconds passed since last frame | ||||
3334 | * @since 5.14 | ||||
3335 | **/ | ||||
3336 | void update(std::chrono::milliseconds delta); | ||||
3337 | | ||||
3338 | /** | ||||
3339 | * Returns the number of elapsed milliseconds. | ||||
3340 | * | ||||
3341 | * @see setElapsed | ||||
3342 | * @since 5.14 | ||||
3343 | **/ | ||||
3344 | std::chrono::milliseconds elapsed() const; | ||||
3345 | | ||||
3346 | /** | ||||
3347 | * Sets the number of elapsed milliseconds. | ||||
3348 | * | ||||
3349 | * This method overwrites previous value of elapsed milliseconds. | ||||
3350 | * If the new value of elapsed milliseconds is greater or equal | ||||
3351 | * to duration of the timeline, the timeline will be finished, i.e. | ||||
3352 | * proceeding TimeLine::done method calls will return @c true. | ||||
3353 | * Please don't use it. Instead, use TimeLine::update. | ||||
3354 | * | ||||
3355 | * @note The new number of elapsed milliseconds should be a non-negative | ||||
3356 | * number, i.e. it should be greater or equal to 0. | ||||
3357 | * | ||||
3358 | * @param elapsed The new number of elapsed milliseconds | ||||
3359 | * @see elapsed | ||||
3360 | * @since 5.14 | ||||
3361 | **/ | ||||
3362 | void setElapsed(std::chrono::milliseconds elapsed); | ||||
3363 | | ||||
3364 | /** | ||||
3365 | * Returns the duration of the timeline. | ||||
3366 | * | ||||
3367 | * @returns Duration of the timeline, in milliseconds | ||||
3368 | * @see setDuration | ||||
3369 | * @since 5.14 | ||||
3370 | **/ | ||||
3371 | std::chrono::milliseconds duration() const; | ||||
3372 | | ||||
3373 | /** | ||||
3374 | * Sets the duration of the timeline. | ||||
3375 | * | ||||
3376 | * In addition to setting new value of duration, the timeline will | ||||
3377 | * try to retarget the number of elapsed milliseconds to match | ||||
3378 | * as close as possible old progress value. If the new duration | ||||
3379 | * is much smaller than old duration, there is a big chance that | ||||
3380 | * the timeline will be finished after setting new duration. | ||||
3381 | * | ||||
3382 | * @note The new duration should be a positive number, i.e. it | ||||
3383 | * should be greater or equal to 1. | ||||
3384 | * | ||||
3385 | * @param duration The new duration of the timeline, in milliseconds | ||||
3386 | * @see duration | ||||
3387 | * @since 5.14 | ||||
3388 | **/ | ||||
3389 | void setDuration(std::chrono::milliseconds duration); | ||||
3390 | | ||||
3391 | /** | ||||
3392 | * Returns the direction of the timeline. | ||||
3393 | * | ||||
3394 | * @returns Direction of the timeline(TimeLine::Forward or TimeLine::Backward) | ||||
3395 | * @see setDirection | ||||
3396 | * @see toggleDirection | ||||
3397 | * @since 5.14 | ||||
3398 | **/ | ||||
3399 | Direction direction() const; | ||||
3400 | | ||||
3401 | /** | ||||
3402 | * Sets the direction of the timeline. | ||||
3403 | * | ||||
3404 | * @param direction The new direction of the timeline | ||||
3405 | * @see direction | ||||
3406 | * @see toggleDirection | ||||
3407 | * @since 5.14 | ||||
3408 | **/ | ||||
3409 | void setDirection(Direction direction); | ||||
3410 | | ||||
3411 | /** | ||||
3412 | * Toggles the direction of the timeline. | ||||
3413 | * | ||||
3414 | * If the direction of the timeline was TimeLine::Forward, it becomes | ||||
3415 | * TimeLine::Backward, and vice verca. | ||||
3416 | * | ||||
3417 | * @see direction | ||||
3418 | * @see setDirection | ||||
3419 | * @since 5.14 | ||||
3420 | **/ | ||||
3421 | void toggleDirection(); | ||||
3422 | | ||||
3423 | /** | ||||
3424 | * Returns the easing curve of the timeline. | ||||
3425 | * | ||||
3426 | * @see setEasingCurve | ||||
3427 | * @since 5.14 | ||||
3428 | **/ | ||||
3429 | QEasingCurve easingCurve() const; | ||||
3430 | | ||||
3431 | /** | ||||
3432 | * Sets new easing curve. | ||||
3433 | * | ||||
3434 | * @param easingCurve An easing curve to be set | ||||
3435 | * @see easingCurve | ||||
3436 | * @since 5.14 | ||||
3437 | **/ | ||||
3438 | void setEasingCurve(const QEasingCurve &easingCurve); | ||||
3439 | | ||||
3440 | /** | ||||
3441 | * Sets new easing curve by providing its type. | ||||
3442 | * | ||||
3443 | * @param type Type of the easing curve(e.g. QEasingCurve::InQuad, etc) | ||||
3444 | * @see easingCurve | ||||
3445 | * @since 5.14 | ||||
3446 | **/ | ||||
3447 | void setEasingCurve(QEasingCurve::Type type); | ||||
3448 | | ||||
3449 | /** | ||||
3450 | * Returns whether the timeline is currently in progress. | ||||
3451 | * | ||||
3452 | * @see done | ||||
3453 | * @since 5.14 | ||||
3454 | **/ | ||||
3455 | bool running() const; | ||||
3456 | | ||||
3457 | /** | ||||
3458 | * Returns whether the timeline is finished. | ||||
3459 | * | ||||
3460 | * @see reset | ||||
3461 | * @since 5.14 | ||||
3462 | **/ | ||||
3463 | bool done() const; | ||||
3464 | | ||||
3465 | /** | ||||
3466 | * Resets the timeline to initial state. | ||||
3467 | * | ||||
3468 | * @since 5.14 | ||||
3469 | **/ | ||||
3470 | void reset(); | ||||
3471 | | ||||
3472 | TimeLine &operator=(const TimeLine &other); | ||||
3473 | | ||||
graesslin: Please use a d-ptr | |||||
3474 | private: | ||||
3475 | qreal progress() const; | ||||
3476 | | ||||
3477 | private: | ||||
3478 | class Data; | ||||
3479 | QSharedDataPointer<Data> d; | ||||
3480 | }; | ||||
3481 | | ||||
3482 | /** | ||||
3287 | * Pointer to the global EffectsHandler object. | 3483 | * Pointer to the global EffectsHandler object. | ||
3288 | **/ | 3484 | **/ | ||
3289 | extern KWINEFFECTS_EXPORT EffectsHandler* effects; | 3485 | extern KWINEFFECTS_EXPORT EffectsHandler* effects; | ||
3290 | 3486 | | |||
3291 | /*************************************************************** | 3487 | /*************************************************************** | ||
3292 | WindowVertex | 3488 | WindowVertex | ||
3293 | ***************************************************************/ | 3489 | ***************************************************************/ | ||
3294 | 3490 | | |||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Line(s) | |||||
3507 | void Effect::initConfig() | 3703 | void Effect::initConfig() | ||
3508 | { | 3704 | { | ||
3509 | T::instance(effects->config()); | 3705 | T::instance(effects->config()); | ||
3510 | } | 3706 | } | ||
3511 | 3707 | | |||
3512 | } // namespace | 3708 | } // namespace | ||
3513 | Q_DECLARE_METATYPE(KWin::EffectWindow*) | 3709 | Q_DECLARE_METATYPE(KWin::EffectWindow*) | ||
3514 | Q_DECLARE_METATYPE(QList<KWin::EffectWindow*>) | 3710 | Q_DECLARE_METATYPE(QList<KWin::EffectWindow*>) | ||
3711 | Q_DECLARE_METATYPE(KWin::TimeLine) | ||||
3515 | 3712 | | |||
3516 | /** @} */ | 3713 | /** @} */ | ||
3517 | 3714 | | |||
3518 | #endif // KWINEFFECTS_H | 3715 | #endif // KWINEFFECTS_H |
As it's new API: maybe use std::chrono::msec instead of int.