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:
mfeemster 2014-10-16 23:05:08 -07:00
parent 2e054820f7
commit f5a707ea63
6 changed files with 116 additions and 94 deletions

View File

@ -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>

View File

@ -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;
}

View File

@ -104,6 +104,8 @@ public:
/// The caller must manually call this after construction.
/// </summary>
void Create()
{
do
{
T fw = T(2.0) * m_Support * m_Supersample * m_FilterRadius / m_PixelAspectRatio;
T adjust, ii, jj;
@ -139,11 +141,15 @@ public:
}
}
//Normalize, and return a bad value if the values were too small.
//Attempt to normalize, and increase the filter width if the values were too small.
if (!Normalize())
m_FinalFilterWidth = -1;
else
{
m_FinalFilterWidth = fwidth;
break;
}
m_FilterRadius += T(0.01);//Values were too small.
} while (1);
}
/// <summary>

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}