Skip to content

Commit bb79474

Browse files
authored
Merge pull request #66 from PartStackerCommunity/multi-select
Fix part multi-select bug, where the quantities would be zeroed out
2 parents ad10995 + d81978f commit bb79474

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/pstack/gui/controls.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct controls {
4545
wxStaticText* min_hole_text;
4646
wxStaticText* minimize_text;
4747
wxSpinCtrl* quantity_spinner;
48+
std::optional<int> quantity_spinner_last_value{ 1 };
4849
wxSpinCtrl* min_hole_spinner;
4950
wxCheckBox* minimize_checkbox;
5051
wxStaticText* rotation_text;

src/pstack/gui/main_window.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ void main_window::on_select_parts(const std::vector<std::size_t>& indices) {
8686
}
8787
if (quantity.has_value()) {
8888
_controls.quantity_spinner->SetValue(*quantity);
89+
_controls.quantity_spinner_last_value.emplace(*quantity);
8990
} else {
9091
_controls.quantity_spinner->SetValue("");
92+
_controls.quantity_spinner_last_value.reset();
9193
}
9294
if (min_hole.has_value()) {
9395
_controls.min_hole_spinner->SetValue(*min_hole);
@@ -425,9 +427,13 @@ void main_window::bind_all_controls() {
425427
_controls.sinterbox_result_button->Bind(wxEVT_BUTTON, &main_window::on_sinterbox_result, this);
426428

427429
_controls.quantity_spinner->Bind(wxEVT_SPINCTRL, [this](wxSpinEvent& event) {
428-
for (auto& current_part : _current_parts) {
429-
current_part.part->quantity = event.GetPosition();
430-
_parts_list.reload_quantity(current_part.index);
430+
if (not _controls.quantity_spinner_last_value.has_value() and event.GetPosition() == 0) {
431+
_controls.quantity_spinner->SetValue("");
432+
} else {
433+
for (auto& current_part : _current_parts) {
434+
current_part.part->quantity = event.GetPosition();
435+
_parts_list.reload_quantity(current_part.index);
436+
}
431437
}
432438
event.Skip();
433439
});

0 commit comments

Comments
 (0)