diff --git a/effects/wobblywindows.cpp b/effects/wobblywindows.cpp index a0f54b63b5..4d787bf6fc 100644 --- a/effects/wobblywindows.cpp +++ b/effects/wobblywindows.cpp @@ -68,6 +68,10 @@ WobblyWindowsEffect::WobblyWindowsEffect() { m_velocityFilter = FourRingLinearMean; } + else if (velFilter == "HeightRingLinearMean") + { + m_velocityFilter = HeightRingLinearMean; + } else if (velFilter == "MeanWithMean") { m_velocityFilter = MeanWithMean; @@ -92,6 +96,10 @@ WobblyWindowsEffect::WobblyWindowsEffect() { m_accelerationFilter = FourRingLinearMean; } + else if (accFilter == "HeightRingLinearMean") + { + m_accelerationFilter = HeightRingLinearMean; + } else if (accFilter == "MeanWithMean") { m_accelerationFilter = MeanWithMean; @@ -295,7 +303,7 @@ void WobblyWindowsEffect::windowUserMovedResized(EffectWindow* w, bool first, bo if (windows.contains(w)) { WindowWobblyInfos& wwi = windows[w]; - wwi.status = Moving; + wwi.status = Free; } } } @@ -886,6 +894,10 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) fourRingLinearMean(&wwi.acceleration, wwi); break; + case HeightRingLinearMean: + heightRingLinearMean(&wwi.acceleration, wwi); + break; + case MeanWithMean: meanWithMean(&wwi.acceleration, wwi); break; @@ -930,6 +942,10 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) fourRingLinearMean(&wwi.velocity, wwi); break; + case HeightRingLinearMean: + heightRingLinearMean(&wwi.velocity, wwi); + break; + case MeanWithMean: meanWithMean(&wwi.velocity, wwi); break; @@ -1217,6 +1233,155 @@ void WobblyWindowsEffect::meanWithMedian(Pair** datas_pointer, WindowWobblyInfos wwi.buffer = tmp; } +void WobblyWindowsEffect::heightRingLinearMean(Pair** datas_pointer, WindowWobblyInfos& wwi) +{ + Pair* datas = *datas_pointer; + Pair neibourgs[8]; + + // for corners + + // top-left + { + Pair& res = wwi.buffer[0]; + Pair vit = datas[0]; + neibourgs[0] = datas[1]; + neibourgs[1] = datas[wwi.width]; + neibourgs[2] = datas[wwi.width+1]; + + res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + 3.0*vit.x) / 6.0; + res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + 3.0*vit.y) / 6.0; + } + + + // top-right + { + Pair& res = wwi.buffer[wwi.width-1]; + Pair vit = datas[wwi.width-1]; + neibourgs[0] = datas[wwi.width-2]; + neibourgs[1] = datas[2*wwi.width-1]; + neibourgs[2] = datas[2*wwi.width-2]; + + res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + 3.0*vit.x) / 6.0; + res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + 3.0*vit.y) / 6.0; + } + + + // bottom-left + { + Pair& res = wwi.buffer[wwi.width*(wwi.height-1)]; + Pair vit = datas[wwi.width*(wwi.height-1)]; + neibourgs[0] = datas[wwi.width*(wwi.height-1)+1]; + neibourgs[1] = datas[wwi.width*(wwi.height-2)]; + neibourgs[2] = datas[wwi.width*(wwi.height-2)+1]; + + res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + 3.0*vit.x) / 6.0; + res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + 3.0*vit.y) / 6.0; + } + + + // bottom-right + { + Pair& res = wwi.buffer[wwi.count-1]; + Pair vit = datas[wwi.count-1]; + neibourgs[0] = datas[wwi.count-2]; + neibourgs[1] = datas[wwi.width*(wwi.height-1)-1]; + neibourgs[2] = datas[wwi.width*(wwi.height-1)-2]; + + res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + 3.0*vit.x) / 6.0; + res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + 3.0*vit.y) / 6.0; + } + + + // for borders + + // top border + for (unsigned int i=1; icurrentIndex() == 0) // velocity + { + velocityFilter = HeightRingLinearMean; + } + else if (m_ui.cbGridFilter->currentIndex() == 1) // acceleration + { + accelerationFilter = HeightRingLinearMean; + } + } + emit changed(true); +} + + void WobblyWindowsEffectConfig::slotRbMeanMean(bool toggled) { if (toggled) @@ -387,7 +422,11 @@ void WobblyWindowsEffectConfig::slotGridParameterSelected(int index) break; case FourRingLinearMean: - m_ui.rbRingMean->setChecked(true); + m_ui.rbFourRingMean->setChecked(true); + break; + + case HeightRingLinearMean: + m_ui.rbHeightRingMean->setChecked(true); break; case MeanWithMean: @@ -408,7 +447,11 @@ void WobblyWindowsEffectConfig::slotGridParameterSelected(int index) break; case FourRingLinearMean: - m_ui.rbRingMean->setChecked(true); + m_ui.rbFourRingMean->setChecked(true); + break; + + case HeightRingLinearMean: + m_ui.rbHeightRingMean->setChecked(true); break; case MeanWithMean: diff --git a/effects/wobblywindows_config.h b/effects/wobblywindows_config.h index e24e3fad22..9598ee5d4c 100644 --- a/effects/wobblywindows_config.h +++ b/effects/wobblywindows_config.h @@ -49,6 +49,7 @@ private: { NoFilter, FourRingLinearMean, + HeightRingLinearMean, MeanWithMean, MeanWithMedian }; @@ -64,7 +65,8 @@ private slots: void slotGridParameterSelected(int); void slotRbNone(bool); - void slotRbRingMean(bool); + void slotRbFourRingMean(bool); + void slotRbHeightRingMean(bool); void slotRbMeanMean(bool); void slotRbMeanMedian(bool); diff --git a/effects/wobblywindows_config.ui b/effects/wobblywindows_config.ui index f9b6ac8cb8..c9e0a084e4 100644 --- a/effects/wobblywindows_config.ui +++ b/effects/wobblywindows_config.ui @@ -6,7 +6,7 @@ 0 0 553 - 383 + 368 @@ -23,8 +23,8 @@ 0 0 - 533 - 338 + 531 + 321 @@ -284,15 +284,22 @@ - + - Ring Mean + Ring Mean (4 ways) false + + + + Ring Mean (8 ways) + + +