20 : QWidget(parent), showAddButton(showAddButton) {
27 auto* button =
new QPushButton(tr(
"Add new variable"));
28 button->setFocusPolicy(Qt::NoFocus);
29 auto *buttonLayout =
new QHBoxLayout();
30 buttonLayout->insertStretch(-1, 100);
31 buttonLayout->addWidget(button, 0);
44 switch (dialog->tabWidget->currentIndex()) {
46 s = QString::fromLatin1(
"%1 = curve(%2,0,0,4,1,1,4);\n")
47 .arg(dialog->variableName->text())
48 .arg(dialog->curveLookup->text());
51 s = QString::fromLatin1(
"%1 = ccurve(%2,0,[0,0,0],4,1,[1,1,1],4);\n")
52 .arg(dialog->variableName->text())
53 .arg(dialog->colorCurveLookup->text());
56 s = QString::fromLatin1(
"%1 = %2; # %3,%4\n")
57 .arg(dialog->variableName->text())
58 .arg(dialog->intDefault->text())
59 .arg(dialog->intMin->text())
60 .arg(dialog->intMax->text());
63 s = QString::fromLatin1(
"%1 = %2; # %3, %4\n")
64 .arg(dialog->variableName->text())
65 .arg(dialog->floatDefault->text())
70 s = QString::fromLatin1(
"%1 = [%2,%3,%4]; # %5, %6\n")
71 .arg(dialog->variableName->text())
72 .arg(dialog->vectorDefault0->text())
73 .arg(dialog->vectorDefault1->text())
74 .arg(dialog->vectorDefault2->text())
79 s = QString::fromLatin1(
"%1 = [%2,%3,%4];\n")
80 .arg(dialog->variableName->text())
81 .arg(dialog->color.redF())
82 .arg(dialog->color.greenF())
83 .arg(dialog->color.blueF());
86 s = QString::fromLatin1(
"%1 = swatch(%2,%3);\n")
87 .arg(dialog->variableName->text())
88 .arg(dialog->swatchLookup->text())
89 .arg(QString::fromLatin1(dialog->initSwatch()));
92 s = QString::fromLatin1(
"%1 = \"%2\"; #%3 %4\n")
93 .arg(dialog->variableName->text())
94 .arg(dialog->stringDefaultWidget->text())
95 .arg(dialog->stringTypeWidget->currentText())
96 .arg(dialog->stringNameWidget->text());
106 newEditable->
setExpr(expressionText.toStdString());
110 bool newVariables =
true;
113 const std::vector<std::string>& vars = newEditable->getVariables();
115 for (
const auto & var : vars) {
116 variables.push_back(QString::fromLatin1(
"$%1").arg(QString::fromStdString(var)));
143 Editable* editable = (*editableExpression)[i];
159 dbgSeExpr <<
"KSeExpr editor logic error, cannot find a widget for the given editable";
171 dbgSeExpr <<
"Expr Editor Logic ERROR did not make widget";
195 if (_linkedId < 0 || _linkedId >= (
int)
_controls.size())
return;
Control for editing a color ramp curve.
A control for editing color swatches.
Control for editing a normal curve ramp.
Factors a SeExpr into an editable expression with controls (i.e. value boxes, curve boxes)
size_t size() const
Return the count of editable parameters.
void setExpr(const std::string &expr)
Set's expressions and parses it into "control editable form".
std::string getEditedExpr() const
Return a reconstructed expression using all the editable's current values.
bool controlsMatch(const EditableExpression &other) const
Check if the other editable expression has editables that all match i.e. the controls are same.
void updateString(const EditableExpression &other)
Update the string refered to into the controls (this is only valid if controlsmatch)
const std::vector< std::string > & getVariables() const
Get list of commentsø
This class is the UI for adding widgets.
void controlChanged(int id)
Notification that a specific control was changed.
~ExprControlCollection() override
void updateText(int id, QString &text)
Request new text, given taking into account control id's new values.
bool rebuildControls(const QString &expressionText, std::vector< QString > &variables)
Rebuild the controls given the new expressionText. Return any local variables found.
void insertString(const QString &controlString)
void singleControlChanged(int id)
Notification when by a control whenever it is edited.
void linkColorOutput(QColor color)
Gives information about when a link color was changed.
QVBoxLayout * controlLayout
ExprControlCollection(QWidget *parent=nullptr, bool showAddButton=true)
void addControlDialog()
When a user clicks "Add new variable" button.
std::vector< ExprControl * > _controls
void linkColorLink(int id)
Notification by a control that a new color link is desired.
void linkColorEdited(int id, QColor color)
Notification by a control that a color is edited (when it is linked)
EditableExpression * editableExpression
void linkColorInput(QColor color)
Base class for all controls for Expressions.
Number slider for either float or int data.
A control for editing strings, filenames, and directories.
A vector or color control (named vector because it edits a KSeExpr::Vec3d literal)
double_t atof(const char *num)