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
60
61
62
63
|
/*
* FilesMenuItem.h
*
* Created on: 25 Apr 2022
* Author: David
*/
#ifndef SRC_DISPLAY_FILESMENUITEM_H_
#define SRC_DISPLAY_FILESMENUITEM_H_
#include "MenuItem.h"
#if SUPPORT_DIRECT_LCD && HAS_MASS_STORAGE
class FilesMenuItem final : public MenuItem
{
public:
DECLARE_FREELIST_NEW_DELETE(FilesMenuItem)
FilesMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, FontNumber fn, const char *_ecv_array cmd, const char *_ecv_array dir, const char *_ecv_array acFile, unsigned int nf) noexcept;
void Draw(Lcd& lcd, PixelNumber rightMargin, bool highlight) noexcept override;
void Enter(bool bForwardDirection) noexcept override;
int Advance(int nCounts) noexcept override;
bool Select(const StringRef& cmd) noexcept override;
void UpdateWidthAndHeight(Lcd& lcd) noexcept override;
PixelNumber GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const noexcept override;
void EnterDirectory() noexcept;
protected:
void vResetViewState() noexcept;
private:
void ListFiles(Lcd& lcd, PixelNumber rightMargin, bool highlight) noexcept;
uint8_t GetDirectoryNesting() const noexcept;
const unsigned int numDisplayLines;
const char *_ecv_array command;
const char *_ecv_array initialDirectory;
const char *_ecv_array m_acFile; // used when action ("command") includes "menu"
// Working
String<MaxFilenameLength> currentDirectory;
bool bInSubdirectory() const noexcept;
unsigned int uListingEntries() const noexcept;
// Files on the file system, real count i.e. no ".." included
unsigned int m_uHardItemsInDirectory;
// Logical items (c. files) for display, referenced to uListingEntries() count
unsigned int m_uListingFirstVisibleIndex;
unsigned int m_uListingSelectedIndex;
enum CardState : uint8_t { notStarted, mounting, mounted, error } sdCardState;
uint8_t initialDirectoryNesting;
};
#endif
#endif /* SRC_DISPLAY_FILESMENUITEM_H_ */
|