summaryrefslogtreecommitdiffstats
path: root/core/equipment.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-09-12 18:50:06 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-09-12 10:36:36 -0700
commit6ea0cc62b8c7b01c37fdfbe50e3cefde4c43d360 (patch)
tree603db8f3ec9ec30fb47eb4064d09a9257c2e436e /core/equipment.h
parent72312bec2f4dcde3150a2d989bd729237c704d66 (diff)
downloadsubsurface-6ea0cc62b8c7b01c37fdfbe50e3cefde4c43d360.tar.gz
desktop: refine auto-fill of weights
In a previous commit, auto-filling of weight based on type was changed to be only performed if the user hadn't already set a weight, by testing for weight=0. However, when the user edited the type and tabbed back and forth, that counted as an edit and therefore the weight would not change anymore. To refine this, introduce an "auto_filled" flag to the weightsystem, which is set if the weight is automatically filled and cleared if the weight is edited. Update the weight if it was zero *or* auto-filled. The flag is not saved to disk, but that should be acceptable. If the user saves and reloads, we can assume that they meant the weight to be set to the default value. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/equipment.h')
-rw-r--r--core/equipment.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/equipment.h b/core/equipment.h
index 7df54ad50..463040b6a 100644
--- a/core/equipment.h
+++ b/core/equipment.h
@@ -50,9 +50,10 @@ typedef struct
{
weight_t weight;
const char *description; /* "integrated", "belt", "ankle" */
+ bool auto_filled; /* weight was automatically derived from the type */
} weightsystem_t;
-static const weightsystem_t empty_weightsystem = { { 0 }, 0 };
+static const weightsystem_t empty_weightsystem = { { 0 }, 0, false };
/* Table of weightsystems. Attention: this stores weightsystems,
* *not* pointers * to weightsystems. This has two crucial