Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ValueMenuItem.h « Display « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2660bb7efc9fc6885ded69bd0e995a3e2651281c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * ValueMenuItem.h
 *
 *  Created on: 25 Apr 2022
 *      Author: David
 */

#ifndef SRC_DISPLAY_VALUEMENUITEM_H_
#define SRC_DISPLAY_VALUEMENUITEM_H_

#include "MenuItem.h"

#if SUPPORT_DIRECT_LCD

#include <ObjectModel/ObjectModel.h>

class ValueMenuItem final : public MenuItem
{
public:
	DECLARE_FREELIST_NEW_DELETE(ValueMenuItem)

	ValueMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, bool adj, const char *_ecv_array _ecv_null om, unsigned int v, unsigned int d) noexcept;
	void Draw(Lcd& lcd, PixelNumber maxWidth, bool highlight) noexcept override;
	bool Select(const StringRef& cmd) noexcept override;
	bool CanAdjust() const noexcept override { return true; }
	bool Adjust(int clicks) noexcept override;
	void UpdateWidthAndHeight(Lcd& lcd) noexcept override;

	PixelNumber GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const noexcept override;

	unsigned int GetReferencedToolNumber() const noexcept;

protected:
	void CorePrint(Lcd& lcd) noexcept override;

private:
	enum class AdjustMode : uint8_t { displaying, adjusting, liveAdjusting };

	bool Adjust_SelectHelper() noexcept;
	bool Adjust_AlterHelper(int clicks) noexcept;

	static constexpr PixelNumber DefaultWidth =  25;			// default numeric field width

	ExpressionValue currentValue;								// the last value fetched for the item
	const char *_ecv_array _ecv_null const omText;				// an object model expression to fetch the item value (optional)
	const unsigned int valIndex;								// the item index, if no object model expression was provided
	const char *_ecv_array _ecv_null textValue;					// for temporary use when printing

	const uint8_t decimals : 4,
				  adjustable : 1;
	AdjustMode adjusting;
	uint8_t error : 1,											// for temporary use when printing
			asPercent : 1;										// true if we print this as a percentage
};


#endif

#endif /* SRC_DISPLAY_VALUEMENUITEM_H_ */