Latest libopenui updates
This commit is contained in:
@@ -20,19 +20,22 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
coord_t drawStringWithIndex(BitmapBuffer * dc, coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix, const char * suffix)
|
||||
{
|
||||
char s[64];
|
||||
char * tmp = (prefix ? strAppend(s, prefix) : s);
|
||||
tmp = strAppend(tmp, str);
|
||||
tmp = strAppendUnsigned(tmp, abs(idx));
|
||||
if (suffix)
|
||||
strAppend(tmp, suffix);
|
||||
return dc->drawText(x, y, s, flags);
|
||||
}
|
||||
|
||||
void drawStatusText(BitmapBuffer * dc, const char * text)
|
||||
{
|
||||
dc->drawText(MENUS_MARGIN_LEFT, MENU_FOOTER_TOP, text, TEXT_STATUSBAR_COLOR);
|
||||
}
|
||||
|
||||
void drawColumnHeader(BitmapBuffer * dc, const char * const * headers, const char * const * descriptions, uint8_t index)
|
||||
{
|
||||
dc->drawText(LCD_W-MENUS_MARGIN_LEFT, MENU_TITLE_TOP + 2, headers[index], RIGHT | SMLSIZE | MENU_COLOR);
|
||||
if (descriptions) {
|
||||
drawStatusText(dc, descriptions[index]);
|
||||
}
|
||||
}
|
||||
|
||||
void drawVerticalScrollbar(BitmapBuffer * dc, coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible)
|
||||
{
|
||||
if (visible < count) {
|
||||
@@ -277,7 +280,7 @@ void drawModelName(BitmapBuffer * dc, coord_t x, coord_t y, char * name, uint8_t
|
||||
uint8_t len = sizeof(g_model.header.name);
|
||||
while (len>0 && !name[len-1]) --len;
|
||||
if (len==0) {
|
||||
drawStringWithIndex(x, y, STR_MODEL, id+1, att|LEADING0);
|
||||
drawStringWithIndex(dc, x, y, STR_MODEL, id+1, att|LEADING0);
|
||||
}
|
||||
else {
|
||||
dc->drawSizedText(x, y, name, sizeof(g_model.header.name), att);
|
||||
|
||||
@@ -40,25 +40,20 @@
|
||||
#define OPTION_SLIDER_NUMBER_BUTTON 0x100
|
||||
#define OPTION_SLIDER_SQUARE_BUTTON 0x200
|
||||
|
||||
//void drawStringWithIndex(coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix, const char * suffix);
|
||||
//void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att);
|
||||
//int editChoice(coord_t x, coord_t y, const char * values, int value, int min, int max, LcdFlags attr, event_t event, IsValueAvailable isValueAvailable=nullptr);
|
||||
//uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, LcdFlags attr, event_t event);
|
||||
//swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event);
|
||||
coord_t drawStringWithIndex(BitmapBuffer * dc, coord_t x, coord_t y, const char * str, int idx, LcdFlags flags = 0, const char * prefix = nullptr, const char * suffix = nullptr);
|
||||
void drawFatalErrorScreen(const char * message);
|
||||
void runFatalErrorScreen(const char * message);
|
||||
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att);
|
||||
//void lcdDrawMMM(coord_t x, coord_t y, LcdFlags flags);
|
||||
void drawSource(BitmapBuffer * dc, coord_t x, coord_t y, mixsrc_t idx, LcdFlags flags=0);
|
||||
void drawSwitch(BitmapBuffer * dc, coord_t x, coord_t y, int32_t idx, LcdFlags flags=0);
|
||||
void drawTrimMode(BitmapBuffer * dc, coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags flags = 0);
|
||||
void drawCurveRef(BitmapBuffer * dc, coord_t x, coord_t y, const CurveRef & curve, LcdFlags flags = 0);
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
void drawFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att);
|
||||
#endif
|
||||
|
||||
void drawStatusText(BitmapBuffer * dc, const char * text);
|
||||
void drawColumnHeader(BitmapBuffer * dc, const char * const * headers, const char * const * descriptions, uint8_t index);
|
||||
void drawVerticalScrollbar(BitmapBuffer * dc, coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible);
|
||||
void drawProgressScreen(BitmapBuffer * dc, const char * title, const char * message, int num, int den);
|
||||
void drawTrimSquare(BitmapBuffer * dc, coord_t x, coord_t y);
|
||||
|
||||
@@ -131,16 +131,17 @@ void GVarRenderer::paint(BitmapBuffer * dc)
|
||||
lastFlightMode = getFlightMode();
|
||||
FlightModeData * fmData = &g_model.flightModeData[lastFlightMode];
|
||||
lastGVar = fmData->gvars[index];
|
||||
drawStringWithIndex(0, FIELD_PADDING_TOP, TR_GV, index + 1, MENU_COLOR);
|
||||
coord_t x = drawStringWithIndex(dc, 0, FIELD_PADDING_TOP, STR_GV, index + 1, MENU_COLOR, nullptr, "=");
|
||||
if (lastGVar > GVAR_MAX) {
|
||||
uint8_t fm = lastGVar - GVAR_MAX - 1;
|
||||
if (fm >= lastFlightMode) fm++;
|
||||
if (fm >= lastFlightMode)
|
||||
fm++;
|
||||
char label[16];
|
||||
getFlightModeString(label, fm + 1);
|
||||
dc->drawSizedText(GVAR_NAME_SIZE, FIELD_PADDING_TOP, label, strlen(label), MENU_COLOR);
|
||||
dc->drawSizedText(x, FIELD_PADDING_TOP, label, strlen(label), MENU_COLOR);
|
||||
}
|
||||
else {
|
||||
drawGVarValue(dc, GVAR_NAME_SIZE, FIELD_PADDING_TOP, index, lastGVar, MENU_COLOR);
|
||||
drawGVarValue(dc, x, FIELD_PADDING_TOP, index, lastGVar, MENU_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,8 +207,10 @@ void GVarEditWindow::setProperties(int onlyForFlightMode)
|
||||
}
|
||||
FlightModeData * fmData;
|
||||
for (int fm = 0; fm < MAX_FLIGHT_MODES; fm++) {
|
||||
if (onlyForFlightMode >= 0 && fm != onlyForFlightMode) continue;
|
||||
if (!values[fm]) continue;
|
||||
if (onlyForFlightMode >= 0 && fm != onlyForFlightMode)
|
||||
continue;
|
||||
if (!values[fm])
|
||||
continue;
|
||||
fmData = &g_model.flightModeData[fm];
|
||||
|
||||
// custom value
|
||||
@@ -221,10 +224,11 @@ void GVarEditWindow::setProperties(int onlyForFlightMode)
|
||||
values[fm]->setMax(GVAR_MAX + MAX_FLIGHT_MODES - 1);
|
||||
values[fm]->setDisplayHandler([=](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
||||
uint8_t targetFlightMode = value - GVAR_MAX - 1;
|
||||
if (targetFlightMode >= fm) targetFlightMode++;
|
||||
if (targetFlightMode >= fm)
|
||||
targetFlightMode++;
|
||||
char label[16];
|
||||
getFlightModeString(label, targetFlightMode + 1);
|
||||
dc->drawSizedText(2, 2, label, strlen(label), flags);
|
||||
dc->drawSizedText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, label, strlen(label), flags);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -304,13 +308,14 @@ void GVarEditWindow::buildBody(FormWindow * window)
|
||||
}
|
||||
new StaticText(window, grid.getLabelSlot(), flightModeName);
|
||||
if (flightMode > 0) {
|
||||
CheckBox * cb = new CheckBox(window, grid.getFieldSlot(2, 0),
|
||||
[=] { return fmData->gvars[index] <= GVAR_MAX; }, [=](uint8_t checked) {
|
||||
if (!values[flightMode]) return;
|
||||
auto cb = new CheckBox(window, grid.getFieldSlot(2, 0),
|
||||
[=] { return fmData->gvars[index] <= GVAR_MAX; }, [=](uint8_t checked) {
|
||||
if (!values[flightMode])
|
||||
return;
|
||||
fmData->gvars[index] = checked ? 0 : GVAR_MAX + 1;
|
||||
setProperties(flightMode);
|
||||
});
|
||||
//TODO cb->setLabel(STR_OWN);
|
||||
cb->setLabel(STR_OWN);
|
||||
}
|
||||
values[flightMode] = new NumberEdit(window, grid.getFieldSlot(2, 1), GVAR_MIN + gvar->min, GVAR_MAX + MAX_FLIGHT_MODES - 1,
|
||||
GET_SET_DEFAULT(fmData->gvars[index]));
|
||||
|
||||
@@ -48,7 +48,7 @@ class ModelGVarsPage : public PageTab {
|
||||
|
||||
class GVarRenderer : public Window {
|
||||
public:
|
||||
GVarRenderer(Window* window, rect_t rect, uint8_t gvarIndex) :
|
||||
GVarRenderer(Window * window, rect_t rect, uint8_t gvarIndex) :
|
||||
Window(window, rect),
|
||||
index(gvarIndex)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ class OptionsText : public StaticText {
|
||||
}
|
||||
};
|
||||
|
||||
virtual void paint(BitmapBuffer * dc) override
|
||||
void paint(BitmapBuffer * dc) override
|
||||
{
|
||||
coord_t y = 0;
|
||||
lcdNextPos = 0;
|
||||
@@ -47,7 +47,7 @@ class OptionsText : public StaticText {
|
||||
const char * option = options[i];
|
||||
coord_t optionWidth = getTextWidth(option);
|
||||
|
||||
if((lcdNextPos + 5 + optionWidth) > width()) {
|
||||
if (lcdNextPos + 5 + optionWidth > width()) {
|
||||
dc->drawText(lcdNextPos, y, ",");
|
||||
lcdNextPos = 0;
|
||||
y += FH;
|
||||
|
||||
@@ -338,7 +338,7 @@ class SpecialFunctionButton : public Button {
|
||||
break;
|
||||
|
||||
case FUNC_SET_TIMER:
|
||||
drawStringWithIndex(col1, line2, STR_TIMER, CFN_TIMER_INDEX(cfn) + 1, 0);
|
||||
drawStringWithIndex(dc, col1, line2, STR_TIMER, CFN_TIMER_INDEX(cfn) + 1, 0);
|
||||
break;
|
||||
|
||||
case FUNC_SET_FAILSAFE:
|
||||
|
||||
@@ -46,8 +46,8 @@ class FlyskyTheme: public ThemeBase
|
||||
lcdColorTable[FOCUS_BGCOLOR_INDEX] = RED;
|
||||
lcdColorTable[TEXT_STATUSBAR_COLOR_INDEX] = WHITE;
|
||||
lcdColorTable[LINE_COLOR_INDEX] = GREY;
|
||||
lcdColorTable[CHECKBOX_COLOR_INDEX] = RED;
|
||||
lcdColorTable[MENU_BGCOLOR_INDEX] = DARKGREY;
|
||||
lcdColorTable[CHECKBOX_COLOR_INDEX] = RGB(0, 71, 157);
|
||||
lcdColorTable[MENU_BGCOLOR_INDEX] = DARKBLUE;
|
||||
lcdColorTable[MENU_COLOR_INDEX] = WHITE;
|
||||
lcdColorTable[MENU_TITLE_DISABLE_COLOR_INDEX] = RGB(GET_RED(RED)>>1, GET_GREEN(RED)>>1, GET_BLUE(RED)>>1);
|
||||
lcdColorTable[HEADER_COLOR_INDEX] = DARKGREY;
|
||||
@@ -63,7 +63,6 @@ class FlyskyTheme: public ThemeBase
|
||||
lcdColorTable[MAINVIEW_PANES_COLOR_INDEX] = WHITE;
|
||||
lcdColorTable[MAINVIEW_GRAPHICS_COLOR_INDEX] = RED;
|
||||
|
||||
|
||||
// The menu header (top bar)
|
||||
lcdColorTable[HEADER_BGCOLOR_INDEX] = DARKBLUE;
|
||||
lcdColorTable[HEADER_ICON_BGCOLOR_INDEX] = RGB(0, 71, 157);
|
||||
|
||||
@@ -123,16 +123,6 @@ void drawSourceValue(coord_t x, coord_t y, source_t channel, LcdFlags flags=0);
|
||||
|
||||
void drawCurve(coord_t offset=0);
|
||||
|
||||
#if defined(COLORLCD)
|
||||
void drawStringWithIndex(coord_t x, coord_t y, const char * str, int idx, LcdFlags flags=0, const char * prefix=nullptr, const char * suffix=nullptr);
|
||||
void drawCurveRef(BitmapBuffer * dc, coord_t x, coord_t y, const CurveRef & curve, LcdFlags flags=0);
|
||||
int editChoice(coord_t x, coord_t y, const char * values, int value, int min, int max, LcdFlags flags, event_t event);
|
||||
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, LcdFlags flags, event_t event);
|
||||
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags flags, event_t event);
|
||||
void drawFatalErrorScreen(const char * message);
|
||||
void runFatalErrorScreen(const char * message);
|
||||
#endif
|
||||
|
||||
// model_setup Defines that are used in all uis in the same way
|
||||
#define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON((uint8_t)1)
|
||||
#define EXTERNAL_MODULE_CHANNELS_ROWS IF_EXTERNAL_MODULE_ON((isModuleDSM2(EXTERNAL_MODULE) || isModuleCrossfire(EXTERNAL_MODULE) || isModuleSBUS(EXTERNAL_MODULE) || (isModuleMultimodule(EXTERNAL_MODULE) && g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(true) != MODULE_SUBTYPE_MULTI_DSM2)) ? (uint8_t)0 : (uint8_t)1)
|
||||
|
||||
Reference in New Issue
Block a user