Functions to smooth out, and overcome dull linearity of, object translation/rotation by adding extra acceleration are called easing functions.
Add the following code just above SplitterCallBack() in Splitter.h:
// Easing equation for an exponential (2^^t) ease-in/out: accelerate until halfway, then decelerate.
__forceinline float easeInOutExpo(float t) {
if (t == 0) return 0;
if (t == 1) return 1;
t *= 2;
if (t < 1) return 0.5f * powf(2, 10 * (t - 1));
return 0.5f * (-powf(2, -10 * (t - 1)) + 2);
}
Then use the following code instead of existing case WM_NCLBUTTONDBLCLK in SplitterCallBack():
case WM_NCLBUTTONDBLCLK:
RightPanelSize = ClientW - ClientWGL + SPLITTER_WIDTH;
GetViewRect(GetParent(hWnd), &tmi);
w = Width(tmi);
h = Height(tmi);
WasXoffset = gP.splitXoffset;
nStep = 15;
if (GetWindowPlacement(gP.hMain, &wp)) {
if (wp.showCmd == SW_SHOWMAXIMIZED) { nStep *= 2; }
}
void gl_DrawScene();
if (gP.splitXoffset == 0) { // Move to center
gP.splitXoffset = (w - SPLITTER_WIDTH) / 2;
x = 0;
while (x < gP.splitXoffset) {
long xPos = (long)(easeInOutExpo((float)x / (float)gP.splitXoffset) * gP.splitXoffset);
MoveWindow(gP.hGL, -xPos, 0, w, h, TRUE);
MoveSplitter();
gP.bRedraw = TRUE; gl_DrawScene(); // Let the animation play while moving the window
glFinish(); // Complete redraw first then proceed
x += nStep;
}
} else { // Dock to the right
x = WasXoffset;
gP.splitXoffset = 0;
while (x > 0) {
long xPos = (long)(easeInOutExpo((float)x / (float)WasXoffset) * WasXoffset);
MoveWindow(gP.hGL, -xPos, 0, w, h, TRUE);
MoveSplitter();
gP.bRedraw = TRUE; gl_DrawScene(); // Let the animation play while moving the window
glFinish(); // Complete redraw first then proceed
x -= nStep;
}
}
MoveWindow(gP.hGL, -gP.splitXoffset, 0, w, h, TRUE);
MoveSplitter();
skSetAnchorCtrl(gP.hGL, ANCHOR_HEIGHT_WIDTH);
gP.bRedraw = TRUE; // Redraw the OpenGL scene
nRet = 1;
break;
Please let me know if splitter movement and gP.hGL redraw run smoothly enough for you.