-
Notifications
You must be signed in to change notification settings - Fork 3
/
filescreen.h
149 lines (115 loc) · 3.24 KB
/
filescreen.h
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#ifndef FILESCREEN_H
#define FILESCREEN_H
#include "screen.h"
#include "screentask.h"
#include <lvslot.hpp>
#include <ui_api.h>
class LVSlot;
class LVStyle;
class LVButton;
class LVLabel;
class LVImage;
/**
* @brief 文件浏览界面
*
* BUG:无法保存文件视图状态
*
*/
class FileScreen :public Screen
{
LV_OBJECT
protected:
//char m_printFileName[30]; //!<打印文件名 marlin中最长文件名是24字节
char m_dirName[256]; //!< 目录路径
char m_folderName[25]; //!< 文件夹名称
uint16_t m_filePage = 0;
ExtUI::FileList m_fileList; //!< 文件列表
bool m_keepViewer = false; //!< 保持
LVLabel* m_labPath = nullptr;
LVButton * m_butItem0 = nullptr;
LVImage * m_imgItem0 = nullptr;
LVLabel * m_labItem0 = nullptr;
LVButton * m_butItem1 = nullptr;
LVImage * m_imgItem1 = nullptr;
LVLabel * m_labItem1 = nullptr;
LVButton * m_butItem2 = nullptr;
LVImage * m_imgItem2 = nullptr;
LVLabel * m_labItem2 = nullptr;
LVButton * m_butItem3 = nullptr;
LVImage * m_imgItem3 = nullptr;
LVLabel * m_labItem3 = nullptr;
LVButton * butPre = nullptr;
LVButton * butNext = nullptr;
LVLabel * labPageIdx = nullptr;
LVSlot m_slotMediaInserted ; //!< 存储设备插入
LVSlot m_slotMediaError ; //!< 存储设备错误
LVSlot m_slotMediaRemoved ; //!< 存储设备移除
//LVStyle * m_styleNavigation = nullptr; //!< 导航按钮样式
public:
enum ItemType : unsigned char
{
folder = 0b00001111,
file = 0b11110000,
};
FileScreen();
virtual ~FileScreen();
/**
* @brief 重置文件到根目录
*/
void resetFileList();
void setFileItem0(const char * name,bool isDir);
void setFileItem1(const char * name,bool isDir);
void setFileItem2(const char * name,bool isDir);
void setFileItem3(const char * name,bool isDir);
void setFileItem(const char * name,bool isDir,LVButton * but,LVImage * img , LVLabel * lab);
uint16_t maxFilePage();
/**
* @brief 上一个文件页面
*/
void preFilePage();
/**
* @brief 下一个文件页面
*/
void nextFilePage();
/**
* @brief 打开文件夹
* @param name
*/
void openFolder(const char * name);
/**
* @brief 返回上一级目录
*/
void backFolder();
/**
* @brief 刷新文件视图
*/
void updateFilesView();
/**
* @brief 重初始化文件视图
*/
void reinitFilesView(LVSignal *);
/**
* @brief Item按钮按下
* @param obj
* @return
*/
lv_res_t onButItemClicked (struct _lv_obj_t * obj);
lv_res_t onButBackClicked (struct _lv_obj_t * obj);
void printMesgFunc(uint32_t retId);
/**
* @brief 保持文件视图状态(只生效一次)
* @return
*/
bool keepViewer() const;
void setKeepViewer(bool keepViewer);
// Screen interface
protected:
virtual bool initScreen() override;
virtual void onLangChanged() override;
virtual void onThemeChanged() override;
virtual bool beforeShow() override;
virtual void afterHide() override;
virtual void afterCleanScreen() override;
virtual void beforeCleanScreen() override;
};
#endif // FILESCREEN_H