git-svn-id: svn://db.shs.com.ru/libs@701 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
MaterialMapEditor::MaterialMapEditor(QWidget * parent): QWidget(parent) {
|
||||
ui = new Ui::MaterialMapEditor();
|
||||
ui->setupUi(this);
|
||||
ui->widgetMap->hide();
|
||||
active = true;
|
||||
}
|
||||
|
||||
@@ -42,8 +43,9 @@ void MaterialMapEditor::changeEvent(QEvent * e) {
|
||||
|
||||
|
||||
void MaterialMapEditor::resizeEvent(QResizeEvent * e) {
|
||||
ui->iconedLabel->setFixedWidth(ui->iconedLabel->height());
|
||||
ui->iconedLabel->setIconSize(ui->iconedLabel->size());
|
||||
QSize sz = preferredIconSize(6, this);
|
||||
ui->iconedLabel->setFixedSize(sz);
|
||||
ui->iconedLabel->setIconSize(sz);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +56,18 @@ void MaterialMapEditor::updateIcon() {
|
||||
|
||||
void MaterialMapEditor::mapChanged() {
|
||||
if (!active || !map) return;
|
||||
map->color_amount = ui->sliderAmount->value();
|
||||
map->color_offset = ui->sliderOffset->value();
|
||||
active = false;
|
||||
map->use_bitmap = ui->checkMap->isChecked();
|
||||
if (ui->checkMap->isChecked()) {
|
||||
map->color_amount = ui->sliderAmount->value();
|
||||
map->color_offset = ui->sliderOffset->value();
|
||||
} else {
|
||||
map->color_amount = ui->sliderValue->value();
|
||||
map->color_offset = 0.f;
|
||||
}
|
||||
map->bitmap_scale.setX(ui->spinScaleX->value());
|
||||
map->bitmap_scale.setY(ui->spinScaleY->value());
|
||||
active = true;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
@@ -67,6 +77,9 @@ void MaterialMapEditor::setMap(Map * m) {
|
||||
map = m;
|
||||
setEnabled(m);
|
||||
if (!map) return;
|
||||
ui->stackedWidget->setCurrentIndex(map->use_bitmap ? 1 : 0);
|
||||
ui->checkMap->setChecked(map->use_bitmap);
|
||||
ui->sliderValue->setValue(map->color_amount);
|
||||
ui->sliderAmount->setValue(map->color_amount);
|
||||
ui->sliderOffset->setValue(map->color_offset);
|
||||
ui->spinScaleX->setValue(map->bitmap_scale.x());
|
||||
@@ -76,6 +89,24 @@ void MaterialMapEditor::setMap(Map * m) {
|
||||
active = true;
|
||||
}
|
||||
|
||||
|
||||
void MaterialMapEditor::configure(QString title, bool has_color) {
|
||||
ui->labelTitle->setText(title);
|
||||
ui->colorButton->setVisible(has_color);
|
||||
}
|
||||
|
||||
|
||||
void MaterialMapEditor::setColor(QColor c) {
|
||||
active = false;
|
||||
ui->colorButton->setColor(c);
|
||||
active = true;
|
||||
}
|
||||
|
||||
|
||||
QColor MaterialMapEditor::color() const {
|
||||
return ui->colorButton->color();
|
||||
}
|
||||
|
||||
/*
|
||||
Map MaterialMapEditor::map() {
|
||||
Map m;
|
||||
@@ -106,3 +137,14 @@ void MaterialMapEditor::on_buttonClear_clicked() {
|
||||
updateIcon();
|
||||
mapChanged();
|
||||
}
|
||||
|
||||
|
||||
void MaterialMapEditor::on_checkMap_toggled(bool checked) {
|
||||
if (checked) {
|
||||
ui->sliderAmount->setValue(ui->sliderValue->value());
|
||||
resizeEvent(0);
|
||||
} else
|
||||
ui->sliderValue->setValue(ui->sliderAmount->value());
|
||||
ui->stackedWidget->setCurrentIndex(checked ? 1 : 0);
|
||||
mapChanged();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user