Browse Source

⚡️ Enhance and fix FTDI Eve Touch UI file select (#22651)

Marcio T 3 years ago
parent
commit
ab03c9a560
No account linked to committer's email address

+ 52
- 0
Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/arrows.cpp View File

1
+/**************
2
+ * arrows.cpp *
3
+ **************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2021 - SynDaver 3D                          *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <https://www.gnu.org/licenses/>.                             *
20
+ ****************************************************************************/
21
+
22
+#include "ftdi_extended.h"
23
+
24
+#if ENABLED(FTDI_EXTENDED)
25
+
26
+#define COORD(X,Y) cx + s*(swapXY ? Y : (flipX ? -X : X)), cy + s*(swapXY ? (flipX ? -X : X) : Y)
27
+
28
+namespace FTDI {
29
+
30
+  void drawArrow(int x, int y, int w, int h, Direction direction) {
31
+    const bool swapXY = direction == UP || direction == DOWN;
32
+    const bool flipX  = direction == UP || direction == LEFT;
33
+    const int s  = min(w,h);
34
+    const int cx = (x + w/2)*16;
35
+    const int cy = (y + h/2)*16;
36
+
37
+    CommandProcessor cmd;
38
+    cmd.cmd(SAVE_CONTEXT())
39
+       .cmd(LINE_WIDTH(s/2))
40
+       .cmd(BEGIN(LINES))
41
+       .cmd(VERTEX2F(COORD( 5, 0)))
42
+       .cmd(VERTEX2F(COORD( 2,-2)))
43
+       .cmd(VERTEX2F(COORD( 5, 0)))
44
+       .cmd(VERTEX2F(COORD( 2, 2)))
45
+       .cmd(VERTEX2F(COORD( 5, 0)))
46
+       .cmd(VERTEX2F(COORD(-5, 0)))
47
+       .cmd(RESTORE_CONTEXT());
48
+  }
49
+
50
+} // namespace FTDI
51
+
52
+#endif // FTDI_EXTENDED

+ 28
- 0
Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/arrows.h View File

1
+/************
2
+ * arrows.h *
3
+ ************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2021 - SynDaver 3D                          *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <https://www.gnu.org/licenses/>.                             *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+namespace FTDI {
25
+  enum Direction {UP, DOWN, LEFT, RIGHT};
26
+
27
+  void drawArrow(int x, int y, int w, int h, Direction direction);
28
+}

+ 1
- 0
Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h View File

48
   #include "sound_list.h"
48
   #include "sound_list.h"
49
   #include "polygon.h"
49
   #include "polygon.h"
50
   #include "poly_ui.h"
50
   #include "poly_ui.h"
51
+  #include "arrows.h"
51
   #include "text_box.h"
52
   #include "text_box.h"
52
   #include "text_ellipsis.h"
53
   #include "text_ellipsis.h"
53
   #include "adjuster_widget.h"
54
   #include "adjuster_widget.h"

+ 23
- 13
Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/grid_layout.h View File

54
 #define EDGE_L           0
54
 #define EDGE_L           0
55
 #define EDGE_R           0
55
 #define EDGE_R           0
56
 
56
 
57
-// GRID_X and GRID_Y computes the positions of the divisions on
57
+// _GRID_X and _GRID_Y computes the positions of the divisions on
58
 // the layout grid.
58
 // the layout grid.
59
-#define GRID_X(x)        ((x)*(FTDI::display_width-EDGE_R-EDGE_L)/GRID_COLS+EDGE_L)
60
-#define GRID_Y(y)        ((y)*(FTDI::display_height-EDGE_B-EDGE_T)/GRID_ROWS+EDGE_T)
59
+#define _GRID_X(x)       ((x)*(FTDI::display_width-EDGE_R-EDGE_L)/GRID_COLS+EDGE_L)
60
+#define _GRID_Y(y)       ((y)*(FTDI::display_height-EDGE_B-EDGE_T)/GRID_ROWS+EDGE_T)
61
+
62
+// BOX_X, BOX_Y, BOX_W and BOX_X returns the top-left and width
63
+// and height of position on the grid.
64
+
65
+#define BOX_X(x)         (_GRID_X((x)-1))
66
+#define BOX_Y(y)         (_GRID_Y((y)-1))
67
+#define BOX_W(w)         (_GRID_X(w) - _GRID_X(0))
68
+#define BOX_H(h)         (_GRID_Y(h) - _GRID_Y(0))
61
 
69
 
62
 // BTN_X, BTN_Y, BTN_W and BTN_X returns the top-left and width
70
 // BTN_X, BTN_Y, BTN_W and BTN_X returns the top-left and width
63
 // and height of a button, taking into account the button margins.
71
 // and height of a button, taking into account the button margins.
64
 
72
 
65
-#define BTN_X(x)         (GRID_X((x)-1) + MARGIN_L)
66
-#define BTN_Y(y)         (GRID_Y((y)-1) + MARGIN_T)
67
-#define BTN_W(w)         (GRID_X(w) - GRID_X(0) - MARGIN_L - MARGIN_R)
68
-#define BTN_H(h)         (GRID_Y(h) - GRID_Y(0) - MARGIN_T - MARGIN_B)
73
+#define BTN_X(x)         (BOX_X(x) + MARGIN_L)
74
+#define BTN_Y(y)         (BOX_Y(y) + MARGIN_T)
75
+#define BTN_W(w)         (BOX_W(w) - MARGIN_L - MARGIN_R)
76
+#define BTN_H(h)         (BOX_H(h) - MARGIN_T - MARGIN_B)
69
 
77
 
70
-// Abbreviations for common phrases, to allow a button to be
71
-// defined in one line of source.
78
+// Abbreviations for common phrases, to allow a box or button
79
+// to be defined in one line of source.
72
 #define BTN_POS(x,y)     BTN_X(x), BTN_Y(y)
80
 #define BTN_POS(x,y)     BTN_X(x), BTN_Y(y)
73
 #define BTN_SIZE(w,h)    BTN_W(w), BTN_H(h)
81
 #define BTN_SIZE(w,h)    BTN_W(w), BTN_H(h)
82
+#define BOX_POS(x,y)     BOX_X(x), BOX_Y(y)
83
+#define BOX_SIZE(w,h)    BOX_W(w), BOX_H(h)
74
 
84
 
75
 // Draw a reference grid for ease of spacing out widgets.
85
 // Draw a reference grid for ease of spacing out widgets.
76
 #define DRAW_LAYOUT_GRID \
86
 #define DRAW_LAYOUT_GRID \
78
     cmd.cmd(LINE_WIDTH(4)); \
88
     cmd.cmd(LINE_WIDTH(4)); \
79
     for (int i = 1; i <= GRID_COLS; i++) { \
89
     for (int i = 1; i <= GRID_COLS; i++) { \
80
       cmd.cmd(BEGIN(LINES)); \
90
       cmd.cmd(BEGIN(LINES)); \
81
-      cmd.cmd(VERTEX2F(GRID_X(i) *16, 0             *16)); \
82
-      cmd.cmd(VERTEX2F(GRID_X(i) *16, FTDI::display_height *16)); \
91
+      cmd.cmd(VERTEX2F(_GRID_X(i) *16, 0             *16)); \
92
+      cmd.cmd(VERTEX2F(_GRID_X(i) *16, FTDI::display_height *16)); \
83
     } \
93
     } \
84
     for (int i = 1; i < GRID_ROWS; i++) { \
94
     for (int i = 1; i < GRID_ROWS; i++) { \
85
       cmd.cmd(BEGIN(LINES)); \
95
       cmd.cmd(BEGIN(LINES)); \
86
-      cmd.cmd(VERTEX2F(0                       *16, GRID_Y(i) *16)); \
87
-      cmd.cmd(VERTEX2F(FTDI::display_width     *16, GRID_Y(i) *16)); \
96
+      cmd.cmd(VERTEX2F(0                       *16, _GRID_Y(i) *16)); \
97
+      cmd.cmd(VERTEX2F(FTDI::display_width     *16, _GRID_Y(i) *16)); \
88
     } \
98
     } \
89
     cmd.cmd(LINE_WIDTH(16)); \
99
     cmd.cmd(LINE_WIDTH(16)); \
90
   }
100
   }

+ 0
- 6
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.cpp View File

157
   injectCommands_P(PSTR(BED_LEVELING_COMMANDS));
157
   injectCommands_P(PSTR(BED_LEVELING_COMMANDS));
158
 }
158
 }
159
 
159
 
160
-void BedMeshViewScreen::doMeshValidation() {
161
-  mydata.count = 0;
162
-  GOTO_SCREEN(StatusScreen);
163
-  injectCommands_P(PSTR("G28\nM117 Heating...\nG26 R X0 Y0\nG27"));
164
-}
165
-
166
 void BedMeshViewScreen::show() {
160
 void BedMeshViewScreen::show() {
167
   injectCommands_P(PSTR("G29 L1"));
161
   injectCommands_P(PSTR("G29 L1"));
168
   GOTO_SCREEN(BedMeshViewScreen);
162
   GOTO_SCREEN(BedMeshViewScreen);

+ 0
- 1
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_view_screen.h View File

43
     static bool onTouchEnd(uint8_t tag);
43
     static bool onTouchEnd(uint8_t tag);
44
 
44
 
45
     static void doProbe();
45
     static void doProbe();
46
-    static void doMeshValidation();
47
     static void show();
46
     static void show();
48
 };
47
 };

+ 99
- 82
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp View File

26
 
26
 
27
 #ifdef FTDI_FILES_SCREEN
27
 #ifdef FTDI_FILES_SCREEN
28
 
28
 
29
+#if ENABLED(TOUCH_UI_PORTRAIT)
30
+  #define GRID_COLS  6
31
+  #define GRID_ROWS  15
32
+  #define FILES_PER_PAGE 11
33
+  #define PREV_DIR LEFT
34
+  #define NEXT_DIR RIGHT
35
+
36
+  #define PREV_POS BTN_POS(1,1),  BTN_SIZE(1,2)
37
+  #define HEAD_POS BTN_POS(2,1),  BTN_SIZE(4,2)
38
+  #define NEXT_POS BTN_POS(6,1),  BTN_SIZE(1,2)
39
+  #define LIST_POS BTN_POS(1,3),  BTN_SIZE(6,FILES_PER_PAGE)
40
+  #define BTN1_POS BTN_POS(1,14), BTN_SIZE(3,2)
41
+  #define BTN2_POS BTN_POS(4,14), BTN_SIZE(3,2)
42
+#else
43
+  #define GRID_COLS  12
44
+  #define GRID_ROWS  8
45
+  #define FILES_PER_PAGE 6
46
+  #define PREV_DIR UP
47
+  #define NEXT_DIR DOWN
48
+
49
+  #define PREV_POS BTN_POS(12,2), BTN_SIZE(1,3)
50
+  #define HEAD_POS BTN_POS( 1,1), BTN_SIZE(12,1)
51
+  #define NEXT_POS BTN_POS(12,5), BTN_SIZE(1,4)
52
+  #define LIST_POS BTN_POS( 1,2), BTN_SIZE(11,FILES_PER_PAGE)
53
+  #define BTN1_POS BTN_POS( 1,8), BTN_SIZE(6,1)
54
+  #define BTN2_POS BTN_POS( 7,8), BTN_SIZE(5,1)
55
+#endif
56
+
29
 using namespace FTDI;
57
 using namespace FTDI;
30
 using namespace ExtUI;
58
 using namespace ExtUI;
31
 using namespace Theme;
59
 using namespace Theme;
49
 }
77
 }
50
 
78
 
51
 void FilesScreen::drawSelectedFile() {
79
 void FilesScreen::drawSelectedFile() {
80
+  if(mydata.selected_tag == 0xFF) return;
52
   FileList files;
81
   FileList files;
53
   files.seek(getSelectedFileIndex(), true);
82
   files.seek(getSelectedFileIndex(), true);
54
   mydata.flags.is_dir = files.isDir();
83
   mydata.flags.is_dir = files.isDir();
65
 }
94
 }
66
 
95
 
67
 uint16_t FilesScreen::getFileForTag(uint8_t tag) {
96
 uint16_t FilesScreen::getFileForTag(uint8_t tag) {
68
-  return mydata.cur_page * files_per_page + tag - 2;
97
+  return mydata.cur_page * FILES_PER_PAGE + tag - 2;
69
 }
98
 }
70
 
99
 
71
-#if ENABLED(TOUCH_UI_PORTRAIT)
72
-  #define GRID_COLS  6
73
-  #define GRID_ROWS (files_per_page + header_h + footer_h)
74
-#else
75
-  #define GRID_COLS  6
76
-  #define GRID_ROWS (files_per_page + header_h + footer_h)
77
-#endif
100
+void FilesScreen::drawFileButton(int x, int y, int w, int h, const char *filename, uint8_t tag, bool is_dir, bool is_highlighted) {
101
+  #define SUB_COLS 6
102
+  #define SUB_ROWS FILES_PER_PAGE
103
+
104
+  const int bx = SUB_X(1);
105
+  const int by = SUB_Y(getLineForTag(tag)+1);
106
+  const int bw = SUB_W(6);
107
+  const int bh = SUB_H(1);
78
 
108
 
79
-void FilesScreen::drawFileButton(const char *filename, uint8_t tag, bool is_dir, bool is_highlighted) {
80
-  const uint8_t line = getLineForTag(tag)+1;
81
   CommandProcessor cmd;
109
   CommandProcessor cmd;
82
   cmd.tag(tag);
110
   cmd.tag(tag);
83
   cmd.cmd(COLOR_RGB(is_highlighted ? fg_action : bg_color));
111
   cmd.cmd(COLOR_RGB(is_highlighted ? fg_action : bg_color));
84
-  cmd.font(font_medium)
85
-     .rectangle( 0, BTN_Y(header_h+line), display_width, BTN_H(1));
112
+  cmd.font(font_medium).rectangle(bx, by, bw, bh);
86
   cmd.cmd(COLOR_RGB(is_highlighted ? normal_btn.rgb : bg_text_enabled));
113
   cmd.cmd(COLOR_RGB(is_highlighted ? normal_btn.rgb : bg_text_enabled));
87
-  constexpr uint16_t dim[2] = {BTN_SIZE(6,1)};
88
-  #define POS_AND_SHORTEN(SHORTEN) BTN_POS(1,header_h+line), dim[0] - (SHORTEN), dim[1]
89
-  #define POS_AND_SIZE             POS_AND_SHORTEN(0)
90
   #if ENABLED(SCROLL_LONG_FILENAMES)
114
   #if ENABLED(SCROLL_LONG_FILENAMES)
91
     if (is_highlighted) {
115
     if (is_highlighted) {
92
       cmd.cmd(SAVE_CONTEXT());
116
       cmd.cmd(SAVE_CONTEXT());
117
+      cmd.cmd(SCISSOR_XY(x,y));
118
+      cmd.cmd(SCISSOR_SIZE(w,h));
93
       cmd.cmd(MACRO(0));
119
       cmd.cmd(MACRO(0));
94
-      cmd.text(POS_AND_SIZE, filename, OPT_CENTERY | OPT_NOFIT);
120
+      cmd.text(bx, by, bw, bh, filename, OPT_CENTERY | OPT_NOFIT);
95
     } else
121
     } else
96
   #endif
122
   #endif
97
-  draw_text_with_ellipsis(cmd, POS_AND_SHORTEN(is_dir ? 20 : 0), filename, OPT_CENTERY, font_medium);
98
-  if (is_dir && !is_highlighted) {
99
-    cmd.text(POS_AND_SIZE, F("> "),  OPT_CENTERY | OPT_RIGHTX);
100
-  }
123
+  draw_text_with_ellipsis(cmd, bx,by, bw - (is_dir ? 20 : 0), bh, filename, OPT_CENTERY, font_medium);
124
+  if (is_dir && !is_highlighted) cmd.text(bx, by, bw, bh, F("> "),  OPT_CENTERY | OPT_RIGHTX);
101
   #if ENABLED(SCROLL_LONG_FILENAMES)
125
   #if ENABLED(SCROLL_LONG_FILENAMES)
102
-    if (is_highlighted) {
103
-      cmd.cmd(RESTORE_CONTEXT());
104
-    }
126
+    if (is_highlighted) cmd.cmd(RESTORE_CONTEXT());
105
   #endif
127
   #endif
106
 }
128
 }
107
 
129
 
108
 void FilesScreen::drawFileList() {
130
 void FilesScreen::drawFileList() {
109
   FileList files;
131
   FileList files;
110
-  mydata.num_page = max(1,ceil(float(files.count()) / files_per_page));
132
+  mydata.num_page = max(1,ceil(float(files.count()) / FILES_PER_PAGE));
111
   mydata.cur_page = min(mydata.cur_page, mydata.num_page-1);
133
   mydata.cur_page = min(mydata.cur_page, mydata.num_page-1);
112
   mydata.flags.is_root  = files.isAtRootDir();
134
   mydata.flags.is_root  = files.isAtRootDir();
113
 
135
 
114
-  #undef MARGIN_T
115
-  #undef MARGIN_B
116
-  #define MARGIN_T 0
117
-  #define MARGIN_B 0
118
-  uint16_t fileIndex = mydata.cur_page * files_per_page;
119
-  for (uint8_t i = 0; i < files_per_page; i++, fileIndex++) {
120
-    if (files.seek(fileIndex)) {
136
+  uint16_t fileIndex = mydata.cur_page * FILES_PER_PAGE;
137
+  for (uint8_t i = 0; i < FILES_PER_PAGE; i++, fileIndex++) {
138
+    if (files.seek(fileIndex))
121
       drawFileButton(files.filename(), getTagForLine(i), files.isDir(), false);
139
       drawFileButton(files.filename(), getTagForLine(i), files.isDir(), false);
122
-    }
123
-    else {
140
+    else
124
       break;
141
       break;
125
-    }
126
   }
142
   }
127
 }
143
 }
128
 
144
 
129
 void FilesScreen::drawHeader() {
145
 void FilesScreen::drawHeader() {
130
-  const bool prev_enabled = mydata.cur_page > 0;
131
-  const bool next_enabled = mydata.cur_page < (mydata.num_page - 1);
132
-
133
-  #undef MARGIN_T
134
-  #undef MARGIN_B
135
-  #define MARGIN_T 0
136
-  #define MARGIN_B 2
137
-
138
   char str[16];
146
   char str[16];
139
-  sprintf_P(str, PSTR("Page %d of %d"),
140
-    mydata.cur_page + 1, mydata.num_page);
147
+  sprintf_P(str, PSTR("Page %d of %d"), mydata.cur_page + 1, mydata.num_page);
141
 
148
 
142
   CommandProcessor cmd;
149
   CommandProcessor cmd;
143
   cmd.colors(normal_btn)
150
   cmd.colors(normal_btn)
144
      .font(font_small)
151
      .font(font_small)
145
-     .tag(0).button(BTN_POS(2,1), BTN_SIZE(4,header_h), str, OPT_CENTER | OPT_FLAT)
146
-     .font(font_medium)
147
-     .colors(action_btn)
148
-     .tag(241).enabled(prev_enabled).button(BTN_POS(1,1), BTN_SIZE(1,header_h), F("<"))
149
-     .tag(242).enabled(next_enabled).button(BTN_POS(6,1), BTN_SIZE(1,header_h), F(">"));
152
+     .tag(0).button(HEAD_POS, str, OPT_CENTER | OPT_FLAT);
153
+}
154
+
155
+void FilesScreen::drawArrows() {
156
+  const bool prev_enabled = mydata.cur_page > 0;
157
+  const bool next_enabled = mydata.cur_page < (mydata.num_page - 1);
158
+
159
+  CommandProcessor cmd;
160
+  cmd.colors(normal_btn);
161
+  cmd.tag(242).enabled(prev_enabled).button(PREV_POS, F("")); if (prev_enabled) drawArrow(PREV_POS, PREV_DIR);
162
+  cmd.tag(243).enabled(next_enabled).button(NEXT_POS, F("")); if (next_enabled) drawArrow(NEXT_POS, NEXT_DIR);
150
 }
163
 }
151
 
164
 
152
 void FilesScreen::drawFooter() {
165
 void FilesScreen::drawFooter() {
153
-  #undef MARGIN_T
154
-  #undef MARGIN_B
155
-  #if ENABLED(TOUCH_UI_PORTRAIT)
156
-    #define MARGIN_T 15
157
-    #define MARGIN_B 5
158
-  #else
159
-    #define MARGIN_T 5
160
-    #define MARGIN_B 5
161
-  #endif
162
-  const bool    has_selection = mydata.selected_tag != 0xFF;
163
-  const uint8_t back_tag      = mydata.flags.is_root ? 240 : 245;
164
-  const uint8_t y             = GRID_ROWS - footer_h + 1;
165
-  const uint8_t h             = footer_h;
166
+  const bool has_selection = mydata.selected_tag != 0xFF;
166
 
167
 
167
   CommandProcessor cmd;
168
   CommandProcessor cmd;
168
   cmd.colors(normal_btn)
169
   cmd.colors(normal_btn)
169
      .font(font_medium)
170
      .font(font_medium)
170
-     .colors(has_selection ? normal_btn : action_btn)
171
-     .tag(back_tag).button(BTN_POS(4,y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_DONE))
172
-     .enabled(has_selection)
171
+     .colors(has_selection ? normal_btn : action_btn);
172
+
173
+  if (mydata.flags.is_root)
174
+    cmd.tag(240).button(BTN2_POS, GET_TEXT_F(MSG_BUTTON_DONE));
175
+  else
176
+    cmd.tag(245).button(BTN2_POS, F("Up Dir"));
177
+
178
+  cmd.enabled(has_selection)
173
      .colors(has_selection ? action_btn : normal_btn);
179
      .colors(has_selection ? action_btn : normal_btn);
174
 
180
 
175
   if (mydata.flags.is_dir)
181
   if (mydata.flags.is_dir)
176
-    cmd.tag(244).button(BTN_POS(1, y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_OPEN));
182
+    cmd.tag(244).button(BTN1_POS, GET_TEXT_F(MSG_BUTTON_OPEN));
177
   else
183
   else
178
-    cmd.tag(243).button(BTN_POS(1, y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_PRINT));
184
+    cmd.tag(241).button(BTN1_POS, GET_TEXT_F(MSG_BUTTON_PRINT));
185
+}
186
+
187
+void FilesScreen::drawFileButton(const char *filename, uint8_t tag, bool is_dir, bool is_highlighted) {
188
+  #undef  MARGIN_L
189
+  #undef  MARGIN_R
190
+  #define MARGIN_L 0
191
+  #define MARGIN_R 0
192
+  drawFileButton(LIST_POS, filename, tag, is_dir, is_highlighted);
179
 }
193
 }
180
 
194
 
181
 void FilesScreen::onRedraw(draw_mode_t what) {
195
 void FilesScreen::onRedraw(draw_mode_t what) {
182
   if (what & FOREGROUND) {
196
   if (what & FOREGROUND) {
183
     drawHeader();
197
     drawHeader();
198
+    drawArrows();
184
     drawSelectedFile();
199
     drawSelectedFile();
185
     drawFooter();
200
     drawFooter();
186
   }
201
   }
200
 
215
 
201
 bool FilesScreen::onTouchEnd(uint8_t tag) {
216
 bool FilesScreen::onTouchEnd(uint8_t tag) {
202
   switch (tag) {
217
   switch (tag) {
203
-    case 240: GOTO_PREVIOUS();                  return true;
204
-    case 241:
218
+    case 240: // Done button
219
+      GOTO_PREVIOUS();
220
+      return true;
221
+    case 241: // Print highlighted file
222
+      ConfirmStartPrintDialogBox::show(getSelectedFileIndex());
223
+      return true;
224
+    case 242: // Previous page
205
       if (mydata.cur_page > 0) {
225
       if (mydata.cur_page > 0) {
206
         gotoPage(mydata.cur_page-1);
226
         gotoPage(mydata.cur_page-1);
207
       }
227
       }
208
       break;
228
       break;
209
-    case 242:
229
+    case 243: // Next page
210
       if (mydata.cur_page < (mydata.num_page-1)) {
230
       if (mydata.cur_page < (mydata.num_page-1)) {
211
         gotoPage(mydata.cur_page+1);
231
         gotoPage(mydata.cur_page+1);
212
       }
232
       }
213
       break;
233
       break;
214
-    case 243:
215
-      ConfirmStartPrintDialogBox::show(getSelectedFileIndex());
216
-      return true;
217
-    case 244:
234
+    case 244: // Select directory
218
       {
235
       {
219
         FileList files;
236
         FileList files;
220
         files.changeDir(getSelectedShortFilename());
237
         files.changeDir(getSelectedShortFilename());
221
         gotoPage(0);
238
         gotoPage(0);
222
       }
239
       }
223
       break;
240
       break;
224
-    case 245:
241
+    case 245: // Up directory
225
       {
242
       {
226
         FileList files;
243
         FileList files;
227
         files.upDir();
244
         files.upDir();
228
         gotoPage(0);
245
         gotoPage(0);
229
       }
246
       }
230
       break;
247
       break;
231
-    default:
248
+    default: // File selected
232
       if (tag < 240) {
249
       if (tag < 240) {
233
         mydata.selected_tag = tag;
250
         mydata.selected_tag = tag;
234
         #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810)
251
         #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810)
252
+          mydata.scroll_pos = 0;
253
+          mydata.scroll_max = 0;
235
           if (FTDI::ftdi_chip >= 810) {
254
           if (FTDI::ftdi_chip >= 810) {
236
             const char *longFilename = getSelectedLongFilename();
255
             const char *longFilename = getSelectedLongFilename();
237
             if (longFilename[0]) {
256
             if (longFilename[0]) {
238
               CommandProcessor cmd;
257
               CommandProcessor cmd;
239
-              uint16_t text_width = cmd.font(font_medium).text_width(longFilename);
240
-              mydata.scroll_pos = 0;
241
-              if (text_width > display_width)
242
-                mydata.scroll_max = text_width - display_width + MARGIN_L + MARGIN_R;
243
-              else
244
-                mydata.scroll_max = 0;
258
+              constexpr int dim[4] = {LIST_POS};
259
+              const uint16_t text_width = cmd.font(font_medium).text_width(longFilename);
260
+              if (text_width > dim[2])
261
+                mydata.scroll_max = text_width - dim[2] + MARGIN_L + MARGIN_R + 10;
245
             }
262
             }
246
           }
263
           }
247
         #endif
264
         #endif

+ 2
- 10
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.h View File

41
 
41
 
42
 class FilesScreen : public BaseScreen, public CachedScreen<FILES_SCREEN_CACHE, FILE_SCREEN_DL_SIZE> {
42
 class FilesScreen : public BaseScreen, public CachedScreen<FILES_SCREEN_CACHE, FILE_SCREEN_DL_SIZE> {
43
   private:
43
   private:
44
-    #if ENABLED(TOUCH_UI_PORTRAIT)
45
-      static constexpr uint8_t header_h       = 2;
46
-      static constexpr uint8_t footer_h       = 2;
47
-      static constexpr uint8_t files_per_page = 11;
48
-    #else
49
-      static constexpr uint8_t header_h       = 1;
50
-      static constexpr uint8_t footer_h       = 1;
51
-      static constexpr uint8_t files_per_page = 6;
52
-    #endif
53
-
54
     static uint8_t  getTagForLine(uint8_t line) {return line + 2;}
44
     static uint8_t  getTagForLine(uint8_t line) {return line + 2;}
55
     static uint8_t  getLineForTag(uint8_t tag)  {return  tag - 2;}
45
     static uint8_t  getLineForTag(uint8_t tag)  {return  tag - 2;}
56
     static uint16_t getFileForTag(uint8_t tag);
46
     static uint16_t getFileForTag(uint8_t tag);
60
     inline static const char *getSelectedLongFilename()  {return getSelectedFilename(true);}
50
     inline static const char *getSelectedLongFilename()  {return getSelectedFilename(true);}
61
     static const char *getSelectedFilename(bool longName);
51
     static const char *getSelectedFilename(bool longName);
62
 
52
 
53
+    static void drawFileButton(int x, int y, int w, int h, const char *filename, uint8_t tag, bool is_dir, bool is_highlighted);
63
     static void drawFileButton(const char *filename, uint8_t tag, bool is_dir, bool is_highlighted);
54
     static void drawFileButton(const char *filename, uint8_t tag, bool is_dir, bool is_highlighted);
64
     static void drawFileList();
55
     static void drawFileList();
65
     static void drawHeader();
56
     static void drawHeader();
57
+    static void drawArrows();
66
     static void drawFooter();
58
     static void drawFooter();
67
     static void drawSelectedFile();
59
     static void drawSelectedFile();
68
 
60
 

+ 4
- 1
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp View File

123
       case 5: BedMeshEditScreen::show(); break;
123
       case 5: BedMeshEditScreen::show(); break;
124
     #endif
124
     #endif
125
     #if ENABLED(G26_MESH_VALIDATION)
125
     #if ENABLED(G26_MESH_VALIDATION)
126
-      case 6: BedMeshViewScreen::doMeshValidation(); break;
126
+      case 6:
127
+        GOTO_SCREEN(StatusScreen);
128
+        injectCommands_P(PSTR("G28\nM117 Heating...\nG26 R X0 Y0\nG27"));
129
+        break;
127
     #endif
130
     #endif
128
     #if ENABLED(BLTOUCH)
131
     #if ENABLED(BLTOUCH)
129
       case 7: injectCommands_P(PSTR("M280 P0 S60")); break;
132
       case 7: injectCommands_P(PSTR("M280 P0 S60")); break;

Loading…
Cancel
Save