Skip to content

Commit

Permalink
Add force update button in node settings (fix #155)
Browse files Browse the repository at this point in the history
  • Loading branch information
otto-link committed May 12, 2024
1 parent 072f1bf commit 5869be0
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Hesiod/include/hesiod/gui/widgets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class AttributesWidget : public QWidget
Q_SIGNALS:
void value_changed();

void update_button_released();

private:
std::map<std::string, std::unique_ptr<Attribute>> *p_attr_map;
std::vector<std::string> *p_attr_ordered_key;
Expand Down
4 changes: 4 additions & 0 deletions Hesiod/src/gui/nodes/base_node_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ void BaseNode::context_menu(const QPointF /* pos */)
this->compute();
Q_EMIT this->settings_changed();
});

connect(attributes_widget,
&AttributesWidget::update_button_released,
[this]() { this->compute(); });
}

this->qmenu->popup(QCursor::pos());
Expand Down
10 changes: 10 additions & 0 deletions Hesiod/src/gui/widgets/attributes_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ AttributesWidget::AttributesWidget(
layout->setSpacing(0);

int row = 0;

QPushButton *update_button = new QPushButton("Force update");
layout->addWidget(update_button, row, 0);

connect(update_button,
&QPushButton::released,
[this]() { Q_EMIT this->update_button_released(); });

row++;

// to check the number of widgets corresponds to the number of keys
// in "p_attr_ordered_key"
int count = 0;
Expand Down
2 changes: 1 addition & 1 deletion Hesiod/src/model/nodes/export_asset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ExportAsset::ExportAsset(const ModelConfig *p_config) : BaseNode(p_config)
this->output_types = {};

// attributes
this->attr["auto_export"] = NEW_ATTR_BOOL(false);
this->attr["auto_export"] = NEW_ATTR_BOOL(true);
this->attr["fname"] = NEW_ATTR_FILENAME("export");

{
Expand Down
2 changes: 1 addition & 1 deletion Hesiod/src/model/nodes/export_heightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ExportHeightmap::ExportHeightmap(const ModelConfig *p_config) : BaseNode(p_confi
// attributes
this->attr["fname"] = NEW_ATTR_FILENAME("hmap.png");
this->attr["format"] = NEW_ATTR_MAPENUM(heightmap_export_format_map, "png (8 bit)");
this->attr["auto_export"] = NEW_ATTR_BOOL(false);
this->attr["auto_export"] = NEW_ATTR_BOOL(true);

this->attr_ordered_key = {"fname", "format", "auto_export"};

Expand Down
2 changes: 1 addition & 1 deletion Hesiod/src/model/nodes/export_normal_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ExportNormalMap::ExportNormalMap(const ModelConfig *p_config) : BaseNode(p_confi
// attributes
this->attr["fname"] = NEW_ATTR_FILENAME("nmap.png");
this->attr["16bit"] = NEW_ATTR_BOOL(false);
this->attr["auto_export"] = NEW_ATTR_BOOL(false);
this->attr["auto_export"] = NEW_ATTR_BOOL(true);

this->attr_ordered_key = {"fname", "16bit", "auto_export"};

Expand Down
2 changes: 1 addition & 1 deletion Hesiod/src/model/nodes/export_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ExportTexture::ExportTexture(const ModelConfig *p_config) : BaseNode(p_config)
// attributes
this->attr["fname"] = NEW_ATTR_FILENAME("texture.png");
this->attr["16 bit"] = NEW_ATTR_BOOL(false);
this->attr["auto_export"] = NEW_ATTR_BOOL(false);
this->attr["auto_export"] = NEW_ATTR_BOOL(true);

this->attr_ordered_key = {"fname", "16 bit", "auto_export"};

Expand Down

0 comments on commit 5869be0

Please sign in to comment.