Browse Source

Add bgColor to LedDisplayChoice. Add learningId UI to MIDI-Map.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
591597a99a
3 changed files with 44 additions and 0 deletions
  1. +1
    -0
      include/app/LedDisplay.hpp
  2. +35
    -0
      src/Core/MIDI_Map.cpp
  3. +8
    -0
      src/app/LedDisplay.cpp

+ 1
- 0
include/app/LedDisplay.hpp View File

@@ -23,6 +23,7 @@ struct LedDisplayChoice : widget::TransparentWidget {
std::shared_ptr<Font> font;
math::Vec textOffset;
NVGcolor color;
NVGcolor bgColor;
LedDisplayChoice();
void draw(const widget::DrawContext &ctx) override;
void onButton(const event::Button &e) override;


+ 35
- 0
src/Core/MIDI_Map.cpp View File

@@ -17,6 +17,8 @@ struct MIDI_Map : Module {

midi::InputQueue midiInput;
int8_t values[128];
int learningId = -1;
int learnedCcs[16] = {};
dsp::ExponentialFilter valueFilters[8];

MIDI_Map() {
@@ -35,10 +37,42 @@ struct MIDI_Map : Module {

struct MIDI_MapChoice : LedDisplayChoice {
MIDI_Map *module;
int id;

void setModule(MIDI_Map *module) {
this->module = module;
}

void onSelect(const event::Select &e) override {
if (!module)
return;
module->learningId = id;
e.consume(this);
}

void onDeselect(const event::Deselect &e) override {
if (!module)
return;
if (module->learningId == id) {
module->learningId = -1;
}
}

void step() override {
if (!module)
return;
if (module->learningId == id) {
text = "Mapping...";
color.a = 1.0;
bgColor = color;
bgColor.a = 0.15;
}
else {
text = "Unmapped";
color.a = 0.5;
bgColor = nvgRGBA(0, 0, 0, 0);
}
}
};


@@ -52,6 +86,7 @@ struct MIDI_MapDisplay : MidiWidget {

MIDI_MapChoice *choice = createWidget<MIDI_MapChoice>(pos);
choice->box.size.x = box.size.x;
choice->id = i;
choice->setModule(module);
addChild(choice);
pos = choice->box.getBottomLeft();


+ 8
- 0
src/app/LedDisplay.cpp View File

@@ -37,12 +37,20 @@ LedDisplayChoice::LedDisplayChoice() {
box.size = mm2px(math::Vec(0, 28.0 / 3));
font = APP->window->loadFont(asset::system("res/fonts/ShareTechMono-Regular.ttf"));
color = nvgRGB(0xff, 0xd7, 0x14);
bgColor = nvgRGBAf(0, 0, 0, 0);
textOffset = math::Vec(10, 18);
}

void LedDisplayChoice::draw(const widget::DrawContext &ctx) {
nvgScissor(ctx.vg, 0, 0, box.size.x, box.size.y);

if (bgColor.a > 0.0) {
nvgBeginPath(ctx.vg);
nvgRect(ctx.vg, 0, 0, box.size.x, box.size.y);
nvgFillColor(ctx.vg, bgColor);
nvgFill(ctx.vg);
}

if (font->handle >= 0) {
nvgFillColor(ctx.vg, color);
nvgFontFaceId(ctx.vg, font->handle);


Loading…
Cancel
Save