mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-22 05:30:06 -05:00
90ec5b8246
-Show common folder locations such as documents, downloads, pictures in the sidebar in all file dialogs. -Warning message about exceeding memory in final render dialog now suggests strips as the solution to the problem. -Strips now has a tooltip explaining what it does. -Allow more digits in the spinners on the color section the flame tab. -Add manually adjustable size spinners in the final render dialog. Percentage scale and absolute size are fully synced. -Default prefix in final render is now the filename when doing animations (coming from sequence section of the library tab). -Changed the elliptic variation back to using a less precise version for float, and a more precise version for double. The last release had it always using double. -New applied xaos table that shows a read-only view of actual weights by taking the base xform weights and multiplying them by the xaos values. -New table in the xaos tab that gives a graphical representation of the probability that each xform is chosen, with and without xaos. -Add button to transpose the xaos rows and columns. -Add support for importing .chaos files from Chaotica. --Pasting back to Chaotica will work for most, but not all, variations due to incompatible parameter names in some. -Curves are now splines instead of Bezier. This adds compatibility with Chaotica, but breaks it for Apophysis. Xmls are still pastable, but the color curves will look different. --The curve editor on the palette tab can now add points by clicking on the lines and remove points by clicking on the points themselves, just like Chaotica. --Splines are saved in four new xml fields: overall_curve, red_curve, green_curve and blue_curve. -Allow for specifying the percentage of a sub batch each thread should iterate through per kernel call when running with OpenCL. This gives a roughly 1% performance increase due to having to make less kernel calls while iterating. --This field is present for interactive editing (where it's not very useful) and in the final render dialog. --On the command line, this is specified as --sbpctth for EmberRender and EmberAnimate. -Allow double clicking to toggle the supersample field in the flame tab between 1 and 2 for easily checking the effect of the field. -When showing affine values as polar coordinates, show angles normalized to 360 to match Chaotica. -Fuse Count spinner now toggles between 15 and 100 when double clicking for easily checking the effect of the field. -Added field for limiting the range in the x and y direction that the initial points are chosen from. -Added a field called K2 which is an alternative way to set brightness, ignored when zero. --This has no effect for many variations, but hs a noticeable effect for some. -Added new variations: arcsech arcsech2 arcsinh arctanh asteria block bwraps_rand circlecrop2 coth_spiral crackle2 depth_blur depth_blur2 depth_gaussian depth_gaussian2 depth_ngon depth_ngon2 depth_sine depth_sine2 dragonfire dspherical dust excinis exp2 flipx flowerdb foci_p gaussian glynnia2 glynnsim4 glynnsim5 henon henon hex_rand hex_truchet hypershift lazyjess lens lozi lozi modulusx modulusy oscilloscope2 point_symmetry pointsymmetry projective pulse rotate scry2 shift smartshape spher squares starblur2 swirl3 swirl3r tanh_spiral target0 target2 tile_hlp truchet_glyph truchet_inv truchet_knot unicorngaloshen vibration vibration2 --hex_truchet, hex_rand should always use double. They are extremely sensitive. --Bug fixes: -Bounds sign was flipped for x coordinate of world space when center was not zero. -Right clicking and dragging spinner showed menu on mouse up, even if it was very far away. -Text boxes for size in final render dialog were hard to type in. Same bug as xform weight used to be so fix the same way. -Fix spelling to be plural in toggle color speed box. -Stop using the blank user palette to generate flames. Either put colored palettes in it, or exclude it from randoms. -Clicking the random palette button for a palette file with only one palette in it would freeze the program. -Clicking none scale in final render did not re-render the preview. -Use less precision on random xaos. No need for 12 decimal places. -The term sub batch is overloaded in the options dialog. Change the naming and tooltip of those settings for cpu and opencl. --Also made clear in the tooltip for the default opencl quality setting that the value is per device. -The arrows spinner in palette editor appears like a read-only label. Made it look like a spinner. -Fix border colors for various spin boxes and table headers in the style sheet. Requires reload. -Fix a bug in the bwraps variation which would produce different results than Chaotica and Apophysis. -Synth was allowed to be selected for random flame generation when using an Nvidia card but it shouldn't have been because Nvidia has a hard time compiling synth. -A casting bug in the OpenCL kernels for log scaling and density filtering was preventing successful compilations on Intel iGPUs. Fixed even though we don't support anything other than AMD and Nvidia. -Palette rotation (click and drag) position was not being reset when loading a new flame. -When the xform circles were hidden, opening and closing the options dialog would improperly reshow them. -Double click toggle was broken on integer spin boxes. -Fixed tab order of some controls. -Creating a palette from a jpg in the palette editor only produced a single color. --Needed to package imageformats/qjpeg.dll with the Windows installer. -The basic memory benchmark test flame was not really testing memory. Make it more spread out. -Remove the temporal samples field from the flame tab, it was never used because it's only an animation parameter which is specified in the final render dialog or on the command line with EmberAnimate. --Code changes: -Add IsEmpty() to Palette to determine if a palette is all black. -Attempt to avoid selecting a blank palette in PaletteList::GetRandomPalette(). -Add function ScanForChaosNodes() and some associated helper functions in XmlToEmber. -Make variation param name correction be case insensitive in XmlToEmber. -Report error when assigning a variation param value in XmlToEmber. -Add SubBatchPercentPerThread() method to RendererCL. -Override enterEvent() and leaveEvent() in DoubleSpinBox and SpinBox to prevent the context menu from showing up on right mouse up after already leaving the spinner. -Filtering the mouse wheel event in TableWidget no longer appears to be needed. It was probably an old Qt bug that has been fixed. -Gui/ember syncing code in the final render dialog needed to be reworked to accommodate absolute sizes.
376 lines
9.6 KiB
C++
376 lines
9.6 KiB
C++
#include "FractoriumPch.h"
|
|
#include "SpinBox.h"
|
|
#include "FractoriumSettings.h"
|
|
|
|
QTimer SpinBox::s_Timer;
|
|
|
|
/// <summary>
|
|
/// Constructor that passes parent to the base and sets up height and step.
|
|
/// Specific focus policy is used to allow the user to hover over the control
|
|
/// and change its value using the mouse wheel without explicitly having to click
|
|
/// inside of it.
|
|
/// </summary>
|
|
/// <param name="p">The parent widget. Default: nullptr.</param>
|
|
/// <param name="h">The height of the spin box. Default: 16.</param>
|
|
/// <param name="step">The step used to increment/decrement the spin box when using the mouse wheel. Default: 1.</param>
|
|
SpinBox::SpinBox(QWidget* p, int h, int step)
|
|
: QSpinBox(p)
|
|
{
|
|
m_DoubleClick = false;
|
|
m_DoubleClickLowVal = 0;
|
|
m_DoubleClickNonZero = 0;
|
|
m_DoubleClickZero = 1;
|
|
m_Step = step;
|
|
m_SmallStep = 1;
|
|
m_Settings = FractoriumSettings::DefInstance();
|
|
setSingleStep(step);
|
|
setFrame(false);
|
|
setButtonSymbols(QAbstractSpinBox::NoButtons);
|
|
setFocusPolicy(Qt::StrongFocus);
|
|
setMinimumHeight(h);//setGeometry() has no effect, so set both of these instead.
|
|
setMaximumHeight(h);
|
|
setContextMenuPolicy(Qt::PreventContextMenu);
|
|
lineEdit()->installEventFilter(this);
|
|
lineEdit()->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
|
connect(this, SIGNAL(valueChanged(int)), this, SLOT(onSpinBoxValueChanged(int)), Qt::QueuedConnection);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the value of the control without triggering signals.
|
|
/// </summary>
|
|
/// <param name="d">The value to set it to</param>
|
|
void SpinBox::SetValueStealth(int d)
|
|
{
|
|
blockSignals(true);
|
|
setValue(d);
|
|
blockSignals(false);
|
|
}
|
|
|
|
void SpinBox::SetValueStealth(size_t d) { SetValueStealth(int(d)); }
|
|
|
|
/// <summary>
|
|
/// Set whether to respond to double click events.
|
|
/// </summary>
|
|
/// <param name="b">True if this should respond to double click events, else false.</param>
|
|
void SpinBox::DoubleClick(bool b)
|
|
{
|
|
m_DoubleClick = b;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the value to be used instead of zero to represent the lower value
|
|
/// used when responding to a double click.
|
|
/// </summary>
|
|
/// <param name="val">The value to be used for the lower value instead of zero</param>
|
|
void SpinBox::DoubleClickLowVal(int val)
|
|
{
|
|
m_DoubleClickLowVal = val;
|
|
}
|
|
|
|
int SpinBox::DoubleClickLowVal()
|
|
{
|
|
return m_DoubleClickLowVal;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the value to be used when the user double clicks the spinner while
|
|
/// it contains zero.
|
|
/// </summary>
|
|
/// <param name="val">The value to be used</param>
|
|
void SpinBox::DoubleClickZero(int val)
|
|
{
|
|
m_DoubleClickZero = val;
|
|
}
|
|
|
|
int SpinBox::DoubleClickZero()
|
|
{
|
|
return m_DoubleClickZero;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the value to be used when the user double clicks the spinner while
|
|
/// it contains a non-zero value.
|
|
/// </summary>
|
|
/// <param name="val">The value to be used</param>
|
|
void SpinBox::DoubleClickNonZero(int val)
|
|
{
|
|
m_DoubleClickNonZero = val;
|
|
}
|
|
|
|
int SpinBox::DoubleClickNonZero()
|
|
{
|
|
return m_DoubleClickNonZero;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the small step to be used when the user holds down shift while scrolling.
|
|
/// The default is step / 10, so use this if something else is needed.
|
|
/// </summary>
|
|
/// <param name="step">The small step to use for scrolling while the shift key is down</param>
|
|
void SpinBox::SmallStep(int step)
|
|
{
|
|
m_SmallStep = std::min(1, step);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Expose the underlying QLineEdit control to the caller.
|
|
/// </summary>
|
|
/// <returns>A pointer to the QLineEdit</returns>
|
|
QLineEdit* SpinBox::lineEdit()
|
|
{
|
|
return QSpinBox::lineEdit();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Another workaround for the persistent text selection bug in Qt.
|
|
/// </summary>
|
|
void SpinBox::onSpinBoxValueChanged(int i)
|
|
{
|
|
lineEdit()->deselect();//Gets rid of nasty "feature" that always has text selected.
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called while the timer is activated due to the right mouse button being held down.
|
|
/// </summary>
|
|
void SpinBox::OnTimeout()
|
|
{
|
|
int xdistance = m_MouseMovePoint.x() - m_MouseDownPoint.x();
|
|
int ydistance = m_MouseMovePoint.y() - m_MouseDownPoint.y();
|
|
int distance = abs(xdistance) > abs(ydistance) ? xdistance : ydistance;
|
|
distance = Sqr(distance) * (distance < 0 ? -1 : 1);
|
|
double scale, val;
|
|
int d = value();
|
|
bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
|
|
bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
|
|
double amount = (m_SmallStep + m_Step) * 0.5;
|
|
|
|
if (shift)
|
|
scale = 0.001;
|
|
else if (ctrl)
|
|
scale = 0.01;
|
|
else
|
|
scale = 0.01;
|
|
|
|
val = d + (distance * amount * scale);
|
|
setValue(int(val));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event filter for taking special action on double click events.
|
|
/// </summary>
|
|
/// <param name="o">The object</param>
|
|
/// <param name="e">The eevent</param>
|
|
/// <returns>false</returns>
|
|
bool SpinBox::eventFilter(QObject* o, QEvent* e)
|
|
{
|
|
if (!isEnabled())
|
|
return QSpinBox::eventFilter(o, e);
|
|
|
|
auto me = dynamic_cast<QMouseEvent*>(e);
|
|
|
|
if (me)
|
|
{
|
|
if (!m_Settings->ToggleType() &&//Ensure double click toggles, not right click.
|
|
me->type() == QMouseEvent::MouseButtonPress &&
|
|
me->button() == Qt::RightButton)
|
|
{
|
|
m_MouseDownPoint = m_MouseMovePoint = me->pos();
|
|
StartTimer();
|
|
e->accept();
|
|
return true;
|
|
}
|
|
else if (!m_Settings->ToggleType() &&
|
|
me->type() == QMouseEvent::MouseButtonRelease &&
|
|
me->button() == Qt::RightButton)
|
|
{
|
|
StopTimer();
|
|
m_MouseDownPoint = m_MouseMovePoint = me->pos();
|
|
e->accept();
|
|
return true;
|
|
}
|
|
else if (!m_Settings->ToggleType() &&
|
|
me->type() == QMouseEvent::MouseMove &&
|
|
QGuiApplication::mouseButtons() & Qt::RightButton)
|
|
{
|
|
m_MouseMovePoint = me->pos();
|
|
e->accept();
|
|
return true;
|
|
}
|
|
else if (m_DoubleClick &&
|
|
((!m_Settings->ToggleType() && e->type() == QMouseEvent::MouseButtonDblClick && me->button() == Qt::LeftButton) ||
|
|
(m_Settings->ToggleType() && me->type() == QMouseEvent::MouseButtonRelease && me->button() == Qt::RightButton)))
|
|
{
|
|
if (m_DoubleClickLowVal == value())
|
|
{
|
|
m_DoubleClickZeroEvent(this, m_DoubleClickZero);
|
|
setValue(m_DoubleClickZero);
|
|
}
|
|
else
|
|
{
|
|
m_DoubleClickNonZeroEvent(this, m_DoubleClickNonZero);
|
|
setValue(m_DoubleClickNonZero);
|
|
}
|
|
|
|
e->accept();
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (e->type() == QEvent::Wheel)
|
|
{
|
|
if (QWheelEvent* we = dynamic_cast<QWheelEvent*>(e))
|
|
{
|
|
bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
|
|
bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
|
|
|
|
if (we->angleDelta().ry() > 0)
|
|
{
|
|
if (shift)
|
|
{
|
|
setSingleStep(m_SmallStep);
|
|
setValue(value() + m_SmallStep);
|
|
}
|
|
else
|
|
{
|
|
setSingleStep(m_Step);
|
|
setValue(value() + (ctrl ? m_Step * 10 : m_Step));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (shift)
|
|
{
|
|
setSingleStep(m_SmallStep);
|
|
setValue(value() - m_SmallStep);
|
|
}
|
|
else
|
|
{
|
|
setSingleStep(m_Step);
|
|
setValue(value() - (ctrl ? m_Step * 10 : m_Step));
|
|
}
|
|
}
|
|
|
|
e->accept();
|
|
return true;
|
|
}
|
|
}
|
|
else if (dynamic_cast<QKeyEvent*>(e))
|
|
{
|
|
e->accept();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return QSpinBox::eventFilter(o, e);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Override which is for handling specific key presses while this control is focused.
|
|
/// In particular, + = and up arrow increase the value, equivalent to scrolling the mouse wheel up, while also observing shift/ctrl modifiers.
|
|
/// Values are decreased in the same way by pressing - _ or down arrow.
|
|
/// </summary>
|
|
/// <param name="ke">The key event</param>
|
|
void SpinBox::keyPressEvent(QKeyEvent* ke)
|
|
{
|
|
bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
|
|
bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
|
|
|
|
if (ke->key() == Qt::Key_Up)
|
|
{
|
|
if (shift)
|
|
{
|
|
setSingleStep(m_SmallStep);
|
|
setValue(value() + m_SmallStep);
|
|
}
|
|
else
|
|
{
|
|
setSingleStep(m_Step);
|
|
setValue(value() + (ctrl ? m_Step * 10 : m_Step));
|
|
}
|
|
|
|
ke->accept();
|
|
}
|
|
else if (ke->key() == Qt::Key_Down)
|
|
{
|
|
if (shift)
|
|
{
|
|
setSingleStep(m_SmallStep);
|
|
setValue(value() - m_SmallStep);
|
|
}
|
|
else
|
|
{
|
|
setSingleStep(m_Step);
|
|
setValue(value() - (ctrl ? m_Step * 10 : m_Step));
|
|
}
|
|
|
|
ke->accept();
|
|
}
|
|
else
|
|
QSpinBox::keyPressEvent(ke);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when focus enters the spinner.
|
|
/// </summary>
|
|
/// <param name="e">The event</param>
|
|
void SpinBox::focusInEvent(QFocusEvent* e)
|
|
{
|
|
StopTimer();
|
|
QSpinBox::focusInEvent(e);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when focus leaves the spinner.
|
|
/// Qt has a nasty "feature" that leaves the text in a spinner selected
|
|
/// and the cursor visible, regardless of whether it has the focus.
|
|
/// Manually clear both here.
|
|
/// </summary>
|
|
/// <param name="e">The event</param>
|
|
void SpinBox::focusOutEvent(QFocusEvent* e)
|
|
{
|
|
StopTimer();
|
|
QSpinBox::focusOutEvent(e);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when focus enters the spinner.
|
|
/// Must set the focus to make sure key down messages don't erroneously go to the GLWidget.
|
|
/// </summary>
|
|
/// <param name="e">The event</param>
|
|
void SpinBox::enterEvent(QEvent* e)
|
|
{
|
|
StopTimer();
|
|
QSpinBox::enterEvent(e);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when focus leaves the spinner.
|
|
/// Must clear the focus to make sure key down messages don't erroneously go to the GLWidget.
|
|
/// </summary>
|
|
/// <param name="e">The event</param>
|
|
void SpinBox::leaveEvent(QEvent* e)
|
|
{
|
|
StopTimer();
|
|
QSpinBox::leaveEvent(e);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Start the timer in response to the right mouse button being pressed.
|
|
/// </summary>
|
|
void SpinBox::StartTimer()
|
|
{
|
|
s_Timer.stop();
|
|
connect(&s_Timer, SIGNAL(timeout()), this, SLOT(OnTimeout()));
|
|
s_Timer.start(300);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Stop the timer in response to the left mouse button being pressed.
|
|
/// </summary>
|
|
void SpinBox::StopTimer()
|
|
{
|
|
s_Timer.stop();
|
|
disconnect(&s_Timer, SIGNAL(timeout()), this, SLOT(OnTimeout()));
|
|
}
|