fractorium/Source/Fractorium/TwoButtonComboWidget.h
mfeemster 9e94170a70 0.4.1.3 Beta 10/14/2014
--User Changes
 Size is no longer fixed to the window size.
 Size scaling is done differently in the final render dialog. This fixes several bugs.
 Remove Xml saving size from settings and options dialog, it no longer applies.
 Final render can be broken into strips.
 Set default save path to the desktop if none is found in the settings file.
 Set default output size to 1920x1080 if none is found in the settings file.

--Bug Fixes
 Better memory size reporting in final render dialog.

--Code Changes
 Migrate to C++11, Qt 5.3.1, and Visual Studio 2013.
 Change most instances of unsigned int to size_t, and int to intmax_t.
 Add m_OrigPixPerUnit and m_ScaleType to Ember for scaling purposes.
 Replace some sprintf_s() calls in XmlToEmber with ostringstream.
 Move more non-templated members into RendererBase.
 Add CopyVec() overload that takes a per element function pointer.
 Add vector Memset().
 Replace '&' with '+' instead of "&" in XmlToEmber for much faster parsing.
 Break strips rendering out into EmberCommon and call from EmberRender and Fractorium.
 Make AddAndWriteBuffer() just call WriteBuffer().
 Make AddAndWriteImage() delete the existing image first before replacing it.
 Add SetOutputTexture() to RendererCL to support making new textures in response to resize events.
 Remove multiple return statements in RendererCL, and replace with a bool that tracks results.
 Add ToDouble(), MakeEnd(), ToString() and Exists() wrappers in Fractorium.
 Add Size() wrapper in EmberFile.
 Make QString function arguments const QString&, and string with const string&.
 Make ShowCritical() wrapper for invoking a message box from another thread.
 Add combo box to TwoButtonWidget and rename.
2014-10-14 08:53:15 -07:00

121 lines
3.5 KiB
C++

#pragma once
#include "FractoriumPch.h"
#include "DoubleSpinBox.h"
/// <summary>
/// TwoButtonComboWidget and SpinnerButtonWidget classes.
/// </summary>
/// <summary>
/// Thin container that is both a widget and a container of two QPushButtons.
/// Used for when a layout expects a single widget, but two need to go in its place.
/// The buttons are public so the caller can easily use them individually.
/// </summary>
class TwoButtonComboWidget : public QWidget
{
Q_OBJECT
public:
/// <summary>
/// Constructor that passes the parent to the base, then creates two QPushButtons,
/// and sets up their captions and dimensions.
/// </summary>
/// <param name="caption1">The caption of the first button</param>
/// <param name="caption2">The caption of the second button</param>
/// <param name="w1">The width of the first button</param>
/// <param name="w2">The width of the second button</param>
/// <param name="h">The height of both buttons</param>
/// <param name="parent">The parent widget</param>
TwoButtonComboWidget(const QString& caption1, const QString& caption2, QStringList comboStrings, int w1, int w2, int h, QWidget* parent)
: QWidget(parent)
{
QHBoxLayout* layout = new QHBoxLayout(this);
m_Button1 = new QPushButton(caption1, parent);
m_Button2 = new QPushButton(caption2, parent);
m_Combo = new QComboBox(parent);
m_Combo->addItems(comboStrings);
if (w1 != -1)
{
m_Button1->setMinimumWidth(w1);
m_Button1->setMaximumWidth(w1);
}
if (w2 != -1)
{
m_Button2->setMinimumWidth(w2);
m_Button2->setMaximumWidth(w2);
}
m_Button1->setMinimumHeight(h);
m_Button1->setMaximumHeight(h);
m_Button2->setMinimumHeight(h);
m_Button2->setMaximumHeight(h);
m_Combo->setMinimumHeight(h - 3);
m_Combo->setMaximumHeight(h - 3);
layout->addWidget(m_Combo);
layout->addWidget(m_Button1);
layout->addWidget(m_Button2);
layout->setAlignment(Qt::AlignLeft);
layout->setMargin(0);
layout->setSpacing(2);
setLayout(layout);
}
QPushButton* m_Button1;
QPushButton* m_Button2;
QComboBox* m_Combo;
};
/// <summary>
/// Thin container that is both a widget and a container of one DoubleSpinBox and one QPushButton.
/// Used for when a layout expects a single widget, but two need to go in its place.
/// The widgets are public so the caller can easily use them individually.
/// </summary>
class SpinnerButtonWidget : public QWidget
{
Q_OBJECT
public:
/// <summary>
/// Constructor that passes the parent to the base, then creates a QPushButton and
/// sets up its caption and dimensions, then assigns the DoubleSpinBox.
/// </summary>
/// <param name="spinBox">The pre-created DoubleSpinBox</param>
/// <param name="buttonCaption">The caption of the button</param>
/// <param name="w">The width of the button</param>
/// <param name="h">The height of the button</param>
/// <param name="parent">The parent widget</param>
SpinnerButtonWidget(DoubleSpinBox* spinBox, QString buttonCaption, int w, int h, QWidget* parent)
: QWidget(parent)
{
QHBoxLayout* layout = new QHBoxLayout(this);
m_Button = new QPushButton(buttonCaption, parent);
m_SpinBox = spinBox;
if (w != -1)
{
m_Button->setMinimumWidth(w);
m_Button->setMaximumWidth(w);
}
m_Button->setMinimumHeight(h);
m_Button->setMaximumHeight(h);
layout->addWidget(spinBox);
layout->addWidget(m_Button);
layout->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
layout->setMargin(0);
layout->setSpacing(0);
setLayout(layout);
}
DoubleSpinBox* m_SpinBox;
QPushButton* m_Button;
};