MenuDisplay row count configurable
This commit is contained in:
7
Kconfig.projbuild
Normal file
7
Kconfig.projbuild
Normal file
@ -0,0 +1,7 @@
|
||||
menu "ESP Gui settings"
|
||||
|
||||
config ESPGUI_MENUDISPLAY_ROWS
|
||||
int "Number of rows for MenuDisplays"
|
||||
default 10
|
||||
|
||||
endmenu
|
@ -93,7 +93,7 @@ void MenuDisplay::redraw()
|
||||
const auto drawItemRect = [](const auto &label, const auto color){
|
||||
tft.drawRect(5,
|
||||
label.y()-1,
|
||||
240 - 10,
|
||||
tft.width() - 10,
|
||||
lineHeight+2,
|
||||
color);
|
||||
};
|
||||
@ -121,7 +121,7 @@ void MenuDisplay::redraw()
|
||||
|
||||
if (item.icon() != *iconsIter)
|
||||
{
|
||||
tft.fillRect(5, labelsIter->y()+1, 24, 24, TFT_BLACK);
|
||||
tft.fillRect(6, labelsIter->y()+1, 24, 24, TFT_BLACK);
|
||||
|
||||
auto icon = item.icon();
|
||||
if (icon)
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
// system includes
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
@ -94,26 +96,47 @@ protected:
|
||||
private:
|
||||
Label m_titleLabel{5, 5}; // 230, 25
|
||||
|
||||
static constexpr size_t rowCount = CONFIG_ESPGUI_MENUDISPLAY_ROWS;
|
||||
static constexpr auto iconWidth = 25;
|
||||
static constexpr auto horizontalSpacing = 10;
|
||||
static constexpr auto topMargin = 40;
|
||||
static constexpr auto lineHeight = 25;
|
||||
static constexpr auto verticalSpacing = 3;
|
||||
static constexpr auto verticalSpacing = 4;
|
||||
|
||||
std::array<Label, 10> m_labels {{
|
||||
std::array<Label, rowCount> m_labels {{
|
||||
#if CONFIG_ESPGUI_MENUDISPLAY_ROWS >= 1
|
||||
Label{horizontalSpacing + iconWidth, topMargin+(0*(lineHeight+verticalSpacing))}, // 240-(horizontalSpacing*2)-iconWidth, lineHeight
|
||||
#endif
|
||||
#if CONFIG_ESPGUI_MENUDISPLAY_ROWS >= 2
|
||||
Label{horizontalSpacing + iconWidth, topMargin+(1*(lineHeight+verticalSpacing))}, // 240-(horizontalSpacing*2)-iconWidth, lineHeight
|
||||
#endif
|
||||
#if CONFIG_ESPGUI_MENUDISPLAY_ROWS >= 3
|
||||
Label{horizontalSpacing + iconWidth, topMargin+(2*(lineHeight+verticalSpacing))}, // 240-(horizontalSpacing*2)-iconWidth, lineHeight
|
||||
#endif
|
||||
#if CONFIG_ESPGUI_MENUDISPLAY_ROWS >= 4
|
||||
Label{horizontalSpacing + iconWidth, topMargin+(3*(lineHeight+verticalSpacing))}, // 240-(horizontalSpacing*2)-iconWidth, lineHeight
|
||||
#endif
|
||||
#if CONFIG_ESPGUI_MENUDISPLAY_ROWS >= 5
|
||||
Label{horizontalSpacing + iconWidth, topMargin+(4*(lineHeight+verticalSpacing))}, // 240-(horizontalSpacing*2)-iconWidth, lineHeight
|
||||
#endif
|
||||
#if CONFIG_ESPGUI_MENUDISPLAY_ROWS >= 6
|
||||
Label{horizontalSpacing + iconWidth, topMargin+(5*(lineHeight+verticalSpacing))}, // 240-(horizontalSpacing*2)-iconWidth, lineHeight
|
||||
#endif
|
||||
#if CONFIG_ESPGUI_MENUDISPLAY_ROWS >= 7
|
||||
Label{horizontalSpacing + iconWidth, topMargin+(6*(lineHeight+verticalSpacing))}, // 240-(horizontalSpacing*2)-iconWidth, lineHeight
|
||||
#endif
|
||||
#if CONFIG_ESPGUI_MENUDISPLAY_ROWS >= 8
|
||||
Label{horizontalSpacing + iconWidth, topMargin+(7*(lineHeight+verticalSpacing))}, // 240-(horizontalSpacing*2)-iconWidth, lineHeight
|
||||
#endif
|
||||
#if CONFIG_ESPGUI_MENUDISPLAY_ROWS >= 9
|
||||
Label{horizontalSpacing + iconWidth, topMargin+(8*(lineHeight+verticalSpacing))}, // 240-(horizontalSpacing*2)-iconWidth, lineHeight
|
||||
#endif
|
||||
#if CONFIG_ESPGUI_MENUDISPLAY_ROWS >= 10
|
||||
Label{horizontalSpacing + iconWidth, topMargin+(9*(lineHeight+verticalSpacing))}, // 240-(horizontalSpacing*2)-iconWidth, lineHeight
|
||||
#endif
|
||||
}};
|
||||
|
||||
std::array<const Icon<24, 24> *, 10> m_icons;
|
||||
std::array<const Icon<24, 24> *, rowCount> m_icons;
|
||||
|
||||
int m_selectedIndex;
|
||||
int m_scrollOffset;
|
||||
|
Reference in New Issue
Block a user