Facelift round 2

This commit is contained in:
Raphael Coeffic
2021-06-14 06:34:57 +02:00
parent 57aa76c424
commit 85bc612f4a
11 changed files with 286 additions and 177 deletions
+48 -25
View File
@@ -58,18 +58,30 @@ class MixerChannelBar : public ChannelBar
chanVal = limit<int>(-VIEW_CHANNELS_LIMIT_PCT, chanVal, VIEW_CHANNELS_LIMIT_PCT);
// Draw Background
dc->drawSolidFilledRect(0, 0, width(), height(), BARGRAPH_BGCOLOR);
dc->drawSolidFilledRect(0, 0, width(), height(), FIELD_BGCOLOR);
// Draw mixer bar
if (chanVal > 0) {
dc->drawSolidFilledRect(0 + width() / 2, 0, divRoundClosest(chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2), height(), BARGRAPH2_COLOR);
dc->drawNumber(width() / 2 - 10, 0, displayVal, FONT(XS) | DEFAULT_COLOR | RIGHT, 0, nullptr, "%");
}
else if (chanVal < 0) {
dc->drawSolidFilledRect(
0 + width() / 2, 0,
divRoundClosest(chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2),
height(), FOCUS_BGCOLOR);
dc->drawNumber(width() / 2 - 10, 0, displayVal,
FONT(XS) | DEFAULT_COLOR | RIGHT, 0, nullptr, "%");
} else if (chanVal < 0) {
const unsigned endpoint = width() / 2;
const unsigned size = divRoundClosest(-chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2);
dc->drawSolidFilledRect(endpoint - size, 0, size, height(), BARGRAPH2_COLOR);
dc->drawNumber(10 + width() / 2, 0, displayVal, FONT(XS) | DEFAULT_COLOR, 0, nullptr, "%");
const unsigned size =
divRoundClosest(-chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2);
dc->drawSolidFilledRect(endpoint - size, 0, size, height(),
FOCUS_BGCOLOR);
dc->drawNumber(10 + width() / 2, 0, displayVal,
FONT(XS) | DEFAULT_COLOR, 0, nullptr, "%");
}
// Draw middle bar
@@ -100,36 +112,47 @@ class OutputChannelBar : public ChannelBar
int chanVal = calcRESXto100(channelOutputs[channel]);
int displayVal = chanVal;
chanVal = limit<int>(-VIEW_CHANNELS_LIMIT_PCT, chanVal, VIEW_CHANNELS_LIMIT_PCT);
chanVal = limit<int>(-VIEW_CHANNELS_LIMIT_PCT, chanVal,
VIEW_CHANNELS_LIMIT_PCT);
// Draw Background
dc->drawSolidFilledRect(0, 0, width(), height(), BARGRAPH_BGCOLOR);
dc->drawSolidFilledRect(0, 0, width(), height(), FIELD_BGCOLOR);
// Draw output bar
if (chanVal > 0) {
dc->drawSolidFilledRect(width() / 2, 0, divRoundClosest(chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2), height(), BARGRAPH1_COLOR);
dc->drawNumber(width() / 2 - 10, 0, displayVal, FONT(XS) | DEFAULT_COLOR | RIGHT, 0, nullptr, "%");
}
else if (chanVal < 0) {
dc->drawSolidFilledRect(
width() / 2, 0,
divRoundClosest(chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2),
height(), HIGHLIGHT_COLOR);
dc->drawNumber(width() / 2 - 10, 0, displayVal,
FONT(XS) | DEFAULT_COLOR | RIGHT, 0, nullptr, "%");
} else if (chanVal < 0) {
unsigned endpoint = width() / 2;
unsigned size = divRoundClosest(-chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2);
dc->drawSolidFilledRect(endpoint - size, 0, size, height(), BARGRAPH1_COLOR);
dc->drawNumber(width() / 2 + 10, 0, displayVal, FONT(XS) | DEFAULT_COLOR, 0, nullptr, "%");
unsigned size =
divRoundClosest(-chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2);
dc->drawSolidFilledRect(endpoint - size, 0, size, height(),
HIGHLIGHT_COLOR);
dc->drawNumber(width() / 2 + 10, 0, displayVal,
FONT(XS) | DEFAULT_COLOR, 0, nullptr, "%");
}
// Draw middle bar
dc->drawSolidVerticalLine(width() / 2, 0, height(), DEFAULT_COLOR);
// Draw output limits bars
LimitData * ld = limitAddress(channel);
LimitData* ld = limitAddress(channel);
if (ld && ld->revert) {
drawOutputBarLimits(dc, posOnBar(-100 - ld->max / 10), posOnBar(100 - ld->min / 10));
//lcd->drawBitmap(x - X_OFFSET + 7, y + 25, chanMonInvertedBitmap);
drawOutputBarLimits(dc, posOnBar(-100 - ld->max / 10),
posOnBar(100 - ld->min / 10));
} else if (ld) {
drawOutputBarLimits(dc, posOnBar(-100 + ld->min / 10),
posOnBar(100 + ld->max / 10));
}
else if (ld) {
drawOutputBarLimits(dc, posOnBar(-100 + ld->min / 10), posOnBar(100 + ld->max / 10));
}
}
inline unsigned posOnBar(int value_to100)
@@ -215,4 +238,4 @@ class ComboChannelBar : public ChannelBar
protected:
int value = 0;
};
};
+4 -2
View File
@@ -56,6 +56,8 @@ enum LcdColorIndex
MAINVIEW_PANES_COLOR_INDEX,
MENU_BGCOLOR_INDEX,
MENU_COLOR_INDEX,
MENU_HIGHLIGHT_COLOR_INDEX,
MENU_LINE_COLOR_INDEX,
MENU_TITLE_DISABLE_COLOR_INDEX,
OVERLAY_COLOR_INDEX,
SCROLLBAR_COLOR_INDEX,
@@ -73,8 +75,8 @@ enum LcdColorIndex
};
#define MENU_HIGHLIGHT_COLOR_INDEX HIGHLIGHT_COLOR_INDEX
#define MENU_LINE_COLOR_INDEX LINE_COLOR_INDEX
//#define MENU_HIGHLIGHT_COLOR_INDEX HIGHLIGHT_COLOR_INDEX
//#define MENU_LINE_COLOR_INDEX LINE_COLOR_INDEX
//
+21 -6
View File
@@ -42,10 +42,16 @@ class CurveEditWindow : public Page
void buildHeader(Window * window)
{
new StaticText(window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, STR_MENUCURVE, 0, MENU_COLOR);
new StaticText(window,
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT,
PAGE_LINE_HEIGHT},
STR_MENUCURVE, 0, MENU_COLOR);
char s[16];
strAppendStringWithIndex(s, STR_CV, index + 1);
new StaticText(window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, s, 0, MENU_COLOR);
new StaticText(window,
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT,
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
s, 0, MENU_COLOR);
}
#if LCD_W > LCD_H
@@ -226,8 +232,14 @@ class CurveButton : public Button {
void paint(BitmapBuffer * dc) override
{
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FIELD_BGCOLOR);
// bounding rect
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, hasFocus() ? CHECKBOX_COLOR : DISABLE_COLOR);
if (hasFocus()) {
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR);
} else {
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, FIELD_FRAME_COLOR);
}
// curve characteristics
if (isCurveUsed(index)) {
@@ -297,7 +309,10 @@ void ModelCurvesPage::build(FormWindow * window, int8_t focusIndex)
if (isCurveUsed(index)) {
// Curve label
new StaticText(window, grid.getLabelSlot(), getCurveString(1 + index), BUTTON_BACKGROUND, CENTERED);
auto text =
new StaticText(window, grid.getLabelSlot(), getCurveString(1 + index),
BUTTON_BACKGROUND, CENTERED);
text->setBackgroundColor(FOCUS_COLOR);
// Curve drawing
Button * button = new CurveButton(window, grid.getFieldSlot(), index);
@@ -325,10 +340,10 @@ void ModelCurvesPage::build(FormWindow * window, int8_t focusIndex)
}
grid.spacer(button->height() + 5);
}
else {
} else {
auto button = new TextButton(window, grid.getLabelSlot(),
getCurveString(1 + index));
button->setPressHandler([=]() {
Menu *menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() {
+39 -20
View File
@@ -302,19 +302,23 @@ void CommonInputOrMixButton::checkEvents()
Button::checkEvents();
}
void CommonInputOrMixButton::drawFlightModes(BitmapBuffer *dc, FlightModesType value)
void CommonInputOrMixButton::drawFlightModes(BitmapBuffer *dc,
FlightModesType value,
LcdFlags textColor)
{
dc->drawMask(146, 2 + PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupFlightmodeIcon, DEFAULT_COLOR);
dc->drawMask(146, 2 + PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
mixerSetupFlightmodeIcon, textColor);
coord_t x = 166;
for (int i = 0; i < MAX_FLIGHT_MODES; i++) {
char s[] = " ";
s[0] = '0' + i;
if (value & (1 << i)) {
dc->drawText(x, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP + 2, s, FONT(XS) | TEXT_DISABLE_COLOR);
}
else {
dc->drawSolidFilledRect(x, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP + 2, 8, 3, CHECKBOX_COLOR);
dc->drawText(x, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP + 2, s, FONT(XS));
dc->drawText(x, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP + 2, s,
FONT(XS) | TEXT_DISABLE_COLOR);
} else {
dc->drawSolidFilledRect(x, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP + 2, 8, 3,
FOCUS_BGCOLOR);
dc->drawText(x, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP + 2, s, FONT(XS) | textColor);
}
x += 8;
}
@@ -322,10 +326,11 @@ void CommonInputOrMixButton::drawFlightModes(BitmapBuffer *dc, FlightModesType v
void CommonInputOrMixButton::paint(BitmapBuffer * dc)
{
if (active)
dc->drawSolidFilledRect(2, 2, rect.w - 4, rect.h - 4, HIGHLIGHT_COLOR);
dc->drawSolidFilledRect(0, 0, width(), height(),
hasFocus() ? FOCUS_BGCOLOR : FIELD_BGCOLOR);
paintBody(dc);
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, hasFocus() ? CHECKBOX_COLOR : DISABLE_COLOR);
if (!hasFocus())
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FIELD_FRAME_COLOR);
}
class InputLineButton : public CommonInputOrMixButton {
@@ -348,28 +353,38 @@ class InputLineButton : public CommonInputOrMixButton {
{
const ExpoData & line = g_model.expoData[index];
LcdFlags textColor = DEFAULT_COLOR;
if (hasFocus())
textColor = FOCUS_COLOR;
// first line ...
drawValueOrGVar(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, line.weight, -100, 100);
drawSource(dc, 60, FIELD_PADDING_TOP, line.srcRaw);
drawValueOrGVar(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, line.weight,
-100, 100, textColor);
drawSource(dc, 60, FIELD_PADDING_TOP, line.srcRaw, textColor);
if (line.name[0]) {
dc->drawMask(146, FIELD_PADDING_TOP, mixerSetupLabelIcon, DEFAULT_COLOR);
dc->drawSizedText(166, FIELD_PADDING_TOP, line.name, sizeof(line.name));
dc->drawMask(146, FIELD_PADDING_TOP, mixerSetupLabelIcon, textColor);
dc->drawSizedText(166, FIELD_PADDING_TOP, line.name, sizeof(line.name),
textColor);
}
// second line ...
if (line.swtch) {
dc->drawMask(3, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupSwitchIcon, DEFAULT_COLOR);
drawSwitch(dc, 21, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.swtch);
dc->drawMask(3, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
mixerSetupSwitchIcon, textColor);
drawSwitch(dc, 21, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.swtch,
textColor);
}
if (line.curve.value != 0 ) {
dc->drawMask(60, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupCurveIcon, DEFAULT_COLOR);
drawCurveRef(dc, 80, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.curve);
dc->drawMask(60, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
mixerSetupCurveIcon, textColor);
drawCurveRef(dc, 80, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.curve,
textColor);
}
if (line.flightModes) {
drawFlightModes(dc, line.flightModes);
drawFlightModes(dc, line.flightModes, textColor);
}
}
};
@@ -406,7 +421,11 @@ void ModelInputsPage::build(FormWindow * window, int8_t focusIndex)
ExpoData * line = g_model.expoData;
for (uint8_t input = 0; input < MAX_INPUTS; input++) {
if (inputIndex < MAX_EXPOS && line->chn == input && EXPO_VALID(line)) {
new StaticText(window, grid.getLabelSlot(), getSourceString(MIXSRC_FIRST_INPUT + input), BUTTON_BACKGROUND, CENTERED);
auto txt = new StaticText(window, grid.getLabelSlot(),
getSourceString(MIXSRC_FIRST_INPUT + input),
0, CENTERED);
txt->setBackgroundColor(FIELD_BGCOLOR);
while (inputIndex < MAX_EXPOS && line->chn == input && EXPO_VALID(line)) {
Button * button = new InputLineButton(window, grid.getFieldSlot(), inputIndex);
if (focusIndex == inputIndex)
+1 -1
View File
@@ -56,7 +56,7 @@ class CommonInputOrMixButton : public Button {
void checkEvents() override;
void drawFlightModes(BitmapBuffer *dc, FlightModesType value);
void drawFlightModes(BitmapBuffer *dc, FlightModesType value, LcdFlags textColor);
void paint(BitmapBuffer * dc) override;
+23 -10
View File
@@ -246,28 +246,38 @@ class MixLineButton : public CommonInputOrMixButton {
{
const MixData & line = g_model.mixData[index];
LcdFlags textColor = DEFAULT_COLOR;
if (hasFocus())
textColor = FOCUS_COLOR;
// first line ...
drawValueOrGVar(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, line.weight, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX);
drawSource(dc, 60, FIELD_PADDING_TOP, line.srcRaw);
drawValueOrGVar(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, line.weight,
MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, textColor);
drawSource(dc, 60, FIELD_PADDING_TOP, line.srcRaw, textColor);
if (line.name[0]) {
dc->drawMask(146, FIELD_PADDING_TOP, mixerSetupLabelIcon, DEFAULT_COLOR);
dc->drawSizedText(166, FIELD_PADDING_TOP, line.name, sizeof(line.name));
dc->drawMask(146, FIELD_PADDING_TOP, mixerSetupLabelIcon, textColor);
dc->drawSizedText(166, FIELD_PADDING_TOP, line.name, sizeof(line.name),
textColor);
}
// second line ...
if (line.swtch) {
dc->drawMask(3, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupSwitchIcon, DEFAULT_COLOR);
drawSwitch(dc, 21, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.swtch);
dc->drawMask(3, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
mixerSetupSwitchIcon, textColor);
drawSwitch(dc, 21, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.swtch,
textColor);
}
if (line.curve.value) {
dc->drawMask(60, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupCurveIcon, DEFAULT_COLOR);
drawCurveRef(dc, 80, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.curve, 0);
dc->drawMask(60, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
mixerSetupCurveIcon, textColor);
drawCurveRef(dc, 80, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.curve,
textColor);
}
if (line.flightModes) {
drawFlightModes(dc, line.flightModes);
drawFlightModes(dc, line.flightModes, textColor);
}
}
};
@@ -329,7 +339,10 @@ void ModelMixesPage::build(FormWindow * window, int8_t focusMixIndex)
MixData * mix = g_model.mixData;
for (uint8_t ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) {
if (mixIndex < MAX_MIXERS && mix->srcRaw > 0 && mix->destCh == ch) {
new StaticText(window, grid.getLabelSlot(), getSourceString(MIXSRC_CH1 + ch), BUTTON_BACKGROUND, CENTERED);
auto txt = new StaticText(window, grid.getLabelSlot(),
getSourceString(MIXSRC_CH1 + ch), 0,
CENTERED);
txt->setBackgroundColor(FIELD_BGCOLOR);
uint8_t count = 0;
while (mixIndex < MAX_MIXERS && mix->srcRaw > 0 && mix->destCh == ch) {
Button * button = new MixLineButton(window, grid.getFieldSlot(), mixIndex);
+42 -14
View File
@@ -39,8 +39,14 @@ class OutputEditWindow : public Page {
void buildHeader(Window * window)
{
new StaticText(window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, STR_MENULIMITS, 0, MENU_COLOR);
new StaticText(window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, getSourceString(MIXSRC_CH1 + channel), 0, MENU_COLOR);
new StaticText(window,
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT,
PAGE_LINE_HEIGHT},
STR_MENULIMITS, 0, MENU_COLOR);
new StaticText(window,
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT,
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
getSourceString(MIXSRC_CH1 + channel), 0, MENU_COLOR);
}
void buildBody(FormWindow * window)
@@ -120,28 +126,47 @@ class OutputLineButton : public Button {
void paint(BitmapBuffer * dc) override
{
LcdFlags textColor = DEFAULT_COLOR;
LcdFlags bgColor = FIELD_BGCOLOR;
if (hasFocus()) {
textColor = FOCUS_COLOR;
bgColor = FOCUS_BGCOLOR;
}
dc->drawSolidFilledRect(0, 0, width(), height(), bgColor);
// first line
dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, output->min - 1000, PREC1);
dc->drawNumber(68, FIELD_PADDING_TOP, output->max + 1000, PREC1);
dc->drawNumber(132, FIELD_PADDING_TOP, output->offset, PREC1);
dc->drawNumber(226, FIELD_PADDING_TOP, PPM_CENTER + output->ppmCenter, RIGHT);
dc->drawText(228, FIELD_PADDING_TOP, output->symetrical ? "=" : "\210");
dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, output->min - 1000,
PREC1 | textColor);
dc->drawNumber(68, FIELD_PADDING_TOP, output->max + 1000, PREC1 | textColor);
dc->drawNumber(132, FIELD_PADDING_TOP, output->offset, PREC1 | textColor);
dc->drawNumber(226, FIELD_PADDING_TOP, PPM_CENTER + output->ppmCenter,
RIGHT | textColor);
dc->drawText(228, FIELD_PADDING_TOP, output->symetrical ? "=" : "\210",
textColor);
// second line
if (output->revert) {
dc->drawTextAtIndex(4, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, STR_MMMINV, output->revert);
dc->drawTextAtIndex(4, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, STR_MMMINV,
output->revert, textColor);
}
if (output->curve) {
dc->drawMask(68, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupCurveIcon, DEFAULT_COLOR);
dc->drawText(88, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, getCurveString(output->curve));
dc->drawMask(68, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
mixerSetupCurveIcon, textColor);
dc->drawText(88, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
getCurveString(output->curve), textColor);
}
if (output->name[0]) {
dc->drawMask(146, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupLabelIcon, DEFAULT_COLOR);
dc->drawSizedText(166, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, output->name, sizeof(output->name));
dc->drawMask(146, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
mixerSetupLabelIcon, textColor);
dc->drawSizedText(166, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
output->name, sizeof(output->name), textColor);
}
// bounding rect
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, hasFocus() ? CHECKBOX_COLOR : DISABLE_COLOR);
dc->drawSolidRect(0, 0, rect.w, rect.h, 2,
hasFocus() ? FOCUS_BGCOLOR : FIELD_FRAME_COLOR);
}
protected:
@@ -171,7 +196,10 @@ void ModelOutputsPage::build(FormWindow * window, int8_t focusChannel)
LimitData * output = limitAddress(ch);
// Channel label
new StaticText(window, grid.getLabelSlot(), getSourceString(MIXSRC_CH1 + ch), BUTTON_BACKGROUND, CENTERED);
auto txt = new StaticText(window, grid.getLabelSlot(),
getSourceString(MIXSRC_CH1 + ch), 0,
CENTERED);
txt->setBackgroundColor(FIELD_BGCOLOR);
// Channel settings
Button * button = new OutputLineButton(window, grid.getFieldSlot(), output);
@@ -36,7 +36,7 @@ constexpr uint16_t __TAB_BACKGROUND_COLOR = RGB(0xE4, 0xEE, 0xF2);
constexpr uint16_t __PARAM_BACKGROUND_COLOR = WHITE;
constexpr uint16_t __EDIT_MARKER_COLOR = RGB(0x00, 0x99, 0x09);
constexpr uint16_t __ACTIVE_MARKER_COLOR = RGB(0xFF, 0x99, 0x00);
constexpr uint16_t __ACTIVE_MARKER_COLOR = RGB(0xFF, 0xDE, 0x00);
class Theme480: public OpenTxTheme
{
@@ -69,7 +69,7 @@ class Theme480: public OpenTxTheme
lcdColorTable[HEADER_COLOR_INDEX] = __BACKGROUND_COLOR;
lcdColorTable[HEADER_CURRENT_BGCOLOR_INDEX] = __FOCUS_COLOR;
lcdColorTable[HEADER_ICON_BGCOLOR_INDEX] = __BACKGROUND_COLOR;
lcdColorTable[HIGHLIGHT_COLOR_INDEX] = YELLOW;
lcdColorTable[HIGHLIGHT_COLOR_INDEX] = __ACTIVE_MARKER_COLOR;
lcdColorTable[LINE_COLOR_INDEX] = GREY;
lcdColorTable[MAINVIEW_GRAPHICS_COLOR_INDEX] = RED;
lcdColorTable[MAINVIEW_PANES_COLOR_INDEX] = WHITE;
@@ -383,7 +383,7 @@ class Theme480: public OpenTxTheme
dc->drawSolidFilledRect(0, MENU_TITLE_TOP, LCD_W, MENU_TITLE_HEIGHT,
TITLE_BGCOLOR); // the title line background
if (title) {
dc->drawText(MENUS_MARGIN_LEFT, MENU_TITLE_TOP + 3, title, MENU_COLOR);
dc->drawText(MENUS_MARGIN_LEFT, MENU_TITLE_TOP + 3, title, FOCUS_COLOR);
}
drawMenuDatetime(dc);
+2 -2
View File
@@ -57,8 +57,8 @@ class ChannelsViewFooter: public Window {
// Draw legend bar
coord_t x = 10;
dc->drawSolidFilledRect(0, 0, width(), height(), TITLE_BGCOLOR);
x = drawChannelsMonitorLegend(dc, MENUS_MARGIN_LEFT, STR_MONITOR_OUTPUT_DESC, BARGRAPH1_COLOR);
drawChannelsMonitorLegend(dc, x, STR_MONITOR_MIXER_DESC, BARGRAPH2_COLOR);
x = drawChannelsMonitorLegend(dc, MENUS_MARGIN_LEFT, STR_MONITOR_OUTPUT_DESC, HIGHLIGHT_COLOR);
drawChannelsMonitorLegend(dc, x, STR_MONITOR_MIXER_DESC, FOCUS_BGCOLOR);
}
};
@@ -27,27 +27,30 @@
class LogicalSwitchDisplayButton : public TextButton
{
public:
LogicalSwitchDisplayButton(FormGroup * parent, const rect_t & rect, std::string text, unsigned index):
TextButton(parent, rect, std::move(text)),
index(index)
{
}
LogicalSwitchDisplayButton(FormGroup* parent, const rect_t& rect,
std::string text, unsigned index) :
TextButton(parent, rect, std::move(text), nullptr, OPAQUE), index(index)
{
setBgColorHandler([=]() -> LcdFlags {
if (getSwitch(SWSRC_SW1 + index)) return HIGHLIGHT_COLOR;
return FIELD_BGCOLOR;
});
}
void checkEvents() override
{
bool newvalue = getSwitch(SWSRC_SW1 + index);
if (value != newvalue) {
if (newvalue) {
setTextFlags(FONT(BOLD) | HIGHLIGHT_COLOR);
}
else {
setTextFlags(FONT(STD) | DEFAULT_COLOR);
}
value = newvalue;
invalidate();
}
Button::checkEvents();
}
void checkEvents() override
{
bool newvalue = getSwitch(SWSRC_SW1 + index);
if (value != newvalue) {
if (newvalue) {
setTextFlags(FONT(BOLD) | DEFAULT_COLOR);
} else {
setTextFlags(FONT(STD) | DEFAULT_COLOR);
}
value = newvalue;
invalidate();
}
Button::checkEvents();
}
protected:
unsigned index = 0;
@@ -61,21 +64,28 @@ void LogicalSwitchesViewPage::build(FormWindow * window)
grid.spacer(PAGE_PADDING);
grid.setLabelWidth(8);
// Footer
footer = new LogicalSwitchDisplayFooter(
window, {0, window->height() - LSW_VIEW_FOOTER_HEIGHT, window->width(),
LSW_VIEW_FOOTER_HEIGHT});
// LSW table
std::string lsString ("LS64");
std::string lsString("LS64");
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(160, 160, 160);
for (uint8_t i = 0; i < MAX_LOGICAL_SWITCHES; i++) {
strAppendSigned(&lsString[1], i + 1, 2);
auto button = new LogicalSwitchDisplayButton(window, grid.getFieldSlot(8, i % 8), lsString, i);
button->setPressHandler([=]() {
footer->setIndex(i);
footer->invalidate();
auto button = new LogicalSwitchDisplayButton(
window, grid.getFieldSlot(8, i % 8), lsString, i);
button->setFocusHandler([=](bool focus) {
if (focus) {
footer->setIndex(i);
footer->invalidate();
}
return 0;
});
if ((i + 1) % 8 == 0)
grid.nextLine();
if ((i + 1) % 8 == 0) grid.nextLine();
}
// Footer
footer = new LogicalSwitchDisplayFooter(window, {0,window->height() - LSW_VIEW_FOOTER_HEIGHT, window->width(), LSW_VIEW_FOOTER_HEIGHT});
}
+63 -64
View File
@@ -30,77 +30,76 @@ constexpr coord_t CSW_4TH_COLUMN = 280;
constexpr coord_t CSW_5TH_COLUMN = 340;
constexpr coord_t CSW_6TH_COLUMN = 390;
void putsEdgeDelayParam(BitmapBuffer * dc, coord_t x, coord_t y, LogicalSwitchData * ls, LcdFlags flags);
void putsEdgeDelayParam(BitmapBuffer* dc, coord_t x, coord_t y,
LogicalSwitchData* ls, LcdFlags flags);
class LogicalSwitchDisplayFooter: public Window {
public:
explicit LogicalSwitchDisplayFooter(Window * parent, rect_t rect):
Window(parent, rect, OPAQUE),
rect(rect)
{
class LogicalSwitchDisplayFooter : public Window
{
public:
explicit LogicalSwitchDisplayFooter(Window* parent, rect_t rect) :
Window(parent, rect, OPAQUE), rect(rect)
{
}
void setIndex(unsigned value) { index = value; }
void paint(BitmapBuffer* dc) override
{
dc->clear(TITLE_BGCOLOR);
LogicalSwitchData* cs = lswAddress(index);
LcdFlags textColor = FOCUS_COLOR;
dc->drawTextAtIndex(10, 1, STR_VCSWFUNC, cs->func, textColor);
// CSW params
unsigned int cstate = lswFamily(cs->func);
if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) {
drawSwitch(dc, CSW_2ND_COLUMN, 1, cs->v1, textColor);
drawSwitch(dc, CSW_3RD_COLUMN, 1, cs->v2, textColor);
} else if (cstate == LS_FAMILY_EDGE) {
drawSwitch(dc, CSW_2ND_COLUMN, 1, cs->v1, textColor);
putsEdgeDelayParam(dc, CSW_3RD_COLUMN, 1, cs, textColor);
} else if (cstate == LS_FAMILY_COMP) {
drawSource(dc, CSW_2ND_COLUMN, 1, cs->v1, textColor);
drawSource(dc, CSW_3RD_COLUMN, 1, cs->v2, textColor);
} else if (cstate == LS_FAMILY_TIMER) {
dc->drawNumber(CSW_2ND_COLUMN, 1, lswTimerValue(cs->v1),
LEFT | PREC1 | textColor);
dc->drawNumber(CSW_3RD_COLUMN, 1, lswTimerValue(cs->v2),
LEFT | PREC1 | textColor);
} else {
drawSource(dc, CSW_2ND_COLUMN, 1, cs->v1, textColor);
drawSourceCustomValue(
dc, CSW_3RD_COLUMN, 1, cs->v1,
cs->v1 <= MIXSRC_LAST_CH ? calc100toRESX(cs->v2) : cs->v2,
LEFT | textColor);
}
void setIndex(unsigned value)
{
index = value;
// CSW AND switch
drawSwitch(dc, CSW_4TH_COLUMN, 1, cs->andsw, textColor);
// CSW duration
if (cs->duration > 0)
dc->drawNumber(CSW_5TH_COLUMN, 1, cs->duration,
PREC1 | LEFT | textColor);
else
dc->drawTextAtIndex(CSW_5TH_COLUMN, 1, STR_MMMINV, 0, textColor);
// CSW delay
if (cstate == LS_FAMILY_EDGE) {
dc->drawText(CSW_6TH_COLUMN, 1, STR_NA, textColor);
} else if (cs->delay > 0) {
dc->drawNumber(CSW_6TH_COLUMN, 1, cs->delay, PREC1 | LEFT | textColor);
} else {
dc->drawTextAtIndex(CSW_6TH_COLUMN, 1, STR_MMMINV, 0, textColor);
}
}
void paint(BitmapBuffer * dc) override
{
dc->clear(TITLE_BGCOLOR);
LogicalSwitchData * cs = lswAddress(index);
dc->drawTextAtIndex(10, 1, STR_VCSWFUNC, cs->func, MENU_COLOR);
// CSW params
unsigned int cstate = lswFamily(cs->func);
if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) {
drawSwitch(dc, CSW_2ND_COLUMN, 1, cs->v1, MENU_COLOR);
drawSwitch(dc, CSW_3RD_COLUMN, 1, cs->v2, MENU_COLOR);
}
else if (cstate == LS_FAMILY_EDGE) {
drawSwitch(dc, CSW_2ND_COLUMN, 1, cs->v1, MENU_COLOR);
putsEdgeDelayParam(dc, CSW_3RD_COLUMN, 1, cs, MENU_COLOR);
}
else if (cstate == LS_FAMILY_COMP) {
drawSource(dc, CSW_2ND_COLUMN, 1, cs->v1, MENU_COLOR);
drawSource(dc, CSW_3RD_COLUMN, 1, cs->v2, MENU_COLOR);
}
else if (cstate == LS_FAMILY_TIMER) {
dc->drawNumber(CSW_2ND_COLUMN, 1, lswTimerValue(cs->v1), LEFT | PREC1 | MENU_COLOR);
dc->drawNumber(CSW_3RD_COLUMN, 1, lswTimerValue(cs->v2), LEFT | PREC1 | MENU_COLOR);
}
else {
drawSource(dc, CSW_2ND_COLUMN, 1, cs->v1, MENU_COLOR);
drawSourceCustomValue(dc, CSW_3RD_COLUMN, 1, cs->v1, cs->v1 <= MIXSRC_LAST_CH ? calc100toRESX(cs->v2) : cs->v2, LEFT | MENU_COLOR);
}
// CSW AND switch
drawSwitch(dc, CSW_4TH_COLUMN, 1, cs->andsw, MENU_COLOR);
// CSW duration
if (cs->duration > 0)
dc->drawNumber(CSW_5TH_COLUMN, 1, cs->duration, PREC1 | LEFT | MENU_COLOR);
else
dc->drawTextAtIndex(CSW_5TH_COLUMN, 1, STR_MMMINV, 0, MENU_COLOR);
// CSW delay
if (cstate == LS_FAMILY_EDGE) {
dc->drawText(CSW_6TH_COLUMN, 1, STR_NA, MENU_COLOR);
}
else if (cs->delay > 0) {
dc->drawNumber(CSW_6TH_COLUMN, 1, cs->delay, PREC1 | LEFT | MENU_COLOR);
}
else {
dc->drawTextAtIndex(CSW_6TH_COLUMN, 1, STR_MMMINV, 0, MENU_COLOR);
}
}
protected:
rect_t rect;
unsigned index = 0;
protected:
rect_t rect;
unsigned index = 0;
};
class LogicalSwitchesViewPage : public PageTab
{
public: