[apps/math_toolbox] Add fork nodes in tree

Some nodes of the ToolboxMessageTree can be marked as "forks",
dispatching one branch or the other depending on preferences.
They are used in the Unit menu to provide a different toolbox depending
on the unit system.

Change-Id: I591f7abc3d24e682e827a540a9defac1877871b5
This commit is contained in:
Gabriel Ozouf
2020-09-21 18:02:09 +02:00
committed by Émilie Feral
parent 6105f44a46
commit 2e2845370a
5 changed files with 31 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
#include "math_toolbox.h"
#include "global_preferences.h"
#include "./shared/toolbox_helpers.h"
#include <assert.h>
#include <string.h>
@@ -384,3 +385,13 @@ MessageTableCellWithChevron* MathToolbox::nodeCellAtIndex(int index) {
int MathToolbox::maxNumberOfDisplayedRows() {
return k_maxNumberOfDisplayedRows;
}
int MathToolbox::indexAfterFork() const {
Preferences::UnitFormat unitFormat = GlobalPreferences::sharedGlobalPreferences()->unitFormat();
if (unitFormat == Preferences::UnitFormat::Metric) {
return 0;
}
assert(unitFormat == Preferences::UnitFormat::Imperial);
return 1;
}