--User changes

-Attempt to preserve xaos when adding xforms. Note this is not an exact copy, but just a preservation of some values based on position.
 -Add some acceleration to the changing of spinner values when dragging the right mouse button to adjust.
 -Make the pivot be the center of the viewable area when doing drag/rotate/scale with the right mouse button.
 --Clamp minimum scale to 10
 --Draw a line from the mouse position to the pivot.
 -Keep a cache of the last added final xform with each flame so that it can be quickly added, removed, then added back for testing its effect.
 --This is not saved with the xml file and is solely for interactive editing.

--Bug fixes
 -File filtering in open and save dialogs were broken.
 -Right clicking on integer spin boxes was causing the context menu to pop up, when it should be supressed just like double spin boxes.
 -Deleting xforms was still broken.

--Code changes
 -Refactor the code for adding and pasting xforms into a single global static function called AddXformsWithXaos().
This commit is contained in:
Person
2018-08-10 18:06:04 -07:00
parent 26c558a2f5
commit dee4304bf2
13 changed files with 173 additions and 62 deletions

View File

@ -82,7 +82,7 @@ T GLEmberController<T>::CalcScale()
{
//Can't operate using world coords here because every time scale changes, the world bounds change.
//So must instead calculate distance traveled based on window coords, which do not change outside of resize events.
v2T windowCenter(T(m_GL->width()) / T(2), T(m_GL->height()) / T(2));
auto windowCenter = ScrolledCenter(false);
v2T windowMousePosDistanceFromCenter(m_MousePos.x - windowCenter.x, m_MousePos.y - windowCenter.y);
v2T windowMouseDownDistanceFromCenter(m_MouseDownPos.x - windowCenter.x, m_MouseDownPos.y - windowCenter.y);
T lengthMousePosFromCenterInPixels = glm::length(windowMousePosDistanceFromCenter);
@ -98,11 +98,43 @@ T GLEmberController<T>::CalcScale()
template <typename T>
T GLEmberController<T>::CalcRotation()
{
T rotStart = NormalizeDeg180<T>(T(90) - (atan2(-m_MouseDownWorldPos.y, m_MouseDownWorldPos.x) * RAD_2_DEG_T));
T rot = NormalizeDeg180<T>(T(90) - (atan2(-m_MouseWorldPos.y, m_MouseWorldPos.x) * RAD_2_DEG_T));
auto scrolledWorldCenter = ScrolledCenter(true);
T rotStart = NormalizeDeg180<T>((std::atan2(m_MouseDownWorldPos.y - scrolledWorldCenter.y, m_MouseDownWorldPos.x - scrolledWorldCenter.x) * RAD_2_DEG_T));
T rot = NormalizeDeg180<T>((std::atan2(m_MouseWorldPos.y - scrolledWorldCenter.y, m_MouseWorldPos.x - scrolledWorldCenter.x) * RAD_2_DEG_T));
return rotStart - rot;
}
/// <summary>
/// Return the window coordinates of the center of the viewable area.
/// This is the middle of the parent scroll area plus the scroll bar offset, all scaled by the device pixel ratio.
/// </summary>
/// <param name="toWorld">True to return world coordinates, else return window coordinates.</param>
/// <returns>The coordinates of the center of the viewable area in either window space or world space.</returns>
template <typename T>
v3T GLEmberController<T>::ScrolledCenter(bool toWorld)
{
auto dprf = m_GL->devicePixelRatioF();
auto wpsa = m_Fractorium->ui.GLParentScrollArea->width();
auto hpsa = m_Fractorium->ui.GLParentScrollArea->height();
auto hpos = m_Fractorium->ui.GLParentScrollArea->horizontalScrollBar()->value();
auto vpos = m_Fractorium->ui.GLParentScrollArea->verticalScrollBar()->value();
v3T v;
if (!m_Fractorium->ui.GLParentScrollArea->horizontalScrollBar()->isVisible() && !m_Fractorium->ui.GLParentScrollArea->verticalScrollBar()->isVisible())
v = v3T(((m_GL->width() / 2)) * dprf,
((m_GL->height() / 2)) * dprf,
0);
else
v = v3T((hpos + (wpsa / 2)) * dprf,
(vpos + (hpsa / 2)) * dprf,
0);
if (toWorld)
return WindowToWorld(v, true);
return v;
}
/// <summary>
/// Snap the passed in world cartesian coordinate to the grid for rotation, scale or translation.
/// </summary>