mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-21 05:00:06 -05:00
Remove focus handling code from spin boxes. It was originally done to compensate for a bug in Qt, but required the user to make very precise mouse movements. This is no longer needed since the bug has been fixed.
Prevent spatial and density filters from returning empty filters. Another attempt at properly setting the locale for the affine rotate/move/scale combo boxes.
This commit is contained in:
parent
2e054820f7
commit
f5a707ea63
@ -56,6 +56,12 @@ public:
|
||||
|
||||
if (m_MaxRad < m_MinRad)
|
||||
m_MaxRad = m_MinRad + 1;
|
||||
|
||||
//Ensure it's valid.
|
||||
while (!Valid())
|
||||
{
|
||||
m_Curve += T(0.1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -244,6 +244,8 @@ bool Renderer<T, bucketT>::CreateSpatialFilter(bool& newAlloc)
|
||||
{
|
||||
m_SpatialFilter = unique_ptr<SpatialFilter<T>>(
|
||||
SpatialFilterCreator<T>::Create(m_Ember.m_SpatialFilterType, m_Ember.m_SpatialFilterRadius, m_Ember.m_Supersample, m_PixelAspectRatio));
|
||||
|
||||
m_Ember.m_SpatialFilterRadius = m_SpatialFilter->FilterRadius();//It may have been changed internally if it was too small, so ensure they're synced.
|
||||
newAlloc = true;
|
||||
}
|
||||
|
||||
|
@ -105,45 +105,51 @@ public:
|
||||
/// </summary>
|
||||
void Create()
|
||||
{
|
||||
T fw = T(2.0) * m_Support * m_Supersample * m_FilterRadius / m_PixelAspectRatio;
|
||||
T adjust, ii, jj;
|
||||
|
||||
int fwidth = ((int)fw) + 1;
|
||||
int i, j;
|
||||
|
||||
//Make sure the filter kernel has same parity as oversample.
|
||||
if ((fwidth ^ m_Supersample) & 1)
|
||||
fwidth++;
|
||||
|
||||
//Calculate the coordinate scaling factor for the kernel values.
|
||||
if (fw > 0.0)
|
||||
adjust = m_Support * fwidth / fw;
|
||||
else
|
||||
adjust = T(1.0);
|
||||
|
||||
m_Filter.resize(fwidth * fwidth);
|
||||
|
||||
//Fill in the coefs.
|
||||
for (i = 0; i < fwidth; i++)
|
||||
do
|
||||
{
|
||||
for (j = 0; j < fwidth; j++)
|
||||
T fw = T(2.0) * m_Support * m_Supersample * m_FilterRadius / m_PixelAspectRatio;
|
||||
T adjust, ii, jj;
|
||||
|
||||
int fwidth = ((int)fw) + 1;
|
||||
int i, j;
|
||||
|
||||
//Make sure the filter kernel has same parity as oversample.
|
||||
if ((fwidth ^ m_Supersample) & 1)
|
||||
fwidth++;
|
||||
|
||||
//Calculate the coordinate scaling factor for the kernel values.
|
||||
if (fw > 0.0)
|
||||
adjust = m_Support * fwidth / fw;
|
||||
else
|
||||
adjust = T(1.0);
|
||||
|
||||
m_Filter.resize(fwidth * fwidth);
|
||||
|
||||
//Fill in the coefs.
|
||||
for (i = 0; i < fwidth; i++)
|
||||
{
|
||||
//Calculate the function inputs for the kernel function.
|
||||
ii = ((T(2.0) * i + T(1.0)) / T(fwidth) - T(1.0)) * adjust;
|
||||
jj = ((T(2.0) * j + T(1.0)) / T(fwidth) - T(1.0)) * adjust;
|
||||
for (j = 0; j < fwidth; j++)
|
||||
{
|
||||
//Calculate the function inputs for the kernel function.
|
||||
ii = ((T(2.0) * i + T(1.0)) / T(fwidth) - T(1.0)) * adjust;
|
||||
jj = ((T(2.0) * j + T(1.0)) / T(fwidth) - T(1.0)) * adjust;
|
||||
|
||||
//Adjust for aspect ratio.
|
||||
jj /= m_PixelAspectRatio;
|
||||
//Adjust for aspect ratio.
|
||||
jj /= m_PixelAspectRatio;
|
||||
|
||||
m_Filter[i + j * fwidth] = Filter(ii) * Filter(jj);//Call virtual Filter(), implemented in specific derived filter classes.
|
||||
m_Filter[i + j * fwidth] = Filter(ii) * Filter(jj);//Call virtual Filter(), implemented in specific derived filter classes.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Normalize, and return a bad value if the values were too small.
|
||||
if (!Normalize())
|
||||
m_FinalFilterWidth = -1;
|
||||
else
|
||||
m_FinalFilterWidth = fwidth;
|
||||
//Attempt to normalize, and increase the filter width if the values were too small.
|
||||
if (!Normalize())
|
||||
{
|
||||
m_FinalFilterWidth = fwidth;
|
||||
break;
|
||||
}
|
||||
|
||||
m_FilterRadius += T(0.01);//Values were too small.
|
||||
} while (1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -117,26 +117,26 @@ bool DoubleSpinBox::eventFilter(QObject* o, QEvent* e)
|
||||
{
|
||||
if (e->type() == QMouseEvent::MouseButtonPress && isEnabled())
|
||||
{
|
||||
QPoint pt;
|
||||
|
||||
if (QMouseEvent* me = (QMouseEvent*)e)
|
||||
pt = me->localPos().toPoint();
|
||||
|
||||
int pos = lineEdit()->cursorPositionAt(pt);
|
||||
|
||||
if (lineEdit()->selectedText() != "")
|
||||
{
|
||||
lineEdit()->deselect();
|
||||
lineEdit()->setCursorPosition(pos);
|
||||
return true;
|
||||
}
|
||||
else if (m_Select)
|
||||
{
|
||||
lineEdit()->setCursorPosition(pos);
|
||||
selectAll();
|
||||
m_Select = false;
|
||||
return true;
|
||||
}
|
||||
// QPoint pt;
|
||||
//
|
||||
// if (QMouseEvent* me = (QMouseEvent*)e)
|
||||
// pt = me->localPos().toPoint();
|
||||
//
|
||||
// int pos = lineEdit()->cursorPositionAt(pt);
|
||||
//
|
||||
// if (lineEdit()->selectedText() != "")
|
||||
// {
|
||||
// lineEdit()->deselect();
|
||||
// lineEdit()->setCursorPosition(pos);
|
||||
// return true;
|
||||
// }
|
||||
// else if (m_Select)
|
||||
// {
|
||||
// lineEdit()->setCursorPosition(pos);
|
||||
// selectAll();
|
||||
// m_Select = false;
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
else if (m_DoubleClick && e->type() == QMouseEvent::MouseButtonDblClick && isEnabled())
|
||||
{
|
||||
@ -172,7 +172,7 @@ bool DoubleSpinBox::eventFilter(QObject* o, QEvent* e)
|
||||
/// <param name="e">The event</param>
|
||||
void DoubleSpinBox::focusInEvent(QFocusEvent* e)
|
||||
{
|
||||
lineEdit()->setReadOnly(false);
|
||||
//lineEdit()->setReadOnly(false);
|
||||
QDoubleSpinBox::focusInEvent(e);
|
||||
}
|
||||
|
||||
@ -185,8 +185,8 @@ void DoubleSpinBox::focusInEvent(QFocusEvent* e)
|
||||
/// <param name="e">The event</param>
|
||||
void DoubleSpinBox::focusOutEvent(QFocusEvent* e)
|
||||
{
|
||||
lineEdit()->deselect();//Clear selection when leaving.
|
||||
lineEdit()->setReadOnly(true);//Clever hack to clear the cursor when leaving.
|
||||
//lineEdit()->deselect();//Clear selection when leaving.
|
||||
//lineEdit()->setReadOnly(true);//Clever hack to clear the cursor when leaving.
|
||||
QDoubleSpinBox::focusOutEvent(e);
|
||||
}
|
||||
|
||||
@ -197,8 +197,8 @@ void DoubleSpinBox::focusOutEvent(QFocusEvent* e)
|
||||
/// <param name="e">The event</param>
|
||||
void DoubleSpinBox::enterEvent(QEvent* e)
|
||||
{
|
||||
m_Select = true;
|
||||
setFocus();
|
||||
//m_Select = true;
|
||||
//setFocus();
|
||||
QDoubleSpinBox::enterEvent(e);
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ void DoubleSpinBox::enterEvent(QEvent* e)
|
||||
/// <param name="e">The event</param>
|
||||
void DoubleSpinBox::leaveEvent(QEvent* e)
|
||||
{
|
||||
m_Select = false;
|
||||
clearFocus();
|
||||
//m_Select = false;
|
||||
//clearFocus();
|
||||
QDoubleSpinBox::leaveEvent(e);
|
||||
}
|
||||
|
@ -33,13 +33,21 @@ void Fractorium::InitXformsAffineUI()
|
||||
SetupAffineSpinner(table, this, 2, 0, m_PostO1Spin, spinHeight, affineMin, affineMax, affineStep, affinePrec, SIGNAL(valueChanged(double)), SLOT(OnO1Changed(double)));
|
||||
SetupAffineSpinner(table, this, 2, 1, m_PostO2Spin, spinHeight, affineMin, affineMax, affineStep, affinePrec, SIGNAL(valueChanged(double)), SLOT(OnO2Changed(double)));
|
||||
|
||||
ui.PreRotateCombo->setValidator(new QDoubleValidator(ui.PreRotateCombo));
|
||||
ui.PreMoveCombo->setValidator( new QDoubleValidator(ui.PreMoveCombo));
|
||||
ui.PreScaleCombo->setValidator( new QDoubleValidator(ui.PreScaleCombo));
|
||||
QDoubleValidator* preRotateVal = new QDoubleValidator(ui.PreRotateCombo); preRotateVal->setLocale(QLocale::system());
|
||||
QDoubleValidator* preMoveVal = new QDoubleValidator(ui.PreMoveCombo); preMoveVal->setLocale(QLocale::system());
|
||||
QDoubleValidator* preScaleVal = new QDoubleValidator(ui.PreScaleCombo); preScaleVal->setLocale(QLocale::system());
|
||||
|
||||
ui.PostRotateCombo->setValidator(new QDoubleValidator(ui.PostRotateCombo));
|
||||
ui.PostMoveCombo->setValidator( new QDoubleValidator(ui.PostMoveCombo));
|
||||
ui.PostScaleCombo->setValidator( new QDoubleValidator(ui.PostScaleCombo));
|
||||
QDoubleValidator* postRotateVal = new QDoubleValidator(ui.PostRotateCombo); postRotateVal->setLocale(QLocale::system());
|
||||
QDoubleValidator* postMoveVal = new QDoubleValidator(ui.PostMoveCombo); postMoveVal->setLocale(QLocale::system());
|
||||
QDoubleValidator* postScaleVal = new QDoubleValidator(ui.PostScaleCombo); postScaleVal->setLocale(QLocale::system());
|
||||
|
||||
ui.PreRotateCombo->setValidator(preRotateVal);
|
||||
ui.PreMoveCombo->setValidator(preMoveVal);
|
||||
ui.PreScaleCombo->setValidator(preScaleVal);
|
||||
|
||||
ui.PostRotateCombo->setValidator(postRotateVal);
|
||||
ui.PostMoveCombo->setValidator(postMoveVal);
|
||||
ui.PostScaleCombo->setValidator(postScaleVal);
|
||||
|
||||
connect(ui.PreFlipHorizontalButton, SIGNAL(clicked(bool)), this, SLOT(OnFlipHorizontalButtonClicked(bool)), Qt::QueuedConnection);
|
||||
connect(ui.PreFlipVerticalButton, SIGNAL(clicked(bool)), this, SLOT(OnFlipVerticalButtonClicked(bool)), Qt::QueuedConnection);
|
||||
|
@ -107,26 +107,26 @@ bool SpinBox::eventFilter(QObject* o, QEvent* e)
|
||||
{
|
||||
if (e->type() == QMouseEvent::MouseButtonPress && isEnabled())
|
||||
{
|
||||
QPoint pt;
|
||||
|
||||
if (QMouseEvent* me = (QMouseEvent*)e)
|
||||
pt = me->localPos().toPoint();
|
||||
|
||||
int pos = lineEdit()->cursorPositionAt(pt);
|
||||
|
||||
if (lineEdit()->selectedText() != "")
|
||||
{
|
||||
lineEdit()->deselect();
|
||||
lineEdit()->setCursorPosition(pos);
|
||||
return true;
|
||||
}
|
||||
else if (m_Select)
|
||||
{
|
||||
lineEdit()->setCursorPosition(pos);
|
||||
selectAll();
|
||||
m_Select = false;
|
||||
return true;
|
||||
}
|
||||
//QPoint pt;
|
||||
//
|
||||
//if (QMouseEvent* me = (QMouseEvent*)e)
|
||||
// pt = me->localPos().toPoint();
|
||||
//
|
||||
//int pos = lineEdit()->cursorPositionAt(pt);
|
||||
//
|
||||
//if (lineEdit()->selectedText() != "")
|
||||
//{
|
||||
// lineEdit()->deselect();
|
||||
// lineEdit()->setCursorPosition(pos);
|
||||
// return true;
|
||||
//}
|
||||
//else if (m_Select)
|
||||
//{
|
||||
// lineEdit()->setCursorPosition(pos);
|
||||
// selectAll();
|
||||
// m_Select = false;
|
||||
// return true;
|
||||
//}
|
||||
}
|
||||
else if (m_DoubleClick && e->type() == QMouseEvent::MouseButtonDblClick && isEnabled())
|
||||
{
|
||||
@ -153,7 +153,7 @@ bool SpinBox::eventFilter(QObject* o, QEvent* e)
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return QSpinBox::eventFilter(o, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -162,7 +162,7 @@ bool SpinBox::eventFilter(QObject* o, QEvent* e)
|
||||
/// <param name="e">The event</param>
|
||||
void SpinBox::focusInEvent(QFocusEvent* e)
|
||||
{
|
||||
lineEdit()->setReadOnly(false);
|
||||
//lineEdit()->setReadOnly(false);
|
||||
QSpinBox::focusInEvent(e);
|
||||
}
|
||||
|
||||
@ -175,8 +175,8 @@ void SpinBox::focusInEvent(QFocusEvent* e)
|
||||
/// <param name="e">The event</param>
|
||||
void SpinBox::focusOutEvent(QFocusEvent* e)
|
||||
{
|
||||
lineEdit()->deselect();//Clear selection when leaving.
|
||||
lineEdit()->setReadOnly(true);//Clever hack to clear the cursor when leaving.
|
||||
//lineEdit()->deselect();//Clear selection when leaving.
|
||||
//lineEdit()->setReadOnly(true);//Clever hack to clear the cursor when leaving.
|
||||
QSpinBox::focusOutEvent(e);
|
||||
}
|
||||
|
||||
@ -187,8 +187,8 @@ void SpinBox::focusOutEvent(QFocusEvent* e)
|
||||
/// <param name="e">The event</param>
|
||||
void SpinBox::enterEvent(QEvent* e)
|
||||
{
|
||||
m_Select = true;
|
||||
setFocus();
|
||||
//m_Select = true;
|
||||
//setFocus();
|
||||
QSpinBox::enterEvent(e);
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ void SpinBox::enterEvent(QEvent* e)
|
||||
/// <param name="e">The event</param>
|
||||
void SpinBox::leaveEvent(QEvent* e)
|
||||
{
|
||||
m_Select = false;
|
||||
clearFocus();
|
||||
//m_Select = false;
|
||||
//clearFocus();
|
||||
QSpinBox::leaveEvent(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user