--User changes

-Draw selection circles around all selected xforms plus the current one.

--Bug fixes
 -Add control key as a modifier to increase the amount a spinbox is changed when using right mouse drag to edit. Previously only observed shift key to decrease the value.
 -Change the copy/paste selected xforms shortcuts to be Ctrl+X+C and Ctrl+X+V.

--Code changes
 -Add function Fractorium::IsXformSelected() to determine if an xform has been selected with the checkboxes.
This commit is contained in:
mfeemster 2016-02-20 18:44:52 -08:00
parent f1dd20b0ca
commit 66f8f1e50c
12 changed files with 39 additions and 101 deletions

View File

@ -136,25 +136,18 @@ void DoubleSpinBox::OnTimeout()
double scale, val;
double d = value();
bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
//bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
double amount = (m_SmallStep + m_Step) * 0.5;
if (shift)
{
//qDebug() << "Shift pressed";
scale = 0.0001;
}
/* else if (ctrl)
{
qDebug() << "Control pressed";
else if (ctrl)
scale = 0.01;
}*/
else
scale = 0.001;
val = d + (distance * amount * scale);
setValue(val);
//qDebug() << "Timer on, orig val: " << d << ", new val: " << val << ", distance " << distance;
}
/// <summary>
@ -174,27 +167,6 @@ bool DoubleSpinBox::eventFilter(QObject* o, QEvent* e)
{
m_MouseDownPoint = m_MouseMovePoint = me->pos();
StartTimer();
//qDebug() << "Right mouse down";
// 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 (isEnabled() &&
me &&
@ -203,7 +175,6 @@ bool DoubleSpinBox::eventFilter(QObject* o, QEvent* e)
{
StopTimer();
m_MouseDownPoint = m_MouseMovePoint = me->pos();
//qDebug() << "Right mouse up";
}
else if (isEnabled() &&
me &&
@ -211,7 +182,6 @@ bool DoubleSpinBox::eventFilter(QObject* o, QEvent* e)
QGuiApplication::mouseButtons() & Qt::RightButton)
{
m_MouseMovePoint = me->pos();
qDebug() << "Mouse move while right down. Pt = " << me->pos() << ", global: " << mapToGlobal(me->pos());
}
else if (m_DoubleClick && e->type() == QMouseEvent::MouseButtonDblClick && isEnabled())
{
@ -247,7 +217,6 @@ bool DoubleSpinBox::eventFilter(QObject* o, QEvent* e)
/// <param name="e">The event</param>
void DoubleSpinBox::focusInEvent(QFocusEvent* e)
{
//lineEdit()->setReadOnly(false);
StopTimer();
QDoubleSpinBox::focusInEvent(e);
}
@ -261,8 +230,6 @@ 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.
StopTimer();
QDoubleSpinBox::focusOutEvent(e);
}
@ -274,8 +241,6 @@ void DoubleSpinBox::focusOutEvent(QFocusEvent* e)
/// <param name="e">The event</param>
void DoubleSpinBox::enterEvent(QEvent* e)
{
//m_Select = true;
//setFocus();
StopTimer();
QDoubleSpinBox::enterEvent(e);
}
@ -287,8 +252,6 @@ void DoubleSpinBox::enterEvent(QEvent* e)
/// <param name="e">The event</param>
void DoubleSpinBox::leaveEvent(QEvent* e)
{
//m_Select = false;
//clearFocus();.
StopTimer();
QDoubleSpinBox::leaveEvent(e);
}

View File

@ -783,7 +783,7 @@ void Fractorium::ToggleTableRow(QTableView* table, int logicalIndex)
{
for (int i = 0; i < cols; i++)
{
if (auto* spinBox = qobject_cast<DoubleSpinBox*>(tableWidget->cellWidget(logicalIndex, i)))
if (auto spinBox = qobject_cast<DoubleSpinBox*>(tableWidget->cellWidget(logicalIndex, i)))
{
if (!IsNearZero(spinBox->value()))
{
@ -799,7 +799,7 @@ void Fractorium::ToggleTableRow(QTableView* table, int logicalIndex)
double val = allZero ? 1.0 : 0.0;
for (int i = 0; i < cols; i++)
if (auto* spinBox = qobject_cast<DoubleSpinBox*>(tableWidget->cellWidget(logicalIndex, i)))
if (auto spinBox = qobject_cast<DoubleSpinBox*>(tableWidget->cellWidget(logicalIndex, i)))
spinBox->setValue(val);
}
else
@ -844,7 +844,7 @@ void Fractorium::ToggleTableCol(QTableView* table, int logicalIndex)
{
for (int i = 0; i < rows; i++)
{
if (auto* spinBox = qobject_cast<DoubleSpinBox*>(tableWidget->cellWidget(i, logicalIndex)))
if (auto spinBox = qobject_cast<DoubleSpinBox*>(tableWidget->cellWidget(i, logicalIndex)))
{
if (!IsNearZero(spinBox->value()))
{
@ -860,7 +860,7 @@ void Fractorium::ToggleTableCol(QTableView* table, int logicalIndex)
double val = allZero ? 1.0 : 0.0;
for (int i = 0; i < rows; i++)
if (auto* spinBox = qobject_cast<DoubleSpinBox*>(tableWidget->cellWidget(i, logicalIndex)))
if (auto spinBox = qobject_cast<DoubleSpinBox*>(tableWidget->cellWidget(i, logicalIndex)))
spinBox->setValue(val);
}
else

View File

@ -262,6 +262,7 @@ public slots:
//Xforms Selection.
void OnXformsSelectAllButtonClicked(bool checked);
void OnXformsSelectNoneButtonClicked(bool checked);
bool IsXformSelected(size_t i);
//Xaos.
void OnXaosChanged(double d);

View File

@ -3470,8 +3470,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>118</width>
<height>618</height>
<width>263</width>
<height>700</height>
</rect>
</property>
<property name="autoFillBackground">
@ -5485,8 +5485,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>133</width>
<height>52</height>
<width>259</width>
<height>652</height>
</rect>
</property>
<property name="sizePolicy">
@ -7098,7 +7098,7 @@
<string>Copy selected xforms to the clipboard</string>
</property>
<property name="shortcut">
<string>Ctrl+C, X</string>
<string>Ctrl+X, Ctrl+C</string>
</property>
</action>
<action name="ActionPasteSelectedXforms">
@ -7109,7 +7109,7 @@
<string>Paste copied xforms into the current flame</string>
</property>
<property name="shortcut">
<string>Ctrl+V, X</string>
<string>Ctrl+X, Ctrl+V</string>
</property>
</action>
<action name="ActionResetWorkspace">

View File

@ -252,7 +252,7 @@ void FractoriumEmberController<T>::UpdateXform(std::function<void(Xform<T>*)> fu
{
if (auto child = m_Fractorium->m_XformsSelectionLayout->itemAt(i))
{
if (auto* w = qobject_cast<QCheckBox*>(child->widget()))
if (auto w = qobject_cast<QCheckBox*>(child->widget()))
{
if (w->isChecked())
{
@ -281,7 +281,7 @@ void FractoriumEmberController<T>::UpdateXform(std::function<void(Xform<T>*)> fu
{
if (auto child = m_Fractorium->m_XformsSelectionLayout->itemAt(i))
{
if (auto* w = qobject_cast<QCheckBox*>(child->widget()))
if (auto w = qobject_cast<QCheckBox*>(child->widget()))
{
if (w->isChecked())
{

View File

@ -146,7 +146,7 @@ void FractoriumEmberController<T>::RandomXaos()
{
for (size_t i = 0; i < m_Ember.XformCount(); i++)
{
if (auto* xform = m_Ember.GetXform(i))
if (auto xform = m_Ember.GetXform(i))
{
for (size_t j = 0; j < m_Ember.XformCount(); j++)
{

View File

@ -143,7 +143,7 @@ void FractoriumEmberController<T>::AddLinkedXform()
//Set the xaos for all xforms pointing to the new one to zero.
for (i = 0; i < count; i++)
if (auto* xf = m_Ember.GetXform(i))
if (auto xf = m_Ember.GetXform(i))
xf->SetXaos(count - 1, 0);
xform->SetXaos(count - 1, 1);//Set the xaos value for the previous xform pointing to the new one to one.

View File

@ -424,7 +424,7 @@ void FractoriumEmberController<T>::MoveXforms(double x, double y, bool pre)
{
UpdateXform([&] (Xform<T>* xform)
{
auto* affine = pre ? &xform->m_Affine : &xform->m_Post;
auto affine = pre ? &xform->m_Affine : &xform->m_Post;
affine->C(affine->C() + x);
affine->F(affine->F() + y);
}, eXformUpdate::UPDATE_SELECTED);

View File

@ -24,6 +24,19 @@ void Fractorium::OnXformsSelectAllButtonClicked(bool checked) { ForEachXformChec
/// <param name="checked">Ignored</param>
void Fractorium::OnXformsSelectNoneButtonClicked(bool checked) { ForEachXformCheckbox([&](int i, QCheckBox * w) { w->setChecked(false); }); }
/// <summary>
/// Return whether the checkbox at the specified index is checked.
/// </summary>
/// <param name="checked">True if checked, else false.</param>
bool Fractorium::IsXformSelected(size_t i)
{
if (auto child = m_XformsSelectionLayout->itemAt(int(i)))
if (auto w = qobject_cast<QCheckBox*>(child->widget()))
return w->isChecked();
return false;
}
/// <summary>
/// Clear all of the dynamically created xform checkboxes.
/// </summary>
@ -35,7 +48,7 @@ void Fractorium::ClearXformsSelections()
while (m_XformsSelectionLayout->count() && (child = m_XformsSelectionLayout->takeAt(0)))
{
auto* w = child->widget();
auto w = child->widget();
delete child;
delete w;
}
@ -75,10 +88,8 @@ void Fractorium::ForEachXformCheckbox(std::function<void(int, QCheckBox*)> func)
while (QLayoutItem* child = m_XformsSelectionLayout->itemAt(i))
{
if (auto* w = qobject_cast<QCheckBox*>(child->widget()))
{
if (auto w = qobject_cast<QCheckBox*>(child->widget()))
func(i, w);
}
i++;
}

View File

@ -176,7 +176,7 @@ void FractoriumEmberController<T>::ClearVariationsTree()
for (int i = 0; i < tree->topLevelItemCount(); i++)
{
auto item = tree->topLevelItem(i);
auto* spinBox = dynamic_cast<VariationTreeDoubleSpinBox*>(tree->itemWidget(item, 1));
auto spinBox = dynamic_cast<VariationTreeDoubleSpinBox*>(tree->itemWidget(item, 1));
spinBox->SetValueStealth(0);
for (int j = 0; j < item->childCount(); j++)//Iterate through all of the children, which will be the params.

View File

@ -307,7 +307,7 @@ void GLEmberController<T>::DrawAffines(bool pre, bool post)
for (size_t i = 0; i < ember->TotalXformCount(); i++)
{
auto xform = ember->GetTotalXform(i);
bool selected = dragging ? (m_SelectedXform == xform) : (m_HoverXform == xform);
bool selected = m_Fractorium->IsXformSelected(i) || (dragging ? (m_SelectedXform == xform) : (m_HoverXform == xform));
DrawAffine(xform, true, selected);
}
}
@ -321,7 +321,7 @@ void GLEmberController<T>::DrawAffines(bool pre, bool post)
for (size_t i = 0; i < ember->TotalXformCount(); i++)
{
auto xform = ember->GetTotalXform(i);
bool selected = dragging ? (m_SelectedXform == xform) : (m_HoverXform == xform);
bool selected = m_Fractorium->IsXformSelected(i) || (dragging ? (m_SelectedXform == xform) : (m_HoverXform == xform));
DrawAffine(xform, false, selected);
}
}

View File

@ -112,25 +112,18 @@ void SpinBox::OnTimeout()
double scale, val;
int d = value();
bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
//bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
double amount = (m_SmallStep + m_Step) * 0.5;
if (shift)
{
//qDebug() << "Shift pressed";
scale = 0.001;
}
/* else if (ctrl)
{
qDebug() << "Control pressed";
else if (ctrl)
scale = 0.01;
}*/
else
scale = 0.01;
val = d + (distance * amount * scale);
setValue(int(val));
//qDebug() << "Timer on, orig val: " << d << ", new val: " << val << ", distance " << distance;
}
/// <summary>
@ -150,27 +143,6 @@ bool SpinBox::eventFilter(QObject* o, QEvent* e)
{
m_MouseDownPoint = m_MouseMovePoint = me->pos();
StartTimer();
//qDebug() << "Right mouse down";
// 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 (isEnabled() &&
me &&
@ -179,7 +151,6 @@ bool SpinBox::eventFilter(QObject* o, QEvent* e)
{
StopTimer();
m_MouseDownPoint = m_MouseMovePoint = me->pos();
//qDebug() << "Right mouse up";
}
else if (isEnabled() &&
me &&
@ -187,7 +158,6 @@ bool SpinBox::eventFilter(QObject* o, QEvent* e)
QGuiApplication::mouseButtons() & Qt::RightButton)
{
m_MouseMovePoint = me->pos();
qDebug() << "Mouse move while right down. Pt = " << me->pos() << ", global: " << mapToGlobal(me->pos());
}
else if (m_DoubleClick && e->type() == QMouseEvent::MouseButtonDblClick && isEnabled())
{
@ -223,7 +193,6 @@ bool SpinBox::eventFilter(QObject* o, QEvent* e)
/// <param name="e">The event</param>
void SpinBox::focusInEvent(QFocusEvent* e)
{
//lineEdit()->setReadOnly(false);
StopTimer();
QSpinBox::focusInEvent(e);
}
@ -237,8 +206,6 @@ 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.
StopTimer();
QSpinBox::focusOutEvent(e);
}
@ -250,8 +217,6 @@ void SpinBox::focusOutEvent(QFocusEvent* e)
/// <param name="e">The event</param>
void SpinBox::enterEvent(QEvent* e)
{
//m_Select = true;
//setFocus();
StopTimer();
QSpinBox::enterEvent(e);
}
@ -263,8 +228,6 @@ void SpinBox::enterEvent(QEvent* e)
/// <param name="e">The event</param>
void SpinBox::leaveEvent(QEvent* e)
{
//m_Select = false;
//clearFocus();
StopTimer();
QSpinBox::leaveEvent(e);
}