110 lines
3.0 KiB
C++
110 lines
3.0 KiB
C++
#include "eobjectattr.h"
|
|
#include "ui_eobjectattr.h"
|
|
|
|
eObjectAttr::eObjectAttr(const eObject::Data &data, const QRectF &rLimit, QWidget *parent) :
|
|
QGroupBox(parent),
|
|
ui(new Ui::eObjectAttr)
|
|
{
|
|
m_rLimit.setX(rLimit.x());
|
|
m_rLimit.setY(rLimit.y());
|
|
m_rLimit.setWidth(rLimit.width());
|
|
m_rLimit.setHeight(rLimit.height());
|
|
|
|
ui->setupUi(this);
|
|
ui->wX->setValue(static_cast<int>(data.x));
|
|
ui->wY->setValue(static_cast<int>(data.y));
|
|
ui->wW->setValue(static_cast<int>(data.w));
|
|
ui->wH->setValue(static_cast<int>(data.h));
|
|
connect(ui->wX, SIGNAL(valueChanged(int)), this, SLOT(onXChanged(int)));
|
|
connect(ui->wY, SIGNAL(valueChanged(int)), this, SLOT(onYChanged(int)));
|
|
connect(ui->wW, SIGNAL(valueChanged(int)), this, SLOT(onWChanged(int)));
|
|
connect(ui->wH, SIGNAL(valueChanged(int)), this, SLOT(onHChanged(int)));
|
|
|
|
QHBoxLayout *hBox = new QHBoxLayout();
|
|
ui->verticalLayout->addLayout(hBox);
|
|
hBox->addWidget(new QLabel("边框:"));
|
|
}
|
|
|
|
eObjectAttr::~eObjectAttr()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void eObjectAttr::onXChanged(int n)
|
|
{
|
|
if(m_rLimit != INVALID_RECT) {
|
|
int mx = n;
|
|
int mw = ui->wW->value();
|
|
if(mx + mw > m_rLimit.width()) {
|
|
mx = static_cast<int>(m_rLimit.width()) - mw;
|
|
ui->wX->blockSignals(true);
|
|
ui->wX->setValue(mx);
|
|
ui->wX->blockSignals(false);
|
|
}
|
|
}
|
|
onAttrChanged();
|
|
}
|
|
|
|
void eObjectAttr::onYChanged(int n)
|
|
{
|
|
if(m_rLimit != INVALID_RECT) {
|
|
int my = n;
|
|
int mh = ui->wH->value();
|
|
if(my + mh > m_rLimit.height()) {
|
|
my = static_cast<int>(m_rLimit.height()) - mh;
|
|
ui->wY->blockSignals(true);
|
|
ui->wY->setValue(my);
|
|
ui->wY->blockSignals(false);
|
|
}
|
|
}
|
|
onAttrChanged();
|
|
}
|
|
|
|
void eObjectAttr::onWChanged(int n)
|
|
{
|
|
if(m_rLimit != INVALID_RECT) {
|
|
int mx = ui->wX->value();
|
|
int mw = n;
|
|
if(mx + mw > m_rLimit.width()) {
|
|
mw = static_cast<int>(m_rLimit.width()) - mx;
|
|
ui->wW->blockSignals(true);
|
|
ui->wW->setValue(mw);
|
|
ui->wW->blockSignals(false);
|
|
}
|
|
}
|
|
onAttrChanged();
|
|
}
|
|
|
|
void eObjectAttr::onHChanged(int n)
|
|
{
|
|
if(m_rLimit != INVALID_RECT) {
|
|
int my = ui->wY->value();
|
|
int mh = n;
|
|
if(my + mh > m_rLimit.height()) {
|
|
mh = static_cast<int>(m_rLimit.height()) - my;
|
|
ui->wH->blockSignals(true);
|
|
ui->wH->setValue(mh);
|
|
ui->wH->blockSignals(false);
|
|
}
|
|
}
|
|
onAttrChanged();
|
|
}
|
|
|
|
void eObjectAttr::onAttrChanged()
|
|
{
|
|
eObject::Data data;
|
|
data.x = ui->wX->value();
|
|
data.y = ui->wY->value();
|
|
data.w = ui->wW->value();
|
|
data.h = ui->wH->value();
|
|
emit sAttrChanged(data);
|
|
}
|
|
|
|
void eObjectAttr::onAttrSetting(const eObject::Data &data)
|
|
{
|
|
ui->wX->setValue(static_cast<int>(data.x));
|
|
ui->wY->setValue(static_cast<int>(data.y));
|
|
ui->wW->setValue(static_cast<int>(data.w));
|
|
ui->wH->setValue(static_cast<int>(data.h));
|
|
}
|