Fix GF focus issue, add channel bars to mixes edit screen, also #482 (#1074)

* fix issues:
#303
#307
#482

* move channel output display to top.  make it a multi channel bar.

* changed channel bar colors so they work in the mixer screen.  I dont like the choices of colors, but let me know what you think.

Co-authored-by: kkoenig1@optonline.com <kkoenig1@optonline.com>
This commit is contained in:
Kevin Koenig
2021-11-27 21:27:08 +11:00
committed by GitHub
co-authored by kkoenig1@optonline.com <kkoenig1@optonline.com>
parent f97e3e77d5
commit 67708725bd
5 changed files with 81 additions and 97 deletions
+40 -13
View File
@@ -123,6 +123,11 @@ class OutputChannelBar : public ChannelBar
public:
using ChannelBar::ChannelBar;
void setOutputBarLimitColor(uint32_t color)
{
outputBarLimitsColor = color;
}
void paint(BitmapBuffer * dc) override
{
if (!enabled) return;
@@ -196,13 +201,13 @@ class OutputChannelBar : public ChannelBar
void drawOutputBarLimits(BitmapBuffer * dc, coord_t left, coord_t right)
{
dc->drawSolidVerticalLine(left, 0, BAR_HEIGHT, COLOR_THEME_SECONDARY1);
dc->drawSolidHorizontalLine(left, 0, 3, COLOR_THEME_SECONDARY1);
dc->drawSolidHorizontalLine(left, BAR_HEIGHT - 1, 3, COLOR_THEME_SECONDARY1);
dc->drawSolidVerticalLine(left, 0, BAR_HEIGHT, outputBarLimitsColor);
dc->drawSolidHorizontalLine(left, 0, 3, outputBarLimitsColor);
dc->drawSolidHorizontalLine(left, BAR_HEIGHT - 1, 3, outputBarLimitsColor);
dc->drawSolidVerticalLine(right, 0, BAR_HEIGHT, COLOR_THEME_SECONDARY1);
dc->drawSolidHorizontalLine(right - 3, 0, 3, COLOR_THEME_SECONDARY1);
dc->drawSolidHorizontalLine(right - 3, BAR_HEIGHT - 1, 3, COLOR_THEME_SECONDARY1);
dc->drawSolidVerticalLine(right, 0, BAR_HEIGHT, outputBarLimitsColor);
dc->drawSolidHorizontalLine(right - 3, 0, 3, outputBarLimitsColor);
dc->drawSolidHorizontalLine(right - 3, BAR_HEIGHT - 1, 3, outputBarLimitsColor);
}
void checkEvents() override
@@ -236,6 +241,7 @@ class OutputChannelBar : public ChannelBar
int value = 0;
int limMax = 0;
int limMin = 0;
uint32_t outputBarLimitsColor = COLOR_THEME_SECONDARY1;
};
constexpr coord_t lmargin = 25;
@@ -247,8 +253,26 @@ class ComboChannelBar : public ChannelBar
ComboChannelBar(Window * parent, const rect_t & rect, uint8_t channel):
ChannelBar(parent, rect, channel)
{
new OutputChannelBar(this, {lmargin, BAR_HEIGHT, width() - lmargin, BAR_HEIGHT}, channel);
new MixerChannelBar(this, {lmargin, 2 * BAR_HEIGHT + 1, width() - lmargin, BAR_HEIGHT}, channel);
outputChannelBar = new OutputChannelBar(this, {leftMargin, BAR_HEIGHT, width() - leftMargin, BAR_HEIGHT}, channel);
new MixerChannelBar(this, {leftMargin, 2 * BAR_HEIGHT + 1, width() - leftMargin, BAR_HEIGHT}, channel);
}
void setOutputChannelBarLimitColor(uint32_t color)
{
if (outputChannelBar != nullptr) {
outputChannelBar->setOutputBarLimitColor(color);
}
}
void setTextColor(uint32_t color)
{
textColor = color;
invalidate();
}
void setLeftMargin(int margin)
{
leftMargin = margin;
}
void paint(BitmapBuffer * dc) override
@@ -260,24 +284,24 @@ class ComboChannelBar : public ChannelBar
// Channel number
strAppendSigned(&chanString[2], channel + 1, 2);
dc->drawText(lmargin, 0, chanString, FONT(XS) | COLOR_THEME_SECONDARY1 | LEFT);
dc->drawText(leftMargin, 0, chanString, FONT(XS) | textColor | LEFT);
// Channel name
dc->drawSizedText(lmargin + 45, 0, g_model.limitData[channel].name, sizeof(g_model.limitData[channel].name), FONT(XS) | COLOR_THEME_SECONDARY1 | LEFT);
dc->drawSizedText(leftMargin + 45, 0, g_model.limitData[channel].name, sizeof(g_model.limitData[channel].name), FONT(XS) | textColor | LEFT);
// Channel value in µS
dc->drawNumber(width(), 0, usValue, FONT(XS) | COLOR_THEME_SECONDARY1 | RIGHT, 0, nullptr, STR_US);
dc->drawNumber(width(), 0, usValue, FONT(XS) | textColor | RIGHT, 0, nullptr, STR_US);
// Override icon
#if defined(OVERRIDE_CHANNEL_FUNCTION)
if (safetyCh[channel] != OVERRIDE_CHANNEL_UNDEFINED)
dc->drawMask(0, 1, chanMonLockedBitmap, COLOR_THEME_SECONDARY1);
dc->drawMask(0, 1, chanMonLockedBitmap, textColor);
#endif
// Channel reverted icon
LimitData * ld = limitAddress(channel);
if (ld && ld->revert) {
lcd->drawMask(0, 20, chanMonInvertedBitmap, COLOR_THEME_SECONDARY1);
lcd->drawMask(0, 20, chanMonInvertedBitmap, textColor);
}
}
@@ -300,7 +324,10 @@ class ComboChannelBar : public ChannelBar
}
protected:
OutputChannelBar *outputChannelBar = nullptr;
int value = 0;
int leftMargin = lmargin;
uint32_t textColor = COLOR_THEME_SECONDARY1;
#if defined(OVERRIDE_CHANNEL_FUNCTION)
int safetyChValue = OVERRIDE_CHANNEL_UNDEFINED;
#endif
+4
View File
@@ -57,4 +57,8 @@ void ScreenMenu::updateTabs()
break;
}
}
// set the active tab to the currently sown screen on the MainView
if ((g_model.view + 1) < getTabs())
setCurrentTab(g_model.view + 1);
}
+29
View File
@@ -28,6 +28,7 @@
#include "gvar_numberedit.h"
#include "model_curves.h"
#include "dataconstants.h"
#include "channel_bar.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
@@ -57,6 +58,29 @@ bool reachMixesLimit()
return false;
}
class MixerEditStatusBar : public Window
{
public:
MixerEditStatusBar(Window *parent, const rect_t &rect, int8_t channel) :
Window(parent, rect),
_channel(channel)
{
channelBar = new ComboChannelBar(this, {3, 0, rect.w - 6, rect.h}, channel);
channelBar->setLeftMargin(0);
channelBar->setTextColor(COLOR_THEME_PRIMARY2);
channelBar->setOutputChannelBarLimitColor(COLOR_THEME_EDIT);
}
void paint(BitmapBuffer *dc) override
{
// dc->clear(COLOR_THEME_SECONDARY2);
}
protected:
ComboChannelBar *channelBar;
int8_t _channel;
};
class MixEditWindow : public Page
{
public:
@@ -71,6 +95,7 @@ class MixEditWindow : public Page
uint8_t channel;
uint8_t mixIndex;
FormGroup *curveParamField = nullptr;
MixerEditStatusBar *statusBar = nullptr;
void buildHeader(Window *window)
{
@@ -82,6 +107,10 @@ class MixEditWindow : public Page
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT,
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
getSourceString(MIXSRC_CH1 + channel), 0, COLOR_THEME_PRIMARY2);
statusBar = new MixerEditStatusBar(
window, {window->getRect().w - 250, 0, 250, MENU_HEADER_HEIGHT + 3},
channel);
}
void buildBody(FormWindow *window)
-80
View File
@@ -263,86 +263,6 @@ class SetupWidgetsPage: public FormWindow
// }
};
class ThemeEditorPage : public Page
{
public:
explicit ThemeEditorPage(Window *parent, ThemeFile *theme, WindowFlags flags = 0) :
Page(0),
theme(theme)
{
buildBody(&body);
buildHeader(&header);
}
void buildHeader(FormGroup *window)
{
ThemePersistance *tp = ThemePersistance::instance();
new StaticText(window,
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT,
PAGE_LINE_HEIGHT},
"Edit Theme", 0, COLOR_THEME_PRIMARY2);
new StaticText(window,
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT,
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
theme->getName(), 0, COLOR_THEME_PRIMARY2);
rect_t r = {LCD_W - (BUTTON_WIDTH + 5), static_cast<coord_t>(PAGE_TITLE_TOP + ((header.getRect().h - BUTTON_HEIGHT) / 2)), BUTTON_WIDTH, BUTTON_HEIGHT };
new TextButton(window, r, "Save", [=] () {
theme->serialize();
tp->refresh();
tp->applyTheme(tp->getThemeIndex());
body.clear();
buildBody(&body);
return 0;
});
}
void buildBody(FormGroup *window)
{
FormGridLayout grid;
grid.spacer(8);
new StaticText(window, grid.getLabelSlot(), "Name", 0, COLOR_THEME_PRIMARY1);
new TextEdit(window, grid.getFieldSlot(), theme->getName(), NAME_LENGTH);
grid.nextLine();
new StaticText(window, grid.getLabelSlot(), "Author", 0, COLOR_THEME_PRIMARY1);
new TextEdit(window, grid.getFieldSlot(), theme->getAuthor(), AUTHOR_LENGTH);
grid.nextLine();
new StaticText(window, grid.getLineSlot(), "Description", 0, COLOR_THEME_PRIMARY1);
grid.nextLine();
new TextEdit(window, grid.getLineSlot(), theme->getInfo(), INFO_LENGTH);
grid.nextLine();
grid.spacer(10);
new StaticText(window, grid.getLineSlot(), "Colors", 0, COLOR_THEME_PRIMARY1 | FONT(BOLD));
grid.nextLine();
grid.spacer(10);
char **colorNames = ThemePersistance::getColorNames();
for (int i = 0; i < COLOR_COUNT; i++) {
char * name = colorNames[i];
new StaticText(window, grid.getLabelSlot(), name, 0, COLOR_THEME_PRIMARY1);
new ColorEdit(window, grid.getFieldSlot(),
[=] () {
return theme->getColorByName(name);
},
[=] (uint16_t value) {
theme->setColor((LcdColorIndex)i, value);
});
grid.nextLine();
}
grid.spacer(20);
window->setInnerHeight(grid.getWindowHeight());
}
protected:
ThemeFile *theme;
};
ScreenUserInterfacePage::ScreenUserInterfacePage(ScreenMenu* menu):
PageTab(STR_USER_INTERFACE, ICON_THEME_SETUP),
menu(menu)
+8 -4
View File
@@ -638,8 +638,9 @@ void SpecialFunctionsPage::build(FormWindow *window, int8_t focusIndex)
CustomFunctionData *cfn = &functions[i];
strAppendUnsigned(&s[2], i+1);
Button *button;
if (cfn->swtch == 0) {
auto button = new TextButton(window, grid.getLabelSlot(), s);
button = new TextButton(window, grid.getLabelSlot(), s);
button->setPressHandler([=]() {
if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_FUNCTION) {
Menu *menu = new Menu(window);
@@ -658,8 +659,7 @@ void SpecialFunctionsPage::build(FormWindow *window, int8_t focusIndex)
} else {
auto txt = new StaticText(window, grid.getLabelSlot(), s, BUTTON_BACKGROUND, COLOR_THEME_PRIMARY1 | CENTERED);
auto button =
new SpecialFunctionButton(window, grid.getFieldSlot(), functions, i);
button = new SpecialFunctionButton(window, grid.getFieldSlot(), functions, i);
button->setPressHandler([=]() {
button->bringToTop();
Menu *menu = new Menu(window);
@@ -718,7 +718,6 @@ void SpecialFunctionsPage::build(FormWindow *window, int8_t focusIndex)
});
if (focusIndex == i) {
button->setFocus(SET_FOCUS_DEFAULT);
txt->setBackgroundColor(COLOR_THEME_FOCUS);
txt->setTextFlags(COLOR_THEME_PRIMARY2 | CENTERED);
txt->invalidate();
@@ -727,6 +726,11 @@ void SpecialFunctionsPage::build(FormWindow *window, int8_t focusIndex)
txt->setHeight(button->height());
grid.spacer(button->height() + 5);
}
if (focusIndex == i) { // fix focus #303
button->setFocus(SET_FOCUS_DEFAULT);
}
}
grid.nextLine();