Changeset View
Changeset View
Standalone View
Standalone View
effects/cube/cube.cpp
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | 145 | foreach (int i, borderList) { | |||
---|---|---|---|---|---|
146 | borderActivateSphere.append(ElectricBorder(i)); | 146 | borderActivateSphere.append(ElectricBorder(i)); | ||
147 | effects->reserveElectricBorder(ElectricBorder(i), this); | 147 | effects->reserveElectricBorder(ElectricBorder(i), this); | ||
148 | } | 148 | } | ||
149 | 149 | | |||
150 | cubeOpacity = (float)CubeConfig::opacity() / 100.0f; | 150 | cubeOpacity = (float)CubeConfig::opacity() / 100.0f; | ||
151 | opacityDesktopOnly = CubeConfig::opacityDesktopOnly(); | 151 | opacityDesktopOnly = CubeConfig::opacityDesktopOnly(); | ||
152 | displayDesktopName = CubeConfig::displayDesktopName(); | 152 | displayDesktopName = CubeConfig::displayDesktopName(); | ||
153 | reflection = CubeConfig::reflection(); | 153 | reflection = CubeConfig::reflection(); | ||
154 | // TODO: rename rotationDuration to duration | 154 | // TODO: Rename rotationDuration to duration so we | ||
155 | rotationDuration = animationTime(CubeConfig::rotationDuration() != 0 ? CubeConfig::rotationDuration() : 500); | 155 | // can use animationTime<CubeConfig>(500). | ||
156 | const int d = CubeConfig::rotationDuration() != 0 | ||||
157 | ? CubeConfig::rotationDuration() | ||||
158 | : 500; | ||||
159 | rotationDuration = std::chrono::milliseconds(static_cast<int>(animationTime(d))); | ||||
156 | backgroundColor = CubeConfig::backgroundColor(); | 160 | backgroundColor = CubeConfig::backgroundColor(); | ||
157 | capColor = CubeConfig::capColor(); | 161 | capColor = CubeConfig::capColor(); | ||
158 | paintCaps = CubeConfig::caps(); | 162 | paintCaps = CubeConfig::caps(); | ||
159 | closeOnMouseRelease = CubeConfig::closeOnMouseRelease(); | 163 | closeOnMouseRelease = CubeConfig::closeOnMouseRelease(); | ||
160 | zPosition = CubeConfig::zPosition(); | 164 | zPosition = CubeConfig::zPosition(); | ||
161 | 165 | | |||
162 | useForTabBox = CubeConfig::tabBox(); | 166 | useForTabBox = CubeConfig::tabBox(); | ||
163 | invertKeys = CubeConfig::invertKeys(); | 167 | invertKeys = CubeConfig::invertKeys(); | ||
164 | invertMouse = CubeConfig::invertMouse(); | 168 | invertMouse = CubeConfig::invertMouse(); | ||
165 | capDeformationFactor = (float)CubeConfig::capDeformation() / 100.0f; | 169 | capDeformationFactor = (float)CubeConfig::capDeformation() / 100.0f; | ||
166 | useZOrdering = CubeConfig::zOrdering(); | 170 | useZOrdering = CubeConfig::zOrdering(); | ||
167 | delete wallpaper; | 171 | delete wallpaper; | ||
168 | wallpaper = NULL; | 172 | wallpaper = NULL; | ||
169 | delete capTexture; | 173 | delete capTexture; | ||
170 | capTexture = NULL; | 174 | capTexture = NULL; | ||
171 | texturedCaps = CubeConfig::texturedCaps(); | 175 | texturedCaps = CubeConfig::texturedCaps(); | ||
172 | 176 | | |||
173 | timeLine.setCurveShape(QTimeLine::EaseInOutCurve); | 177 | timeLine.setEasingCurve(QEasingCurve::InOutSine); | ||
174 | timeLine.setDuration(rotationDuration); | 178 | timeLine.setDuration(rotationDuration); | ||
175 | 179 | | |||
176 | verticalTimeLine.setCurveShape(QTimeLine::EaseInOutCurve); | 180 | verticalTimeLine.setEasingCurve(QEasingCurve::InOutSine); | ||
177 | verticalTimeLine.setDuration(rotationDuration); | 181 | verticalTimeLine.setDuration(rotationDuration); | ||
178 | 182 | | |||
179 | // do not connect the shortcut if we use cylinder or sphere | 183 | // do not connect the shortcut if we use cylinder or sphere | ||
180 | if (!shortcutsRegistered) { | 184 | if (!shortcutsRegistered) { | ||
181 | QAction* cubeAction = m_cubeAction; | 185 | QAction* cubeAction = m_cubeAction; | ||
182 | cubeAction->setObjectName(QStringLiteral("Cube")); | 186 | cubeAction->setObjectName(QStringLiteral("Cube")); | ||
183 | cubeAction->setText(i18n("Desktop Cube")); | 187 | cubeAction->setText(i18n("Desktop Cube")); | ||
184 | KGlobalAccel::self()->setDefaultShortcut(cubeAction, QList<QKeySequence>() << Qt::CTRL + Qt::Key_F11); | 188 | KGlobalAccel::self()->setDefaultShortcut(cubeAction, QList<QKeySequence>() << Qt::CTRL + Qt::Key_F11); | ||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Line(s) | 324 | } else { | |||
325 | sphereShader->setUniform("height", (float)rect.height() * 0.5f); | 329 | sphereShader->setUniform("height", (float)rect.height() * 0.5f); | ||
326 | sphereShader->setUniform("u_offset", QVector2D(0, 0)); | 330 | sphereShader->setUniform("u_offset", QVector2D(0, 0)); | ||
327 | } | 331 | } | ||
328 | return true; | 332 | return true; | ||
329 | } | 333 | } | ||
330 | 334 | | |||
331 | void CubeEffect::startAnimation(AnimationState state) | 335 | void CubeEffect::startAnimation(AnimationState state) | ||
332 | { | 336 | { | ||
333 | QTimeLine::CurveShape shape; | 337 | QEasingCurve curve; | ||
334 | /* If this is first and only animation -> EaseInOut | 338 | /* If this is first and only animation -> EaseInOut | ||
335 | * there is more -> EaseIn | 339 | * there is more -> EaseIn | ||
336 | * If there was an animation before, and this is the last one -> EaseOut | 340 | * If there was an animation before, and this is the last one -> EaseOut | ||
337 | * there is more -> Linear */ | 341 | * there is more -> Linear */ | ||
338 | if (animationState == AnimationState::None) { | 342 | if (animationState == AnimationState::None) { | ||
339 | shape = animations.empty() ? QTimeLine::EaseInOutCurve : QTimeLine::EaseInCurve; | 343 | curve.setType(animations.empty() ? QEasingCurve::InOutSine : QEasingCurve::InCurve); | ||
340 | } else { | 344 | } else { | ||
341 | shape = animations.empty() ? QTimeLine::EaseOutCurve : QTimeLine::LinearCurve; | 345 | curve.setType(animations.empty() ? QEasingCurve::OutCurve : QEasingCurve::Linear); | ||
342 | } | 346 | } | ||
343 | timeLine.setCurveShape(shape); | 347 | timeLine.reset(); | ||
344 | timeLine.setCurrentTime(0); | 348 | timeLine.setEasingCurve(curve); | ||
345 | startAngle = currentAngle; | 349 | startAngle = currentAngle; | ||
346 | startFrontDesktop = frontDesktop; | 350 | startFrontDesktop = frontDesktop; | ||
347 | animationState = state; | 351 | animationState = state; | ||
348 | } | 352 | } | ||
349 | 353 | | |||
350 | void CubeEffect::startVerticalAnimation(VerticalAnimationState state) | 354 | void CubeEffect::startVerticalAnimation(VerticalAnimationState state) | ||
351 | { | 355 | { | ||
352 | /* Ignore if there is nowhere to rotate */ | 356 | /* Ignore if there is nowhere to rotate */ | ||
353 | if ((qFuzzyIsNull(verticalCurrentAngle - 90.0f) && state == VerticalAnimationState::Upwards) || | 357 | if ((qFuzzyIsNull(verticalCurrentAngle - 90.0f) && state == VerticalAnimationState::Upwards) || | ||
354 | (qFuzzyIsNull(verticalCurrentAngle + 90.0f) && state == VerticalAnimationState::Downwards)) { | 358 | (qFuzzyIsNull(verticalCurrentAngle + 90.0f) && state == VerticalAnimationState::Downwards)) { | ||
355 | return; | 359 | return; | ||
356 | } | 360 | } | ||
357 | verticalTimeLine.setCurrentTime(0); | 361 | verticalTimeLine.reset(); | ||
358 | verticalStartAngle = verticalCurrentAngle; | 362 | verticalStartAngle = verticalCurrentAngle; | ||
359 | verticalAnimationState = state; | 363 | verticalAnimationState = state; | ||
360 | } | 364 | } | ||
361 | 365 | | |||
362 | void CubeEffect::prePaintScreen(ScreenPrePaintData& data, int time) | 366 | void CubeEffect::prePaintScreen(ScreenPrePaintData& data, int time) | ||
363 | { | 367 | { | ||
364 | if (activated) { | 368 | if (activated) { | ||
365 | data.mask |= PAINT_SCREEN_TRANSFORMED | Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS | PAINT_SCREEN_BACKGROUND_FIRST; | 369 | data.mask |= PAINT_SCREEN_TRANSFORMED | Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS | PAINT_SCREEN_BACKGROUND_FIRST; | ||
366 | if (animationState == AnimationState::None && !animations.empty()) { | 370 | if (animationState == AnimationState::None && !animations.empty()) { | ||
367 | startAnimation(animations.dequeue()); | 371 | startAnimation(animations.dequeue()); | ||
368 | } | 372 | } | ||
369 | if (verticalAnimationState == VerticalAnimationState::None && !verticalAnimations.empty()) { | 373 | if (verticalAnimationState == VerticalAnimationState::None && !verticalAnimations.empty()) { | ||
370 | startVerticalAnimation(verticalAnimations.dequeue()); | 374 | startVerticalAnimation(verticalAnimations.dequeue()); | ||
371 | } | 375 | } | ||
372 | 376 | | |||
373 | if (animationState != AnimationState::None || verticalAnimationState != VerticalAnimationState::None) { | 377 | if (animationState != AnimationState::None || verticalAnimationState != VerticalAnimationState::None) { | ||
374 | if (animationState != AnimationState::None) { | 378 | if (animationState != AnimationState::None) { | ||
375 | timeLine.setCurrentTime(timeLine.currentTime() + time); | 379 | timeLine.update(std::chrono::milliseconds(time)); | ||
376 | } | 380 | } | ||
377 | if (verticalAnimationState != VerticalAnimationState::None) { | 381 | if (verticalAnimationState != VerticalAnimationState::None) { | ||
378 | verticalTimeLine.setCurrentTime(verticalTimeLine.currentTime() + time); | 382 | verticalTimeLine.update(std::chrono::milliseconds(time)); | ||
379 | } | 383 | } | ||
380 | rotateCube(); | 384 | rotateCube(); | ||
381 | } | 385 | } | ||
382 | } | 386 | } | ||
383 | effects->prePaintScreen(data, time); | 387 | effects->prePaintScreen(data, time); | ||
384 | } | 388 | } | ||
385 | 389 | | |||
386 | void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) | 390 | void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) | ||
Show All 20 Lines | 392 | if (activated) { | |||
407 | glEnable(GL_BLEND); | 411 | glEnable(GL_BLEND); | ||
408 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 412 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||
409 | 413 | | |||
410 | // some veriables needed for painting the caps | 414 | // some veriables needed for painting the caps | ||
411 | float cubeAngle = (float)((float)(effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 180.0f); | 415 | float cubeAngle = (float)((float)(effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 180.0f); | ||
412 | float point = rect.width() / 2 * tan(cubeAngle * 0.5f * M_PI / 180.0f); | 416 | float point = rect.width() / 2 * tan(cubeAngle * 0.5f * M_PI / 180.0f); | ||
413 | float zTranslate = zPosition + zoom; | 417 | float zTranslate = zPosition + zoom; | ||
414 | if (animationState == AnimationState::Start) { | 418 | if (animationState == AnimationState::Start) { | ||
415 | zTranslate *= timeLine.currentValue(); | 419 | zTranslate *= timeLine.value(); | ||
416 | } else if (animationState == AnimationState::Stop) { | 420 | } else if (animationState == AnimationState::Stop) { | ||
417 | zTranslate *= (1.0 - timeLine.currentValue()); | 421 | zTranslate *= (1.0 - timeLine.value()); | ||
418 | } | 422 | } | ||
419 | // reflection | 423 | // reflection | ||
420 | if (reflection) { | 424 | if (reflection) { | ||
421 | // we can use a huge scale factor (needed to calculate the rearground vertices) | 425 | // we can use a huge scale factor (needed to calculate the rearground vertices) | ||
422 | float scaleFactor = 1000000 * tan(60.0 * M_PI / 360.0f) / rect.height(); | 426 | float scaleFactor = 1000000 * tan(60.0 * M_PI / 360.0f) / rect.height(); | ||
423 | m_reflectionMatrix.setToIdentity(); | 427 | m_reflectionMatrix.setToIdentity(); | ||
424 | m_reflectionMatrix.scale(1.0, -1.0, 1.0); | 428 | m_reflectionMatrix.scale(1.0, -1.0, 1.0); | ||
425 | 429 | | |||
Show All 35 Lines | 464 | float vertices[] = { | |||
461 | -width * 0.5f, height, 0.0, | 465 | -width * 0.5f, height, 0.0, | ||
462 | width * 0.5f, height, 0.0, | 466 | width * 0.5f, height, 0.0, | ||
463 | width * scaleFactor, height, -5000, | 467 | width * scaleFactor, height, -5000, | ||
464 | -width * scaleFactor, height, -5000 | 468 | -width * scaleFactor, height, -5000 | ||
465 | }; | 469 | }; | ||
466 | // foreground | 470 | // foreground | ||
467 | float alpha = 0.7; | 471 | float alpha = 0.7; | ||
468 | if (animationState == AnimationState::Start) { | 472 | if (animationState == AnimationState::Start) { | ||
469 | alpha = 0.3 + 0.4 * timeLine.currentValue(); | 473 | alpha = 0.3 + 0.4 * timeLine.value(); | ||
470 | } else if (animationState == AnimationState::Stop) { | 474 | } else if (animationState == AnimationState::Stop) { | ||
471 | alpha = 0.3 + 0.4 * (1.0 - timeLine.currentValue()); | 475 | alpha = 0.3 + 0.4 * (1.0 - timeLine.value()); | ||
472 | } | 476 | } | ||
473 | glEnable(GL_BLEND); | 477 | glEnable(GL_BLEND); | ||
474 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 478 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||
475 | if (m_reflectionShader && m_reflectionShader->isValid()) { | 479 | if (m_reflectionShader && m_reflectionShader->isValid()) { | ||
476 | // ensure blending is enabled - no attribute stack | 480 | // ensure blending is enabled - no attribute stack | ||
477 | ShaderBinder binder(m_reflectionShader); | 481 | ShaderBinder binder(m_reflectionShader); | ||
478 | QMatrix4x4 windowTransformation = data.projectionMatrix(); | 482 | QMatrix4x4 windowTransformation = data.projectionMatrix(); | ||
479 | windowTransformation.translate(rect.x() + rect.width() * 0.5f, 0.0, 0.0); | 483 | windowTransformation.translate(rect.x() + rect.width() * 0.5f, 0.0, 0.0); | ||
Show All 38 Lines | |||||
518 | glDisable(GL_CULL_FACE); | 522 | glDisable(GL_CULL_FACE); | ||
519 | 523 | | |||
520 | glDisable(GL_BLEND); | 524 | glDisable(GL_BLEND); | ||
521 | 525 | | |||
522 | // desktop name box - inspired from coverswitch | 526 | // desktop name box - inspired from coverswitch | ||
523 | if (displayDesktopName) { | 527 | if (displayDesktopName) { | ||
524 | double opacity = 1.0; | 528 | double opacity = 1.0; | ||
525 | if (animationState == AnimationState::Start) { | 529 | if (animationState == AnimationState::Start) { | ||
526 | opacity = timeLine.currentValue(); | 530 | opacity = timeLine.value(); | ||
527 | } else if (animationState == AnimationState::Stop) { | 531 | } else if (animationState == AnimationState::Stop) { | ||
528 | opacity = 1.0 - timeLine.currentValue(); | 532 | opacity = 1.0 - timeLine.value(); | ||
529 | } | 533 | } | ||
530 | QRect screenRect = effects->clientArea(ScreenArea, activeScreen, frontDesktop); | 534 | QRect screenRect = effects->clientArea(ScreenArea, activeScreen, frontDesktop); | ||
531 | QRect frameRect = QRect(screenRect.width() * 0.33f + screenRect.x(), screenRect.height() * 0.95f + screenRect.y(), | 535 | QRect frameRect = QRect(screenRect.width() * 0.33f + screenRect.x(), screenRect.height() * 0.95f + screenRect.y(), | ||
532 | screenRect.width() * 0.34f, QFontMetrics(desktopNameFont).height()); | 536 | screenRect.width() * 0.34f, QFontMetrics(desktopNameFont).height()); | ||
533 | if (!desktopNameFrame) { | 537 | if (!desktopNameFrame) { | ||
534 | desktopNameFrame = effects->effectFrame(EffectFrameStyled); | 538 | desktopNameFrame = effects->effectFrame(EffectFrameStyled); | ||
535 | desktopNameFrame->setFont(desktopNameFont); | 539 | desktopNameFrame->setFont(desktopNameFont); | ||
536 | } | 540 | } | ||
Show All 11 Lines | 551 | { | |||
548 | QRect rect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); | 552 | QRect rect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); | ||
549 | m_rotationMatrix.setToIdentity(); | 553 | m_rotationMatrix.setToIdentity(); | ||
550 | float internalCubeAngle = 360.0f / effects->numberOfDesktops(); | 554 | float internalCubeAngle = 360.0f / effects->numberOfDesktops(); | ||
551 | float zTranslate = zPosition + zoom; | 555 | float zTranslate = zPosition + zoom; | ||
552 | float cubeAngle = (float)((float)(effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 180.0f); | 556 | float cubeAngle = (float)((float)(effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 180.0f); | ||
553 | float point = rect.width() / 2 * tan(cubeAngle * 0.5f * M_PI / 180.0f); | 557 | float point = rect.width() / 2 * tan(cubeAngle * 0.5f * M_PI / 180.0f); | ||
554 | /* Animations */ | 558 | /* Animations */ | ||
555 | if (animationState == AnimationState::Start) { | 559 | if (animationState == AnimationState::Start) { | ||
556 | zTranslate *= timeLine.currentValue(); | 560 | zTranslate *= timeLine.value(); | ||
557 | } else if (animationState == AnimationState::Stop) { | 561 | } else if (animationState == AnimationState::Stop) { | ||
558 | currentAngle = startAngle * (1.0 - timeLine.currentValue()); | 562 | currentAngle = startAngle * (1.0 - timeLine.value()); | ||
559 | zTranslate *= (1.0 - timeLine.currentValue()); | 563 | zTranslate *= (1.0 - timeLine.value()); | ||
560 | } else if (animationState != AnimationState::None) { | 564 | } else if (animationState != AnimationState::None) { | ||
561 | /* Left or right */ | 565 | /* Left or right */ | ||
562 | float endAngle = animationState == AnimationState::Right ? internalCubeAngle : -internalCubeAngle; | 566 | float endAngle = animationState == AnimationState::Right ? internalCubeAngle : -internalCubeAngle; | ||
563 | currentAngle = startAngle + timeLine.currentValue() * (endAngle - startAngle); | 567 | currentAngle = startAngle + timeLine.value() * (endAngle - startAngle); | ||
564 | frontDesktop = startFrontDesktop; | 568 | frontDesktop = startFrontDesktop; | ||
565 | } | 569 | } | ||
566 | /* Switching to next desktop: either by mouse or due to animation */ | 570 | /* Switching to next desktop: either by mouse or due to animation */ | ||
567 | if (currentAngle > internalCubeAngle * 0.5f) { | 571 | if (currentAngle > internalCubeAngle * 0.5f) { | ||
568 | currentAngle -= internalCubeAngle; | 572 | currentAngle -= internalCubeAngle; | ||
569 | frontDesktop--; | 573 | frontDesktop--; | ||
570 | if (frontDesktop < 1) { | 574 | if (frontDesktop < 1) { | ||
571 | frontDesktop = effects->numberOfDesktops(); | 575 | frontDesktop = effects->numberOfDesktops(); | ||
Show All 11 Lines | 586 | if (verticalAnimationState != VerticalAnimationState::None) { | |||
583 | float verticalEndAngle = 0.0; | 587 | float verticalEndAngle = 0.0; | ||
584 | if (verticalAnimationState == VerticalAnimationState::Upwards && verticalStartAngle >= 0.0) { | 588 | if (verticalAnimationState == VerticalAnimationState::Upwards && verticalStartAngle >= 0.0) { | ||
585 | verticalEndAngle = 90.0; | 589 | verticalEndAngle = 90.0; | ||
586 | } | 590 | } | ||
587 | if (verticalAnimationState == VerticalAnimationState::Downwards && verticalStartAngle <= 0.0) { | 591 | if (verticalAnimationState == VerticalAnimationState::Downwards && verticalStartAngle <= 0.0) { | ||
588 | verticalEndAngle = -90.0; | 592 | verticalEndAngle = -90.0; | ||
589 | } | 593 | } | ||
590 | // This also handles the "VerticalAnimationState::Stop" correctly, since it has endAngle = 0.0 | 594 | // This also handles the "VerticalAnimationState::Stop" correctly, since it has endAngle = 0.0 | ||
591 | verticalCurrentAngle = verticalStartAngle + verticalTimeLine.currentValue() * (verticalEndAngle - verticalStartAngle); | 595 | verticalCurrentAngle = verticalStartAngle + verticalTimeLine.value() * (verticalEndAngle - verticalStartAngle); | ||
592 | } | 596 | } | ||
593 | /* Updating rotation matrix */ | 597 | /* Updating rotation matrix */ | ||
594 | if (verticalAnimationState != VerticalAnimationState::None || verticalCurrentAngle != 0.0f) { | 598 | if (verticalAnimationState != VerticalAnimationState::None || verticalCurrentAngle != 0.0f) { | ||
595 | m_rotationMatrix.translate(rect.width() / 2, rect.height() / 2, -point - zTranslate); | 599 | m_rotationMatrix.translate(rect.width() / 2, rect.height() / 2, -point - zTranslate); | ||
596 | m_rotationMatrix.rotate(verticalCurrentAngle, 1.0, 0.0, 0.0); | 600 | m_rotationMatrix.rotate(verticalCurrentAngle, 1.0, 0.0, 0.0); | ||
597 | m_rotationMatrix.translate(-rect.width() / 2, -rect.height() / 2, point + zTranslate); | 601 | m_rotationMatrix.translate(-rect.width() / 2, -rect.height() / 2, point + zTranslate); | ||
598 | } | 602 | } | ||
599 | if (animationState != AnimationState::None || currentAngle != 0.0f) { | 603 | if (animationState != AnimationState::None || currentAngle != 0.0f) { | ||
600 | m_rotationMatrix.translate(rect.width() / 2, rect.height() / 2, -point - zTranslate); | 604 | m_rotationMatrix.translate(rect.width() / 2, rect.height() / 2, -point - zTranslate); | ||
601 | m_rotationMatrix.rotate(currentAngle, 0.0, 1.0, 0.0); | 605 | m_rotationMatrix.rotate(currentAngle, 0.0, 1.0, 0.0); | ||
602 | m_rotationMatrix.translate(-rect.width() / 2, -rect.height() / 2, point + zTranslate); | 606 | m_rotationMatrix.translate(-rect.width() / 2, -rect.height() / 2, point + zTranslate); | ||
603 | } | 607 | } | ||
604 | } | 608 | } | ||
605 | 609 | | |||
606 | void CubeEffect::paintCube(int mask, QRegion region, ScreenPaintData& data) | 610 | void CubeEffect::paintCube(int mask, QRegion region, ScreenPaintData& data) | ||
607 | { | 611 | { | ||
608 | QRect rect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); | 612 | QRect rect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); | ||
609 | float internalCubeAngle = 360.0f / effects->numberOfDesktops(); | 613 | float internalCubeAngle = 360.0f / effects->numberOfDesktops(); | ||
610 | cube_painting = true; | 614 | cube_painting = true; | ||
611 | float zTranslate = zPosition + zoom; | 615 | float zTranslate = zPosition + zoom; | ||
612 | if (animationState == AnimationState::Start) { | 616 | if (animationState == AnimationState::Start) { | ||
613 | zTranslate *= timeLine.currentValue(); | 617 | zTranslate *= timeLine.value(); | ||
614 | } else if (animationState == AnimationState::Stop) { | 618 | } else if (animationState == AnimationState::Stop) { | ||
615 | zTranslate *= (1.0 - timeLine.currentValue()); | 619 | zTranslate *= (1.0 - timeLine.value()); | ||
616 | } | 620 | } | ||
617 | 621 | | |||
618 | // Rotation of the cube | 622 | // Rotation of the cube | ||
619 | float cubeAngle = (float)((float)(effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 180.0f); | 623 | float cubeAngle = (float)((float)(effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 180.0f); | ||
620 | float point = rect.width() / 2 * tan(cubeAngle * 0.5f * M_PI / 180.0f); | 624 | float point = rect.width() / 2 * tan(cubeAngle * 0.5f * M_PI / 180.0f); | ||
621 | 625 | | |||
622 | for (int i = 0; i < effects->numberOfDesktops(); i++) { | 626 | for (int i = 0; i < effects->numberOfDesktops(); i++) { | ||
623 | // start painting the cube | 627 | // start painting the cube | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 646 | { | |||
674 | } | 678 | } | ||
675 | 679 | | |||
676 | bool capShader = false; | 680 | bool capShader = false; | ||
677 | if (effects->compositingType() == OpenGL2Compositing && m_capShader && m_capShader->isValid()) { | 681 | if (effects->compositingType() == OpenGL2Compositing && m_capShader && m_capShader->isValid()) { | ||
678 | capShader = true; | 682 | capShader = true; | ||
679 | ShaderManager::instance()->pushShader(m_capShader); | 683 | ShaderManager::instance()->pushShader(m_capShader); | ||
680 | float opacity = cubeOpacity; | 684 | float opacity = cubeOpacity; | ||
681 | if (animationState == AnimationState::Start) { | 685 | if (animationState == AnimationState::Start) { | ||
682 | opacity *= timeLine.currentValue(); | 686 | opacity *= timeLine.value(); | ||
683 | } else if (animationState == AnimationState::Stop) { | 687 | } else if (animationState == AnimationState::Stop) { | ||
684 | opacity *= (1.0 - timeLine.currentValue()); | 688 | opacity *= (1.0 - timeLine.value()); | ||
685 | } | 689 | } | ||
686 | m_capShader->setUniform("u_opacity", opacity); | 690 | m_capShader->setUniform("u_opacity", opacity); | ||
687 | m_capShader->setUniform("u_mirror", 1); | 691 | m_capShader->setUniform("u_mirror", 1); | ||
688 | if (reflectionPainting) { | 692 | if (reflectionPainting) { | ||
689 | capMvp = projection * m_reflectionMatrix * m_rotationMatrix; | 693 | capMvp = projection * m_reflectionMatrix * m_rotationMatrix; | ||
690 | } else { | 694 | } else { | ||
691 | capMvp = projection * m_rotationMatrix; | 695 | capMvp = projection * m_rotationMatrix; | ||
692 | } | 696 | } | ||
▲ Show 20 Lines • Show All 254 Lines • ▼ Show 20 Line(s) | |||||
947 | 951 | | |||
948 | void CubeEffect::postPaintScreen() | 952 | void CubeEffect::postPaintScreen() | ||
949 | { | 953 | { | ||
950 | effects->postPaintScreen(); | 954 | effects->postPaintScreen(); | ||
951 | if (!activated) | 955 | if (!activated) | ||
952 | return; | 956 | return; | ||
953 | 957 | | |||
954 | bool animation = (animationState != AnimationState::None || verticalAnimationState != VerticalAnimationState::None); | 958 | bool animation = (animationState != AnimationState::None || verticalAnimationState != VerticalAnimationState::None); | ||
955 | if (animationState != AnimationState::None && timeLine.currentValue() == 1.0) { | 959 | if (animationState != AnimationState::None && timeLine.done()) { | ||
956 | /* An animation have just finished! */ | 960 | /* An animation have just finished! */ | ||
957 | if (animationState == AnimationState::Stop) { | 961 | if (animationState == AnimationState::Stop) { | ||
958 | /* If the stop animation is finished, we're done */ | 962 | /* If the stop animation is finished, we're done */ | ||
959 | if (keyboard_grab) | 963 | if (keyboard_grab) | ||
960 | effects->ungrabKeyboard(); | 964 | effects->ungrabKeyboard(); | ||
961 | keyboard_grab = false; | 965 | keyboard_grab = false; | ||
962 | effects->stopMouseInterception(this); | 966 | effects->stopMouseInterception(this); | ||
963 | effects->setCurrentDesktop(frontDesktop); | 967 | effects->setCurrentDesktop(frontDesktop); | ||
Show All 11 Lines | |||||
975 | } else { | 979 | } else { | ||
976 | if (!animations.empty()) | 980 | if (!animations.empty()) | ||
977 | startAnimation(animations.dequeue()); | 981 | startAnimation(animations.dequeue()); | ||
978 | else | 982 | else | ||
979 | animationState = AnimationState::None; | 983 | animationState = AnimationState::None; | ||
980 | } | 984 | } | ||
981 | } | 985 | } | ||
982 | /* Vertical animation have finished */ | 986 | /* Vertical animation have finished */ | ||
983 | if (verticalAnimationState != VerticalAnimationState::None && verticalTimeLine.currentValue() == 1.0) { | 987 | if (verticalAnimationState != VerticalAnimationState::None && verticalTimeLine.done()) { | ||
984 | if (!verticalAnimations.empty()) { | 988 | if (!verticalAnimations.empty()) { | ||
985 | startVerticalAnimation(verticalAnimations.dequeue()); | 989 | startVerticalAnimation(verticalAnimations.dequeue()); | ||
986 | } else { | 990 | } else { | ||
987 | verticalAnimationState = VerticalAnimationState::None; | 991 | verticalAnimationState = VerticalAnimationState::None; | ||
988 | } | 992 | } | ||
989 | } | 993 | } | ||
990 | /* Repaint if there is any animation */ | 994 | /* Repaint if there is any animation */ | ||
991 | if (animation) { | 995 | if (animation) { | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | |||||
1079 | void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) | 1083 | void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) | ||
1080 | { | 1084 | { | ||
1081 | ShaderManager *shaderManager = ShaderManager::instance(); | 1085 | ShaderManager *shaderManager = ShaderManager::instance(); | ||
1082 | if (activated && cube_painting) { | 1086 | if (activated && cube_painting) { | ||
1083 | region= infiniteRegion(); // we need to explicitly prevent any clipping, bug #325432 | 1087 | region= infiniteRegion(); // we need to explicitly prevent any clipping, bug #325432 | ||
1084 | //qCDebug(KWINEFFECTS) << w->caption(); | 1088 | //qCDebug(KWINEFFECTS) << w->caption(); | ||
1085 | float opacity = cubeOpacity; | 1089 | float opacity = cubeOpacity; | ||
1086 | if (animationState == AnimationState::Start) { | 1090 | if (animationState == AnimationState::Start) { | ||
1087 | opacity = 1.0 - (1.0 - opacity) * timeLine.currentValue(); | 1091 | opacity = 1.0 - (1.0 - opacity) * timeLine.value(); | ||
1088 | if (reflectionPainting) | 1092 | if (reflectionPainting) | ||
1089 | opacity = 0.5 + (cubeOpacity - 0.5) * timeLine.currentValue(); | 1093 | opacity = 0.5 + (cubeOpacity - 0.5) * timeLine.value(); | ||
1090 | // fade in windows belonging to different desktops | 1094 | // fade in windows belonging to different desktops | ||
1091 | if (painting_desktop == effects->currentDesktop() && (!w->isOnDesktop(painting_desktop))) | 1095 | if (painting_desktop == effects->currentDesktop() && (!w->isOnDesktop(painting_desktop))) | ||
1092 | opacity = timeLine.currentValue() * cubeOpacity; | 1096 | opacity = timeLine.value() * cubeOpacity; | ||
1093 | } else if (animationState == AnimationState::Stop) { | 1097 | } else if (animationState == AnimationState::Stop) { | ||
1094 | opacity = 1.0 - (1.0 - opacity) * (1.0 - timeLine.currentValue()); | 1098 | opacity = 1.0 - (1.0 - opacity) * (1.0 - timeLine.value()); | ||
1095 | if (reflectionPainting) | 1099 | if (reflectionPainting) | ||
1096 | opacity = 0.5 + (cubeOpacity - 0.5) * (1.0 - timeLine.currentValue()); | 1100 | opacity = 0.5 + (cubeOpacity - 0.5) * (1.0 - timeLine.value()); | ||
1097 | // fade out windows belonging to different desktops | 1101 | // fade out windows belonging to different desktops | ||
1098 | if (painting_desktop == effects->currentDesktop() && (!w->isOnDesktop(painting_desktop))) | 1102 | if (painting_desktop == effects->currentDesktop() && (!w->isOnDesktop(painting_desktop))) | ||
1099 | opacity = cubeOpacity * (1.0 - timeLine.currentValue()); | 1103 | opacity = cubeOpacity * (1.0 - timeLine.value()); | ||
1100 | } | 1104 | } | ||
1101 | // z-Ordering | 1105 | // z-Ordering | ||
1102 | if (!w->isDesktop() && !w->isDock() && useZOrdering && !w->isOnAllDesktops()) { | 1106 | if (!w->isDesktop() && !w->isDock() && useZOrdering && !w->isOnAllDesktops()) { | ||
1103 | float zOrdering = (effects->stackingOrder().indexOf(w) + 1) * zOrderingFactor; | 1107 | float zOrdering = (effects->stackingOrder().indexOf(w) + 1) * zOrderingFactor; | ||
1104 | if (animationState == AnimationState::Start) { | 1108 | if (animationState == AnimationState::Start) { | ||
1105 | zOrdering *= timeLine.currentValue(); | 1109 | zOrdering *= timeLine.value(); | ||
1106 | } else if (animationState == AnimationState::Stop) { | 1110 | } else if (animationState == AnimationState::Stop) { | ||
1107 | zOrdering *= (1.0 - timeLine.currentValue()); | 1111 | zOrdering *= (1.0 - timeLine.value()); | ||
1108 | } | 1112 | } | ||
1109 | data.translate(0.0, 0.0, zOrdering); | 1113 | data.translate(0.0, 0.0, zOrdering); | ||
1110 | } | 1114 | } | ||
1111 | // check for windows belonging to the previous desktop | 1115 | // check for windows belonging to the previous desktop | ||
1112 | int prev_desktop = painting_desktop - 1; | 1116 | int prev_desktop = painting_desktop - 1; | ||
1113 | if (prev_desktop == 0) | 1117 | if (prev_desktop == 0) | ||
1114 | prev_desktop = effects->numberOfDesktops(); | 1118 | prev_desktop = effects->numberOfDesktops(); | ||
1115 | int next_desktop = painting_desktop + 1; | 1119 | int next_desktop = painting_desktop + 1; | ||
Show All 22 Lines | 1133 | if (w->isOnDesktop(next_desktop) && (mask & PAINT_WINDOW_TRANSFORMED)) { | |||
1138 | data.setXTranslation(rect.width()); | 1142 | data.setXTranslation(rect.width()); | ||
1139 | } | 1143 | } | ||
1140 | QRect rect = effects->clientArea(FullArea, activeScreen, painting_desktop); | 1144 | QRect rect = effects->clientArea(FullArea, activeScreen, painting_desktop); | ||
1141 | 1145 | | |||
1142 | if (animationState == AnimationState::Start || animationState == AnimationState::Stop) { | 1146 | if (animationState == AnimationState::Start || animationState == AnimationState::Stop) { | ||
1143 | // we have to change opacity values for fade in/out of windows which are shown on front-desktop | 1147 | // we have to change opacity values for fade in/out of windows which are shown on front-desktop | ||
1144 | if (prev_desktop == effects->currentDesktop() && w->x() < rect.x()) { | 1148 | if (prev_desktop == effects->currentDesktop() && w->x() < rect.x()) { | ||
1145 | if (animationState == AnimationState::Start) { | 1149 | if (animationState == AnimationState::Start) { | ||
1146 | opacity = timeLine.currentValue() * cubeOpacity; | 1150 | opacity = timeLine.value() * cubeOpacity; | ||
1147 | } else if (animationState == AnimationState::Stop) { | 1151 | } else if (animationState == AnimationState::Stop) { | ||
1148 | opacity = cubeOpacity * (1.0 - timeLine.currentValue()); | 1152 | opacity = cubeOpacity * (1.0 - timeLine.value()); | ||
1149 | } | 1153 | } | ||
1150 | } | 1154 | } | ||
1151 | if (next_desktop == effects->currentDesktop() && w->x() + w->width() > rect.x() + rect.width()) { | 1155 | if (next_desktop == effects->currentDesktop() && w->x() + w->width() > rect.x() + rect.width()) { | ||
1152 | if (animationState == AnimationState::Start) { | 1156 | if (animationState == AnimationState::Start) { | ||
1153 | opacity = timeLine.currentValue() * cubeOpacity; | 1157 | opacity = timeLine.value() * cubeOpacity; | ||
1154 | } else if (animationState == AnimationState::Stop) { | 1158 | } else if (animationState == AnimationState::Stop) { | ||
1155 | opacity = cubeOpacity * (1.0 - timeLine.currentValue()); | 1159 | opacity = cubeOpacity * (1.0 - timeLine.value()); | ||
1156 | } | 1160 | } | ||
1157 | } | 1161 | } | ||
1158 | } | 1162 | } | ||
1159 | // HACK set opacity to 0.99 in case of fully opaque to ensure that windows are painted in correct sequence | 1163 | // HACK set opacity to 0.99 in case of fully opaque to ensure that windows are painted in correct sequence | ||
1160 | // bug #173214 | 1164 | // bug #173214 | ||
1161 | if (opacity > 0.99f) | 1165 | if (opacity > 0.99f) | ||
1162 | opacity = 0.99f; | 1166 | opacity = 0.99f; | ||
1163 | if (opacityDesktopOnly && !w->isDesktop()) | 1167 | if (opacityDesktopOnly && !w->isDesktop()) | ||
Show All 38 Lines | |||||
1202 | } | 1206 | } | ||
1203 | GLShader *currentShader = nullptr; | 1207 | GLShader *currentShader = nullptr; | ||
1204 | if (mode == Cylinder) { | 1208 | if (mode == Cylinder) { | ||
1205 | shaderManager->pushShader(cylinderShader); | 1209 | shaderManager->pushShader(cylinderShader); | ||
1206 | cylinderShader->setUniform("xCoord", (float)w->x()); | 1210 | cylinderShader->setUniform("xCoord", (float)w->x()); | ||
1207 | cylinderShader->setUniform("cubeAngle", (effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 90.0f); | 1211 | cylinderShader->setUniform("cubeAngle", (effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 90.0f); | ||
1208 | float factor = 0.0f; | 1212 | float factor = 0.0f; | ||
1209 | if (animationState == AnimationState::Start) { | 1213 | if (animationState == AnimationState::Start) { | ||
1210 | factor = 1.0f - timeLine.currentValue(); | 1214 | factor = 1.0f - timeLine.value(); | ||
1211 | } else if (animationState == AnimationState::Stop) { | 1215 | } else if (animationState == AnimationState::Stop) { | ||
1212 | factor = timeLine.currentValue(); | 1216 | factor = timeLine.value(); | ||
1213 | } | 1217 | } | ||
1214 | cylinderShader->setUniform("timeLine", factor); | 1218 | cylinderShader->setUniform("timeLine", factor); | ||
1215 | currentShader = cylinderShader; | 1219 | currentShader = cylinderShader; | ||
1216 | } | 1220 | } | ||
1217 | if (mode == Sphere) { | 1221 | if (mode == Sphere) { | ||
1218 | shaderManager->pushShader(sphereShader); | 1222 | shaderManager->pushShader(sphereShader); | ||
1219 | sphereShader->setUniform("u_offset", QVector2D(w->x(), w->y())); | 1223 | sphereShader->setUniform("u_offset", QVector2D(w->x(), w->y())); | ||
1220 | sphereShader->setUniform("cubeAngle", (effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 90.0f); | 1224 | sphereShader->setUniform("cubeAngle", (effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 90.0f); | ||
1221 | float factor = 0.0f; | 1225 | float factor = 0.0f; | ||
1222 | if (animationState == AnimationState::Start) { | 1226 | if (animationState == AnimationState::Start) { | ||
1223 | factor = 1.0f - timeLine.currentValue(); | 1227 | factor = 1.0f - timeLine.value(); | ||
1224 | } else if (animationState == AnimationState::Stop) { | 1228 | } else if (animationState == AnimationState::Stop) { | ||
1225 | factor = timeLine.currentValue(); | 1229 | factor = timeLine.value(); | ||
1226 | } | 1230 | } | ||
1227 | sphereShader->setUniform("timeLine", factor); | 1231 | sphereShader->setUniform("timeLine", factor); | ||
1228 | currentShader = sphereShader; | 1232 | currentShader = sphereShader; | ||
1229 | } | 1233 | } | ||
1230 | if (currentShader) { | 1234 | if (currentShader) { | ||
1231 | data.shader = currentShader; | 1235 | data.shader = currentShader; | ||
1232 | } | 1236 | } | ||
1233 | data.setProjectionMatrix(data.screenProjectionMatrix()); | 1237 | data.setProjectionMatrix(data.screenProjectionMatrix()); | ||
▲ Show 20 Lines • Show All 503 Lines • Show Last 20 Lines |