feat: add consistant padding
This commit is contained in:
@@ -13,12 +13,12 @@ enzo::ui::AbstractFormParm::AbstractFormParm(std::weak_ptr<prm::Parameter> param
|
||||
if(auto sharedParameter=parameter_.lock())
|
||||
{
|
||||
std::string name = sharedParameter->getName();
|
||||
auto label = new QLabel(QString::fromStdString(name+":"));
|
||||
label->setStyleSheet("QLabel{background: none}");
|
||||
label->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
label_ = new QLabel(QString::fromStdString(name+":"));
|
||||
label_->setStyleSheet("QLabel{background: none}");
|
||||
label_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
|
||||
mainLayout_ = new QHBoxLayout();
|
||||
mainLayout_->addWidget(label);
|
||||
mainLayout_->addWidget(label_);
|
||||
mainLayout_->setContentsMargins(0,0,0,0);
|
||||
|
||||
switch(sharedParameter->getType())
|
||||
@@ -65,6 +65,18 @@ enzo::ui::AbstractFormParm::AbstractFormParm(std::weak_ptr<prm::Parameter> param
|
||||
|
||||
}
|
||||
|
||||
int enzo::ui::AbstractFormParm::getLeftPadding()
|
||||
{
|
||||
|
||||
return label_->minimumSizeHint().width();
|
||||
}
|
||||
|
||||
void enzo::ui::AbstractFormParm::setLeftPadding(int padding)
|
||||
{
|
||||
label_->setFixedWidth(padding);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void enzo::ui::AbstractFormParm::changeValue(enzo::bt::floatT value, unsigned int index)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <memory>
|
||||
#include <qtmetamacros.h>
|
||||
#include <QLabel>
|
||||
|
||||
namespace enzo::ui
|
||||
{
|
||||
@@ -13,12 +14,15 @@ class AbstractFormParm
|
||||
Q_OBJECT
|
||||
public:
|
||||
AbstractFormParm(std::weak_ptr<prm::Parameter> parameter);
|
||||
int getLeftPadding();
|
||||
void setLeftPadding(int padding);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void changeValue(bt::floatT value, unsigned int index=0);
|
||||
|
||||
private:
|
||||
QHBoxLayout* mainLayout_;
|
||||
QLabel* label_;
|
||||
std::weak_ptr<prm::Parameter> parameter_;
|
||||
|
||||
};
|
||||
|
||||
@@ -33,12 +33,6 @@ ParametersPanel::ParametersPanel(QWidget *parent, Qt::WindowFlags f)
|
||||
|
||||
mainLayout_->addWidget(bgWidget_);
|
||||
|
||||
// parametersLayout_->addWidget(new enzo::ui::AbstractFormParm());
|
||||
// parametersLayout_->addWidget(new enzo::ui::AbstractFormParm());
|
||||
// parametersLayout_->addWidget(new enzo::ui::AbstractFormParm());
|
||||
// parametersLayout_->addWidget(new enzo::ui::AbstractFormParm());
|
||||
|
||||
|
||||
setLayout(mainLayout_);
|
||||
}
|
||||
|
||||
@@ -59,27 +53,30 @@ void ParametersPanel::selectionChanged()
|
||||
|
||||
enzo::nt::GeometryOperator& displayOp = nm.getGeoOperator(displayOpId.value());
|
||||
auto parameters = displayOp.getParameters();
|
||||
|
||||
std::vector<enzo::ui::AbstractFormParm*> parameterWidgets;
|
||||
parameterWidgets.reserve(parameters.size());
|
||||
|
||||
int maxLeftPadding = 0;
|
||||
|
||||
for(auto parameter : parameters)
|
||||
{
|
||||
auto parameterShared = parameter.lock();
|
||||
if(!parameterShared) throw std::runtime_error("Failed to lock parameter");
|
||||
|
||||
|
||||
enzo::ui::AbstractFormParm* parameterWidget = new enzo::ui::AbstractFormParm(parameter);
|
||||
int leftPadding = parameterWidget->getLeftPadding();
|
||||
if(leftPadding > maxLeftPadding) maxLeftPadding = leftPadding;
|
||||
|
||||
parametersLayout_->addWidget(new enzo::ui::AbstractFormParm(parameter));
|
||||
// switch(parameterShared->getType())
|
||||
// {
|
||||
// case prm::Type::FLOAT:
|
||||
// parametersLayout_->addWidget(new enzo::ui::AbstractFormParm(parameter));
|
||||
// break;
|
||||
// case prm::Type::VECTOR3:
|
||||
// parametersLayout_->addWidget(new enzo::ui::VectorParr(parameter));
|
||||
// break;
|
||||
// default:
|
||||
// throw std::runtime_error("Parameter panel: paremeter type not accounted for");
|
||||
parameterWidgets.push_back(parameterWidget);
|
||||
}
|
||||
|
||||
// }
|
||||
const int leftPadding = maxLeftPadding + 5;
|
||||
|
||||
for(auto parameterWidget : parameterWidgets)
|
||||
{
|
||||
parameterWidget->setLeftPadding(leftPadding);
|
||||
parametersLayout_->addWidget(parameterWidget);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user